diff options
author | Joshua Leung <aligorith@gmail.com> | 2015-01-21 16:08:29 +0300 |
---|---|---|
committer | Joshua Leung <aligorith@gmail.com> | 2015-01-21 16:09:16 +0300 |
commit | 3df93d063e2d52a2c2e73cfe31801c15682bf0b4 (patch) | |
tree | fab2039dd84ce9666d02fb4e1af68eaa645337bc /source/blender/editors/armature/armature_relations.c | |
parent | f087e9930d5b8c876206af117ce085dec0ec4578 (diff) |
Fix: Joining armatures loses drivers
Currently, when joining two armatures, the drivers of the armatures being merged
in are lost. This commit introduces a new AnimData API function for merging
animation data into another AnimData block.
NOTE:
* For now, this only copies the drivers over. As a result, manual effort will
still be needed to go through and fix the drivers.
I am working on automating that process, but it's more important that the
drivers don't have to be created from scratch for now (since this is needed
for the Goosberry rigging work).
Diffstat (limited to 'source/blender/editors/armature/armature_relations.c')
-rw-r--r-- | source/blender/editors/armature/armature_relations.c | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/source/blender/editors/armature/armature_relations.c b/source/blender/editors/armature/armature_relations.c index 3e226c39c8c..2a19d7a0bec 100644 --- a/source/blender/editors/armature/armature_relations.c +++ b/source/blender/editors/armature/armature_relations.c @@ -40,6 +40,7 @@ #include "BLF_translation.h" #include "BKE_action.h" +#include "BKE_animsys.h" #include "BKE_constraint.h" #include "BKE_context.h" #include "BKE_depsgraph.h" @@ -200,6 +201,33 @@ int join_armature_exec(bContext *C, wmOperator *op) if ((base->object->type == OB_ARMATURE) && (base->object != ob)) { bArmature *curarm = base->object->data; + /* we assume that each armature datablock is only used in a single place */ + BLI_assert(ob->data != base->object->data); + + /* copy over animdata first, so that the link fixing can access and fix the links */ + if (base->object->adt) { + if (ob->adt == NULL) { + /* no animdata, so just use a copy of the whole thing */ + ob->adt = BKE_copy_animdata(base->object->adt, false); + } + else { + /* merge in data - we'll fix the drivers manually */ + BKE_animdata_merge_copy(&ob->id, &base->object->id, ADT_MERGECOPY_KEEP_DST, false); + } + } + + if (curarm->adt) { + if (arm->adt == NULL) { + /* no animdata, so just use a copy of the whole thing */ + arm->adt = BKE_copy_animdata(curarm->adt, false); + } + else { + /* merge in data - we'll fix the drivers manually */ + BKE_animdata_merge_copy(&arm->id, &curarm->id, ADT_MERGECOPY_KEEP_DST, false); + } + } + + /* Make a list of editbones in current armature */ ED_armature_to_edit(base->object->data); |