[c][cpp] Allow negative scale and shear mix in transform constraint. See #1227.

This commit is contained in:
badlogic 2018-12-13 17:49:19 +01:00
parent 0062424589
commit 4a5c031540
2 changed files with 8 additions and 8 deletions

View File

@ -205,13 +205,13 @@ void _spTransformConstraint_applyAbsoluteLocal (spTransformConstraint* self) {
}
scaleX = bone->ascaleX, scaleY = bone->ascaleY;
if (scaleMix > 0) {
if (scaleMix != 0) {
if (scaleX > 0.00001) scaleX = (scaleX + (target->ascaleX - scaleX + self->data->offsetScaleX) * scaleMix) / scaleX;
if (scaleY > 0.00001) scaleY = (scaleY + (target->ascaleY - scaleY + self->data->offsetScaleY) * scaleMix) / scaleY;
}
shearY = bone->ashearY;
if (shearMix > 0) {
if (shearMix != 0) {
r = target->ashearY - shearY + self->data->offsetShearY;
r -= (16384 - (int)(16384.499999999996 - r / 360)) * 360;
bone->shearY += r * shearMix;
@ -245,13 +245,13 @@ void _spTransformConstraint_applyRelativeLocal (spTransformConstraint* self) {
scaleX = bone->ascaleX;
scaleY = bone->ascaleY;
if (scaleMix > 0) {
if (scaleMix != 0) {
if (scaleX > 0.00001f) scaleX *= ((target->ascaleX - 1 + self->data->offsetScaleX) * scaleMix) + 1;
if (scaleY > 0.00001f) scaleY *= ((target->ascaleY - 1 + self->data->offsetScaleY) * scaleMix) + 1;
}
shearY = bone->ashearY;
if (shearMix > 0) shearY += (target->ashearY + self->data->offsetShearY) * shearMix;
if (shearMix != 0) shearY += (target->ashearY + self->data->offsetShearY) * shearMix;
spBone_updateWorldTransformWith(bone, x, y, rotation, scaleX, scaleY, bone->ashearX, shearY);
}

View File

@ -315,7 +315,7 @@ void TransformConstraint::applyAbsoluteLocal() {
}
float scaleX = bone._ascaleX, scaleY = bone._ascaleY;
if (scaleMix > 0) {
if (scaleMix != 0) {
if (scaleX > 0.00001f) {
scaleX = (scaleX + (target._ascaleX - scaleX + _data._offsetScaleX) * scaleMix) / scaleX;
}
@ -326,7 +326,7 @@ void TransformConstraint::applyAbsoluteLocal() {
}
float shearY = bone._ashearY;
if (shearMix > 0) {
if (shearMix != 0) {
float r = target._ashearY - shearY + _data._offsetShearY;
r -= (16384 - (int) (16384.499999999996 - r / 360)) * 360;
bone._shearY += r * shearMix;
@ -363,7 +363,7 @@ void TransformConstraint::applyRelativeLocal() {
}
float scaleX = bone._ascaleX, scaleY = bone._ascaleY;
if (scaleMix > 0) {
if (scaleMix != 0) {
if (scaleX > 0.00001f) {
scaleX *= ((target._ascaleX - 1 + _data._offsetScaleX) * scaleMix) + 1;
}
@ -374,7 +374,7 @@ void TransformConstraint::applyRelativeLocal() {
}
float shearY = bone._ashearY;
if (shearMix > 0) {
if (shearMix != 0) {
shearY += (target._ashearY + _data._offsetShearY) * shearMix;
}