From 8b6b5341a55541110684e5272f8856559b89337f Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Fri, 25 Mar 2011 08:43:41 +0000 Subject: move object re-linking into a function. --- source/blender/blenkernel/BKE_object.h | 2 ++ source/blender/blenkernel/intern/object.c | 29 ++++++++++++++++++++++++ source/blender/editors/object/object_add.c | 23 +------------------ source/blender/editors/object/object_relations.c | 22 +----------------- 4 files changed, 33 insertions(+), 43 deletions(-) (limited to 'source') diff --git a/source/blender/blenkernel/BKE_object.h b/source/blender/blenkernel/BKE_object.h index 065810089f1..cacfa702f7f 100644 --- a/source/blender/blenkernel/BKE_object.h +++ b/source/blender/blenkernel/BKE_object.h @@ -143,6 +143,8 @@ void object_camera_matrix( float winmat[][4], struct rctf *viewplane, float *clipsta, float *clipend, float *lens, float *ycor, float *viewdx, float *viewdy); +void object_relink(struct Object *ob); + #ifdef __cplusplus } #endif diff --git a/source/blender/blenkernel/intern/object.c b/source/blender/blenkernel/intern/object.c index 9f2de5be84a..0348d188a7d 100644 --- a/source/blender/blenkernel/intern/object.c +++ b/source/blender/blenkernel/intern/object.c @@ -3082,3 +3082,32 @@ int object_is_modified(Scene *scene, Object *ob) return flag; } + +static void copy_object__forwardModifierLinks(void *UNUSED(userData), Object *UNUSED(ob), ID **idpoin) +{ + /* this is copied from ID_NEW; it might be better to have a macro */ + if(*idpoin && (*idpoin)->newid) *idpoin = (*idpoin)->newid; +} + +void object_relink(Object *ob) +{ + if(ob->id.lib) + return; + + relink_constraints(&ob->constraints); + if (ob->pose){ + bPoseChannel *chan; + for (chan = ob->pose->chanbase.first; chan; chan=chan->next){ + relink_constraints(&chan->constraints); + } + } + modifiers_foreachIDLink(ob, copy_object__forwardModifierLinks, NULL); + + if(ob->adt) + BKE_relink_animdata(ob->adt); + + ID_NEW(ob->parent); + + ID_NEW(ob->proxy); + ID_NEW(ob->proxy_group); +} diff --git a/source/blender/editors/object/object_add.c b/source/blender/editors/object/object_add.c index 289a66a1484..f630b05d8f2 100644 --- a/source/blender/editors/object/object_add.c +++ b/source/blender/editors/object/object_add.c @@ -843,13 +843,6 @@ void OBJECT_OT_delete(wmOperatorType *ot) /**************************** Copy Utilities ******************************/ -static void copy_object__forwardModifierLinks(void *UNUSED(userData), Object *UNUSED(ob), - ID **idpoin) -{ - /* this is copied from ID_NEW; it might be better to have a macro */ - if(*idpoin && (*idpoin)->newid) *idpoin = (*idpoin)->newid; -} - /* after copying objects, copied data should get new pointers */ static void copy_object_set_idnew(bContext *C, int dupflag) { @@ -860,21 +853,7 @@ static void copy_object_set_idnew(bContext *C, int dupflag) /* XXX check object pointers */ CTX_DATA_BEGIN(C, Object*, ob, selected_editable_objects) { - relink_constraints(&ob->constraints); - if (ob->pose){ - bPoseChannel *chan; - for (chan = ob->pose->chanbase.first; chan; chan=chan->next){ - relink_constraints(&chan->constraints); - } - } - modifiers_foreachIDLink(ob, copy_object__forwardModifierLinks, NULL); - - if(ob->adt) - BKE_relink_animdata(ob->adt); - - ID_NEW(ob->parent); - ID_NEW(ob->proxy); - ID_NEW(ob->proxy_group); + object_relink(ob); } CTX_DATA_END; diff --git a/source/blender/editors/object/object_relations.c b/source/blender/editors/object/object_relations.c index eccc826f01f..1aa6de18bad 100644 --- a/source/blender/editors/object/object_relations.c +++ b/source/blender/editors/object/object_relations.c @@ -1366,11 +1366,6 @@ void OBJECT_OT_make_links_data(wmOperatorType *ot) /**************************** Make Single User ********************************/ -static void single_object_users__forwardModifierLinks(void *UNUSED(userData), Object *UNUSED(ob), Object **obpoin) -{ - ID_NEW(*obpoin); -} - static void single_object_users(Scene *scene, View3D *v3d, int flag) { Base *base; @@ -1402,22 +1397,7 @@ static void single_object_users(Scene *scene, View3D *v3d, int flag) /* object pointers */ for(base= FIRSTBASE; base; base= base->next) { - ob= base->object; - if(ob->id.lib==NULL) { - relink_constraints(&base->object->constraints); - if (base->object->pose){ - bPoseChannel *chan; - for (chan = base->object->pose->chanbase.first; chan; chan=chan->next){ - relink_constraints(&chan->constraints); - } - } - modifiers_foreachObjectLink(base->object, single_object_users__forwardModifierLinks, NULL); - - if(ob->adt) - BKE_relink_animdata(ob->adt); - - ID_NEW(ob->parent); - } + object_relink(base->object); } set_sca_new_poins(); -- cgit v1.2.3