diff options
author | Campbell Barton <ideasman42@gmail.com> | 2007-12-24 20:07:52 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2007-12-24 20:07:52 +0300 |
commit | 052a0551e49da2a1b07a42c3e67579d9ead4c1fe (patch) | |
tree | 0a06ed4edda3967364d8a00af33ce5c67357a191 /source/blender | |
parent | 8a07e665c28a94ffd188daa431a4fd0c5a460eba (diff) |
Added 'File->External Data->Make all files Absolute'
OpenGL stamp also wasnt checking correctly (own error)
Diffstat (limited to 'source/blender')
-rw-r--r-- | source/blender/blenkernel/intern/image.c | 4 | ||||
-rw-r--r-- | source/blender/blenlib/BLI_bpath.h | 1 | ||||
-rw-r--r-- | source/blender/blenlib/intern/bpath.c | 48 | ||||
-rw-r--r-- | source/blender/src/header_info.c | 18 | ||||
-rw-r--r-- | source/blender/src/renderwin.c | 8 |
5 files changed, 66 insertions, 13 deletions
diff --git a/source/blender/blenkernel/intern/image.c b/source/blender/blenkernel/intern/image.c index ed944a3a4ea..dc8a020a189 100644 --- a/source/blender/blenkernel/intern/image.c +++ b/source/blender/blenkernel/intern/image.c @@ -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'; } diff --git a/source/blender/blenlib/BLI_bpath.h b/source/blender/blenlib/BLI_bpath.h index e2d7d23410c..32d20c4b13e 100644 --- a/source/blender/blenlib/BLI_bpath.h +++ b/source/blender/blenlib/BLI_bpath.h @@ -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); diff --git a/source/blender/blenlib/intern/bpath.c b/source/blender/blenlib/intern/bpath.c index 2c1ebd59a55..2548c059064 100644 --- a/source/blender/blenlib/intern/bpath.c +++ b/source/blender/blenlib/intern/bpath.c @@ -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) diff --git a/source/blender/src/header_info.c b/source/blender/src/header_info.c index 174a5c683f0..beb3eb52820 100644 --- a/source/blender/src/header_info.c +++ b/source/blender/src/header_info.c @@ -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); diff --git a/source/blender/src/renderwin.c b/source/blender/src/renderwin.c index 8250ba4902d..e97fdef27ff 100644 --- a/source/blender/src/renderwin.c +++ b/source/blender/src/renderwin.c @@ -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); } |