mirror of
https://github.com/EsotericSoftware/spine-runtimes.git
synced 2026-02-04 22:34:53 +08:00
Fixed single bone IK with skeleton flipping.
This commit is contained in:
parent
ef0b4b4bb9
commit
f9d3988ee5
@ -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);
|
||||
|
||||
@ -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);
|
||||
|
||||
@ -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;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user