Skip to content

Commit b1cdc2d

Browse files
committed
[unity] Fixed SkeletonUtilityBone follow-hierarchy producing wrong result with TransformConstraints. Closes #3035.
1 parent 945be36 commit b1cdc2d

File tree

3 files changed

+16
-10
lines changed

3 files changed

+16
-10
lines changed

spine-unity/Assets/Spine/Runtime/spine-unity/Components/SkeletonUtility/SkeletonUtility.cs

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -204,8 +204,8 @@ void UpdateToMeshScaleAndOffset (MeshGeneratorBuffers ignoredParameter) {
204204
UpdateLocal(skeletonGraphic);
205205
UpdateWorld(skeletonGraphic);
206206
UpdateComplete(skeletonGraphic);
207-
}
208-
}
207+
}
208+
}
209209

210210
[HideInInspector] public SkeletonRenderer skeletonRenderer;
211211
[HideInInspector] public SkeletonGraphic skeletonGraphic;
@@ -362,16 +362,21 @@ public void CollectBones () {
362362
if (skeleton == null) return;
363363

364364
if (boneRoot != null) {
365-
List<object> constraintTargets = new List<object>();
365+
List<Bone> constrainedBones = new List<Bone>();
366366
ExposedList<IConstraint> constraints = skeleton.Constraints;
367367
for (int i = 0, n = constraints.Count; i < n; i++) {
368368
IConstraint constraint = constraints.Items[i];
369+
ExposedList<BonePose> bones = null;
369370
if (constraint is IkConstraint)
370-
constraintTargets.Add(((IkConstraint)constraint).Bones);
371+
bones = ((IkConstraint)constraint).Bones;
371372
else if (constraint is TransformConstraint)
372-
constraintTargets.Add(((TransformConstraint)constraint).Bones);
373+
bones = ((TransformConstraint)constraint).Bones;
373374
else if (constraint is PathConstraint)
374-
constraintTargets.Add(((PathConstraint)constraint).Bones);
375+
bones = ((PathConstraint)constraint).Bones;
376+
if (bones != null) {
377+
for (int j = 0, m = bones.Count; j < m; j++)
378+
constrainedBones.Add(bones.Items[j].bone);
379+
}
375380
}
376381

377382
List<SkeletonUtilityBone> boneComponents = this.boneComponents;
@@ -382,7 +387,7 @@ public void CollectBones () {
382387
if (b.bone == null) continue;
383388
}
384389
hasOverrideBones |= (b.mode == SkeletonUtilityBone.Mode.Override);
385-
hasConstraintTargetBones |= constraintTargets.Contains(b.bone);
390+
hasConstraintTargetBones |= constrainedBones.Contains(b.bone);
386391
}
387392

388393
needToReprocessBones = false;

spine-unity/Assets/Spine/Runtime/spine-unity/Components/SkeletonUtility/SkeletonUtilityBone.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,15 +54,15 @@ public enum UpdatePhase {
5454
Complete
5555
}
5656

57-
#region Inspector
57+
#region Inspector
5858
/// <summary>If a bone isn't set, boneName is used to find the bone.</summary>
5959
public string boneName;
6060
public Transform parentReference;
6161
public Mode mode;
6262
public bool position, rotation, scale, zPosition = true;
6363
[Range(0f, 1f)]
6464
public float overrideAlpha = 1;
65-
#endregion
65+
#endregion
6666

6767
public SkeletonUtility hierarchy;
6868
[System.NonSerialized] public Bone bone;
@@ -159,6 +159,7 @@ public void DoUpdate (UpdatePhase phase) {
159159
case UpdatePhase.World:
160160
case UpdatePhase.Complete:
161161
var appliedPose = bone.AppliedPose;
162+
appliedPose.ValidateLocalTransform(skeleton);
162163
if (position)
163164
thisTransform.localPosition = new Vector3(appliedPose.X * positionScale, appliedPose.Y * positionScale,
164165
zPosition ? 0 : thisTransform.localPosition.z);

spine-unity/Assets/Spine/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "com.esotericsoftware.spine.spine-unity",
33
"displayName": "spine-unity Runtime",
44
"description": "This plugin provides the spine-unity runtime core and examples. Spine Examples can be installed via the Samples tab.",
5-
"version": "4.3.48",
5+
"version": "4.3.49",
66
"unity": "2018.3",
77
"author": {
88
"name": "Esoteric Software",

0 commit comments

Comments
 (0)