mirror of
https://github.com/EsotericSoftware/spine-runtimes.git
synced 2025-12-20 17:26:01 +08:00
[Unity] Fixed SkeletonRootMotion out of bounds access when selecting non-default Root Motion Bone with a TransformConstraint. Closes #2110.
This commit is contained in:
parent
766105189f
commit
2ef38e4f01
@ -372,7 +372,7 @@ namespace Spine.Unity {
|
||||
Vector2 invMixXY = timeline.EvaluateTranslateXYMix(time);
|
||||
Vector2 constraintPos;
|
||||
if (useLastConstraintPos)
|
||||
constraintPos = transformConstraintLastPos[constraintIndex];
|
||||
constraintPos = transformConstraintLastPos[GetConstraintLastPosIndex(constraintIndex)];
|
||||
else {
|
||||
Bone targetBone = constraint.Target;
|
||||
constraintPos = new Vector2(targetBone.X, targetBone.Y);
|
||||
@ -391,7 +391,7 @@ namespace Spine.Unity {
|
||||
float invMixRotate = timeline.EvaluateRotateMix(time);
|
||||
float constraintRotation;
|
||||
if (useLastConstraintRotation)
|
||||
constraintRotation = transformConstraintLastRotation[constraintIndex];
|
||||
constraintRotation = transformConstraintLastRotation[GetConstraintLastPosIndex(constraintIndex)];
|
||||
else {
|
||||
Bone targetBone = constraint.Target;
|
||||
constraintRotation = targetBone.Rotation;
|
||||
@ -403,7 +403,7 @@ namespace Spine.Unity {
|
||||
foreach (int constraintIndex in this.transformConstraintIndices) {
|
||||
TransformConstraint constraint = transformConstraintsItems[constraintIndex];
|
||||
Bone targetBone = constraint.Target;
|
||||
transformConstraintLastPos[constraintIndex] = new Vector2(targetBone.X, targetBone.Y);
|
||||
transformConstraintLastPos[GetConstraintLastPosIndex(constraintIndex)] = new Vector2(targetBone.X, targetBone.Y);
|
||||
}
|
||||
}
|
||||
|
||||
@ -411,7 +411,7 @@ namespace Spine.Unity {
|
||||
foreach (int constraintIndex in this.transformConstraintIndices) {
|
||||
TransformConstraint constraint = transformConstraintsItems[constraintIndex];
|
||||
Bone targetBone = constraint.Target;
|
||||
transformConstraintLastRotation[constraintIndex] = targetBone.Rotation;
|
||||
transformConstraintLastRotation[GetConstraintLastPosIndex(constraintIndex)] = targetBone.Rotation;
|
||||
}
|
||||
}
|
||||
|
||||
@ -440,6 +440,12 @@ namespace Spine.Unity {
|
||||
return rootMotion;
|
||||
}
|
||||
|
||||
int GetConstraintLastPosIndex (int constraintIndex) {
|
||||
var constraints = skeletonComponent.Skeleton.TransformConstraints;
|
||||
TransformConstraint targetConstraint = constraints.Items[constraintIndex];
|
||||
return constraints.FindIndex(constraint => constraint == targetConstraint);
|
||||
}
|
||||
|
||||
void FindTransformConstraintsAffectingBone () {
|
||||
var constraints = skeletonComponent.Skeleton.TransformConstraints;
|
||||
var constraintsItems = constraints.Items;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user