diff --git a/spine-c/src/spine/PathConstraint.c b/spine-c/src/spine/PathConstraint.c index 1a2f0eda6..825f8c713 100644 --- a/spine-c/src/spine/PathConstraint.c +++ b/spine-c/src/spine/PathConstraint.c @@ -89,6 +89,7 @@ void spPathConstraint_apply (spPathConstraint* self) { int tangents = rotateMode == SP_ROTATE_MODE_TANGENT, scale = rotateMode == SP_ROTATE_MODE_CHAIN_SCALE; int boneCount = self->bonesCount, spacesCount = tangents ? boneCount : boneCount + 1; spBone** bones = self->bones; + spBone* pa; if (!translate && !rotate) return; if ((attachment == 0) || (attachment->super.super.type != SP_ATTACHMENT_PATH)) return; @@ -127,7 +128,14 @@ void spPathConstraint_apply (spPathConstraint* self) { positions = spPathConstraint_computeWorldPositions(self, attachment, spacesCount, tangents, data->positionMode == SP_POSITION_MODE_PERCENT, spacingMode == SP_SPACING_MODE_PERCENT); boneX = positions[0], boneY = positions[1], offsetRotation = self->data->offsetRotation; - tip = rotateMode == SP_ROTATE_MODE_CHAIN_SCALE && offsetRotation == 0; + tip = 0; + if (offsetRotation == 0) + tip = rotateMode == SP_ROTATE_MODE_CHAIN; + else { + tip = 0; + pa = self->target->bone; + offsetRotation *= pa->a * pa->d - pa->b * pa->c > 0 ? DEG_RAD : -DEG_RAD; + } for (i = 0, p = 3; i < boneCount; i++, p += 3) { spBone* bone = bones[i]; CONST_CAST(float, bone->worldX) += (boneX - bone->worldX) * translateMix; @@ -158,7 +166,8 @@ void spPathConstraint_apply (spPathConstraint* self) { length = bone->data->length; boneX += (length * (cosine * a - sine * c) - dx) * rotateMix; boneY += (length * (sine * a + cosine * c) - dy) * rotateMix; - } + } else + r += offsetRotation; if (r > PI) r -= PI2; else if (r < -PI) diff --git a/spine-c/src/spine/TransformConstraint.c b/spine-c/src/spine/TransformConstraint.c index d16d3b18e..528cc6a8a 100644 --- a/spine-c/src/spine/TransformConstraint.c +++ b/spine-c/src/spine/TransformConstraint.c @@ -57,6 +57,8 @@ void spTransformConstraint_apply (spTransformConstraint* self) { float rotateMix = self->rotateMix, translateMix = self->translateMix, scaleMix = self->scaleMix, shearMix = self->shearMix; spBone* target = self->target; float ta = target->a, tb = target->b, tc = target->c, td = target->d; + float degRadReflect = ta * td - tb * tc > 0 ? DEG_RAD : -DEG_RAD; + float offsetRotation = self->data->offsetRotation * degRadReflect, offsetShearY = self->data->offsetShearY * degRadReflect; int /*bool*/ modified; int i; for (i = 0; i < self->bonesCount; ++i) { @@ -65,7 +67,7 @@ void spTransformConstraint_apply (spTransformConstraint* self) { if (rotateMix != 0) { float a = bone->a, b = bone->b, c = bone->c, d = bone->d; - float r = ATAN2(tc, ta) - ATAN2(c, a) + self->data->offsetRotation * DEG_RAD; + float r = ATAN2(tc, ta) - ATAN2(c, a) + offsetRotation; float cosine, sine; if (r > PI) r -= PI2; else if (r < -PI) r += PI2; @@ -108,7 +110,7 @@ void spTransformConstraint_apply (spTransformConstraint* self) { float s = SQRT(b * b + d * d); if (r > PI) r -= PI2; else if (r < -PI) r += PI2; - r = by + (r + self->data->offsetShearY * DEG_RAD) * shearMix; + r = by + (r + offsetShearY) * shearMix; CONST_CAST(float, bone->b) = COS(r) * s; CONST_CAST(float, bone->d) = SIN(r) * s; modified = 1;