From f7d5cea669bd40de9c0aa5fc3aaa4c7f49f697a8 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Thu, 27 Oct 2011 05:34:39 +0000 Subject: use path remapping for all make local functions, patch from Alex Fraser with changes. --- source/blender/blenkernel/intern/armature.c | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) (limited to 'source/blender/blenkernel/intern/armature.c') diff --git a/source/blender/blenkernel/intern/armature.c b/source/blender/blenkernel/intern/armature.c index b4b5dfedad2..2ebede13d70 100644 --- a/source/blender/blenkernel/intern/armature.c +++ b/source/blender/blenkernel/intern/armature.c @@ -37,6 +37,7 @@ #include "MEM_guardedalloc.h" +#include "BLI_bpath.h" #include "BLI_math.h" #include "BLI_blenlib.h" #include "BLI_utildefines.h" @@ -136,29 +137,33 @@ void free_armature(bArmature *arm) void make_local_armature(bArmature *arm) { Main *bmain= G.main; - int local=0, lib=0; + int is_local= FALSE, is_lib= FALSE; Object *ob; if (arm->id.lib==NULL) return; if (arm->id.us==1) { - id_clear_lib_data(bmain, (ID *)arm); + id_clear_lib_data(bmain, &arm->id); return; } - for(ob= bmain->object.first; ob && ELEM(0, lib, local); ob= ob->id.next) { + for(ob= bmain->object.first; ob && ELEM(0, is_lib, is_local); ob= ob->id.next) { if(ob->data == arm) { - if(ob->id.lib) lib= 1; - else local= 1; + if(ob->id.lib) is_lib= TRUE; + else is_local= TRUE; } } - if(local && lib==0) { - id_clear_lib_data(bmain, (ID *)arm); + if(is_local && is_lib == FALSE) { + id_clear_lib_data(bmain, &arm->id); } - else if(local && lib) { + else if(is_local && is_lib) { + char *bpath_user_data[2]= {bmain->name, arm->id.lib->filepath}; bArmature *armn= copy_armature(arm); armn->id.us= 0; - + + /* Remap paths of new ID using old library as base. */ + bpath_traverse_id(bmain, &armn->id, bpath_relocate_visitor, 0, bpath_user_data); + for(ob= bmain->object.first; ob; ob= ob->id.next) { if(ob->data == arm) { if(ob->id.lib==NULL) { -- cgit v1.2.3