[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 NONE: number;
static BEFORE: number; static BEFORE: number;
static AFTER: number; static AFTER: number;
static epsilon: number;
data: PathConstraintData; data: PathConstraintData;
bones: Array<Bone>; bones: Array<Bone>;
target: Slot; target: Slot;

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

File diff suppressed because one or more lines are too long

View File

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