mirror of
https://github.com/EsotericSoftware/spine-runtimes.git
synced 2026-02-06 07:14:55 +08:00
Transform constraint offset rotation and shearY reflects if the target is reflected.
This commit is contained in:
parent
16eb6b5ede
commit
5b8a7420ea
@ -84,6 +84,8 @@ public class TransformConstraint implements Constraint {
|
||||
float rotateMix = this.rotateMix, translateMix = this.translateMix, scaleMix = this.scaleMix, shearMix = this.shearMix;
|
||||
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;
|
||||
float offsetRotation = data.offsetRotation * degRadReflect, offsetShearY = data.offsetShearY * degRadReflect;
|
||||
Array<Bone> bones = this.bones;
|
||||
for (int i = 0, n = bones.size; i < n; i++) {
|
||||
Bone bone = bones.get(i);
|
||||
@ -91,7 +93,7 @@ public class TransformConstraint implements Constraint {
|
||||
|
||||
if (rotateMix != 0) {
|
||||
float a = bone.a, b = bone.b, c = bone.c, d = bone.d;
|
||||
float r = atan2(tc, ta) - atan2(c, a) + data.offsetRotation * degRad;
|
||||
float r = atan2(tc, ta) - atan2(c, a) + offsetRotation;
|
||||
if (r > PI)
|
||||
r -= PI2;
|
||||
else if (r < -PI) r += PI2;
|
||||
@ -133,7 +135,7 @@ public class TransformConstraint implements Constraint {
|
||||
if (r > PI)
|
||||
r -= PI2;
|
||||
else if (r < -PI) r += PI2;
|
||||
r = by + (r + data.offsetShearY * degRad) * shearMix;
|
||||
r = by + (r + offsetShearY) * shearMix;
|
||||
float s = (float)Math.sqrt(b * b + d * d);
|
||||
bone.b = cos(r) * s;
|
||||
bone.d = sin(r) * s;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user