From a687a6c05c60b4824b9ddc9e911a15bc045e3688 Mon Sep 17 00:00:00 2001 From: Harald Csaszar Date: Tue, 15 Jul 2025 18:58:10 +0200 Subject: [PATCH] [csharp] Port of commit 9272327: Fixed bone disable inherit scale/reflection. Closes #2888. --- spine-csharp/src/BonePose.cs | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/spine-csharp/src/BonePose.cs b/spine-csharp/src/BonePose.cs index da421aebd..e288d7931 100644 --- a/spine-csharp/src/BonePose.cs +++ b/spine-csharp/src/BonePose.cs @@ -128,8 +128,7 @@ namespace Spine { } case Inherit.NoScale: case Inherit.NoScaleOrReflection: { - rotation *= MathUtils.DegRad; - float cos = (float)Math.Cos(rotation), sin = (float)Math.Sin(rotation); + float r = rotation * MathUtils.DegRad, cos = (float)Math.Cos(r), sin = (float)Math.Sin(r); float za = (pa * cos + pb * sin) / skeleton.scaleX; float zc = (pc * cos + pd * sin) / skeleton.ScaleY; float s = (float)Math.Sqrt(za * za + zc * zc); @@ -138,15 +137,15 @@ namespace Spine { zc *= s; 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; - rotation = MathUtils.PI / 2 + MathUtils.Atan2(zc, za); - float zb = (float)Math.Cos(rotation) * s; - float zd = (float)Math.Sin(rotation) * s; - shearX *= MathUtils.DegRad; - shearY = (90 + shearY) * MathUtils.DegRad; - float la = (float)Math.Cos(shearX) * scaleX; - float lb = (float)Math.Cos(shearY) * scaleY; - float lc = (float)Math.Sin(shearX) * scaleX; - float ld = (float)Math.Sin(shearY) * scaleY; + r = MathUtils.PI / 2 + MathUtils.Atan2(zc, za); + float zb = (float)Math.Cos(r) * s; + float zd = (float)Math.Sin(r) * s; + float rx = shearX * MathUtils.DegRad; + float ry = (90 + shearY) * MathUtils.DegRad; + float la = (float)Math.Cos(rx) * scaleX; + float lb = (float)Math.Cos(ry) * scaleY; + float lc = (float)Math.Sin(rx) * scaleX; + float ld = (float)Math.Sin(ry) * scaleY; a = za * la + zb * lc; b = za * lb + zb * ld; c = zc * la + zd * lc;