fix [#26607] blender won't duplicate or assign new drivers on duplication

This commit is contained in:
Campbell Barton 2011-03-25 07:34:44 +00:00
parent 06b04fa886
commit d8e6dd705f
5 changed files with 38 additions and 2 deletions

View File

@ -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 */

View File

@ -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

View File

@ -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);

View File

@ -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);
}
}

View File

@ -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) */