mirror of
https://github.com/EsotericSoftware/spine-runtimes.git
synced 2026-03-26 22:49:01 +08:00
Fixed IK constraint child bone using uninitialized world transform to calculate applied transform.
This commit is contained in:
parent
217aa60c4f
commit
5a45d3df30
@ -53,6 +53,7 @@ public class Skeleton {
|
|||||||
final Array<PathConstraint> pathConstraints;
|
final Array<PathConstraint> pathConstraints;
|
||||||
final Array<Constraint> sortedConstraints = new Array();
|
final Array<Constraint> sortedConstraints = new Array();
|
||||||
final Array<Updatable> updateCache = new Array();
|
final Array<Updatable> updateCache = new Array();
|
||||||
|
final Array<Bone> updateCacheReset = new Array();
|
||||||
Skin skin;
|
Skin skin;
|
||||||
final Color color;
|
final Color color;
|
||||||
float time;
|
float time;
|
||||||
@ -160,31 +161,38 @@ public class Skeleton {
|
|||||||
for (int i = 0, n = bones.size; i < n; i++)
|
for (int i = 0, n = bones.size; i < n; i++)
|
||||||
bones.get(i).sorted = false;
|
bones.get(i).sorted = false;
|
||||||
|
|
||||||
Array<Constraint> constraints = sortedConstraints;
|
Array<IkConstraint> ikConstraints = this.ikConstraints;
|
||||||
constraints.addAll(ikConstraints);
|
Array<TransformConstraint> transformConstraints = this.transformConstraints;
|
||||||
constraints.addAll(transformConstraints);
|
Array<PathConstraint> pathConstraints = this.pathConstraints;
|
||||||
constraints.addAll(pathConstraints);
|
int ikCount = ikConstraints.size, transformCount = transformConstraints.size, pathCount = pathConstraints.size;
|
||||||
constraints.sort(constraintComparator);
|
int constraintCount = ikCount + transformCount + pathCount;
|
||||||
for (int i = 0, n = constraints.size; i < n; i++) {
|
outer:
|
||||||
Constraint constraint = constraints.get(i);
|
for (int i = 0; i < constraintCount; i++) {
|
||||||
if (constraint instanceof IkConstraint)
|
for (int ii = 0; ii < ikCount; ii++) {
|
||||||
sortIkConstraint((IkConstraint)constraint);
|
IkConstraint constraint = ikConstraints.get(ii);
|
||||||
else if (constraint instanceof TransformConstraint)
|
if (constraint.data.order == i) {
|
||||||
sortTransformConstraint((TransformConstraint)constraint);
|
sortIkConstraint(constraint);
|
||||||
else
|
continue outer;
|
||||||
sortPathConstraint((PathConstraint)constraint);
|
}
|
||||||
|
}
|
||||||
|
for (int ii = 0; ii < transformCount; ii++) {
|
||||||
|
TransformConstraint constraint = transformConstraints.get(ii);
|
||||||
|
if (constraint.data.order == i) {
|
||||||
|
sortTransformConstraint(constraint);
|
||||||
|
continue outer;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for (int ii = 0; ii < pathCount; ii++) {
|
||||||
|
PathConstraint constraint = pathConstraints.get(ii);
|
||||||
|
if (constraint.data.order == i) {
|
||||||
|
sortPathConstraint(constraint);
|
||||||
|
continue outer;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
constraints.clear();
|
|
||||||
|
|
||||||
for (int i = 0, n = bones.size; i < n; i++)
|
for (int i = 0, n = bones.size; i < n; i++)
|
||||||
sortBone(bones.get(i));
|
sortBone(bones.get(i));
|
||||||
|
|
||||||
// BOZO
|
|
||||||
// for (int i = 0, n = updateCache.size; i < n; i++) {
|
|
||||||
// Updatable item = updateCache.get(i);
|
|
||||||
// if (item instanceof Constraint) System.out.print(item + ", ");
|
|
||||||
// }
|
|
||||||
// System.out.println();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void sortIkConstraint (IkConstraint constraint) {
|
private void sortIkConstraint (IkConstraint constraint) {
|
||||||
@ -195,6 +203,11 @@ public class Skeleton {
|
|||||||
Bone parent = constrained.first();
|
Bone parent = constrained.first();
|
||||||
sortBone(parent);
|
sortBone(parent);
|
||||||
|
|
||||||
|
if (constrained.size > 1) {
|
||||||
|
Bone child = constrained.peek();
|
||||||
|
if (!updateCache.contains(child, true)) updateCacheReset.add(child);
|
||||||
|
}
|
||||||
|
|
||||||
updateCache.add(constraint);
|
updateCache.add(constraint);
|
||||||
|
|
||||||
sortReset(parent.children);
|
sortReset(parent.children);
|
||||||
@ -278,6 +291,18 @@ public class Skeleton {
|
|||||||
|
|
||||||
/** Updates the world transform for each bone and applies constraints. */
|
/** Updates the world transform for each bone and applies constraints. */
|
||||||
public void updateWorldTransform () {
|
public void updateWorldTransform () {
|
||||||
|
Array<Bone> updateCacheReset = this.updateCacheReset;
|
||||||
|
for (int i = 0, n = updateCacheReset.size; i < n; i++) {
|
||||||
|
Bone bone = updateCacheReset.get(i);
|
||||||
|
bone.ax = bone.x;
|
||||||
|
bone.ay = bone.y;
|
||||||
|
bone.arotation = bone.rotation;
|
||||||
|
bone.ascaleX = bone.scaleX;
|
||||||
|
bone.ascaleY = bone.scaleY;
|
||||||
|
bone.ashearX = bone.shearX;
|
||||||
|
bone.ashearY = bone.shearY;
|
||||||
|
bone.appliedValid = true;
|
||||||
|
}
|
||||||
Array<Updatable> updateCache = this.updateCache;
|
Array<Updatable> updateCache = this.updateCache;
|
||||||
for (int i = 0, n = updateCache.size; i < n; i++)
|
for (int i = 0, n = updateCache.size; i < n; i++)
|
||||||
updateCache.get(i).update();
|
updateCache.get(i).update();
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user