[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [12988] trunk/blender/source/blender: Added 'File->External Data->Make all files Absolute'
Campbell Barton
ideasman42 at gmail.com
Mon Dec 24 18:07:52 CET 2007
Revision: 12988
http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=12988
Author: campbellbarton
Date: 2007-12-24 18:07:52 +0100 (Mon, 24 Dec 2007)
Log Message:
-----------
Added 'File->External Data->Make all files Absolute'
OpenGL stamp also wasnt checking correctly (own error)
Modified Paths:
--------------
trunk/blender/source/blender/blenkernel/intern/image.c
trunk/blender/source/blender/blenlib/BLI_bpath.h
trunk/blender/source/blender/blenlib/intern/bpath.c
trunk/blender/source/blender/src/header_info.c
trunk/blender/source/blender/src/renderwin.c
Modified: trunk/blender/source/blender/blenkernel/intern/image.c
===================================================================
--- trunk/blender/source/blender/blenkernel/intern/image.c 2007-12-24 16:51:25 UTC (rev 12987)
+++ trunk/blender/source/blender/blenkernel/intern/image.c 2007-12-24 17:07:52 UTC (rev 12988)
@@ -812,8 +812,8 @@
}
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';
}
Modified: trunk/blender/source/blender/blenlib/BLI_bpath.h
===================================================================
--- trunk/blender/source/blender/blenlib/BLI_bpath.h 2007-12-24 16:51:25 UTC (rev 12987)
+++ trunk/blender/source/blender/blenlib/BLI_bpath.h 2007-12-24 17:07:52 UTC (rev 12988)
@@ -56,4 +56,5 @@
/* 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);
Modified: trunk/blender/source/blender/blenlib/intern/bpath.c
===================================================================
--- trunk/blender/source/blender/blenlib/intern/bpath.c 2007-12-24 16:51:25 UTC (rev 12987)
+++ trunk/blender/source/blender/blenlib/intern/bpath.c 2007-12-24 17:07:52 UTC (rev 12988)
@@ -347,15 +347,15 @@
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 @@
}
}
}
+ 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 @@
char path[FILE_MAX];
int size;
- printf("DIR %s\n", dirname);
-
dir = opendir(dirname);
if (dir==0)
Modified: trunk/blender/source/blender/src/header_info.c
===================================================================
--- trunk/blender/source/blender/src/header_info.c 2007-12-24 16:51:25 UTC (rev 12987)
+++ trunk/blender/source/blender/src/header_info.c 2007-12-24 17:07:52 UTC (rev 12988)
@@ -963,8 +963,17 @@
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 @@
}
}
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 @@
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);
Modified: trunk/blender/source/blender/src/renderwin.c
===================================================================
--- trunk/blender/source/blender/src/renderwin.c 2007-12-24 16:51:25 UTC (rev 12987)
+++ trunk/blender/source/blender/src/renderwin.c 2007-12-24 17:07:52 UTC (rev 12988)
@@ -1300,7 +1300,9 @@
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 @@
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);
}
More information about the Bf-blender-cvs
mailing list