mirror of
https://github.com/EsotericSoftware/spine-runtimes.git
synced 2026-03-26 22:49:01 +08:00
[c] Fix PathConstraint length spacing for zero length bones. See #1023.
This commit is contained in:
parent
52a300eeae
commit
299fa5dc8f
@ -35,6 +35,7 @@
|
|||||||
#define PATHCONSTRAINT_NONE -1
|
#define PATHCONSTRAINT_NONE -1
|
||||||
#define PATHCONSTRAINT_BEFORE -2
|
#define PATHCONSTRAINT_BEFORE -2
|
||||||
#define PATHCONSTRAINT_AFTER -3
|
#define PATHCONSTRAINT_AFTER -3
|
||||||
|
#define EPSILON 0.00001f
|
||||||
|
|
||||||
spPathConstraint* spPathConstraint_create (spPathConstraintData* data, const spSkeleton* skeleton) {
|
spPathConstraint* spPathConstraint_create (spPathConstraintData* data, const spSkeleton* skeleton) {
|
||||||
int i;
|
int i;
|
||||||
@ -113,13 +114,17 @@ void spPathConstraint_apply (spPathConstraint* self) {
|
|||||||
lengths = self->lengths;
|
lengths = self->lengths;
|
||||||
}
|
}
|
||||||
for (i = 0, n = spacesCount - 1; i < n;) {
|
for (i = 0, n = spacesCount - 1; i < n;) {
|
||||||
spBone* bone = bones[i];
|
spBone *bone = bones[i];
|
||||||
setupLength = bone->data->length;
|
setupLength = bone->data->length;
|
||||||
if (setupLength == 0) setupLength = 0.000000001f;
|
if (setupLength < EPSILON) {
|
||||||
x = setupLength * bone->a, y = setupLength * bone->c;
|
if (scale) lengths[i] = 0;
|
||||||
length = SQRT(x * x + y * y);
|
spaces[++i] = 0;
|
||||||
if (scale) lengths[i] = length;
|
} else {
|
||||||
spaces[++i] = (lengthSpacing ? setupLength + spacing : spacing) * length / setupLength;
|
x = setupLength * bone->a, y = setupLength * bone->c;
|
||||||
|
length = SQRT(x * x + y * y);
|
||||||
|
if (scale) lengths[i] = length;
|
||||||
|
spaces[++i] = (lengthSpacing ? setupLength + spacing : spacing) * length / setupLength;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
for (i = 1; i < spacesCount; i++) {
|
for (i = 1; i < spacesCount; i++) {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user