forked from bartvdbraak/blender
Fix for proxy fix: copy drivers on synchronize now does proper relinking
of driver targets, sharing code with make proxy.
This commit is contained in:
parent
9790647ce6
commit
939c3ba9cb
@ -67,6 +67,7 @@ void object_link_modifiers(struct Object *ob, struct Object *from);
|
||||
void object_free_modifiers(struct Object *ob);
|
||||
|
||||
void object_make_proxy(struct Object *ob, struct Object *target, struct Object *gob);
|
||||
void object_copy_proxy_drivers(struct Object *ob, struct Object *target);
|
||||
|
||||
void unlink_object(struct Scene *scene, struct Object *ob);
|
||||
int exist_object(struct Object *obtest);
|
||||
|
@ -61,7 +61,6 @@
|
||||
#include "BKE_depsgraph.h"
|
||||
#include "BKE_DerivedMesh.h"
|
||||
#include "BKE_displist.h"
|
||||
#include "BKE_fcurve.h"
|
||||
#include "BKE_global.h"
|
||||
#include "BKE_idprop.h"
|
||||
#include "BKE_library.h"
|
||||
@ -1573,15 +1572,6 @@ static void pose_proxy_synchronize(Object *ob, Object *from, int layer_protected
|
||||
pchan->custom= pchanp->custom;
|
||||
}
|
||||
}
|
||||
|
||||
/* copy drivers */
|
||||
adt= BKE_animdata_from_id(&ob->id);
|
||||
fromadt= BKE_animdata_from_id(&from->id);
|
||||
if(!adt)
|
||||
adt= BKE_id_add_animdata(&ob->id);
|
||||
|
||||
free_fcurves(&adt->drivers);
|
||||
copy_fcurves(&adt->drivers, &fromadt->drivers);
|
||||
}
|
||||
|
||||
static int rebuild_pose_bone(bPose *pose, Bone *bone, bPoseChannel *parchan, int counter)
|
||||
@ -1644,8 +1634,10 @@ void armature_rebuild_pose(Object *ob, bArmature *arm)
|
||||
// printf("rebuild pose %s, %d bones\n", ob->id.name, counter);
|
||||
|
||||
/* synchronize protected layers with proxy */
|
||||
if(ob->proxy)
|
||||
if(ob->proxy) {
|
||||
object_copy_proxy_drivers(ob, ob->proxy);
|
||||
pose_proxy_synchronize(ob, ob->proxy, arm->layer_protected);
|
||||
}
|
||||
|
||||
update_pose_constraint_flags(ob->pose); // for IK detection for example
|
||||
|
||||
|
@ -1453,6 +1453,38 @@ static void armature_set_id_extern(Object *ob)
|
||||
|
||||
}
|
||||
|
||||
void object_copy_proxy_drivers(Object *ob, Object *target)
|
||||
{
|
||||
if ((target->adt) && (target->adt->drivers.first)) {
|
||||
FCurve *fcu;
|
||||
|
||||
/* add new animdata block */
|
||||
if(!ob->adt)
|
||||
ob->adt= BKE_id_add_animdata(&ob->id);
|
||||
|
||||
/* make a copy of all the drivers (for now), then correct any links that need fixing */
|
||||
free_fcurves(&ob->adt->drivers);
|
||||
copy_fcurves(&ob->adt->drivers, &target->adt->drivers);
|
||||
|
||||
for (fcu= ob->adt->drivers.first; fcu; fcu= fcu->next) {
|
||||
ChannelDriver *driver= fcu->driver;
|
||||
DriverVar *dvar;
|
||||
|
||||
for (dvar= driver->variables.first; dvar; dvar= dvar->next) {
|
||||
/* all drivers */
|
||||
DRIVER_TARGETS_LOOPER(dvar)
|
||||
{
|
||||
if ((Object *)dtar->id == target)
|
||||
dtar->id= (ID *)ob;
|
||||
else
|
||||
id_lib_extern((ID *)dtar->id);
|
||||
}
|
||||
DRIVER_TARGETS_LOOPER_END
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* proxy rule: lib_object->proxy_from == the one we borrow from, set temporally while object_update */
|
||||
/* local_object->proxy == pointer to library object, saved in files and read */
|
||||
/* local_object->proxy_group == pointer to group dupli-object, saved in files and read */
|
||||
@ -1489,33 +1521,8 @@ void object_make_proxy(Object *ob, Object *target, Object *gob)
|
||||
copy_m4_m4(ob->parentinv, target->parentinv);
|
||||
|
||||
/* 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;
|
||||
DriverVar *dvar;
|
||||
|
||||
for (dvar= driver->variables.first; dvar; dvar= dvar->next) {
|
||||
/* all drivers */
|
||||
DRIVER_TARGETS_LOOPER(dvar)
|
||||
{
|
||||
if ((Object *)dtar->id == target)
|
||||
dtar->id= (ID *)ob;
|
||||
else
|
||||
id_lib_extern((ID *)dtar->id);
|
||||
}
|
||||
DRIVER_TARGETS_LOOPER_END
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
object_copy_proxy_drivers(ob, target);
|
||||
|
||||
/* skip constraints? */
|
||||
// FIXME: this is considered by many as a bug
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user