diff options
Diffstat (limited to 'source/blender/blenkernel')
-rw-r--r-- | source/blender/blenkernel/BKE_armature.h | 1 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/armature.c | 39 |
2 files changed, 23 insertions, 17 deletions
diff --git a/source/blender/blenkernel/BKE_armature.h b/source/blender/blenkernel/BKE_armature.h index 666c6758ce0..b57630a348e 100644 --- a/source/blender/blenkernel/BKE_armature.h +++ b/source/blender/blenkernel/BKE_armature.h @@ -100,6 +100,7 @@ void BKE_armature_where_is(struct bArmature *arm); void BKE_armature_where_is_bone(struct Bone *bone, struct Bone *prevbone, const bool use_recursion); void BKE_pose_clear_pointers(struct bPose *pose); void BKE_pose_remap_bone_pointers(struct bArmature *armature, struct bPose *pose); +void BKE_pchan_rebuild_bbone_handles(struct bPose *pose, struct bPoseChannel *pchan); void BKE_pose_rebuild(struct Main *bmain, struct Object *ob, struct bArmature *arm, const bool do_id_user); void BKE_pose_where_is(struct Depsgraph *depsgraph, struct Scene *scene, struct Object *ob); void BKE_pose_where_is_bone(struct Depsgraph *depsgraph, struct Scene *scene, struct Object *ob, struct bPoseChannel *pchan, float ctime, bool do_extra); diff --git a/source/blender/blenkernel/intern/armature.c b/source/blender/blenkernel/intern/armature.c index e0caec323c1..be29819a0ee 100644 --- a/source/blender/blenkernel/intern/armature.c +++ b/source/blender/blenkernel/intern/armature.c @@ -1953,6 +1953,8 @@ static void pose_proxy_synchronize(Object *ob, Object *from, int layer_protected pchanw.parent = pchan->parent; pchanw.child = pchan->child; pchanw.custom_tx = pchan->custom_tx; + pchanw.bbone_prev = pchan->bbone_prev; + pchanw.bbone_next = pchan->bbone_next; pchanw.mpath = pchan->mpath; pchan->mpath = NULL; @@ -2077,6 +2079,19 @@ void BKE_pose_remap_bone_pointers(bArmature *armature, bPose *pose) BLI_ghash_free(bone_hash, NULL, NULL); } +/** Find the matching pose channel using the bone name, if not NULL. */ +static bPoseChannel *pose_channel_find_bone(bPose *pose, Bone *bone) +{ + return (bone != NULL) ? BKE_pose_channel_find_name(pose, bone->name) : NULL; +} + +/** Update the links for the B-Bone handles from Bone data. */ +void BKE_pchan_rebuild_bbone_handles(bPose *pose, bPoseChannel *pchan) +{ + pchan->bbone_prev = pose_channel_find_bone(pose, pchan->bone->bbone_prev); + pchan->bbone_next = pose_channel_find_bone(pose, pchan->bone->bbone_next); +} + /** * Only after leave editmode, duplicating, validating older files, library syncing. * @@ -2117,23 +2132,15 @@ void BKE_pose_rebuild(Main *bmain, Object *ob, bArmature *arm, const bool do_id_ BKE_pose_channels_hash_free(pose); BLI_freelinkN(&pose->chanbase, pchan); } - else { - /* Find the custom B-Bone handles. */ - if (pchan->bone->bbone_prev) { - pchan->bbone_prev = BKE_pose_channel_find_name(pose, pchan->bone->bbone_prev->name); - } - else { - pchan->bbone_prev = NULL; - } + } - if (pchan->bone->bbone_next) { - pchan->bbone_next = BKE_pose_channel_find_name(pose, pchan->bone->bbone_next->name); - } - else { - pchan->bbone_next = NULL; - } - } + BKE_pose_channels_hash_make(pose); + + for (pchan = pose->chanbase.first; pchan; pchan = pchan->next) { + /* Find the custom B-Bone handles. */ + BKE_pchan_rebuild_bbone_handles(pose, pchan); } + /* printf("rebuild pose %s, %d bones\n", ob->id.name, counter); */ /* synchronize protected layers with proxy */ @@ -2150,8 +2157,6 @@ void BKE_pose_rebuild(Main *bmain, Object *ob, bArmature *arm, const bool do_id_ pose->flag &= ~POSE_RECALC; pose->flag |= POSE_WAS_REBUILT; - BKE_pose_channels_hash_make(pose); - /* Rebuilding poses forces us to also rebuild the dependency graph, since there is one node per pose/bone... */ if (bmain != NULL) { DEG_relations_tag_update(bmain); |