瀏覽代碼

[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 年之前
父節點
當前提交
8c55b1b5d0
共有 1 個文件被更改,包括 2 次插入1 次删除
  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) {
 		public float WorldToLocalRotation (float worldRotation) {
 			float sin = MathUtils.SinDeg(worldRotation), cos = MathUtils.CosDeg(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) {
 		public float LocalToWorldRotation (float localRotation) {
+			localRotation -= rotation - shearX;
 			float sin = MathUtils.SinDeg(localRotation), cos = MathUtils.CosDeg(localRotation);
 			float sin = MathUtils.SinDeg(localRotation), cos = MathUtils.CosDeg(localRotation);
 			return MathUtils.Atan2(cos * c + sin * d, cos * a + sin * b) * MathUtils.RadDeg;
 			return MathUtils.Atan2(cos * c + sin * d, cos * a + sin * b) * MathUtils.RadDeg;
 		}
 		}