Skip to content

Commit f91bb92

Browse files
sohailshafiiWkfacebook-github-bot
authored andcommitted
fix(Runtime): DeformationJob checks for animator avatar for bone queries
Summary: Animator's `GetBoneTransform` used to simply return null if the Animator's avatar component was set to null (https://docs.unity3d.com/2021.1/Documentation/ScriptReference/Animator.GetBoneTransform.html). In later versions (https://docs.unity3d.com/ScriptReference/Animator.GetBoneTransform.html), an exception is thrown. To prevent that, bone queries should make sure that the avatar component is not null. Reviewed By: mvaganov-fb Differential Revision: D52575669 fbshipit-source-id: c0fb9521ef8b1704f2fddf14c3e27b9fd474f33f
1 parent 7d0d721 commit f91bb92

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

Runtime/Scripts/AnimationRigging/DeformationJob.cs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -700,9 +700,11 @@ public override DeformationJob Create(Animator animator, ref T data, Component c
700700
job.RightLowerArmToHandAxis = data.RightArm.LowerArmToHandAxis;
701701
job.HipsIndex = (int)HumanBodyBones.Hips;
702702
job.SpineLowerIndex = job.HipsIndex + 1;
703-
job.SpineUpperIndex = animator.GetBoneTransform(HumanBodyBones.Chest) != null ?
703+
job.SpineUpperIndex =
704+
(animator.avatar != null && animator.GetBoneTransform(HumanBodyBones.Chest) != null) ?
704705
job.SpineLowerIndex + 1 : -1;
705-
job.ChestIndex = animator.GetBoneTransform(HumanBodyBones.UpperChest) != null ?
706+
job.ChestIndex =
707+
(animator.avatar != null && animator.GetBoneTransform(HumanBodyBones.UpperChest) != null) ?
706708
job.SpineUpperIndex + 1 : -1;
707709
job.HeadIndex = data.HipsToHeadBones.Length - 1;
708710

0 commit comments

Comments
 (0)