Added 'File->External Data->Make all files Absolute'
authorCampbell Barton <ideasman42@gmail.com>
Mon, 24 Dec 2007 17:07:52 +0000 (17:07 +0000)
committerCampbell Barton <ideasman42@gmail.com>
Mon, 24 Dec 2007 17:07:52 +0000 (17:07 +0000)
OpenGL stamp also wasnt checking correctly (own error)

source/blender/blenkernel/intern/image.c
source/blender/blenlib/BLI_bpath.h
source/blender/blenlib/intern/bpath.c
source/blender/src/header_info.c
source/blender/src/renderwin.c

index ed944a3a4ea8dbb249f3d13040d2f24bae2d02a5..dc8a020a1897deb7b7bfb7ecc50c56d9b4ea7c33 100644 (file)
@@ -812,8 +812,8 @@ static void stampdata(StampData *stamp_data, int do_prefix)
        }
        
        if (G.scene->r.stamp & R_STAMP_NOTE) {
-               if (do_prefix)          sprintf(stamp_data->note, "Note %s", G.scene->r.stamp_udata);
-               else                            sprintf(stamp_data->note, "%s", G.scene->r.stamp_udata);
+               /* Never do prefix for Note */
+               sprintf(stamp_data->note, "%s", G.scene->r.stamp_udata);
        } else {
                stamp_data->note[0] = '\0';
        }
index e2d7d23410c71325f82e1f05c155ea3cbd1c01bb..32d20c4b13e3500ac4c7c7194e7ea3016dc996a0 100644 (file)
@@ -56,4 +56,5 @@ void                  BLI_bpathIterator_copyPathExpanded( struct BPathIterator *bpi, char *path
 /* creates a text file with missing files if there are any */
 struct Text * checkMissingFiles(void);
 void makeFilesRelative(int *tot, int *changed, int *failed, int *linked);
+void makeFilesAbsolute(int *tot, int *changed, int *failed, int *linked);
 void findMissingFiles(char *str);
index 2c1ebd59a55b14beee1755a95b65e8daa9831e57..2548c059064f1e1d2116c4437ed95c79c6ee57d3 100644 (file)
@@ -347,15 +347,15 @@ void makeFilesRelative(int *tot, int *changed, int *failed, int *linked) {
                libpath = BLI_bpathIterator_getLib(&bpi);
                
                if(strncmp(filepath, "//", 2)) {
-                       if (libpath) { /* cant make relative if we are kibrary - TODO, LOG THIS */
+                       if (libpath) { /* cant make relative if we are library - TODO, LOG THIS */
                                (*linked)++;
                        } else { /* local data, use the blend files path */
                                BLI_strncpy(filepath_relative, filepath, sizeof(filepath_relative));
                                BLI_makestringcode(G.sce, filepath_relative);
-                               if (BLI_bpathIterator_getPathMaxLen(&bpi) < strlen(filepath_relative)) {
+                               /* be safe and check the length */
+                               if (BLI_bpathIterator_getPathMaxLen(&bpi) <= strlen(filepath_relative)) {
                                        (*failed)++;
                                } else {
-                                       /* safe to to check the length */
                                        if(strncmp(filepath_relative, "//", 2)==0) {
                                                strcpy(filepath, filepath_relative);
                                                (*changed)++;
@@ -365,12 +365,52 @@ void makeFilesRelative(int *tot, int *changed, int *failed, int *linked) {
                                }
                        }
                }
+               BLI_bpathIterator_step(&bpi);
+               (*tot)++;
+       }
+}
+
+/* dont log any errors at the moment, should probably do this -
+ * Verry similar to makeFilesRelative - keep in sync! */
+void makeFilesAbsolute(int *tot, int *changed, int *failed, int *linked) {
+       struct BPathIterator bpi;
+       char *filepath, *libpath;
+       
+       /* be sure there is low chance of the path being too short */
+       char filepath_absolute[(FILE_MAXDIR * 2) + FILE_MAXFILE];
+       
+       *tot = *changed = *failed = *linked = 0;
+       
+       BLI_bpathIterator_init(&bpi);
+       while (!BLI_bpathIterator_isDone(&bpi)) {
+               filepath = BLI_bpathIterator_getPath(&bpi);
+               libpath = BLI_bpathIterator_getLib(&bpi);
                
+               if(strncmp(filepath, "//", 2)==0) {
+                       if (libpath) { /* cant make absolute if we are library - TODO, LOG THIS */
+                               (*linked)++;
+                       } else { /* get the expanded path and check it is relative or too long */
+                               BLI_bpathIterator_copyPathExpanded( &bpi, filepath_absolute );
+                               
+                               /* safe be safe, check the length */
+                               if (BLI_bpathIterator_getPathMaxLen(&bpi) <= strlen(filepath_absolute)) {
+                                       (*failed)++;
+                               } else {
+                                       if(strncmp(filepath_absolute, "//", 2)) {
+                                               strcpy(filepath, filepath_absolute);
+                                               (*changed)++;
+                                       } else {
+                                               (*failed)++;
+                                       }
+                               }
+                       }
+               }
                BLI_bpathIterator_step(&bpi);
                (*tot)++;
        }
 }
 
+
 /* find this file recursively, use the biggest file so thumbnails dont get used by mistake
  - dir: subdir to search
  - filename: set this filename
@@ -387,8 +427,6 @@ static int findFileRecursive(char *filename_new, const char *dirname, const char
        char path[FILE_MAX];
        int size;
        
-       printf("DIR %s\n", dirname);
-       
        dir = opendir(dirname);
        
        if (dir==0)
index 174a5c683f060c9a17e7a1ded9c578c2e86d0a24..beb3eb5282014ee101b92deae93a861c2f2ba814 100644 (file)
@@ -963,7 +963,16 @@ static void do_info_externalfiles(void *arg, int event)
                        pupmenu("Can't set relative paths with an unsaved blend file");
                }
                break;
-       case 11: /* check images exist */
+       case 11: /* make all paths relative */
+               {
+                       int tot,changed,failed,linked;
+                       char str[512];
+                       makeFilesAbsolute(&tot, &changed, &failed, &linked);
+                       sprintf(str, "Make Absolute%%t|Total files %i|Changed %i|Failed %i|Linked %i", tot, changed, failed, linked);
+                       pupmenu(str);
+               }
+               break;
+       case 12: /* check images exist */
                {
                        /* Its really text but only care about the name */
                        ID *btxt = (ID *)checkMissingFiles();
@@ -977,7 +986,7 @@ static void do_info_externalfiles(void *arg, int event)
                        }
                }
                break;
-       case 12: /* search for referenced files that are not available  */
+       case 13: /* search for referenced files that are not available  */
                activate_fileselect(FILE_SPECIAL, "Find Missing Files", "", findMissingFiles);
                break;
        }
@@ -1002,8 +1011,9 @@ static uiBlock *info_externalfiles(void *arg_unused)
        uiDefBut(block, SEPR, 0, "",                                    0, yco-=6, menuwidth, 6, NULL, 0.0, 0.0, 0, 0, "");
        
        uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Make all Paths Relative",                                0, yco-=20, 160, 19, NULL, 0.0, 0.0, 1, 10, "");
-       uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Report Missing Files",                           0, yco-=20, 160, 19, NULL, 0.0, 0.0, 1, 11, "");
-       uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Find Missing Files",                             0, yco-=20, 160, 19, NULL, 0.0, 0.0, 1, 12, "");
+       uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Make all Paths Absolute",                                0, yco-=20, 160, 19, NULL, 0.0, 0.0, 1, 11, "");
+       uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Report Missing Files",                           0, yco-=20, 160, 19, NULL, 0.0, 0.0, 1, 12, "");
+       uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Find Missing Files",                             0, yco-=20, 160, 19, NULL, 0.0, 0.0, 1, 13, "");
 
        uiBlockSetDirection(block, UI_RIGHT);
        uiTextBoundsBlock(block, 60);
index 8250ba4902d34fd605103f84422a50f54a637169..e97fdef27ff754f95dd9dd64fbd4dcc65ccb5db8 100644 (file)
@@ -1300,7 +1300,9 @@ void BIF_do_ogl_render(View3D *v3d, int anim)
 
                        do_ogl_view3d_render(re, v3d, winx, winy);
                        glReadPixels(0, 0, winx, winy, GL_RGBA, GL_UNSIGNED_BYTE, rr->rect32);
-                       BKE_stamp_buf((unsigned char *)rr->rect32, rr->rectf, rr->rectx, rr->recty);
+                       if((G.scene->r.scemode & R_STAMP_INFO) && (G.scene->r.stamp & R_STAMP_DRAW)) {
+                               BKE_stamp_buf((unsigned char *)rr->rect32, rr->rectf, rr->rectx, rr->recty);
+                       }
                        window_swap_buffers(render_win->win);
                        
                        if(BKE_imtype_is_movie(G.scene->r.imtype)) {
@@ -1340,7 +1342,9 @@ void BIF_do_ogl_render(View3D *v3d, int anim)
        else {
                do_ogl_view3d_render(re, v3d, winx, winy);
                glReadPixels(0, 0, winx, winy, GL_RGBA, GL_UNSIGNED_BYTE, rr->rect32);
-               BKE_stamp_buf((unsigned char *)rr->rect32, rr->rectf, rr->rectx, rr->recty);
+               if((G.scene->r.scemode & R_STAMP_INFO) && (G.scene->r.stamp & R_STAMP_DRAW)) {
+                       BKE_stamp_buf((unsigned char *)rr->rect32, rr->rectf, rr->rectx, rr->recty);
+               }
                window_swap_buffers(render_win->win);
        }