Преглед изворни кода

[c][cpp][csharp][lua][ts][as3] worldToLocalRotation and localToWorldRotation take shear into account. Fixes #1199.

badlogic пре 6 година
родитељ
комит
e4ab2c63f3

BIN
spine-as3/spine-as3-example/lib/spine-as3.swc


+ 2 - 1
spine-as3/spine-as3/src/spine/Bone.as

@@ -293,10 +293,11 @@ package spine {
 
 		public function worldToLocalRotation(worldRotation : Number) : Number {
 			var sin : Number = MathUtils.sinDeg(worldRotation), cos : Number = MathUtils.cosDeg(worldRotation);
-			return Math.atan2(this.a * sin - this.c * cos, this.d * cos - this.b * sin) * MathUtils.radDeg;
+			return Math.atan2(this.a * sin - this.c * cos, this.d * cos - this.b * sin) * MathUtils.radDeg + rotation - shearX;
 		}
 
 		public function localToWorldRotation(localRotation : Number) : Number {
+			localRotation -= rotation - shearX;
 			var sin : Number = MathUtils.sinDeg(localRotation), cos : Number = MathUtils.cosDeg(localRotation);
 			return Math.atan2(cos * this.c + sin * this.d, cos * this.a + sin * this.b) * MathUtils.radDeg;
 		}

+ 2 - 1
spine-c/spine-c/src/spine/Bone.c

@@ -264,11 +264,12 @@ float spBone_worldToLocalRotation (spBone* self, float worldRotation) {
 	float sine, cosine;
 	sine = SIN_DEG(worldRotation);
 	cosine = COS_DEG(worldRotation);
-	return ATAN2(self->a * sine - self->c * cosine, self->d * cosine - self->b * sine) * RAD_DEG;
+	return ATAN2(self->a * sine - self->c * cosine, self->d * cosine - self->b * sine) * RAD_DEG + self->rotation - self->shearX;
 }
 
 float spBone_localToWorldRotation (spBone* self, float localRotation) {
 	float sine, cosine;
+	localRotation -= self->rotation - self->shearX;
 	sine = SIN_DEG(localRotation);
 	cosine = COS_DEG(localRotation);
 	return ATAN2(cosine * self->c + sine * self->d, cosine * self->a + sine * self->b) * RAD_DEG;

+ 2 - 1
spine-cpp/spine-cpp/src/spine/Bone.cpp

@@ -237,10 +237,11 @@ float Bone::worldToLocalRotation(float worldRotation) {
 	float sin = MathUtil::sinDeg(worldRotation);
 	float cos = MathUtil::cosDeg(worldRotation);
 
-	return MathUtil::atan2(_a * sin - _c * cos, _d * cos - _b * sin) * MathUtil::Rad_Deg;
+	return MathUtil::atan2(_a * sin - _c * cos, _d * cos - _b * sin) * MathUtil::Rad_Deg + this->_rotation - this->_shearX;
 }
 
 float Bone::localToWorldRotation(float localRotation) {
+	localRotation -= this->_rotation - this->_shearX;
 	float sin = MathUtil::sinDeg(localRotation);
 	float cos = MathUtil::cosDeg(localRotation);
 

+ 2 - 1
spine-lua/Bone.lua

@@ -286,10 +286,11 @@ end
 function Bone:worldToLocalRotation (worldRotation)
 	local sin = math_sin(math_rad(worldRotation))
 	local cos = math_cos(math_rad(worldRotation))
-	return math_deg(math_atan2(self.a * sin - self.c * cos, self.d * cos - self.b * sin))
+	return math_deg(math_atan2(self.a * sin - self.c * cos, self.d * cos - self.b * sin)) + self.rotation - self.shearX
 end
 
 function Bone:localToWorldRotation (localRotation)
+	localRotation = localRotation - (self.rotation - self.shearX)
 	local sin = math_sin(math_rad(localRotation))
 	local cos = math_cos(math_rad(localRotation))
 	return math_deg(math_atan2(cos * self.c + sin * self.d, cos * self.a + sin * self.b))

BIN
spine-starling/spine-starling-example/lib/spine-as3.swc


BIN
spine-starling/spine-starling/lib/spine-as3.swc


+ 2 - 1
spine-ts/build/spine-all.js

@@ -2576,9 +2576,10 @@ var spine;
 		};
 		Bone.prototype.worldToLocalRotation = function (worldRotation) {
 			var sin = spine.MathUtils.sinDeg(worldRotation), cos = spine.MathUtils.cosDeg(worldRotation);
-			return Math.atan2(this.a * sin - this.c * cos, this.d * cos - this.b * sin) * spine.MathUtils.radDeg;
+			return Math.atan2(this.a * sin - this.c * cos, this.d * cos - this.b * sin) * spine.MathUtils.radDeg + this.rotation - this.shearX;
 		};
 		Bone.prototype.localToWorldRotation = function (localRotation) {
+			localRotation -= this.rotation - this.shearX;
 			var sin = spine.MathUtils.sinDeg(localRotation), cos = spine.MathUtils.cosDeg(localRotation);
 			return Math.atan2(cos * this.c + sin * this.d, cos * this.a + sin * this.b) * spine.MathUtils.radDeg;
 		};

Разлика између датотеке није приказан због своје велике величине
+ 0 - 0
spine-ts/build/spine-all.js.map


+ 2 - 1
spine-ts/build/spine-canvas.js

@@ -2576,9 +2576,10 @@ var spine;
 		};
 		Bone.prototype.worldToLocalRotation = function (worldRotation) {
 			var sin = spine.MathUtils.sinDeg(worldRotation), cos = spine.MathUtils.cosDeg(worldRotation);
-			return Math.atan2(this.a * sin - this.c * cos, this.d * cos - this.b * sin) * spine.MathUtils.radDeg;
+			return Math.atan2(this.a * sin - this.c * cos, this.d * cos - this.b * sin) * spine.MathUtils.radDeg + this.rotation - this.shearX;
 		};
 		Bone.prototype.localToWorldRotation = function (localRotation) {
+			localRotation -= this.rotation - this.shearX;
 			var sin = spine.MathUtils.sinDeg(localRotation), cos = spine.MathUtils.cosDeg(localRotation);
 			return Math.atan2(cos * this.c + sin * this.d, cos * this.a + sin * this.b) * spine.MathUtils.radDeg;
 		};

Разлика између датотеке није приказан због своје велике величине
+ 0 - 0
spine-ts/build/spine-canvas.js.map


+ 2 - 1
spine-ts/build/spine-core.js

@@ -2576,9 +2576,10 @@ var spine;
 		};
 		Bone.prototype.worldToLocalRotation = function (worldRotation) {
 			var sin = spine.MathUtils.sinDeg(worldRotation), cos = spine.MathUtils.cosDeg(worldRotation);
-			return Math.atan2(this.a * sin - this.c * cos, this.d * cos - this.b * sin) * spine.MathUtils.radDeg;
+			return Math.atan2(this.a * sin - this.c * cos, this.d * cos - this.b * sin) * spine.MathUtils.radDeg + this.rotation - this.shearX;
 		};
 		Bone.prototype.localToWorldRotation = function (localRotation) {
+			localRotation -= this.rotation - this.shearX;
 			var sin = spine.MathUtils.sinDeg(localRotation), cos = spine.MathUtils.cosDeg(localRotation);
 			return Math.atan2(cos * this.c + sin * this.d, cos * this.a + sin * this.b) * spine.MathUtils.radDeg;
 		};

Разлика између датотеке није приказан због своје велике величине
+ 0 - 0
spine-ts/build/spine-core.js.map


+ 2 - 1
spine-ts/build/spine-threejs.js

@@ -2576,9 +2576,10 @@ var spine;
 		};
 		Bone.prototype.worldToLocalRotation = function (worldRotation) {
 			var sin = spine.MathUtils.sinDeg(worldRotation), cos = spine.MathUtils.cosDeg(worldRotation);
-			return Math.atan2(this.a * sin - this.c * cos, this.d * cos - this.b * sin) * spine.MathUtils.radDeg;
+			return Math.atan2(this.a * sin - this.c * cos, this.d * cos - this.b * sin) * spine.MathUtils.radDeg + this.rotation - this.shearX;
 		};
 		Bone.prototype.localToWorldRotation = function (localRotation) {
+			localRotation -= this.rotation - this.shearX;
 			var sin = spine.MathUtils.sinDeg(localRotation), cos = spine.MathUtils.cosDeg(localRotation);
 			return Math.atan2(cos * this.c + sin * this.d, cos * this.a + sin * this.b) * spine.MathUtils.radDeg;
 		};

Разлика између датотеке није приказан због своје велике величине
+ 0 - 0
spine-ts/build/spine-threejs.js.map


+ 2 - 1
spine-ts/build/spine-webgl.js

@@ -2576,9 +2576,10 @@ var spine;
 		};
 		Bone.prototype.worldToLocalRotation = function (worldRotation) {
 			var sin = spine.MathUtils.sinDeg(worldRotation), cos = spine.MathUtils.cosDeg(worldRotation);
-			return Math.atan2(this.a * sin - this.c * cos, this.d * cos - this.b * sin) * spine.MathUtils.radDeg;
+			return Math.atan2(this.a * sin - this.c * cos, this.d * cos - this.b * sin) * spine.MathUtils.radDeg + this.rotation - this.shearX;
 		};
 		Bone.prototype.localToWorldRotation = function (localRotation) {
+			localRotation -= this.rotation - this.shearX;
 			var sin = spine.MathUtils.sinDeg(localRotation), cos = spine.MathUtils.cosDeg(localRotation);
 			return Math.atan2(cos * this.c + sin * this.d, cos * this.a + sin * this.b) * spine.MathUtils.radDeg;
 		};

Разлика између датотеке није приказан због своје велике величине
+ 0 - 0
spine-ts/build/spine-webgl.js.map


+ 2 - 1
spine-ts/build/spine-widget.js

@@ -2576,9 +2576,10 @@ var spine;
 		};
 		Bone.prototype.worldToLocalRotation = function (worldRotation) {
 			var sin = spine.MathUtils.sinDeg(worldRotation), cos = spine.MathUtils.cosDeg(worldRotation);
-			return Math.atan2(this.a * sin - this.c * cos, this.d * cos - this.b * sin) * spine.MathUtils.radDeg;
+			return Math.atan2(this.a * sin - this.c * cos, this.d * cos - this.b * sin) * spine.MathUtils.radDeg + this.rotation - this.shearX;
 		};
 		Bone.prototype.localToWorldRotation = function (localRotation) {
+			localRotation -= this.rotation - this.shearX;
 			var sin = spine.MathUtils.sinDeg(localRotation), cos = spine.MathUtils.cosDeg(localRotation);
 			return Math.atan2(cos * this.c + sin * this.d, cos * this.a + sin * this.b) * spine.MathUtils.radDeg;
 		};

Разлика између датотеке није приказан због своје велике величине
+ 0 - 0
spine-ts/build/spine-widget.js.map


+ 2 - 1
spine-ts/core/src/Bone.ts

@@ -260,10 +260,11 @@ module spine {
 
 		worldToLocalRotation (worldRotation: number) {
 			let sin = MathUtils.sinDeg(worldRotation), cos = MathUtils.cosDeg(worldRotation);
-			return Math.atan2(this.a * sin - this.c * cos, this.d * cos - this.b * sin) * MathUtils.radDeg;
+			return Math.atan2(this.a * sin - this.c * cos, this.d * cos - this.b * sin) * MathUtils.radDeg + this.rotation - this.shearX;
 		}
 
 		localToWorldRotation (localRotation: number) {
+			localRotation -= this.rotation - this.shearX;
 			let sin = MathUtils.sinDeg(localRotation), cos = MathUtils.cosDeg(localRotation);
 			return Math.atan2(cos * this.c + sin * this.d, cos * this.a + sin * this.b) * MathUtils.radDeg;
 		}

Неке датотеке нису приказане због велике количине промена