image re-project now uses offscreen render function and has input for render size.
authorCampbell Barton <ideasman42@gmail.com>
Mon, 8 Mar 2010 20:08:04 +0000 (20:08 +0000)
committerCampbell Barton <ideasman42@gmail.com>
Mon, 8 Mar 2010 20:08:04 +0000 (20:08 +0000)
unrelated changes that ended up being more trouble to commit separate...

- removed BLI_split_dirfile(), was nasty, occasionaly modifying the source string, it could create directories and used the $CWD in some cases. was only used in 2 places in filesel.c, if this gives problems can address without bringing back this function.
  renamed BLI_split_dirfile_basic --> BLI_split_dirfile

- view3d_operator_needs_opengl was being called for offscreen render when it wasnt needed.

24 files changed:
release/scripts/op/image.py
release/scripts/ui/space_view3d_toolbar.py
source/blender/blenkernel/BKE_displist.h
source/blender/blenkernel/BKE_image.h
source/blender/blenkernel/intern/image.c
source/blender/blenkernel/intern/pointcache.c
source/blender/blenkernel/intern/sequencer.c
source/blender/blenkernel/intern/sound.c
source/blender/blenkernel/intern/text.c
source/blender/blenlib/BLI_path_util.h
source/blender/blenlib/intern/bpath.c
source/blender/blenlib/intern/path_util.c
source/blender/blenloader/intern/writefile.c
source/blender/collada/DocumentExporter.cpp
source/blender/collada/DocumentImporter.cpp
source/blender/editors/include/ED_view3d.h
source/blender/editors/render/render_opengl.c
source/blender/editors/sculpt_paint/paint_image.c
source/blender/editors/space_sequencer/sequencer_add.c
source/blender/editors/space_view3d/view3d_draw.c
source/blender/makesdna/DNA_scene_types.h
source/blender/makesrna/intern/rna_sculpt_paint.c
source/blender/makesrna/intern/rna_sequencer.c
source/gameengine/Ketsji/KX_PythonInit.cpp

index d68fc6a1a67248bd82fd31c9c4aec4c508cba239..b2433481b84a5c589945cd861f75eebf7254905d 100644 (file)
@@ -92,6 +92,7 @@ class ProjectEdit(bpy.types.Operator):
         
         filename = os.path.basename(bpy.data.filename)
         filename = os.path.splitext(filename)[0]
+        # filename = bpy.utils.clean_name(filename) # fixes <memory> rubbish, needs checking
 
         if filename.startswith("."): # TODO, have a way to check if the file is saved, assuem .B25.blend
             filename = os.path.join(os.path.dirname(bpy.data.filename), filename)
index 7996407445fc578d84f3325c939be13afd7daa25..b8cde368e0bd9ccbdc66f740619fab380f171bf1 100644 (file)
@@ -910,6 +910,8 @@ class VIEW3D_PT_tools_projectpaint(View3DPanel):
         row = col.row(align=True)
         row.operator("image.project_edit", text="View Edit")
         row.operator("image.project_apply", text="Apply")
+
+        col.prop(ipaint, "screen_grab_size", text="")
         
         sub = col.column()
         sub.operator("paint.project_image")
index e685dd90223b0a82b53f75a84864441270311fdd..01a1126e464cdbb214598eb1161264e5520d8e7f 100644 (file)
@@ -62,6 +62,7 @@ struct Material;
 struct Bone;
 struct Mesh;
 struct EditMesh;
+struct DerivedMesh;
 
 /* used for curves, nurbs, mball, importing */
 typedef struct DispList {
index 6b22b10cf24d33a07a88f8f1e7653cb5fed2c993..d1808366944b543957e1195371e9959423ca9bb9 100644 (file)
@@ -117,6 +117,8 @@ struct Image *BKE_add_image_file(const char *name, int frame);
 
 /* adds image, adds ibuf, generates color or pattern */
 struct Image *BKE_add_image_size(int width, int height, char *name, int floatbuf, short uvtestgrid, float color[4]);
+/* adds image from imbuf, owns imbuf */
+struct Image *BKE_add_image_imbuf(struct ImBuf *ibuf);
 
 /* for reload, refresh, pack */
 void BKE_image_signal(struct Image *ima, struct ImageUser *iuser, int signal);
index accadb3d434981b384c995fbfe94c3105902b80a..ac107212e302f395e043012da0c43445c750f19a 100644 (file)
@@ -563,10 +563,8 @@ static ImBuf *add_ibuf_size(int width, int height, char *name, int floatbuf, sho
 /* adds new image block, creates ImBuf and initializes color */
 Image *BKE_add_image_size(int width, int height, char *name, int floatbuf, short uvtestgrid, float color[4])
 {
-       Image *ima;
-       
        /* on save, type is changed to FILE in editsima.c */
-       ima= image_alloc(name, IMA_SRC_GENERATED, IMA_TYPE_UV_TEST);
+       Image *ima= image_alloc(name, IMA_SRC_GENERATED, IMA_TYPE_UV_TEST);
        
        if (ima) {
                ImBuf *ibuf;
@@ -585,6 +583,23 @@ Image *BKE_add_image_size(int width, int height, char *name, int floatbuf, short
        return ima;
 }
 
+/* creates an image image owns the imbuf passed */
+Image *BKE_add_image_imbuf(ImBuf *ibuf)
+{
+       /* on save, type is changed to FILE in editsima.c */
+       char filename[sizeof(ibuf->name)];
+       BLI_split_dirfile(ibuf->name, NULL, filename);
+       Image *ima= image_alloc(filename, IMA_SRC_FILE, IMA_TYPE_IMAGE);
+
+       if (ima) {
+               BLI_strncpy(ima->name, ibuf->name, FILE_MAX);
+               image_assign_ibuf(ima, ibuf, IMA_NO_INDEX, 0);
+               ima->ok= IMA_OK_LOADED;
+       }
+
+       return ima;
+}
+
 /* packs rect from memory as PNG */
 void BKE_image_memorypack(Image *ima)
 {
index b1319a81f5dfb6aa8d243fed8116c6731ffc86b1..7ae2898ab8d310c93246c29a70a94eefd13d722f 100644 (file)
@@ -1060,7 +1060,7 @@ static int ptcache_path(PTCacheID *pid, char *filename)
 
                blendfilename= (lib)? lib->filename: G.sce;
 
-               BLI_split_dirfile_basic(blendfilename, NULL, file);
+               BLI_split_dirfile(blendfilename, NULL, file);
                i = strlen(file);
                
                /* remove .blend */
index 98dbf83f032936608e7f87cd0192f5cd4374f2b6..d3b05cf802c6ecb7026387c4aa35655cfb0403e7 100644 (file)
@@ -79,6 +79,8 @@ static int seqrecty= 0;
 #define SELECT 1
 ListBase seqbase_clipboard;
 int seqbase_clipboard_frame;
+void *sequencer_view3d_cb= NULL; /* NULL in background mode */
+
 
 void printf_strip(Sequence *seq)
 {
@@ -2104,7 +2106,6 @@ static void do_build_seq_ibuf(Scene *scene, Sequence * seq, TStripElem *se, int
        } else if(seq->type == SEQ_SCENE) {     // scene can be NULL after deletions
                Scene *sce= seq->scene;// *oldsce= scene;
                Render *re;
-               RenderResult rres;
                int have_seq= FALSE;
                int sce_valid= FALSE;
 
@@ -2130,58 +2131,70 @@ static void do_build_seq_ibuf(Scene *scene, Sequence * seq, TStripElem *se, int
                if (!sce_valid) {
                        se->ok = STRIPELEM_FAILED;
                } else if (se->ibuf==NULL && sce_valid) {
-                       int oldcfra;
-                       /* Hack! This function can be called from do_render_seq(), in that case
-                          the seq->scene can already have a Render initialized with same name, 
-                          so we have to use a default name. (compositor uses scene name to
-                          find render).
-                          However, when called from within the UI (image preview in sequencer)
-                          we do want to use scene Render, that way the render result is defined
-                          for display in render/imagewindow 
-
-                          Hmm, don't see, why we can't do that all the time, 
-                          and since G.rendering is uhm, gone... (Peter)
-                       */
-
-                       int rendering = 1;
-                       int doseq;
-
-                       oldcfra = seq->scene->r.cfra;
-
-                       if(rendering)
-                               re= RE_NewRender(" do_build_seq_ibuf", RE_SLOT_DEFAULT);
-                       else
-                               re= RE_NewRender(sce->id.name, RE_SLOT_VIEW);
-                       
-                       /* prevent eternal loop */
-                       doseq= scene->r.scemode & R_DOSEQ;
-                       scene->r.scemode &= ~R_DOSEQ;
-                       
-                       RE_BlenderFrame(re, sce, NULL,
-                                       seq->sfra+se->nr+seq->anim_startofs);
-                       
-                       RE_AcquireResultImage(re, &rres);
-                       
-                       if(rres.rectf) {
-                               se->ibuf= IMB_allocImBuf(rres.rectx, rres.recty, 32, IB_rectfloat, 0);
-                               memcpy(se->ibuf->rect_float, rres.rectf, 4*sizeof(float)*rres.rectx*rres.recty);
-                               if(rres.rectz) {
-                                       addzbuffloatImBuf(se->ibuf);
-                                       memcpy(se->ibuf->zbuf_float, rres.rectz, sizeof(float)*rres.rectx*rres.recty);
+                       int do_opengl= 0;
+                       if(do_opengl && have_seq==0 && (sequencer_view3d_cb!=NULL)) {
+                               /* opengl offscreen render */
+
+                               /* sequencer_view3d_cb */
+                               // void (*seq_view3d_cb)(Scene *, int, int, int, int)= sequencer_view3d_cb;
+
+                               // seq_view3d_cb(scene, cfra, render_size, seqrectx, seqrecty);
+                       }
+                       else {
+                               RenderResult rres;
+                               int oldcfra;
+                               /* Hack! This function can be called from do_render_seq(), in that case
+                                  the seq->scene can already have a Render initialized with same name,
+                                  so we have to use a default name. (compositor uses scene name to
+                                  find render).
+                                  However, when called from within the UI (image preview in sequencer)
+                                  we do want to use scene Render, that way the render result is defined
+                                  for display in render/imagewindow
+
+                                  Hmm, don't see, why we can't do that all the time,
+                                  and since G.rendering is uhm, gone... (Peter)
+                               */
+
+                               int rendering = 1;
+                               int doseq;
+
+                               oldcfra = seq->scene->r.cfra;
+
+                               if(rendering)
+                                       re= RE_NewRender(" do_build_seq_ibuf", RE_SLOT_DEFAULT);
+                               else
+                                       re= RE_NewRender(sce->id.name, RE_SLOT_VIEW);
+
+                               /* prevent eternal loop */
+                               doseq= scene->r.scemode & R_DOSEQ;
+                               scene->r.scemode &= ~R_DOSEQ;
+
+                               RE_BlenderFrame(re, sce, NULL,
+                                               seq->sfra+se->nr+seq->anim_startofs);
+
+                               RE_AcquireResultImage(re, &rres);
+
+                               if(rres.rectf) {
+                                       se->ibuf= IMB_allocImBuf(rres.rectx, rres.recty, 32, IB_rectfloat, 0);
+                                       memcpy(se->ibuf->rect_float, rres.rectf, 4*sizeof(float)*rres.rectx*rres.recty);
+                                       if(rres.rectz) {
+                                               addzbuffloatImBuf(se->ibuf);
+                                               memcpy(se->ibuf->zbuf_float, rres.rectz, sizeof(float)*rres.rectx*rres.recty);
+                                       }
+                               } else if (rres.rect32) {
+                                       se->ibuf= IMB_allocImBuf(rres.rectx, rres.recty, 32, IB_rect, 0);
+                                       memcpy(se->ibuf->rect, rres.rect32, 4*rres.rectx*rres.recty);
                                }
-                       } else if (rres.rect32) {
-                               se->ibuf= IMB_allocImBuf(rres.rectx, rres.recty, 32, IB_rect, 0);
-                               memcpy(se->ibuf->rect, rres.rect32, 4*rres.rectx*rres.recty);
-                       }
 
-                       RE_ReleaseResultImage(re);
-                       
-                       // BIF_end_render_callbacks();
+                               RE_ReleaseResultImage(re);
+
+                               // BIF_end_render_callbacks();
+
+                               /* restore */
+                               scene->r.scemode |= doseq;
                        
-                       /* restore */
-                       scene->r.scemode |= doseq;
-               
-                       seq->scene->r.cfra = oldcfra;
+                               seq->scene->r.cfra = oldcfra;
+                       }
 
                        copy_to_ibuf_still(seq, se);
 
@@ -3803,7 +3816,7 @@ Sequence *sequencer_add_image_strip(bContext *C, ListBase *seqbasep, SeqLoadInfo
        strip->len = seq->len = seq_load->len ? seq_load->len : 1;
        strip->us= 1;
        strip->stripdata= se= MEM_callocN(seq->len*sizeof(StripElem), "stripelem");
-       BLI_split_dirfile_basic(seq_load->path, strip->dir, se->name);
+       BLI_split_dirfile(seq_load->path, strip->dir, se->name);
        
        seq_load_apply(scene, seq, seq_load);
 
@@ -3853,7 +3866,7 @@ Sequence *sequencer_add_sound_strip(bContext *C, ListBase *seqbasep, SeqLoadInfo
 
        strip->stripdata= se= MEM_callocN(seq->len*sizeof(StripElem), "stripelem");
 
-       BLI_split_dirfile_basic(seq_load->path, strip->dir, se->name);
+       BLI_split_dirfile(seq_load->path, strip->dir, se->name);
 
        seq->scene_sound = sound_add_scene_sound(scene, seq, seq_load->start_frame, seq_load->start_frame + strip->len, 0);
 
@@ -3897,7 +3910,7 @@ Sequence *sequencer_add_movie_strip(bContext *C, ListBase *seqbasep, SeqLoadInfo
 
        strip->stripdata= se= MEM_callocN(seq->len*sizeof(StripElem), "stripelem");
 
-       BLI_split_dirfile_basic(seq_load->path, strip->dir, se->name);
+       BLI_split_dirfile(seq_load->path, strip->dir, se->name);
 
        calc_sequence_disp(scene, seq);
 
index e014b209e07aaa821a7e0af9abb057ac4bf5162c..23df930aa8466d614373e7ae3424041d7025277c 100644 (file)
@@ -39,6 +39,7 @@
 
 static int force_device = -1;
 
+#ifdef WITH_JACK
 static void sound_sync_callback(void* data, int mode, float time)
 {
        struct Main* bmain = (struct Main*)data;
@@ -58,6 +59,7 @@ static void sound_sync_callback(void* data, int mode, float time)
                scene = scene->id.next;
        }
 }
+#endif
 
 int sound_define_from_str(char *str)
 {
index b58caf14293a333b856c54a91ce24c4be5e9aa45..a7f80953f22c30eb506421f5b5e8d21238d41446 100644 (file)
@@ -247,7 +247,7 @@ int reopen_text(Text *text)
        
        BLI_strncpy(str, text->name, FILE_MAXDIR+FILE_MAXFILE);
        BLI_convertstringcode(str, G.sce);
-       BLI_split_dirfile_basic(str, NULL, sfile);
+       BLI_split_dirfile(str, NULL, sfile);
        
        fp= fopen(str, "r");
        if(fp==NULL) return 0;
@@ -345,7 +345,7 @@ Text *add_text(char *file, const char *relpath)
        BLI_strncpy(str, file, FILE_MAXDIR+FILE_MAXFILE);
        if (relpath) /* can be NULL (bg mode) */
                BLI_convertstringcode(str, relpath);
-       BLI_split_dirfile_basic(str, NULL, sfile);
+       BLI_split_dirfile(str, NULL, sfile);
        
        fp= fopen(str, "r");
        if(fp==NULL) return NULL;
index 9b4084aa17276e0f82e4cf84e3597d726e9711c8..36a540e4d976d04bb4955b6bced7261e988b7931 100644 (file)
@@ -56,8 +56,7 @@ void BLI_setenv_if_new(const char *env, const char* val);
 void BLI_make_file_string(const char *relabase, char *string,  const char *dir, const char *file);
 void BLI_make_exist(char *dir);
 void BLI_make_existing_file(char *name);
-void BLI_split_dirfile(char *string, char *dir, char *file);
-void BLI_split_dirfile_basic(const char *string, char *dir, char *file);
+void BLI_split_dirfile(const char *string, char *dir, char *file);
 void BLI_join_dirfile(char *string, const char *dir, const char *file);
 int BKE_rebase_path(char *abs, int abs_size, char *rel, int rel_size, const char *base_dir, const char *src_dir, const char *dest_dir);
 void BLI_getlastdir(const char* dir, char *last, int maxlen);
index 8d3d807ba1bbb81c92a1a4ea7506b2004d8123b5..71d16adeab50bcd9ddb86b5571922bbed2523bbd 100644 (file)
@@ -290,7 +290,7 @@ static void seq_setpath(struct BPathIterator *bpi, char *path) {
        
        if (SEQ_HAS_PATH(seq)) {
                if (seq->type == SEQ_IMAGE || seq->type == SEQ_MOVIE) {
-                       BLI_split_dirfile_basic(path, seq->strip->dir, seq->strip->stripdata->name);
+                       BLI_split_dirfile(path, seq->strip->dir, seq->strip->stripdata->name);
                } else {
                        /* simple case */
                        BLI_strncpy(seq->strip->dir, path, sizeof(seq->strip->dir));
@@ -673,7 +673,7 @@ void findMissingFiles(char *basepath, char *str) {
        
        //XXX waitcursor( 1 );
        
-       BLI_split_dirfile_basic(str, dirname, NULL);
+       BLI_split_dirfile(str, dirname, NULL);
        
        BLI_bpathIterator_init(&bpi, basepath);
        
@@ -694,7 +694,7 @@ void findMissingFiles(char *basepath, char *str) {
                                /* can the dir be opened? */
                                filesize = -1;
                                recur_depth = 0;
-                               BLI_split_dirfile_basic(filepath, NULL, filename); /* the file to find */
+                               BLI_split_dirfile(filepath, NULL, filename); /* the file to find */
                                
                                findFileRecursive(filename_new, dirname, filename, &filesize, &recur_depth);
                                if (filesize == -1) { /* could not open dir */
index fe43960b7706e1bd87a459135d5b1a27572ddf3f..2346b172e872f3681dc82abd822761891e8f6dba 100644 (file)
@@ -1163,7 +1163,7 @@ int BLI_testextensie(const char *str, const char *ext)
  * - dosnt use CWD, or deal with relative paths.
  * - Only fill's in *dir and *file when they are non NULL
  * */
-void BLI_split_dirfile_basic(const char *string, char *dir, char *file)
+void BLI_split_dirfile(const char *string, char *dir, char *file)
 {
        int lslash=0, i = 0;
        for (i=0; string[i]!='\0'; i++) {
@@ -1183,128 +1183,6 @@ void BLI_split_dirfile_basic(const char *string, char *dir, char *file)
        }
 }
 
-
-/* Warning,
- * - May modify 'string' variable
- * - May create the directory if it dosnt exist
- * if this is not needed use BLI_split_dirfile_basic(...)
- */
-void BLI_split_dirfile(char *string, char *dir, char *file)
-{
-       int a;
-#ifdef WIN32
-       int sl;
-       short is_relative = 0;
-       char path[FILE_MAX];
-#endif
-
-       dir[0]= 0;
-       file[0]= 0;
-
-#ifdef WIN32
-       BLI_strncpy(path, string, FILE_MAX);
-       BLI_char_switch(path, '/', '\\'); /* make sure we have a valid path format */
-       sl = strlen(path);
-       if (sl) {
-               int len;
-               if (path[0] == '/' || path[0] == '\\') { 
-                       BLI_strncpy(dir, path, FILE_MAXDIR);
-                       if (sl > 1 && path[0] == '\\' && path[1] == '\\') is_relative = 1;
-               } else if (sl > 2 && path[1] == ':' && path[2] == '\\') {
-                       BLI_strncpy(dir, path, FILE_MAXDIR);
-               } else {
-                       BLI_getwdN(dir);
-                       strcat(dir,"\\");
-                       strcat(dir,path);
-                       BLI_strncpy(path,dir,FILE_MAXDIR+FILE_MAXFILE);
-               }
-               
-               // BLI_exist doesn't recognize a slashed dirname as a dir
-               //  check if a trailing slash exists, and remove it. Do not do this
-               //  when we are already at root. -jesterKing
-               a = strlen(dir);
-               if(a>=4 && dir[a-1]=='\\') dir[a-1] = 0;
-
-               if (is_relative) {
-                       printf("WARNING: BLI_split_dirfile needs absolute dir\n");
-               }
-               else {
-                       BLI_make_exist(dir);
-               }
-
-               if (S_ISDIR(BLI_exist(dir))) {
-
-                       /* copy from end of string into file, to ensure filename itself isn't truncated 
-                       if string is too long. (aphex) */
-
-                       len = FILE_MAXFILE - strlen(path);
-
-                       if (len < 0)
-                               BLI_strncpy(file,path + abs(len),FILE_MAXFILE);
-                       else
-                               BLI_strncpy(file,path,FILE_MAXFILE);
-                   
-                       if (strrchr(path,'\\')) {
-                               BLI_strncpy(file,strrchr(path,'\\')+1,FILE_MAXFILE);
-                       }
-                       
-                       if ( (a = strlen(dir)) ) {
-                               if (dir[a-1] != '\\') strcat(dir,"\\");
-                       }
-               }
-               else {
-                       a = strlen(dir) - 1;
-                       while(a>0 && dir[a] != '\\') a--;
-                       dir[a + 1] = 0;
-                       BLI_strncpy(file, path + strlen(dir),FILE_MAXFILE);
-               }
-
-       }
-       else {
-               /* defaulting to first valid drive hoping it's not empty CD and DVD drives */
-               get_default_root(dir);
-               file[0]=0;
-       }
-#else
-       if (strlen(string)) {
-               if (string[0] == '/') { 
-                       strcpy(dir, string);
-               } else if (string[1] == ':' && string[2] == '\\') {
-                       string+=2;
-                       strcpy(dir, string);
-               } else {
-                       BLI_getwdN(dir);
-                       strcat(dir,"/");
-                       strcat(dir,string);
-                       strcpy((char *)string,dir);
-               }
-
-               BLI_make_exist(dir);
-                       
-               if (S_ISDIR(BLI_exist(dir))) {
-                       strcpy(file,string + strlen(dir));
-
-                       if (strrchr(file,'/')) strcpy(file,strrchr(file,'/')+1);
-               
-                       if ( (a = strlen(dir)) ) {
-                               if (dir[a-1] != '/') strcat(dir,"/");
-                       }
-               }
-               else {
-                       a = strlen(dir) - 1;
-                       while(dir[a] != '/') a--;
-                       dir[a + 1] = 0;
-                       strcpy(file, string + strlen(dir));
-               }
-       }
-       else {
-               BLI_getwdN(dir);
-               strcat(dir, "/");
-               file[0] = 0;
-       }
-#endif
-}
-
 /* simple appending of filename to dir, does not check for valid path! */
 void BLI_join_dirfile(char *string, const char *dir, const char *file)
 {
@@ -1363,7 +1241,7 @@ int BKE_rebase_path(char *abs, int abs_size, char *rel, int rel_size, const char
        if (rel)
                rel[0]= 0;
 
-       BLI_split_dirfile_basic(base_dir, blend_dir, NULL);
+       BLI_split_dirfile(base_dir, blend_dir, NULL);
 
        if (src_dir[0]=='\0')
                return 0;
@@ -1374,7 +1252,7 @@ int BKE_rebase_path(char *abs, int abs_size, char *rel, int rel_size, const char
        BLI_convertstringcode(path, base_dir);
 
        /* get the directory part */
-       BLI_split_dirfile_basic(path, dir, base);
+       BLI_split_dirfile(path, dir, base);
 
        len= strlen(blend_dir);
 
index 22fcd28ca00d3933033abd967a55036b7d8be575..3a5b8e14de366a240520f045461412bfdc106e40 100644 (file)
@@ -2466,8 +2466,8 @@ int BLO_write_file(Main *mainvar, char *dir, int write_flags, ReportList *report
        if(write_flags & G_FILE_RELATIVE_REMAP) {
                char dir1[FILE_MAXDIR+FILE_MAXFILE];
                char dir2[FILE_MAXDIR+FILE_MAXFILE];
-               BLI_split_dirfile_basic(dir, dir1, NULL);
-               BLI_split_dirfile_basic(mainvar->name, dir2, NULL);
+               BLI_split_dirfile(dir, dir1, NULL);
+               BLI_split_dirfile(mainvar->name, dir2, NULL);
 
                /* just incase there is some subtle difference */
                BLI_cleanup_dir(mainvar->name, dir1);
index 3e1898a64d926d464a60311d1803cf67ea682125..a4c4535841716031b9f79ee6da0183c15421688f 100644 (file)
@@ -1433,7 +1433,7 @@ public:
                                char src[FILE_MAX];
                                char dir[FILE_MAX];
                                
-                               BLI_split_dirfile_basic(mfilename, dir, NULL);
+                               BLI_split_dirfile(mfilename, dir, NULL);
 
                                BKE_rebase_path(abs, sizeof(abs), rel, sizeof(rel), G.sce, image->name, dir);
 
index 33c9a061cda4d729237d2ff378427da694387b60..e3bdf25bdc0b7dfa3bbde4ac10ab075d623aae3e 100644 (file)
@@ -3407,7 +3407,7 @@ public:
                char dir[FILE_MAX];
                char full_path[FILE_MAX];
                
-               BLI_split_dirfile_basic(filename, dir, NULL);
+               BLI_split_dirfile(filename, dir, NULL);
                BLI_join_dirfile(full_path, dir, filepath.c_str());
                Image *ima = BKE_add_image_file(full_path, 0);
                if (!ima) {
index cb73c5f5b39d5dc73d03d3e81c3d1183a3990546..303748c79fdaedeebbb20fbad84dbeae6131bbd5 100644 (file)
@@ -158,6 +158,8 @@ int ED_view3d_context_activate(struct bContext *C);
 void ED_view3d_draw_offscreen(struct Scene *scene, struct View3D *v3d, struct ARegion *ar,
        int winx, int winy, float viewmat[][4], float winmat[][4]);
 
+struct ImBuf *ED_view3d_draw_offscreen_imbuf(struct Scene *scene, struct View3D *v3d, struct ARegion *ar, int sizex, int sizey);
+
 void view3d_clipping_local(struct RegionView3D *rv3d, float mat[][4]);
 
 Base *ED_view3d_give_base_under_cursor(struct bContext *C, short *mval);
index 7916f29043f38809d91fecaaa6db1c6f38a8c0b8..212dc335a63d7571aa8832727470c70e21af14d8 100644 (file)
 #include "BLI_editVert.h"
 #include "BLI_dlrbTree.h"
 
-#include "DNA_armature_types.h"
-#include "DNA_image_types.h"
-#include "DNA_lattice_types.h"
 #include "DNA_object_types.h"
-#include "DNA_mesh_types.h"
-#include "DNA_curve_types.h"
 #include "DNA_scene_types.h"
-#include "DNA_meta_types.h"
 #include "DNA_view3d_types.h"
 
 #include "BKE_blender.h"
-#include "BKE_colortools.h"
+#include "BKE_object.h"
 #include "BKE_context.h"
-#include "BKE_customdata.h"
 #include "BKE_global.h"
 #include "BKE_image.h"
-#include "BKE_idprop.h"
 #include "BKE_library.h"
 #include "BKE_main.h"
 #include "BKE_mesh.h"
@@ -62,7 +54,6 @@
 #include "BKE_scene.h"
 #include "BKE_screen.h"
 #include "BKE_utildefines.h"
-#include "BKE_sound.h"
 #include "BKE_writeavi.h"
 
 #include "WM_api.h"
@@ -180,7 +171,6 @@ static int screen_opengl_render_init(bContext *C, wmOperator *op)
        sizex= (scene->r.size*scene->r.xsch)/100;
        sizey= (scene->r.size*scene->r.ysch)/100;
 
-       view3d_operator_needs_opengl(C);
        ofs= GPU_offscreen_create(sizex, sizey);
 
        if(!ofs) {
@@ -468,3 +458,6 @@ void RENDER_OT_opengl(wmOperatorType *ot)
 
        RNA_def_boolean(ot->srna, "animation", 0, "Animation", "");
 }
+
+/* function for getting an opengl buffer from a View3D, used by sequencer */
+// extern void *sequencer_view3d_cb;
index bd4462c79133b4eb6321a34af366527df67d3832..4a98f524bc49114e68b0415573709a33e545bfff 100644 (file)
@@ -5479,37 +5479,21 @@ void PAINT_OT_project_image(wmOperatorType *ot)
        ot->prop= prop;
 }
 
-static Image *ED_region_image(ARegion *ar, char *filename)
-{
-       int x= ar->winrct.xmin;
-       int y= ar->winrct.ymin;
-       int w= ar->winrct.xmax-x;
-       int h= ar->winrct.ymax-y;
-
-       if (h && w) {
-               float color[] = {0, 0, 0, 1};
-               Image *image = BKE_add_image_size(w, h, filename, 0, 0, color);
-               ImBuf *ibuf= BKE_image_get_ibuf(image, NULL);
-
-               glReadBuffer(GL_FRONT);
-               glReadPixels(x, y, w, h, GL_RGBA, GL_UNSIGNED_BYTE, ibuf->rect);
-               glFinish();
-               glReadBuffer(GL_BACK);
-
-               return image;
-       }
-
-       return NULL;
-}
-
 static int texture_paint_image_from_view_exec(bContext *C, wmOperator *op)
 {
-       ARegion *ar= CTX_wm_region(C);
        Image *image;
+       ImBuf *ibuf;
        char filename[FILE_MAX];
+
+       Scene *scene= CTX_data_scene(C);
+       ToolSettings *settings= scene->toolsettings;
+       int w= settings->imapaint.screen_grab_size[0];
+       int h= settings->imapaint.screen_grab_size[1];
+
        RNA_string_get(op->ptr, "filename", filename);
 
-       image= ED_region_image(ar, filename);
+       ibuf= ED_view3d_draw_offscreen_imbuf(CTX_data_scene(C), CTX_wm_view3d(C), CTX_wm_region(C), w, h);
+       image= BKE_add_image_imbuf(ibuf);
 
        if(image) {
                /* now for the trickyness. store the view projection here!
index bd1053d8d776106faea81d7ddfeda30ba898f440..7a809f7b668e9a00892cd4c449284f042970b4b1 100644 (file)
@@ -282,7 +282,7 @@ static int sequencer_add_generic_strip_exec(bContext *C, wmOperator *op, SeqLoad
                char dir_only[FILE_MAX];
                char file_only[FILE_MAX];
 
-               BLI_split_dirfile_basic(seq_load.path, dir_only, NULL);
+               BLI_split_dirfile(seq_load.path, dir_only, NULL);
 
                RNA_BEGIN(op->ptr, itemptr, "files") {
                        RNA_string_get(&itemptr, "name", file_only);
@@ -422,7 +422,7 @@ static int sequencer_add_image_strip_exec(bContext *C, wmOperator *op)
                RNA_END;
        }
        else {
-               BLI_split_dirfile_basic(seq_load.path, NULL, se->name);
+               BLI_split_dirfile(seq_load.path, NULL, se->name);
                if(seq_load.start_frame < seq_load.end_frame) {
                        seq->endstill= seq_load.end_frame - seq_load.start_frame;
                }
index ea81a8cafd96534e7f067c582939c5fcd5a9f18e..35818a4e3e0a9aef3ad2f3e02e75912075d0574e 100644 (file)
@@ -95,6 +95,7 @@
 
 #include "GPU_draw.h"
 #include "GPU_material.h"
+#include "GPU_extensions.h"
 
 #include "view3d_intern.h"     // own include
 
@@ -2032,6 +2033,48 @@ void ED_view3d_draw_offscreen(Scene *scene, View3D *v3d, ARegion *ar, int winx,
        glPopMatrix();
 }
 
+/* utility func for ED_view3d_draw_offscreen */
+ImBuf *ED_view3d_draw_offscreen_imbuf(Scene *scene, View3D *v3d, ARegion *ar, int sizex, int sizey)
+{
+       RegionView3D *rv3d= ar->regiondata;
+       ImBuf *ibuf;
+       GPUOffScreen *ofs;
+
+       /* bind */
+       ofs= GPU_offscreen_create(sizex, sizey);
+       if(ofs == NULL)
+               return NULL;
+
+       GPU_offscreen_bind(ofs);
+
+       /* render 3d view */
+       if(rv3d->persp==RV3D_CAMOB && v3d->camera) {
+               float winmat[4][4];
+               float _clipsta, _clipend, _lens, _yco, _dx, _dy;
+               rctf _viewplane;
+
+               object_camera_matrix(&scene->r, v3d->camera, sizex, sizey, 0, winmat, &_viewplane, &_clipsta, &_clipend, &_lens, &_yco, &_dx, &_dy);
+
+               ED_view3d_draw_offscreen(scene, v3d, ar, sizex, sizey, NULL, winmat);
+       }
+       else {
+               ED_view3d_draw_offscreen(scene, v3d, ar, sizex, sizey, NULL, NULL);
+       }
+
+       /* read in pixels & stamp */
+       ibuf= IMB_allocImBuf(sizex, sizey, 24, IB_rect, 0);
+       glReadPixels(0, 0, sizex, sizey, GL_RGBA, GL_UNSIGNED_BYTE, ibuf->rect);
+
+       //if((scene->r.stamp & R_STAMP_ALL) && (scene->r.stamp & R_STAMP_DRAW))
+       //      BKE_stamp_buf(scene, NULL, rr->rectf, rr->rectx, rr->recty, 4);
+
+       /* unbind */
+       GPU_offscreen_unbind(ofs);
+       GPU_offscreen_free(ofs);
+
+       return ibuf;
+}
+
 /* NOTE: the info that this uses is updated in ED_refresh_viewport_fps(), 
  * which currently gets called during SCREEN_OT_animation_step.
  */
index 928637a00475260d9a60d76262755537a37488d1..c9339b4bdddd26a34264e7de3f840e1dade36889 100644 (file)
@@ -521,6 +521,9 @@ typedef struct ImagePaintSettings {
        
        /* for projection painting only */
        short seam_bleed, normal_angle;
+       short screen_grab_size[2]; /* capture size for re-projection */
+
+       int pad1;
 
        void *paintcursor;                      /* wm handle */
 } ImagePaintSettings;
index 456071499e3b85871bdb9fed84559a9033b3ed84..4aa1401ac843d2ea5c06fb2dacaf94790c7fd7b5 100644 (file)
@@ -351,6 +351,9 @@ static void rna_def_image_paint(BlenderRNA *brna)
        prop= RNA_def_property(srna, "normal_angle", PROP_INT, PROP_UNSIGNED);
        RNA_def_property_range(prop, 0, 90);
        RNA_def_property_ui_text(prop, "Angle", "Paint most on faces pointing towards the view acording to this angle");
+
+       prop= RNA_def_int_array(srna, "screen_grab_size", 2, NULL, 0, 0, "screen_grab_size", "Size to capture the image for re-projecting", 0, 0);
+       RNA_def_property_range(prop, 512, 16384);
 }
 
 static void rna_def_particle_edit(BlenderRNA *brna)
index 7464df6eb796a77057739f597257dcbd8f49cd1c..8f80ae8a3018090961431cd7cfd4897c0015ad98 100644 (file)
@@ -319,7 +319,7 @@ static void rna_Sequence_filepath_set(PointerRNA *ptr, const char *value)
        Sequence *seq= (Sequence*)(ptr->data);
        char dir[FILE_MAX], name[FILE_MAX];
 
-       BLI_split_dirfile_basic(value, dir, name);
+       BLI_split_dirfile(value, dir, name);
        BLI_strncpy(seq->strip->dir, dir, sizeof(seq->strip->dir));
        BLI_strncpy(seq->strip->stripdata->name, name, sizeof(seq->strip->stripdata->name));
 }
@@ -347,7 +347,7 @@ static void rna_SoundSequence_filename_set(PointerRNA *ptr, const char *value)
        Sequence *seq= (Sequence*)(ptr->data);
        char dir[FILE_MAX], name[FILE_MAX];
 
-       BLI_split_dirfile_basic(value, dir, name);
+       BLI_split_dirfile(value, dir, name);
        BLI_strncpy(seq->strip->dir, dir, sizeof(seq->strip->dir));
        BLI_strncpy(seq->strip->stripdata->name, name, sizeof(seq->strip->stripdata->name));
 }
@@ -357,7 +357,7 @@ static void rna_SequenceElement_filename_set(PointerRNA *ptr, const char *value)
        StripElem *elem= (StripElem*)(ptr->data);
        char name[FILE_MAX];
 
-       BLI_split_dirfile_basic(value, NULL, name);
+       BLI_split_dirfile(value, NULL, name);
        BLI_strncpy(elem->name, name, sizeof(elem->name));
 }
 
index 6f0ae28439218214f50e144c7f1a0aadad616d56..c30939fba54baa2103a44d372c5546feccfd036e 100644 (file)
@@ -474,7 +474,7 @@ static PyObject* gPyGetBlendFileList(PyObject*, PyObject* args)
                BLI_convertstringcode(cpath, gp_GamePythonPath);
        } else {
                /* Get the dir only */
-               BLI_split_dirfile_basic(gp_GamePythonPath, cpath, NULL);
+               BLI_split_dirfile(gp_GamePythonPath, cpath, NULL);
        }
        
     if((dp  = opendir(cpath)) == NULL) {
@@ -1786,7 +1786,7 @@ static void initPySysObjects__append(PyObject *sys_path, char *filename)
        PyObject *item;
        char expanded[FILE_MAXDIR + FILE_MAXFILE];
        
-       BLI_split_dirfile_basic(filename, expanded, NULL); /* get the dir part of filename only */
+       BLI_split_dirfile(filename, expanded, NULL); /* get the dir part of filename only */
        BLI_convertstringcode(expanded, gp_GamePythonPath); /* filename from lib->filename is (always?) absolute, so this may not be needed but it wont hurt */
        BLI_cleanup_file(gp_GamePythonPath, expanded); /* Dont use BLI_cleanup_dir because it adds a slash - BREAKS WIN32 ONLY */
        item= PyUnicode_FromString(expanded);