Browse Source

[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
pharan 6 years ago
parent
commit
8c55b1b5d0
1 changed files with 2 additions and 1 deletions
  1. 2 1
      spine-csharp/src/Bone.cs

+ 2 - 1
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;
 		}