Skip to content

Commit

Permalink
[c] Closes #2509, SP_INHERIT_NOSCALE was incorrectly implemented
Browse files Browse the repository at this point in the history
  • Loading branch information
badlogic committed May 2, 2024
1 parent 39635f7 commit 04c132f
Showing 1 changed file with 20 additions and 15 deletions.
35 changes: 20 additions & 15 deletions spine-c/spine-c/src/spine/Bone.c
Expand Up @@ -161,21 +161,26 @@ void spBone_updateWorldTransformWith(spBone *self, float x, float y, float rotat
float za = (pa * cosine + pb * sine) / sx;
float zc = (pc * cosine + pd * sine) / sy;
float s = SQRT(za * za + zc * zc);
if (self->data->inherit == SP_INHERIT_NOSCALE && (pa * pd - pb * pc < 0) != (sx < 0 != sy < 0))
s = -s;
rotation = PI / 2 + ATAN2(zc, za);
float zb = COS(rotation) * s;
float zd = SIN(rotation) * s;
shearX *= DEG_RAD;
shearY = (90 + shearY) * DEG_RAD;
float la = COS(shearX) * scaleX;
float lb = COS(shearY) * scaleY;
float lc = SIN(shearX) * scaleX;
float ld = SIN(shearY) * scaleY;
self->a = za * la + zb * lc;
self->b = za * lb + zb * ld;
self->c = zc * la + zd * lc;
self->d = zc * lb + zd * ld;
if (s > 0.00001f) s = 1 / s;
za *= s;
zc *= s;
s = SQRT(za * za + zc * zc);
if (self->inherit == SP_INHERIT_NOSCALE &&
(pa * pd - pb * pc < 0) != (sx < 0 != sy < 0))
s = -s;
rotation = PI / 2 + ATAN2(zc, za);
float zb = COS(rotation) * s;
float zd = SIN(rotation) * s;
shearX *= DEG_RAD;
shearY = (90 + shearY) * DEG_RAD;
float la = COS(shearX) * scaleX;
float lb = COS(shearY) * scaleY;
float lc = SIN(shearX) * scaleX;
float ld = SIN(shearY) * scaleY;
self->a = za * la + zb * lc;
self->b = za * lb + zb * ld;
self->c = zc * la + zd * lc;
self->d = zc * lb + zd * ld;
}
}

Expand Down

0 comments on commit 04c132f

Please sign in to comment.