[ts] Fix PathConstraint length spacing for zero length bones. See #1023.

This commit is contained in:
badlogic 2017-10-20 11:09:42 +02:00
parent bdb97a023f
commit bcc7da56d2
19 changed files with 100 additions and 53 deletions

View File

@ -752,6 +752,7 @@ declare module spine {
static NONE: number;
static BEFORE: number;
static AFTER: number;
static epsilon: number;
data: PathConstraintData;
bones: Array<Bone>;
target: Slot;

View File

@ -3290,13 +3290,18 @@ var spine;
for (var i = 0, n = spacesCount - 1; i < n;) {
var bone = bones[i];
var setupLength = bone.data.length;
if (setupLength == 0)
setupLength = 0.0000001;
var x = setupLength * bone.a, y = setupLength * bone.c;
var length_1 = Math.sqrt(x * x + y * y);
if (scale)
lengths[i] = length_1;
spaces[++i] = (lengthSpacing ? setupLength + spacing : spacing) * length_1 / setupLength;
if (setupLength < PathConstraint.epsilon) {
if (scale)
lengths[i] = 0;
spaces[++i] = 0;
}
else {
var x = setupLength * bone.a, y = setupLength * bone.c;
var length_1 = Math.sqrt(x * x + y * y);
if (scale)
lengths[i] = length_1;
spaces[++i] = (lengthSpacing ? setupLength + spacing : spacing) * length_1 / setupLength;
}
}
}
else {
@ -3602,6 +3607,7 @@ var spine;
PathConstraint.NONE = -1;
PathConstraint.BEFORE = -2;
PathConstraint.AFTER = -3;
PathConstraint.epsilon = 0.00001;
return PathConstraint;
}());
spine.PathConstraint = PathConstraint;

File diff suppressed because one or more lines are too long

View File

@ -752,6 +752,7 @@ declare module spine {
static NONE: number;
static BEFORE: number;
static AFTER: number;
static epsilon: number;
data: PathConstraintData;
bones: Array<Bone>;
target: Slot;

View File

@ -3290,13 +3290,18 @@ var spine;
for (var i = 0, n = spacesCount - 1; i < n;) {
var bone = bones[i];
var setupLength = bone.data.length;
if (setupLength == 0)
setupLength = 0.0000001;
var x = setupLength * bone.a, y = setupLength * bone.c;
var length_1 = Math.sqrt(x * x + y * y);
if (scale)
lengths[i] = length_1;
spaces[++i] = (lengthSpacing ? setupLength + spacing : spacing) * length_1 / setupLength;
if (setupLength < PathConstraint.epsilon) {
if (scale)
lengths[i] = 0;
spaces[++i] = 0;
}
else {
var x = setupLength * bone.a, y = setupLength * bone.c;
var length_1 = Math.sqrt(x * x + y * y);
if (scale)
lengths[i] = length_1;
spaces[++i] = (lengthSpacing ? setupLength + spacing : spacing) * length_1 / setupLength;
}
}
}
else {
@ -3602,6 +3607,7 @@ var spine;
PathConstraint.NONE = -1;
PathConstraint.BEFORE = -2;
PathConstraint.AFTER = -3;
PathConstraint.epsilon = 0.00001;
return PathConstraint;
}());
spine.PathConstraint = PathConstraint;

File diff suppressed because one or more lines are too long

View File

@ -681,6 +681,7 @@ declare module spine {
static NONE: number;
static BEFORE: number;
static AFTER: number;
static epsilon: number;
data: PathConstraintData;
bones: Array<Bone>;
target: Slot;

View File

@ -2969,13 +2969,18 @@ var spine;
for (var i = 0, n = spacesCount - 1; i < n;) {
var bone = bones[i];
var setupLength = bone.data.length;
if (setupLength == 0)
setupLength = 0.0000001;
var x = setupLength * bone.a, y = setupLength * bone.c;
var length_1 = Math.sqrt(x * x + y * y);
if (scale)
lengths[i] = length_1;
spaces[++i] = (lengthSpacing ? setupLength + spacing : spacing) * length_1 / setupLength;
if (setupLength < PathConstraint.epsilon) {
if (scale)
lengths[i] = 0;
spaces[++i] = 0;
}
else {
var x = setupLength * bone.a, y = setupLength * bone.c;
var length_1 = Math.sqrt(x * x + y * y);
if (scale)
lengths[i] = length_1;
spaces[++i] = (lengthSpacing ? setupLength + spacing : spacing) * length_1 / setupLength;
}
}
}
else {
@ -3281,6 +3286,7 @@ var spine;
PathConstraint.NONE = -1;
PathConstraint.BEFORE = -2;
PathConstraint.AFTER = -3;
PathConstraint.epsilon = 0.00001;
return PathConstraint;
}());
spine.PathConstraint = PathConstraint;

File diff suppressed because one or more lines are too long

View File

@ -681,6 +681,7 @@ declare module spine {
static NONE: number;
static BEFORE: number;
static AFTER: number;
static epsilon: number;
data: PathConstraintData;
bones: Array<Bone>;
target: Slot;

View File

@ -2969,13 +2969,18 @@ var spine;
for (var i = 0, n = spacesCount - 1; i < n;) {
var bone = bones[i];
var setupLength = bone.data.length;
if (setupLength == 0)
setupLength = 0.0000001;
var x = setupLength * bone.a, y = setupLength * bone.c;
var length_1 = Math.sqrt(x * x + y * y);
if (scale)
lengths[i] = length_1;
spaces[++i] = (lengthSpacing ? setupLength + spacing : spacing) * length_1 / setupLength;
if (setupLength < PathConstraint.epsilon) {
if (scale)
lengths[i] = 0;
spaces[++i] = 0;
}
else {
var x = setupLength * bone.a, y = setupLength * bone.c;
var length_1 = Math.sqrt(x * x + y * y);
if (scale)
lengths[i] = length_1;
spaces[++i] = (lengthSpacing ? setupLength + spacing : spacing) * length_1 / setupLength;
}
}
}
else {
@ -3281,6 +3286,7 @@ var spine;
PathConstraint.NONE = -1;
PathConstraint.BEFORE = -2;
PathConstraint.AFTER = -3;
PathConstraint.epsilon = 0.00001;
return PathConstraint;
}());
spine.PathConstraint = PathConstraint;

File diff suppressed because one or more lines are too long

View File

@ -681,6 +681,7 @@ declare module spine {
static NONE: number;
static BEFORE: number;
static AFTER: number;
static epsilon: number;
data: PathConstraintData;
bones: Array<Bone>;
target: Slot;

View File

@ -2969,13 +2969,18 @@ var spine;
for (var i = 0, n = spacesCount - 1; i < n;) {
var bone = bones[i];
var setupLength = bone.data.length;
if (setupLength == 0)
setupLength = 0.0000001;
var x = setupLength * bone.a, y = setupLength * bone.c;
var length_1 = Math.sqrt(x * x + y * y);
if (scale)
lengths[i] = length_1;
spaces[++i] = (lengthSpacing ? setupLength + spacing : spacing) * length_1 / setupLength;
if (setupLength < PathConstraint.epsilon) {
if (scale)
lengths[i] = 0;
spaces[++i] = 0;
}
else {
var x = setupLength * bone.a, y = setupLength * bone.c;
var length_1 = Math.sqrt(x * x + y * y);
if (scale)
lengths[i] = length_1;
spaces[++i] = (lengthSpacing ? setupLength + spacing : spacing) * length_1 / setupLength;
}
}
}
else {
@ -3281,6 +3286,7 @@ var spine;
PathConstraint.NONE = -1;
PathConstraint.BEFORE = -2;
PathConstraint.AFTER = -3;
PathConstraint.epsilon = 0.00001;
return PathConstraint;
}());
spine.PathConstraint = PathConstraint;

File diff suppressed because one or more lines are too long

View File

@ -681,6 +681,7 @@ declare module spine {
static NONE: number;
static BEFORE: number;
static AFTER: number;
static epsilon: number;
data: PathConstraintData;
bones: Array<Bone>;
target: Slot;

View File

@ -2969,13 +2969,18 @@ var spine;
for (var i = 0, n = spacesCount - 1; i < n;) {
var bone = bones[i];
var setupLength = bone.data.length;
if (setupLength == 0)
setupLength = 0.0000001;
var x = setupLength * bone.a, y = setupLength * bone.c;
var length_1 = Math.sqrt(x * x + y * y);
if (scale)
lengths[i] = length_1;
spaces[++i] = (lengthSpacing ? setupLength + spacing : spacing) * length_1 / setupLength;
if (setupLength < PathConstraint.epsilon) {
if (scale)
lengths[i] = 0;
spaces[++i] = 0;
}
else {
var x = setupLength * bone.a, y = setupLength * bone.c;
var length_1 = Math.sqrt(x * x + y * y);
if (scale)
lengths[i] = length_1;
spaces[++i] = (lengthSpacing ? setupLength + spacing : spacing) * length_1 / setupLength;
}
}
}
else {
@ -3281,6 +3286,7 @@ var spine;
PathConstraint.NONE = -1;
PathConstraint.BEFORE = -2;
PathConstraint.AFTER = -3;
PathConstraint.epsilon = 0.00001;
return PathConstraint;
}());
spine.PathConstraint = PathConstraint;

File diff suppressed because one or more lines are too long

View File

@ -31,6 +31,7 @@
module spine {
export class PathConstraint implements Constraint {
static NONE = -1; static BEFORE = -2; static AFTER = -3;
static epsilon = 0.00001;
data: PathConstraintData;
bones: Array<Bone>;
@ -81,11 +82,15 @@ module spine {
for (let i = 0, n = spacesCount - 1; i < n;) {
let bone = bones[i];
let setupLength = bone.data.length;
if (setupLength == 0) setupLength = 0.0000001;
let x = setupLength * bone.a, y = setupLength * bone.c;
let length = Math.sqrt(x * x + y * y);
if (scale) lengths[i] = length;
spaces[++i] = (lengthSpacing ? setupLength + spacing : spacing) * length / setupLength;
if (setupLength < PathConstraint.epsilon) {
if (scale) lengths[i] = 0;
spaces[++i] = 0;
} else {
let x = setupLength * bone.a, y = setupLength * bone.c;
let length = Math.sqrt(x * x + y * y);
if (scale) lengths[i] = length;
spaces[++i] = (lengthSpacing ? setupLength + spacing : spacing) * length / setupLength;
}
}
} else {
for (let i = 1; i < spacesCount; i++)