From 8c55b1b5d0db4cd5ed2c50be2e02a5124fd70177 Mon Sep 17 00:00:00 2001 From: pharan Date: Wed, 24 Oct 2018 23:57:49 +0800 Subject: [PATCH] [csharp] Fix world-to-local and local-to-world rotation functions to account for local rotation and shearX. based on : https://github.com/EsotericSoftware/spine-runtimes/commit/3851e201d80b2e4d2195b38c7980ea3cf9928c44 --- spine-csharp/src/Bone.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/spine-csharp/src/Bone.cs b/spine-csharp/src/Bone.cs index 21b471894..acc1a42ed 100644 --- a/spine-csharp/src/Bone.cs +++ b/spine-csharp/src/Bone.cs @@ -329,10 +329,11 @@ namespace Spine { public float WorldToLocalRotation (float worldRotation) { float sin = MathUtils.SinDeg(worldRotation), cos = MathUtils.CosDeg(worldRotation); - return MathUtils.Atan2(a * sin - c * cos, d * cos - b * sin) * MathUtils.RadDeg; + return MathUtils.Atan2(a * sin - c * cos, d * cos - b * sin) * MathUtils.RadDeg + rotation - shearX; } public float LocalToWorldRotation (float localRotation) { + localRotation -= rotation - shearX; float sin = MathUtils.SinDeg(localRotation), cos = MathUtils.CosDeg(localRotation); return MathUtils.Atan2(cos * c + sin * d, cos * a + sin * b) * MathUtils.RadDeg; }