浏览代码

[c][cpp] Fix for #2412

Mario Zechner 1 年之前
父节点
当前提交
501ad3553d
共有 2 个文件被更改,包括 4 次插入4 次删除
  1. 2 2
      spine-c/spine-c/src/spine/IkConstraint.c
  2. 2 2
      spine-cpp/spine-cpp/src/spine/IkConstraint.cpp

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

@@ -80,8 +80,8 @@ void spIkConstraint_apply1(spBone *bone, float targetX, float targetY, int /*boo
 
 	switch (bone->data->transformMode) {
 		case SP_TRANSFORMMODE_ONLYTRANSLATION:
-			tx = targetX - bone->worldX;
-			ty = targetY - bone->worldY;
+			tx = (targetX - bone->worldX) * SIGNUM(bone->skeleton->scaleX);
+			ty = (targetY - bone->worldY) * SIGNUM(bone->skeleton->scaleY);
 			break;
 		case SP_TRANSFORMMODE_NOROTATIONORREFLECTION: {
 			s = ABS(pa * pd - pb * pc) / MAX(0.0001f, pa * pa + pc * pc);

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

@@ -47,8 +47,8 @@ void IkConstraint::apply(Bone &bone, float targetX, float targetY, bool compress
 
 	switch (bone._data.getTransformMode()) {
 		case TransformMode_OnlyTranslation:
-			tx = targetX - bone._worldX;
-			ty = targetY - bone._worldY;
+			tx = (targetX - bone._worldX) * MathUtil::sign(bone.getSkeleton().getScaleX());
+			ty = (targetY - bone._worldY) * MathUtil::sign(bone.getSkeleton().getScaleY());
 			break;
 		case TransformMode_NoRotationOrReflection: {
 			float s = MathUtil::abs(pa * pd - pb * pc) / MathUtil::max(0.0001f, pa * pa + pc * pc);