Browse Source

Fixed flipping to use world axes, fixed disable inherit scale and rotation when flipped.

NathanSweet 9 năm trước cách đây
mục cha
commit
ac2721c553

+ 32 - 18
spine-csharp/src/Bone.cs

@@ -103,16 +103,14 @@ namespace Spine {
 			if (parent == null) { // Root bone.
 			if (parent == null) { // Root bone.
 					Skeleton skeleton = this.skeleton;
 					Skeleton skeleton = this.skeleton;
 					if (skeleton.flipX) {
 					if (skeleton.flipX) {
-						la = -la;
-						lc = -lc;
-						scaleX = -scaleX;
 						x = -x;
 						x = -x;
+						la = -la;
+						lb = -lb;
 					}
 					}
 					if (skeleton.flipY != yDown) {
 					if (skeleton.flipY != yDown) {
-						lb = -lb;
-						ld = -ld;
-						scaleY = -scaleY;
 						y = -y;
 						y = -y;
+						lc = -lc;
+						ld = -ld;
 					}
 					}
 					a = la;
 					a = la;
 					b = lb;
 					b = lb;
@@ -145,24 +143,32 @@ namespace Spine {
                while (p != null) {
                while (p != null) {
                   cos = MathUtils.CosDeg(p.appliedRotation);
                   cos = MathUtils.CosDeg(p.appliedRotation);
                   sin = MathUtils.SinDeg(p.appliedRotation);
                   sin = MathUtils.SinDeg(p.appliedRotation);
-                  float a = pa * cos + pb * sin;
-                  float b = pa * -sin + pb * cos;
-                  float c = pc * cos + pd * sin;
-                  float d = pc * -sin + pd * cos;
-                  pa = a;
-                  pb = b;
-                  pc = c;
-                  pd = d;
+                  float ta = pa * cos + pb * sin;
+                  float tb = pa * -sin + pb * cos;
+                  float tc = pc * cos + pd * sin;
+                  float td = pc * -sin + pd * cos;
+                  pa = ta;
+                  pb = tb;
+                  pc = tc;
+                  pd = td;
                   p = p.parent;
                   p = p.parent;
                }
                }
 					if (yDown) {
 					if (yDown) {
 						pb = -pb;
 						pb = -pb;
 						pd = -pd;
 						pd = -pd;
 					}
 					}
-               this.a = pa * la + pb * lc;
-               this.b = pa * lb + pb * ld;
-               this.c = pc * la + pd * lc;
-               this.d = pc * lb + pd * ld;
+               a = pa * la + pb * lc;
+               b = pa * lb + pb * ld;
+               c = pc * la + pd * lc;
+               d = pc * lb + pd * ld;
+					if (skeleton.flipX) {
+						a = -a;
+						b = -b;
+					}
+					if (skeleton.flipY) {
+						c = -c;
+						d = -d;
+					}
          } else if (data.inheritScale) { // No rotation inheritance.
          } else if (data.inheritScale) { // No rotation inheritance.
                Bone p = parent;
                Bone p = parent;
                pa = 1;
                pa = 1;
@@ -202,6 +208,14 @@ namespace Spine {
                b = pa * lb + pb * ld;
                b = pa * lb + pb * ld;
                c = pc * la + pd * lc;
                c = pc * la + pd * lc;
                d = pc * lb + pd * ld;
                d = pc * lb + pd * ld;
+					if (skeleton.flipX) {
+						a = -a;
+						b = -b;
+					}
+					if (skeleton.flipY) {
+						c = -c;
+						d = -d;
+					}
          } else {
          } else {
                a = la;
                a = la;
                b = lb;
                b = lb;

+ 20 - 6
spine-libgdx/spine-libgdx/src/com/esotericsoftware/spine/Bone.java

@@ -95,16 +95,14 @@ public class Bone implements Updatable {
 		if (parent == null) { // Root bone.
 		if (parent == null) { // Root bone.
 			Skeleton skeleton = this.skeleton;
 			Skeleton skeleton = this.skeleton;
 			if (skeleton.flipX) {
 			if (skeleton.flipX) {
-				la = -la;
-				lc = -lc;
-				scaleX = -scaleX;
 				x = -x;
 				x = -x;
+				la = -la;
+				lb = -lb;
 			}
 			}
 			if (skeleton.flipY) {
 			if (skeleton.flipY) {
-				lb = -lb;
-				ld = -ld;
-				scaleY = -scaleY;
 				y = -y;
 				y = -y;
+				lc = -lc;
+				ld = -ld;
 			}
 			}
 			a = la;
 			a = la;
 			b = lb;
 			b = lb;
@@ -151,6 +149,14 @@ public class Bone implements Updatable {
 			b = pa * lb + pb * ld;
 			b = pa * lb + pb * ld;
 			c = pc * la + pd * lc;
 			c = pc * la + pd * lc;
 			d = pc * lb + pd * ld;
 			d = pc * lb + pd * ld;
+			if (skeleton.flipX) {
+				a = -a;
+				b = -b;
+			}
+			if (skeleton.flipY) {
+				c = -c;
+				d = -d;
+			}
 		} else if (data.inheritScale) { // No rotation inheritance.
 		} else if (data.inheritScale) { // No rotation inheritance.
 			Bone p = parent;
 			Bone p = parent;
 			pa = 1;
 			pa = 1;
@@ -186,6 +192,14 @@ public class Bone implements Updatable {
 			b = pa * lb + pb * ld;
 			b = pa * lb + pb * ld;
 			c = pc * la + pd * lc;
 			c = pc * la + pd * lc;
 			d = pc * lb + pd * ld;
 			d = pc * lb + pd * ld;
+			if (skeleton.flipX) {
+				a = -a;
+				b = -b;
+			}
+			if (skeleton.flipY) {
+				c = -c;
+				d = -d;
+			}
 		} else {
 		} else {
 			a = la;
 			a = la;
 			b = lb;
 			b = lb;