From 1410f0e16fcc4b60803dcc25e5ba9b74ec1db26c Mon Sep 17 00:00:00 2001 From: NathanSweet Date: Fri, 15 Apr 2016 17:40:48 +0200 Subject: [PATCH] Clean up. --- spine-c/src/spine/IkConstraint.c | 11 ++++++----- spine-csharp/src/IkConstraint.cs | 6 +++--- .../src/com/esotericsoftware/spine/IkConstraint.java | 11 ++++++----- .../src/com/esotericsoftware/spine/SkeletonJson.java | 1 - 4 files changed, 15 insertions(+), 14 deletions(-) diff --git a/spine-c/src/spine/IkConstraint.c b/spine-c/src/spine/IkConstraint.c index 0a338fa20..f50b8ed32 100644 --- a/spine-c/src/spine/IkConstraint.c +++ b/spine-c/src/spine/IkConstraint.c @@ -76,11 +76,12 @@ void spIkConstraint_apply1 (spBone* bone, float targetX, float targetY, float al rotationIK = 360 - rotationIK; if (rotationIK > 180) rotationIK -= 360; else if (rotationIK < -180) rotationIK += 360; - spBone_updateWorldTransformWith(bone, bone->x, bone->y, rotation + (rotationIK - rotation) * alpha, bone->scaleX, bone->scaleY); + spBone_updateWorldTransformWith(bone, bone->x, bone->y, rotation + (rotationIK - rotation) * alpha, bone->appliedScaleX, + bone->appliedScaleY); } void spIkConstraint_apply2 (spBone* parent, spBone* child, float targetX, float targetY, int bendDir, float alpha) { - float px = parent->x, py = parent->y, psx = parent->scaleX, psy = parent->scaleY; + float px = parent->x, py = parent->y, psx = parent->appliedScaleX, psy = parent->appliedScaleY; float cx = child->x, cy = child->y, csx = child->appliedScaleX, cwx = child->worldX, cwy = child->worldY; int o1, o2, s2, u; spBone* pp = parent->parent; @@ -198,9 +199,9 @@ void spIkConstraint_apply2 (spBone* parent, spBone* child, float targetX, float } } outer: { - float offset = ATAN2(cy, child->x) * s2; - a1 = (a1 - offset) * RAD_DEG + o1; - a2 = (a2 + offset) * RAD_DEG * s2 + o2; + float os = ATAN2(cy, cx) * s2; + a1 = (a1 - os) * RAD_DEG + o1; + a2 = (a2 + os) * RAD_DEG * s2 + o2; if (a1 > 180) a1 -= 360; else if (a1 < -180) a1 += 360; if (a2 > 180) a2 -= 360; diff --git a/spine-csharp/src/IkConstraint.cs b/spine-csharp/src/IkConstraint.cs index cb3b6938d..63112c064 100644 --- a/spine-csharp/src/IkConstraint.cs +++ b/spine-csharp/src/IkConstraint.cs @@ -90,7 +90,7 @@ namespace Spine { rotationIK = 360 - rotationIK; if (rotationIK > 180) rotationIK -= 360; else if (rotationIK < -180) rotationIK += 360; - bone.UpdateWorldTransform(bone.x, bone.y, rotation + (rotationIK - rotation) * alpha, bone.scaleX, bone.scaleY); + bone.UpdateWorldTransform(bone.x, bone.y, rotation + (rotationIK - rotation) * alpha, bone.appliedScaleX, bone.appliedScaleY); } /// Adjusts the parent and child bone rotations so the tip of the child is as close to the target position as @@ -98,7 +98,7 @@ namespace Spine { /// A direct descendant of the parent bone. static public void Apply (Bone parent, Bone child, float targetX, float targetY, int bendDir, float alpha) { if (alpha == 0) return; - float px = parent.x, py = parent.y, psx = parent.scaleX, psy = parent.scaleY; + float px = parent.x, py = parent.y, psx = parent.appliedScaleX, psy = parent.appliedScaleY; int os1, os2, s2; if (psx < 0) { psx = -psx; @@ -112,7 +112,7 @@ namespace Spine { psy = -psy; s2 = -s2; } - float cx = child.x, cy = child.y, csx = child.scaleX; + float cx = child.x, cy = child.y, csx = child.appliedScaleX; bool u = Math.Abs(psx - psy) <= 0.0001f; if (!u && cy != 0) { child.worldX = parent.a * cx + parent.worldX; 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 57bc8dbb6..75d12e431 100644 --- a/spine-libgdx/spine-libgdx/src/com/esotericsoftware/spine/IkConstraint.java +++ b/spine-libgdx/spine-libgdx/src/com/esotericsoftware/spine/IkConstraint.java @@ -129,7 +129,8 @@ public class IkConstraint implements Updatable { if (rotationIK > 180) rotationIK -= 360; else if (rotationIK < -180) rotationIK += 360; - bone.updateWorldTransform(bone.x, bone.y, rotation + (rotationIK - rotation) * alpha, bone.scaleX, bone.scaleY); + bone.updateWorldTransform(bone.x, bone.y, rotation + (rotationIK - rotation) * alpha, bone.appliedScaleX, + bone.appliedScaleY); } /** Adjusts the parent and child bone rotations so the tip of the child is as close to the target position as possible. The @@ -137,7 +138,7 @@ public class IkConstraint implements Updatable { * @param child A direct descendant of the parent bone. */ static public void apply (Bone parent, Bone child, float targetX, float targetY, int bendDir, float alpha) { if (alpha == 0) return; - float px = parent.x, py = parent.y, psx = parent.scaleX, psy = parent.scaleY; + float px = parent.x, py = parent.y, psx = parent.appliedScaleX, psy = parent.appliedScaleY; int os1, os2, s2; if (psx < 0) { psx = -psx; @@ -248,9 +249,9 @@ public class IkConstraint implements Updatable { a2 = maxAngle * bendDir; } } - float o = atan2(cy, cx) * s2; - a1 = (a1 - o) * radDeg + os1; - a2 = (a2 + o) * radDeg * s2 + os2; + float os = atan2(cy, cx) * s2; + a1 = (a1 - os) * radDeg + os1; + a2 = (a2 + os) * radDeg * s2 + os2; if (a1 > 180) a1 -= 360; else if (a1 < -180) a1 += 360; diff --git a/spine-libgdx/spine-libgdx/src/com/esotericsoftware/spine/SkeletonJson.java b/spine-libgdx/spine-libgdx/src/com/esotericsoftware/spine/SkeletonJson.java index 8e284f45d..3b9872271 100644 --- a/spine-libgdx/spine-libgdx/src/com/esotericsoftware/spine/SkeletonJson.java +++ b/spine-libgdx/spine-libgdx/src/com/esotericsoftware/spine/SkeletonJson.java @@ -594,7 +594,6 @@ public class SkeletonJson { Attachment mesh; public LinkedMesh (Attachment mesh, String skin, int slotIndex, String parent) { - super(); this.mesh = mesh; this.skin = skin; this.slotIndex = slotIndex;