From cd905eef702555b27d4d90983b079a1a62c31fb8 Mon Sep 17 00:00:00 2001 From: Joshua Leung Date: Mon, 3 Aug 2009 12:11:50 +0000 Subject: [PATCH] 2.5 - Make Proxy Tweaks * Drivers are now copied across and relinked as appropriate * Drawtype is also copied now (especially useful for rigs) --- source/blender/blenkernel/intern/object.c | 33 ++++++++++++++++++++--- 1 file changed, 29 insertions(+), 4 deletions(-) diff --git a/source/blender/blenkernel/intern/object.c b/source/blender/blenkernel/intern/object.c index e463d007a2d..150a5aa97aa 100644 --- a/source/blender/blenkernel/intern/object.c +++ b/source/blender/blenkernel/intern/object.c @@ -91,6 +91,7 @@ #include "BKE_constraint.h" #include "BKE_curve.h" #include "BKE_displist.h" +#include "BKE_fcurve.h" #include "BKE_group.h" #include "BKE_icons.h" #include "BKE_key.h" @@ -1402,11 +1403,32 @@ void object_make_proxy(Object *ob, Object *target, Object *gob) ob->parent= target->parent; /* libdata */ Mat4CpyMat4(ob->parentinv, target->parentinv); -#if 0 // XXX old animation system - ob->ipo= target->ipo; /* libdata */ -#endif // XXX old animation system - /* skip constraints, constraintchannels, nla? */ + /* copy animdata stuff - drivers only for now... */ + if ((target->adt) && (target->adt->drivers.first)) { + FCurve *fcu; + + /* add new animdata block */ + ob->adt= BKE_id_add_animdata(&ob->id); + + /* make a copy of all the drivers (for now), then correct any links that need fixing */ + copy_fcurves(&ob->adt->drivers, &target->adt->drivers); + + for (fcu= ob->adt->drivers.first; fcu; fcu= fcu->next) { + ChannelDriver *driver= fcu->driver; + DriverTarget *dtar; + + for (dtar= driver->targets.first; dtar; dtar= dtar->next) { + if ((Object *)dtar->id == target) + dtar->id= (ID *)ob; + else + id_lib_extern((ID *)dtar->id); + } + } + } + + /* skip constraints? */ + // FIXME: this is considered by many as a bug /* set object type and link to data */ ob->type= target->type; @@ -1442,6 +1464,9 @@ void object_make_proxy(Object *ob, Object *target, Object *gob) armature_set_id_extern(ob); } + + /* copy drawtype info */ + ob->dt= target->dt; }