[csharp] Port of commit 9272327: Fixed bone disable inherit scale/reflection. Closes #2888.

This commit is contained in:
Harald Csaszar 2025-07-15 18:58:10 +02:00
parent 0adcacaf13
commit a687a6c05c

View File

@ -128,8 +128,7 @@ namespace Spine {
} }
case Inherit.NoScale: case Inherit.NoScale:
case Inherit.NoScaleOrReflection: { case Inherit.NoScaleOrReflection: {
rotation *= MathUtils.DegRad; float r = rotation * MathUtils.DegRad, cos = (float)Math.Cos(r), sin = (float)Math.Sin(r);
float cos = (float)Math.Cos(rotation), sin = (float)Math.Sin(rotation);
float za = (pa * cos + pb * sin) / skeleton.scaleX; float za = (pa * cos + pb * sin) / skeleton.scaleX;
float zc = (pc * cos + pd * sin) / skeleton.ScaleY; float zc = (pc * cos + pd * sin) / skeleton.ScaleY;
float s = (float)Math.Sqrt(za * za + zc * zc); float s = (float)Math.Sqrt(za * za + zc * zc);
@ -138,15 +137,15 @@ namespace Spine {
zc *= s; zc *= s;
s = (float)Math.Sqrt(za * za + zc * zc); s = (float)Math.Sqrt(za * za + zc * zc);
if (inherit == Inherit.NoScale && (pa * pd - pb * pc < 0) != (skeleton.scaleX < 0 != skeleton.ScaleY < 0)) s = -s; if (inherit == Inherit.NoScale && (pa * pd - pb * pc < 0) != (skeleton.scaleX < 0 != skeleton.ScaleY < 0)) s = -s;
rotation = MathUtils.PI / 2 + MathUtils.Atan2(zc, za); r = MathUtils.PI / 2 + MathUtils.Atan2(zc, za);
float zb = (float)Math.Cos(rotation) * s; float zb = (float)Math.Cos(r) * s;
float zd = (float)Math.Sin(rotation) * s; float zd = (float)Math.Sin(r) * s;
shearX *= MathUtils.DegRad; float rx = shearX * MathUtils.DegRad;
shearY = (90 + shearY) * MathUtils.DegRad; float ry = (90 + shearY) * MathUtils.DegRad;
float la = (float)Math.Cos(shearX) * scaleX; float la = (float)Math.Cos(rx) * scaleX;
float lb = (float)Math.Cos(shearY) * scaleY; float lb = (float)Math.Cos(ry) * scaleY;
float lc = (float)Math.Sin(shearX) * scaleX; float lc = (float)Math.Sin(rx) * scaleX;
float ld = (float)Math.Sin(shearY) * scaleY; float ld = (float)Math.Sin(ry) * scaleY;
a = za * la + zb * lc; a = za * la + zb * lc;
b = za * lb + zb * ld; b = za * lb + zb * ld;
c = zc * la + zd * lc; c = zc * la + zd * lc;