diff --git a/spine-libgdx/spine-libgdx/src/com/esotericsoftware/spine/IkConstraint.java b/spine-libgdx/spine-libgdx/src/com/esotericsoftware/spine/IkConstraint.java index 3aacaf5c6..fb62d0182 100644 --- a/spine-libgdx/spine-libgdx/src/com/esotericsoftware/spine/IkConstraint.java +++ b/spine-libgdx/spine-libgdx/src/com/esotericsoftware/spine/IkConstraint.java @@ -80,11 +80,8 @@ public class IkConstraint implements Updatable { } /** Applies the constraint to the constrained bones. */ - public void apply () { - update(); - } - public void update () { + if (mix == 0) return; Bone target = this.target; Object[] bones = this.bones.items; switch (this.bones.size) { @@ -228,10 +225,6 @@ public class IkConstraint implements Updatable { float alpha) { if (parent == null) throw new IllegalArgumentException("parent cannot be null."); if (child == null) throw new IllegalArgumentException("child cannot be null."); - if (alpha == 0) { - child.updateWorldTransform(); - return; - } if (!parent.appliedValid) parent.updateAppliedTransform(); if (!child.appliedValid) child.updateAppliedTransform(); float px = parent.ax, py = parent.ay, psx = parent.ascaleX, sx = psx, psy = parent.ascaleY, csx = child.ascaleX; diff --git a/spine-libgdx/spine-libgdx/src/com/esotericsoftware/spine/PathConstraint.java b/spine-libgdx/spine-libgdx/src/com/esotericsoftware/spine/PathConstraint.java index bdcd5191a..e6860275c 100644 --- a/spine-libgdx/spine-libgdx/src/com/esotericsoftware/spine/PathConstraint.java +++ b/spine-libgdx/spine-libgdx/src/com/esotericsoftware/spine/PathConstraint.java @@ -88,10 +88,6 @@ public class PathConstraint implements Updatable { } /** Applies the constraint to the constrained bones. */ - public void apply () { - update(); - } - public void update () { Attachment attachment = target.attachment; if (!(attachment instanceof PathAttachment)) return; diff --git a/spine-libgdx/spine-libgdx/src/com/esotericsoftware/spine/Skeleton.java b/spine-libgdx/spine-libgdx/src/com/esotericsoftware/spine/Skeleton.java index 005fa0a81..6fafd649e 100644 --- a/spine-libgdx/spine-libgdx/src/com/esotericsoftware/spine/Skeleton.java +++ b/spine-libgdx/spine-libgdx/src/com/esotericsoftware/spine/Skeleton.java @@ -56,7 +56,6 @@ public class Skeleton { final Array transformConstraints; final Array pathConstraints; final Array updateCache = new Array(); - final Array updateCacheReset = new Array(); @Null Skin skin; final Color color; float time; @@ -161,7 +160,6 @@ public class Skeleton { public void updateCache () { Array updateCache = this.updateCache; updateCache.clear(); - updateCacheReset.clear(); int boneCount = bones.size; Object[] bones = this.bones.items; @@ -227,16 +225,18 @@ public class Skeleton { Array constrained = constraint.bones; Bone parent = constrained.first(); sortBone(parent); - - if (constrained.size > 1) { + if (constrained.size == 1) { + updateCache.add(constraint); + sortReset(parent.children); + } else { Bone child = constrained.peek(); - if (!updateCache.contains(child, true)) updateCacheReset.add(child); + sortBone(child); + + updateCache.add(constraint); + + sortReset(parent.children); + child.sorted = true; } - - updateCache.add(constraint); - - sortReset(parent.children); - constrained.peek().sorted = true; } private void sortPathConstraint (PathConstraint constraint) { @@ -280,7 +280,7 @@ public class Skeleton { for (int i = 0; i < boneCount; i++) { Bone child = (Bone)constrained[i]; sortBone(child.parent); - if (!updateCache.contains(child, true)) updateCacheReset.add(child); + sortBone(child); } } else { for (int i = 0; i < boneCount; i++) @@ -342,21 +342,6 @@ public class Skeleton { * See World transforms in the Spine * Runtimes Guide. */ public void updateWorldTransform () { - // This partial update avoids computing the world transform for constrained bones when 1) the bone is not updated - // before the constraint, 2) the constraint only needs to access the applied local transform, and 3) the constraint calls - // updateWorldTransform. - Object[] updateCacheReset = this.updateCacheReset.items; - for (int i = 0, n = this.updateCacheReset.size; i < n; i++) { - Bone bone = (Bone)updateCacheReset[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; - } Object[] updateCache = this.updateCache.items; for (int i = 0, n = this.updateCache.size; i < n; i++) ((Updatable)updateCache[i]).update(); @@ -369,22 +354,6 @@ public class Skeleton { * Runtimes Guide. */ public void updateWorldTransform (Bone parent) { if (parent == null) throw new IllegalArgumentException("parent cannot be null."); - // This partial update avoids computing the world transform for constrained bones when: - // 1) the bone is not updated before the constraint, - // 2) the constraint only needs to access the applied local transform, and - // 3) the constraint calls updateWorldTransform. - Object[] updateCacheReset = this.updateCacheReset.items; - for (int i = 0, n = this.updateCacheReset.size; i < n; i++) { - Bone bone = (Bone)updateCacheReset[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; - } // Apply the parent bone transform to the root bone. The root bone always inherits scale, rotation and reflection. Bone rootBone = getRootBone(); diff --git a/spine-libgdx/spine-libgdx/src/com/esotericsoftware/spine/TransformConstraint.java b/spine-libgdx/spine-libgdx/src/com/esotericsoftware/spine/TransformConstraint.java index 968304d36..eed6cd7e3 100644 --- a/spine-libgdx/spine-libgdx/src/com/esotericsoftware/spine/TransformConstraint.java +++ b/spine-libgdx/spine-libgdx/src/com/esotericsoftware/spine/TransformConstraint.java @@ -77,11 +77,8 @@ public class TransformConstraint implements Updatable { } /** Applies the constraint to the constrained bones. */ - public void apply () { - update(); - } - public void update () { + if (rotateMix == 0 && translateMix == 0 && scaleMix == 0 && shearMix == 0) return; if (data.local) { if (data.relative) applyRelativeLocal(); @@ -97,7 +94,6 @@ public class TransformConstraint implements Updatable { private void applyAbsoluteWorld () { float rotateMix = this.rotateMix, translateMix = this.translateMix, scaleMix = this.scaleMix, shearMix = this.shearMix; - if (rotateMix == 0 && translateMix == 0 && scaleMix == 0 && shearMix == 0) return; Bone target = this.target; float ta = target.a, tb = target.b, tc = target.c, td = target.d; float degRadReflect = ta * td - tb * tc > 0 ? degRad : -degRad; @@ -157,7 +153,6 @@ public class TransformConstraint implements Updatable { private void applyRelativeWorld () { float rotateMix = this.rotateMix, translateMix = this.translateMix, scaleMix = this.scaleMix, shearMix = this.shearMix; - if (rotateMix == 0 && translateMix == 0 && scaleMix == 0 && shearMix == 0) return; Bone target = this.target; float ta = target.a, tb = target.b, tc = target.c, td = target.d; float degRadReflect = ta * td - tb * tc > 0 ? degRad : -degRad;