[ts] Fixed Path/TransformConstraint handling of reflection

This commit is contained in:
badlogic 2016-11-07 13:54:49 +01:00
parent 5b8a7420ea
commit 231bd26313
14 changed files with 124 additions and 34 deletions

View File

@ -3031,7 +3031,14 @@ var spine;
}
var positions = this.computeWorldPositions(attachment, spacesCount, tangents, data.positionMode == spine.PositionMode.Percent, spacingMode == spine.SpacingMode.Percent);
var boneX = positions[0], boneY = positions[1], offsetRotation = data.offsetRotation;
var tip = rotateMode == spine.RotateMode.Chain && offsetRotation == 0;
var tip = false;
if (offsetRotation == 0)
tip = rotateMode == spine.RotateMode.Chain;
else {
tip = false;
var p = this.target.bone;
offsetRotation *= p.a * p.d - p.b * p.c > 0 ? spine.MathUtils.degRad : -spine.MathUtils.degRad;
}
for (var i = 0, p = 3; i < boneCount; i++, p += 3) {
var bone = bones[i];
bone.worldX += (boneX - bone.worldX) * translateMix;
@ -3055,7 +3062,7 @@ var spine;
r = positions[p + 2];
else
r = Math.atan2(dy, dx);
r -= Math.atan2(c, a) - offsetRotation * spine.MathUtils.degRad;
r -= Math.atan2(c, a);
if (tip) {
cos = Math.cos(r);
sin = Math.sin(r);
@ -3063,6 +3070,9 @@ var spine;
boneX += (length_3 * (cos * a - sin * c) - dx) * rotateMix;
boneY += (length_3 * (sin * a + cos * c) - dy) * rotateMix;
}
else {
r += offsetRotation;
}
if (r > spine.MathUtils.PI)
r -= spine.MathUtils.PI2;
else if (r < -spine.MathUtils.PI)
@ -5155,13 +5165,16 @@ var spine;
var rotateMix = this.rotateMix, translateMix = this.translateMix, scaleMix = this.scaleMix, shearMix = this.shearMix;
var target = this.target;
var ta = target.a, tb = target.b, tc = target.c, td = target.d;
var degRadReflect = ta * td - tb * tc > 0 ? spine.MathUtils.degRad : -spine.MathUtils.degRad;
var offsetRotation = this.data.offsetRotation * degRadReflect;
var offsetShearY = this.data.offsetShearY * degRadReflect;
var bones = this.bones;
for (var i = 0, n = bones.length; i < n; i++) {
var bone = bones[i];
var modified = false;
if (rotateMix != 0) {
var a = bone.a, b = bone.b, c = bone.c, d = bone.d;
var r = Math.atan2(tc, ta) - Math.atan2(c, a) + this.data.offsetRotation * spine.MathUtils.degRad;
var r = Math.atan2(tc, ta) - Math.atan2(c, a) + offsetRotation;
if (r > spine.MathUtils.PI)
r -= spine.MathUtils.PI2;
else if (r < -spine.MathUtils.PI)
@ -5204,7 +5217,7 @@ var spine;
r -= spine.MathUtils.PI2;
else if (r < -spine.MathUtils.PI)
r += spine.MathUtils.PI2;
r = by + (r + this.data.offsetShearY * spine.MathUtils.degRad) * shearMix;
r = by + (r + offsetShearY) * shearMix;
var s = Math.sqrt(b * b + d * d);
bone.b = Math.cos(r) * s;
bone.d = Math.sin(r) * s;

File diff suppressed because one or more lines are too long

View File

@ -3031,7 +3031,14 @@ var spine;
}
var positions = this.computeWorldPositions(attachment, spacesCount, tangents, data.positionMode == spine.PositionMode.Percent, spacingMode == spine.SpacingMode.Percent);
var boneX = positions[0], boneY = positions[1], offsetRotation = data.offsetRotation;
var tip = rotateMode == spine.RotateMode.Chain && offsetRotation == 0;
var tip = false;
if (offsetRotation == 0)
tip = rotateMode == spine.RotateMode.Chain;
else {
tip = false;
var p = this.target.bone;
offsetRotation *= p.a * p.d - p.b * p.c > 0 ? spine.MathUtils.degRad : -spine.MathUtils.degRad;
}
for (var i = 0, p = 3; i < boneCount; i++, p += 3) {
var bone = bones[i];
bone.worldX += (boneX - bone.worldX) * translateMix;
@ -3055,7 +3062,7 @@ var spine;
r = positions[p + 2];
else
r = Math.atan2(dy, dx);
r -= Math.atan2(c, a) - offsetRotation * spine.MathUtils.degRad;
r -= Math.atan2(c, a);
if (tip) {
cos = Math.cos(r);
sin = Math.sin(r);
@ -3063,6 +3070,9 @@ var spine;
boneX += (length_3 * (cos * a - sin * c) - dx) * rotateMix;
boneY += (length_3 * (sin * a + cos * c) - dy) * rotateMix;
}
else {
r += offsetRotation;
}
if (r > spine.MathUtils.PI)
r -= spine.MathUtils.PI2;
else if (r < -spine.MathUtils.PI)
@ -5155,13 +5165,16 @@ var spine;
var rotateMix = this.rotateMix, translateMix = this.translateMix, scaleMix = this.scaleMix, shearMix = this.shearMix;
var target = this.target;
var ta = target.a, tb = target.b, tc = target.c, td = target.d;
var degRadReflect = ta * td - tb * tc > 0 ? spine.MathUtils.degRad : -spine.MathUtils.degRad;
var offsetRotation = this.data.offsetRotation * degRadReflect;
var offsetShearY = this.data.offsetShearY * degRadReflect;
var bones = this.bones;
for (var i = 0, n = bones.length; i < n; i++) {
var bone = bones[i];
var modified = false;
if (rotateMix != 0) {
var a = bone.a, b = bone.b, c = bone.c, d = bone.d;
var r = Math.atan2(tc, ta) - Math.atan2(c, a) + this.data.offsetRotation * spine.MathUtils.degRad;
var r = Math.atan2(tc, ta) - Math.atan2(c, a) + offsetRotation;
if (r > spine.MathUtils.PI)
r -= spine.MathUtils.PI2;
else if (r < -spine.MathUtils.PI)
@ -5204,7 +5217,7 @@ var spine;
r -= spine.MathUtils.PI2;
else if (r < -spine.MathUtils.PI)
r += spine.MathUtils.PI2;
r = by + (r + this.data.offsetShearY * spine.MathUtils.degRad) * shearMix;
r = by + (r + offsetShearY) * shearMix;
var s = Math.sqrt(b * b + d * d);
bone.b = Math.cos(r) * s;
bone.d = Math.sin(r) * s;

File diff suppressed because one or more lines are too long

View File

@ -2788,7 +2788,14 @@ var spine;
}
var positions = this.computeWorldPositions(attachment, spacesCount, tangents, data.positionMode == spine.PositionMode.Percent, spacingMode == spine.SpacingMode.Percent);
var boneX = positions[0], boneY = positions[1], offsetRotation = data.offsetRotation;
var tip = rotateMode == spine.RotateMode.Chain && offsetRotation == 0;
var tip = false;
if (offsetRotation == 0)
tip = rotateMode == spine.RotateMode.Chain;
else {
tip = false;
var p = this.target.bone;
offsetRotation *= p.a * p.d - p.b * p.c > 0 ? spine.MathUtils.degRad : -spine.MathUtils.degRad;
}
for (var i = 0, p = 3; i < boneCount; i++, p += 3) {
var bone = bones[i];
bone.worldX += (boneX - bone.worldX) * translateMix;
@ -2812,7 +2819,7 @@ var spine;
r = positions[p + 2];
else
r = Math.atan2(dy, dx);
r -= Math.atan2(c, a) - offsetRotation * spine.MathUtils.degRad;
r -= Math.atan2(c, a);
if (tip) {
cos = Math.cos(r);
sin = Math.sin(r);
@ -2820,6 +2827,9 @@ var spine;
boneX += (length_3 * (cos * a - sin * c) - dx) * rotateMix;
boneY += (length_3 * (sin * a + cos * c) - dy) * rotateMix;
}
else {
r += offsetRotation;
}
if (r > spine.MathUtils.PI)
r -= spine.MathUtils.PI2;
else if (r < -spine.MathUtils.PI)
@ -4978,13 +4988,16 @@ var spine;
var rotateMix = this.rotateMix, translateMix = this.translateMix, scaleMix = this.scaleMix, shearMix = this.shearMix;
var target = this.target;
var ta = target.a, tb = target.b, tc = target.c, td = target.d;
var degRadReflect = ta * td - tb * tc > 0 ? spine.MathUtils.degRad : -spine.MathUtils.degRad;
var offsetRotation = this.data.offsetRotation * degRadReflect;
var offsetShearY = this.data.offsetShearY * degRadReflect;
var bones = this.bones;
for (var i = 0, n = bones.length; i < n; i++) {
var bone = bones[i];
var modified = false;
if (rotateMix != 0) {
var a = bone.a, b = bone.b, c = bone.c, d = bone.d;
var r = Math.atan2(tc, ta) - Math.atan2(c, a) + this.data.offsetRotation * spine.MathUtils.degRad;
var r = Math.atan2(tc, ta) - Math.atan2(c, a) + offsetRotation;
if (r > spine.MathUtils.PI)
r -= spine.MathUtils.PI2;
else if (r < -spine.MathUtils.PI)
@ -5027,7 +5040,7 @@ var spine;
r -= spine.MathUtils.PI2;
else if (r < -spine.MathUtils.PI)
r += spine.MathUtils.PI2;
r = by + (r + this.data.offsetShearY * spine.MathUtils.degRad) * shearMix;
r = by + (r + offsetShearY) * shearMix;
var s = Math.sqrt(b * b + d * d);
bone.b = Math.cos(r) * s;
bone.d = Math.sin(r) * s;

File diff suppressed because one or more lines are too long

View File

@ -2788,7 +2788,14 @@ var spine;
}
var positions = this.computeWorldPositions(attachment, spacesCount, tangents, data.positionMode == spine.PositionMode.Percent, spacingMode == spine.SpacingMode.Percent);
var boneX = positions[0], boneY = positions[1], offsetRotation = data.offsetRotation;
var tip = rotateMode == spine.RotateMode.Chain && offsetRotation == 0;
var tip = false;
if (offsetRotation == 0)
tip = rotateMode == spine.RotateMode.Chain;
else {
tip = false;
var p = this.target.bone;
offsetRotation *= p.a * p.d - p.b * p.c > 0 ? spine.MathUtils.degRad : -spine.MathUtils.degRad;
}
for (var i = 0, p = 3; i < boneCount; i++, p += 3) {
var bone = bones[i];
bone.worldX += (boneX - bone.worldX) * translateMix;
@ -2812,7 +2819,7 @@ var spine;
r = positions[p + 2];
else
r = Math.atan2(dy, dx);
r -= Math.atan2(c, a) - offsetRotation * spine.MathUtils.degRad;
r -= Math.atan2(c, a);
if (tip) {
cos = Math.cos(r);
sin = Math.sin(r);
@ -2820,6 +2827,9 @@ var spine;
boneX += (length_3 * (cos * a - sin * c) - dx) * rotateMix;
boneY += (length_3 * (sin * a + cos * c) - dy) * rotateMix;
}
else {
r += offsetRotation;
}
if (r > spine.MathUtils.PI)
r -= spine.MathUtils.PI2;
else if (r < -spine.MathUtils.PI)
@ -4978,13 +4988,16 @@ var spine;
var rotateMix = this.rotateMix, translateMix = this.translateMix, scaleMix = this.scaleMix, shearMix = this.shearMix;
var target = this.target;
var ta = target.a, tb = target.b, tc = target.c, td = target.d;
var degRadReflect = ta * td - tb * tc > 0 ? spine.MathUtils.degRad : -spine.MathUtils.degRad;
var offsetRotation = this.data.offsetRotation * degRadReflect;
var offsetShearY = this.data.offsetShearY * degRadReflect;
var bones = this.bones;
for (var i = 0, n = bones.length; i < n; i++) {
var bone = bones[i];
var modified = false;
if (rotateMix != 0) {
var a = bone.a, b = bone.b, c = bone.c, d = bone.d;
var r = Math.atan2(tc, ta) - Math.atan2(c, a) + this.data.offsetRotation * spine.MathUtils.degRad;
var r = Math.atan2(tc, ta) - Math.atan2(c, a) + offsetRotation;
if (r > spine.MathUtils.PI)
r -= spine.MathUtils.PI2;
else if (r < -spine.MathUtils.PI)
@ -5027,7 +5040,7 @@ var spine;
r -= spine.MathUtils.PI2;
else if (r < -spine.MathUtils.PI)
r += spine.MathUtils.PI2;
r = by + (r + this.data.offsetShearY * spine.MathUtils.degRad) * shearMix;
r = by + (r + offsetShearY) * shearMix;
var s = Math.sqrt(b * b + d * d);
bone.b = Math.cos(r) * s;
bone.d = Math.sin(r) * s;

File diff suppressed because one or more lines are too long

View File

@ -2788,7 +2788,14 @@ var spine;
}
var positions = this.computeWorldPositions(attachment, spacesCount, tangents, data.positionMode == spine.PositionMode.Percent, spacingMode == spine.SpacingMode.Percent);
var boneX = positions[0], boneY = positions[1], offsetRotation = data.offsetRotation;
var tip = rotateMode == spine.RotateMode.Chain && offsetRotation == 0;
var tip = false;
if (offsetRotation == 0)
tip = rotateMode == spine.RotateMode.Chain;
else {
tip = false;
var p = this.target.bone;
offsetRotation *= p.a * p.d - p.b * p.c > 0 ? spine.MathUtils.degRad : -spine.MathUtils.degRad;
}
for (var i = 0, p = 3; i < boneCount; i++, p += 3) {
var bone = bones[i];
bone.worldX += (boneX - bone.worldX) * translateMix;
@ -2812,7 +2819,7 @@ var spine;
r = positions[p + 2];
else
r = Math.atan2(dy, dx);
r -= Math.atan2(c, a) - offsetRotation * spine.MathUtils.degRad;
r -= Math.atan2(c, a);
if (tip) {
cos = Math.cos(r);
sin = Math.sin(r);
@ -2820,6 +2827,9 @@ var spine;
boneX += (length_3 * (cos * a - sin * c) - dx) * rotateMix;
boneY += (length_3 * (sin * a + cos * c) - dy) * rotateMix;
}
else {
r += offsetRotation;
}
if (r > spine.MathUtils.PI)
r -= spine.MathUtils.PI2;
else if (r < -spine.MathUtils.PI)
@ -4978,13 +4988,16 @@ var spine;
var rotateMix = this.rotateMix, translateMix = this.translateMix, scaleMix = this.scaleMix, shearMix = this.shearMix;
var target = this.target;
var ta = target.a, tb = target.b, tc = target.c, td = target.d;
var degRadReflect = ta * td - tb * tc > 0 ? spine.MathUtils.degRad : -spine.MathUtils.degRad;
var offsetRotation = this.data.offsetRotation * degRadReflect;
var offsetShearY = this.data.offsetShearY * degRadReflect;
var bones = this.bones;
for (var i = 0, n = bones.length; i < n; i++) {
var bone = bones[i];
var modified = false;
if (rotateMix != 0) {
var a = bone.a, b = bone.b, c = bone.c, d = bone.d;
var r = Math.atan2(tc, ta) - Math.atan2(c, a) + this.data.offsetRotation * spine.MathUtils.degRad;
var r = Math.atan2(tc, ta) - Math.atan2(c, a) + offsetRotation;
if (r > spine.MathUtils.PI)
r -= spine.MathUtils.PI2;
else if (r < -spine.MathUtils.PI)
@ -5027,7 +5040,7 @@ var spine;
r -= spine.MathUtils.PI2;
else if (r < -spine.MathUtils.PI)
r += spine.MathUtils.PI2;
r = by + (r + this.data.offsetShearY * spine.MathUtils.degRad) * shearMix;
r = by + (r + offsetShearY) * shearMix;
var s = Math.sqrt(b * b + d * d);
bone.b = Math.cos(r) * s;
bone.d = Math.sin(r) * s;

File diff suppressed because one or more lines are too long

View File

@ -2788,7 +2788,14 @@ var spine;
}
var positions = this.computeWorldPositions(attachment, spacesCount, tangents, data.positionMode == spine.PositionMode.Percent, spacingMode == spine.SpacingMode.Percent);
var boneX = positions[0], boneY = positions[1], offsetRotation = data.offsetRotation;
var tip = rotateMode == spine.RotateMode.Chain && offsetRotation == 0;
var tip = false;
if (offsetRotation == 0)
tip = rotateMode == spine.RotateMode.Chain;
else {
tip = false;
var p = this.target.bone;
offsetRotation *= p.a * p.d - p.b * p.c > 0 ? spine.MathUtils.degRad : -spine.MathUtils.degRad;
}
for (var i = 0, p = 3; i < boneCount; i++, p += 3) {
var bone = bones[i];
bone.worldX += (boneX - bone.worldX) * translateMix;
@ -2812,7 +2819,7 @@ var spine;
r = positions[p + 2];
else
r = Math.atan2(dy, dx);
r -= Math.atan2(c, a) - offsetRotation * spine.MathUtils.degRad;
r -= Math.atan2(c, a);
if (tip) {
cos = Math.cos(r);
sin = Math.sin(r);
@ -2820,6 +2827,9 @@ var spine;
boneX += (length_3 * (cos * a - sin * c) - dx) * rotateMix;
boneY += (length_3 * (sin * a + cos * c) - dy) * rotateMix;
}
else {
r += offsetRotation;
}
if (r > spine.MathUtils.PI)
r -= spine.MathUtils.PI2;
else if (r < -spine.MathUtils.PI)
@ -4978,13 +4988,16 @@ var spine;
var rotateMix = this.rotateMix, translateMix = this.translateMix, scaleMix = this.scaleMix, shearMix = this.shearMix;
var target = this.target;
var ta = target.a, tb = target.b, tc = target.c, td = target.d;
var degRadReflect = ta * td - tb * tc > 0 ? spine.MathUtils.degRad : -spine.MathUtils.degRad;
var offsetRotation = this.data.offsetRotation * degRadReflect;
var offsetShearY = this.data.offsetShearY * degRadReflect;
var bones = this.bones;
for (var i = 0, n = bones.length; i < n; i++) {
var bone = bones[i];
var modified = false;
if (rotateMix != 0) {
var a = bone.a, b = bone.b, c = bone.c, d = bone.d;
var r = Math.atan2(tc, ta) - Math.atan2(c, a) + this.data.offsetRotation * spine.MathUtils.degRad;
var r = Math.atan2(tc, ta) - Math.atan2(c, a) + offsetRotation;
if (r > spine.MathUtils.PI)
r -= spine.MathUtils.PI2;
else if (r < -spine.MathUtils.PI)
@ -5027,7 +5040,7 @@ var spine;
r -= spine.MathUtils.PI2;
else if (r < -spine.MathUtils.PI)
r += spine.MathUtils.PI2;
r = by + (r + this.data.offsetShearY * spine.MathUtils.degRad) * shearMix;
r = by + (r + offsetShearY) * shearMix;
var s = Math.sqrt(b * b + d * d);
bone.b = Math.cos(r) * s;
bone.d = Math.sin(r) * s;

File diff suppressed because one or more lines are too long

View File

@ -93,7 +93,14 @@ module spine {
let positions = this.computeWorldPositions(<PathAttachment>attachment, spacesCount, tangents,
data.positionMode == PositionMode.Percent, spacingMode == SpacingMode.Percent);
let boneX = positions[0], boneY = positions[1], offsetRotation = data.offsetRotation;
let tip = rotateMode == RotateMode.Chain && offsetRotation == 0;
let tip = false;
if (offsetRotation == 0)
tip = rotateMode == RotateMode.Chain;
else {
tip = false;
let p = this.target.bone;
offsetRotation *= p.a * p.d - p.b * p.c > 0 ? MathUtils.degRad : -MathUtils.degRad;
}
for (let i = 0, p = 3; i < boneCount; i++, p += 3) {
let bone = bones[i];
bone.worldX += (boneX - bone.worldX) * translateMix;
@ -117,13 +124,15 @@ module spine {
r = positions[p + 2];
else
r = Math.atan2(dy, dx);
r -= Math.atan2(c, a) - offsetRotation * MathUtils.degRad;
r -= Math.atan2(c, a);
if (tip) {
cos = Math.cos(r);
sin = Math.sin(r);
let length = bone.data.length;
boneX += (length * (cos * a - sin * c) - dx) * rotateMix;
boneY += (length * (sin * a + cos * c) - dy) * rotateMix;
} else {
r += offsetRotation;
}
if (r > MathUtils.PI)
r -= MathUtils.PI2;

View File

@ -58,6 +58,9 @@ module spine {
let rotateMix = this.rotateMix, translateMix = this.translateMix, scaleMix = this.scaleMix, shearMix = this.shearMix;
let target = this.target;
let ta = target.a, tb = target.b, tc = target.c, td = target.d;
let degRadReflect = ta * td - tb * tc > 0 ? MathUtils.degRad : -MathUtils.degRad;
let offsetRotation = this.data.offsetRotation * degRadReflect;
let offsetShearY = this.data.offsetShearY * degRadReflect;
let bones = this.bones;
for (let i = 0, n = bones.length; i < n; i++) {
let bone = bones[i];
@ -65,7 +68,7 @@ module spine {
if (rotateMix != 0) {
let a = bone.a, b = bone.b, c = bone.c, d = bone.d;
let r = Math.atan2(tc, ta) - Math.atan2(c, a) + this.data.offsetRotation * MathUtils.degRad;
let r = Math.atan2(tc, ta) - Math.atan2(c, a) + offsetRotation;
if (r > MathUtils.PI)
r -= MathUtils.PI2;
else if (r < -MathUtils.PI)
@ -109,7 +112,7 @@ module spine {
r -= MathUtils.PI2;
else if (r < -MathUtils.PI)
r += MathUtils.PI2;
r = by + (r + this.data.offsetShearY * MathUtils.degRad) * shearMix;
r = by + (r + offsetShearY) * shearMix;
let s = Math.sqrt(b * b + d * d);
bone.b = Math.cos(r) * s;
bone.d = Math.sin(r) * s;