diff options
Diffstat (limited to 'source/blender/blenkernel/intern/object.c')
-rw-r--r-- | source/blender/blenkernel/intern/object.c | 76 |
1 files changed, 31 insertions, 45 deletions
diff --git a/source/blender/blenkernel/intern/object.c b/source/blender/blenkernel/intern/object.c index 488ede5c072..29fa731594d 100644 --- a/source/blender/blenkernel/intern/object.c +++ b/source/blender/blenkernel/intern/object.c @@ -97,6 +97,7 @@ #include "BKE_scene.h" #include "BKE_sequencer.h" #include "BKE_softbody.h" +#include "BKE_material.h" #include "LBM_fluidsim.h" @@ -736,51 +737,45 @@ void make_local_camera(Camera *cam) { Main *bmain= G.main; Object *ob; - Camera *camn; int local=0, lib=0; /* - only lib users: do nothing - * - only local users: set flag - * - mixed: make copy - */ + * - only local users: set flag + * - mixed: make copy + */ if(cam->id.lib==NULL) return; if(cam->id.us==1) { cam->id.lib= NULL; cam->id.flag= LIB_LOCAL; - new_id(NULL, (ID *)cam, NULL); + new_id(&bmain->camera, (ID *)cam, NULL); return; } - ob= bmain->object.first; - while(ob) { + for(ob= bmain->object.first; ob && ELEM(0, lib, local); ob= ob->id.next) { if(ob->data==cam) { if(ob->id.lib) lib= 1; else local= 1; } - ob= ob->id.next; } if(local && lib==0) { cam->id.lib= NULL; cam->id.flag= LIB_LOCAL; - new_id(NULL, (ID *)cam, NULL); + new_id(&bmain->camera, (ID *)cam, NULL); } else if(local && lib) { - camn= copy_camera(cam); + Camera *camn= copy_camera(cam); camn->id.us= 0; - ob= bmain->object.first; - while(ob) { - if(ob->data==cam) { - + for(ob= bmain->object.first; ob; ob= ob->id.next) { + if(ob->data == cam) { if(ob->id.lib==NULL) { ob->data= camn; camn->id.us++; cam->id.us--; } } - ob= ob->id.next; } } } @@ -897,7 +892,7 @@ void make_local_lamp(Lamp *la) if(la->id.us==1) { la->id.lib= NULL; la->id.flag= LIB_LOCAL; - new_id(NULL, (ID *)la, NULL); + new_id(&bmain->lamp, (ID *)la, NULL); return; } @@ -913,7 +908,7 @@ void make_local_lamp(Lamp *la) if(local && lib==0) { la->id.lib= NULL; la->id.flag= LIB_LOCAL; - new_id(NULL, (ID *)la, NULL); + new_id(&bmain->lamp, (ID *)la, NULL); } else if(local && lib) { lan= copy_lamp(la); @@ -1366,11 +1361,10 @@ Object *copy_object(Object *ob) return obn; } -void expand_local_object(Object *ob) +static void extern_local_object(Object *ob) { //bActionStrip *strip; ParticleSystem *psys; - int a; #if 0 // XXX old animation system id_lib_extern((ID *)ob->action); @@ -1378,10 +1372,11 @@ void expand_local_object(Object *ob) #endif // XXX old animation system id_lib_extern((ID *)ob->data); id_lib_extern((ID *)ob->dup_group); - - for(a=0; a<ob->totcol; a++) { - id_lib_extern((ID *)ob->mat[a]); - } + id_lib_extern((ID *)ob->poselib); + id_lib_extern((ID *)ob->gpd); + + extern_local_matarar(ob->mat, ob->totcol); + #if 0 // XXX old animation system for (strip=ob->nlastrips.first; strip; strip=strip->next) { id_lib_extern((ID *)strip->act); @@ -1394,16 +1389,15 @@ void expand_local_object(Object *ob) void make_local_object(Object *ob) { Main *bmain= G.main; - Object *obn; Scene *sce; Base *base; int local=0, lib=0; /* - only lib users: do nothing - * - only local users: set flag - * - mixed: make copy - */ - + * - only local users: set flag + * - mixed: make copy + */ + if(ob->id.lib==NULL) return; ob->proxy= ob->proxy_from= NULL; @@ -1411,31 +1405,23 @@ void make_local_object(Object *ob) if(ob->id.us==1) { ob->id.lib= NULL; ob->id.flag= LIB_LOCAL; - new_id(NULL, (ID *)ob, NULL); - + new_id(&bmain->object, (ID *)ob, NULL); } else { - sce= bmain->scene.first; - while(sce) { - base= sce->base.first; - while(base) { - if(base->object==ob) { - if(sce->id.lib) lib++; - else local++; - break; - } - base= base->next; + for(sce= bmain->scene.first; sce && ELEM(0, lib, local); sce= sce->id.next) { + if(object_in_scene(ob, sce)) { + if(sce->id.lib) lib= 1; + else local= 1; } - sce= sce->id.next; } - + if(local && lib==0) { ob->id.lib= NULL; ob->id.flag= LIB_LOCAL; - new_id(NULL, (ID *)ob, NULL); + new_id(&bmain->object, (ID *)ob, NULL); } else if(local && lib) { - obn= copy_object(ob); + Object *obn= copy_object(ob); obn->id.us= 0; sce= bmain->scene.first; @@ -1456,7 +1442,7 @@ void make_local_object(Object *ob) } } - expand_local_object(ob); + extern_local_object(ob); } /* |