Fix (studio-reported) Armature: bug in handling of custom bone transform.

This specific pose channel pointer was not handled at all during
rebuilding of poses, meaning that it could end up pointing at some freed
pchan.
This commit is contained in:
Bastien Montagne 2020-10-21 15:51:15 +02:00
parent ba718c1513
commit 47a84bb338
Notes: blender-bot 2023-02-14 00:57:33 +01:00
Referenced by issue #77348, Blender LTS: Maintenance Task 2.83
1 changed files with 7 additions and 0 deletions

View File

@ -2540,6 +2540,13 @@ void BKE_pose_rebuild(Main *bmain, Object *ob, bArmature *arm, const bool do_id_
for (pchan = pose->chanbase.first; pchan; pchan = pchan->next) {
/* Find the custom B-Bone handles. */
BKE_pchan_rebuild_bbone_handles(pose, pchan);
/* Re-validate that we are still using a valid pchan form custom transform. */
/* Note that we could store pointers of freed pchan in a GSet to speed this up, however this is
* supposed to be a rarely used feature, so for now assuming that always building that GSet
* would be less optimal. */
if (pchan->custom_tx != NULL && BLI_findindex(&pose->chanbase, pchan->custom_tx) == -1) {
pchan->custom_tx = NULL;
}
}
/* printf("rebuild pose %s, %d bones\n", ob->id.name, counter); */