mirror of
https://github.com/EsotericSoftware/spine-runtimes.git
synced 2026-02-19 00:06:42 +08:00
[csharp] Port of commits 1b49736 and df489b1. "Fixed path constraint spacing for zero length bones."
This commit is contained in:
parent
df489b1f4a
commit
5d64ad3776
@ -84,6 +84,11 @@ namespace Spine {
|
|||||||
mixY = constraint.mixY;
|
mixY = constraint.mixY;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void ArraysFill (float[] a, int fromIndex, int toIndex, float val) {
|
||||||
|
for (int i = fromIndex; i < toIndex; i++)
|
||||||
|
a[i] = val;
|
||||||
|
}
|
||||||
|
|
||||||
public void Update () {
|
public void Update () {
|
||||||
PathAttachment attachment = target.Attachment as PathAttachment;
|
PathAttachment attachment = target.Attachment as PathAttachment;
|
||||||
if (attachment == null) return;
|
if (attachment == null) return;
|
||||||
@ -99,20 +104,19 @@ namespace Spine {
|
|||||||
float spacing = this.spacing;
|
float spacing = this.spacing;
|
||||||
switch (data.spacingMode) {
|
switch (data.spacingMode) {
|
||||||
case SpacingMode.Percent:
|
case SpacingMode.Percent:
|
||||||
for (int i = 0, n = spacesCount - 1; i < n;) {
|
if (scale) {
|
||||||
Bone bone = bonesItems[i];
|
for (int i = 0, n = spacesCount - 1; i < n; i++) {
|
||||||
float setupLength = bone.data.length;
|
Bone bone = bonesItems[i];
|
||||||
if (setupLength < PathConstraint.Epsilon) {
|
float setupLength = bone.data.length;
|
||||||
if (scale) lengths[i] = 0;
|
if (setupLength < PathConstraint.Epsilon)
|
||||||
spaces[++i] = 0;
|
lengths[i] = 0;
|
||||||
} else {
|
else {
|
||||||
if (scale) {
|
|
||||||
float x = setupLength * bone.a, y = setupLength * bone.c;
|
float x = setupLength * bone.a, y = setupLength * bone.c;
|
||||||
lengths[i] = (float)Math.Sqrt(x * x + y * y);
|
lengths[i] = (float)Math.Sqrt(x * x + y * y);
|
||||||
}
|
}
|
||||||
spaces[++i] = spacing;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
ArraysFill(spaces, 1, spacesCount, spacing);
|
||||||
break;
|
break;
|
||||||
case SpacingMode.Proportional: {
|
case SpacingMode.Proportional: {
|
||||||
float sum = 0;
|
float sum = 0;
|
||||||
@ -121,7 +125,7 @@ namespace Spine {
|
|||||||
float setupLength = bone.data.length;
|
float setupLength = bone.data.length;
|
||||||
if (setupLength < PathConstraint.Epsilon) {
|
if (setupLength < PathConstraint.Epsilon) {
|
||||||
if (scale) lengths[i] = 0;
|
if (scale) lengths[i] = 0;
|
||||||
spaces[++i] = 0;
|
spaces[++i] = spacing;
|
||||||
} else {
|
} else {
|
||||||
float x = setupLength * bone.a, y = setupLength * bone.c;
|
float x = setupLength * bone.a, y = setupLength * bone.c;
|
||||||
float length = (float)Math.Sqrt(x * x + y * y);
|
float length = (float)Math.Sqrt(x * x + y * y);
|
||||||
@ -130,9 +134,11 @@ namespace Spine {
|
|||||||
sum += length;
|
sum += length;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
sum = spacesCount / sum * spacing;
|
if (sum > 0) {
|
||||||
for (int i = 1; i < spacesCount; i++)
|
sum = spacesCount / sum * spacing;
|
||||||
spaces[i] *= sum;
|
for (int i = 1; i < spacesCount; i++)
|
||||||
|
spaces[i] *= sum;
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
default: {
|
default: {
|
||||||
@ -143,7 +149,7 @@ namespace Spine {
|
|||||||
float setupLength = bone.data.length;
|
float setupLength = bone.data.length;
|
||||||
if (setupLength < PathConstraint.Epsilon) {
|
if (setupLength < PathConstraint.Epsilon) {
|
||||||
if (scale) lengths[i] = 0;
|
if (scale) lengths[i] = 0;
|
||||||
spaces[++i] = 0;
|
spaces[++i] = spacing;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
float x = setupLength * bone.a, y = setupLength * bone.c;
|
float x = setupLength * bone.a, y = setupLength * bone.c;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user