[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [13505] trunk/blender/source/blender/ blenloader/intern/readfile.c: Fix for indirectly linked libraries.

Campbell Barton ideasman42 at gmail.com
Thu Jan 31 22:19:41 CET 2008


Revision: 13505
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=13505
Author:   campbellbarton
Date:     2008-01-31 22:19:40 +0100 (Thu, 31 Jan 2008)

Log Message:
-----------
Fix for indirectly linked libraries.

When a.blend -> //../c.blend -> //d.blend
Blender would see d.blend as //d.blend which is wrong since that is relative to c.blend
This works, except when you make an indirectly linked group into a directly linked group. and then the incorrect path was saved into the blend file and the data not load up again (without copying it there or hex editing the path)

This loop makes all lib files relative to the blend you have open.

Modified Paths:
--------------
    trunk/blender/source/blender/blenloader/intern/readfile.c

Modified: trunk/blender/source/blender/blenloader/intern/readfile.c
===================================================================
--- trunk/blender/source/blender/blenloader/intern/readfile.c	2008-01-31 18:32:33 UTC (rev 13504)
+++ trunk/blender/source/blender/blenloader/intern/readfile.c	2008-01-31 21:19:40 UTC (rev 13505)
@@ -4065,11 +4065,15 @@
 static void lib_link_library(FileData *fd, Main *main)
 {
 	Library *lib;
-
-	lib= main->library.first;
-	while(lib) {
+	for(lib= main->library.first; lib; lib= lib->id.next) {
 		lib->id.us= 1;
-		lib= lib->id.next;
+		
+		/* Libraries store both relative and abs paths, recreate relative paths,
+		 * relative to the blend file since indirectly linked libs will be relative to their direct linked library */
+		if (strncmp(lib->name, "//", 2)==0) { /* if this is relative to begin with? */
+			strncpy(lib->name, lib->filename, sizeof(lib->name));
+			BLI_makestringcode(fd->filename, lib->name);
+		}
 	}
 }
 





More information about the Bf-blender-cvs mailing list