Jelajahi Sumber

[c][cpp] Closes #1742, incorrect rotation value applied for 2 bone IK.

badlogic 5 tahun lalu
induk
melakukan
b4548b9166

+ 1 - 1
spine-c/spine-c/src/spine/IkConstraint.c

@@ -267,7 +267,7 @@ void spIkConstraint_apply2 (spBone* parent, spBone* child, float targetX, float
 		a1 = (a1 - os) * RAD_DEG + o1 - parent->arotation;
 		if (a1 > 180) a1 -= 360;
 		else if (a1 < -180) a1 += 360;
-		spBone_updateWorldTransformWith(parent, px, py, parent->rotation + a1 * alpha, sx, parent->ascaleY, 0, 0);
+		spBone_updateWorldTransformWith(parent, px, py, parent->arotation + a1 * alpha, sx, parent->ascaleY, 0, 0);
 		a2 = ((a2 + os) * RAD_DEG - child->ashearX) * s2 + o2 - child->arotation;
 		if (a2 > 180) a2 -= 360;
 		else if (a2 < -180) a2 += 360;

+ 1 - 1
spine-cpp/spine-cpp/src/spine/IkConstraint.cpp

@@ -242,7 +242,7 @@ void IkConstraint::apply(Bone &parent, Bone &child, float targetX, float targetY
 		a1 = (a1 - os) * MathUtil::Rad_Deg + o1 - parent._arotation;
 		if (a1 > 180) a1 -= 360;
 		else if (a1 < -180) a1 += 360;
-		parent.updateWorldTransform(px, py, parent._rotation + a1 * alpha, sx, parent._ascaleY, 0, 0);
+		parent.updateWorldTransform(px, py, parent._arotation + a1 * alpha, sx, parent._ascaleY, 0, 0);
 		a2 = ((a2 + os) * MathUtil::Rad_Deg - child._ashearX) * s2 + o2 - child._arotation;
 		if (a2 > 180) a2 -= 360;
 		else if (a2 < -180) a2 += 360;

+ 2 - 2
spine-sfml/cpp/example/main.cpp

@@ -37,7 +37,7 @@ using namespace spine;
 #include <memory>
 
 template<typename T, typename... Args>
-unique_ptr<T> make_unique(Args&&... args) {
+unique_ptr<T> make_unique_test(Args&&... args) {
 	return unique_ptr<T>(new T(forward<Args>(args)...));
 }
 
@@ -95,7 +95,7 @@ void testcase (void func(SkeletonData* skeletonData, Atlas* atlas),
 			   const char* jsonName, const char* binaryName, const char* atlasName,
 			   float scale) {
 	SFMLTextureLoader textureLoader;
-	auto atlas = make_unique<Atlas>(atlasName, &textureLoader);
+	auto atlas = make_unique_test<Atlas>(atlasName, &textureLoader);
 
 	auto skeletonData = readSkeletonJsonData(jsonName, atlas.get(), scale);
 	func(skeletonData.get(), atlas.get());