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

This commit is contained in:
badlogic 2020-08-26 16:06:41 +02:00
parent e31b7d581f
commit b4548b9166
3 changed files with 4 additions and 4 deletions

View File

@ -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;

View File

@ -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;

View File

@ -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());