diff options
author | Campbell Barton <ideasman42@gmail.com> | 2011-03-25 10:34:44 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2011-03-25 10:34:44 +0300 |
commit | d8e6dd705fbf7d98043e8a210bb49d6903792872 (patch) | |
tree | 36efce09ef4494dd9b634f519cd0ac73c6d1745b /source/blender | |
parent | 06b04fa8862eee030ea4024f020992664c3457fe (diff) |
fix [#26607] blender won't duplicate or assign new drivers on duplication
Diffstat (limited to 'source/blender')
-rw-r--r-- | source/blender/blenkernel/BKE_animsys.h | 3 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/anim_sys.c | 26 | ||||
-rw-r--r-- | source/blender/editors/object/object_add.c | 4 | ||||
-rw-r--r-- | source/blender/editors/object/object_relations.c | 5 | ||||
-rw-r--r-- | source/blender/makesdna/DNA_anim_types.h | 2 |
5 files changed, 38 insertions, 2 deletions
diff --git a/source/blender/blenkernel/BKE_animsys.h b/source/blender/blenkernel/BKE_animsys.h index a469d05ee26..348b967f9c4 100644 --- a/source/blender/blenkernel/BKE_animsys.h +++ b/source/blender/blenkernel/BKE_animsys.h @@ -72,6 +72,9 @@ void BKE_copy_animdata_id_action(struct ID *id); /* Make Local */ void BKE_animdata_make_local(struct AnimData *adt); +/* Re-Assign ID's */ +void BKE_relink_animdata(struct AnimData *adt); + /* ************************************* */ /* KeyingSets API */ diff --git a/source/blender/blenkernel/intern/anim_sys.c b/source/blender/blenkernel/intern/anim_sys.c index 16269c3f66f..b4adaa0ab07 100644 --- a/source/blender/blenkernel/intern/anim_sys.c +++ b/source/blender/blenkernel/intern/anim_sys.c @@ -282,6 +282,32 @@ void BKE_animdata_make_local(AnimData *adt) make_local_strips(&nlt->strips); } +void BKE_relink_animdata(struct AnimData *adt) +{ + /* drivers */ + if (adt->drivers.first) { + FCurve *fcu; + + /* check each driver against all the base paths to see if any should go */ + for (fcu= adt->drivers.first; fcu; fcu=fcu->next) { + ChannelDriver *driver= fcu->driver; + DriverVar *dvar; + + /* driver variables */ + for (dvar= driver->variables.first; dvar; dvar=dvar->next) { + /* only change the used targets, since the others will need fixing manually anyway */ + DRIVER_TARGETS_USED_LOOPER(dvar) + { + if(dtar->id->newid) { + dtar->id= dtar->id->newid; + } + } + DRIVER_TARGETS_LOOPER_END + } + } + } +} + /* Sub-ID Regrouping ------------------------------------------- */ /* helper heuristic for determining if a path is compatible with the basepath diff --git a/source/blender/editors/object/object_add.c b/source/blender/editors/object/object_add.c index 2463e17d49f..289a66a1484 100644 --- a/source/blender/editors/object/object_add.c +++ b/source/blender/editors/object/object_add.c @@ -868,6 +868,10 @@ static void copy_object_set_idnew(bContext *C, int dupflag) } } 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_relations.c b/source/blender/editors/object/object_relations.c index 7938096c2a6..eccc826f01f 100644 --- a/source/blender/editors/object/object_relations.c +++ b/source/blender/editors/object/object_relations.c @@ -1412,7 +1412,10 @@ static void single_object_users(Scene *scene, View3D *v3d, int flag) } } modifiers_foreachObjectLink(base->object, single_object_users__forwardModifierLinks, NULL); - + + if(ob->adt) + BKE_relink_animdata(ob->adt); + ID_NEW(ob->parent); } } diff --git a/source/blender/makesdna/DNA_anim_types.h b/source/blender/makesdna/DNA_anim_types.h index 31e02ff1877..4b649031f97 100644 --- a/source/blender/makesdna/DNA_anim_types.h +++ b/source/blender/makesdna/DNA_anim_types.h @@ -261,7 +261,7 @@ typedef enum eFMod_Stepped_Flags { * Defines how to access a dependency needed for a driver variable. */ typedef struct DriverTarget { - ID *id; /* ID-block which owns the target */ + ID *id; /* ID-block which owns the target, no user count */ char *rna_path; /* RNA path defining the setting to use (for DVAR_TYPE_SINGLE_PROP) */ |