diff options
Diffstat (limited to 'source/blender/blenkernel/intern/mesh.c')
-rw-r--r-- | source/blender/blenkernel/intern/mesh.c | 75 |
1 files changed, 30 insertions, 45 deletions
diff --git a/source/blender/blenkernel/intern/mesh.c b/source/blender/blenkernel/intern/mesh.c index 9574c886ccc..50525c2b9cd 100644 --- a/source/blender/blenkernel/intern/mesh.c +++ b/source/blender/blenkernel/intern/mesh.c @@ -1,6 +1,4 @@ /* - * $Id$ - * * ***** BEGIN GPL LICENSE BLOCK ***** * * This program is free software; you can redistribute it and/or @@ -45,6 +43,7 @@ #include "DNA_ipo_types.h" #include "BLI_blenlib.h" +#include "BLI_bpath.h" #include "BLI_editVert.h" #include "BLI_math.h" #include "BLI_edgehash.h" @@ -243,39 +242,26 @@ Mesh *copy_mesh(Mesh *me) return men; } -static void make_local_tface(Main *bmain, Mesh *me) +static void expand_local_mesh(Mesh *me) { - MTFace *tface; - Image *ima; - int a, i; - - for(i=0; i<me->fdata.totlayer; i++) { - if(me->fdata.layers[i].type == CD_MTFACE) { - tface= (MTFace*)me->fdata.layers[i].data; - - for(a=0; a<me->totface; a++, tface++) { - /* special case: ima always local immediately */ - if(tface->tpage) { - ima= tface->tpage; - if(ima->id.lib) { - ima->id.lib= NULL; - ima->id.flag= LIB_LOCAL; - new_id(&bmain->image, (ID *)ima, NULL); + id_lib_extern((ID *)me->texcomesh); + + if(me->mtface) { + MTFace *tface; + int a, i; + + for(i=0; i<me->fdata.totlayer; i++) { + if(me->fdata.layers[i].type == CD_MTFACE) { + tface= (MTFace*)me->fdata.layers[i].data; + + for(a=0; a<me->totface; a++, tface++) { + if(tface->tpage) { + id_lib_extern((ID *)tface->tpage); } } } } } -} - -static void expand_local_mesh(Main *bmain, Mesh *me) -{ - id_lib_extern((ID *)me->texcomesh); - - if(me->mtface) { - /* why is this an exception? - should not really make local when extern'ing - campbell */ - make_local_tface(bmain, me); - } if(me->mat) { extern_local_matarar(me->mat, me->totcol); @@ -286,7 +272,7 @@ void make_local_mesh(Mesh *me) { Main *bmain= G.main; Object *ob; - int local=0, lib=0; + int is_local= FALSE, is_lib= FALSE; /* - only lib users: do nothing * - only local users: set flag @@ -295,32 +281,31 @@ void make_local_mesh(Mesh *me) if(me->id.lib==NULL) return; if(me->id.us==1) { - me->id.lib= NULL; - me->id.flag= LIB_LOCAL; - - new_id(&bmain->mesh, (ID *)me, NULL); - expand_local_mesh(bmain, me); + id_clear_lib_data(bmain, &me->id); + expand_local_mesh(me); 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(me == ob->data) { - if(ob->id.lib) lib= 1; - else local= 1; + if(ob->id.lib) is_lib= TRUE; + else is_local= TRUE; } } - if(local && lib==0) { - me->id.lib= NULL; - me->id.flag= LIB_LOCAL; - - new_id(&bmain->mesh, (ID *)me, NULL); - expand_local_mesh(bmain, me); + if(is_local && is_lib == FALSE) { + id_clear_lib_data(bmain, &me->id); + expand_local_mesh(me); } - else if(local && lib) { + else if(is_local && is_lib) { + char *bpath_user_data[2]= {bmain->name, me->id.lib->filepath}; Mesh *men= copy_mesh(me); men->id.us= 0; + + /* Remap paths of new ID using old library as base. */ + bpath_traverse_id(bmain, &men->id, bpath_relocate_visitor, 0, bpath_user_data); + for(ob= bmain->object.first; ob; ob= ob->id.next) { if(me == ob->data) { if(ob->id.lib==NULL) { |