Browse Source

Fixed single bone IK with skeleton flipping.

NathanSweet 9 years ago
parent
commit
f9d3988ee5

+ 2 - 1
spine-c/src/spine/IkConstraint.c

@@ -72,7 +72,8 @@ void spIkConstraint_apply1 (spBone* bone, float targetX, float targetY, float al
 	float parentRotation = !bone->parent ? 0 : spBone_getWorldRotationX(bone->parent);
 	float rotation = bone->rotation;
 	float rotationIK = ATAN2(targetY - bone->worldY, targetX - bone->worldX) * RAD_DEG - parentRotation;
-	if (bone->worldSignX != bone->worldSignY) rotationIK = 360 - rotationIK;
+	if ((bone->worldSignX != bone->worldSignY) != (bone->skeleton->flipX != (bone->skeleton->flipY != spBone_isYDown())))
+		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);

+ 2 - 1
spine-csharp/src/IkConstraint.cs

@@ -86,7 +86,8 @@ namespace Spine {
 			float parentRotation = bone.parent == null ? 0 : bone.parent.WorldRotationX;
 			float rotation = bone.rotation;
 			float rotationIK = MathUtils.Atan2(targetY - bone.worldY, targetX - bone.worldX) * MathUtils.radDeg - parentRotation;
-			if (bone.worldSignX != bone.worldSignY) rotationIK = 360 - rotationIK;
+			if ((bone.worldSignX != bone.worldSignY) != (bone.skeleton.flipX != (bone.skeleton.flipY != Bone.yDown)))
+				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);

+ 1 - 1
spine-libgdx/spine-libgdx/src/com/esotericsoftware/spine/IkConstraint.java

@@ -125,7 +125,7 @@ public class IkConstraint implements Updatable {
 		float parentRotation = bone.parent == null ? 0 : bone.parent.getWorldRotationX();
 		float rotation = bone.rotation;
 		float rotationIK = atan2(targetY - bone.worldY, targetX - bone.worldX) * radDeg - parentRotation;
-		if (bone.worldSignX != bone.worldSignY) rotationIK = 360 - rotationIK;
+		if ((bone.worldSignX != bone.worldSignY) != (bone.skeleton.flipX != bone.skeleton.flipY)) rotationIK = 360 - rotationIK;
 		if (rotationIK > 180)
 			rotationIK -= 360;
 		else if (rotationIK < -180) rotationIK += 360;