mirror of
https://github.com/EsotericSoftware/spine-runtimes.git
synced 2026-03-26 22:49:01 +08:00
Merge branch '3.6' of https://github.com/esotericsoftware/spine-runtimes into 3.6
This commit is contained in:
commit
df4fb90402
@ -862,6 +862,8 @@ public class Animation {
|
|||||||
|
|
||||||
/** Changes a slot's {@link Slot#getAttachmentVertices()} to deform a {@link VertexAttachment}. */
|
/** Changes a slot's {@link Slot#getAttachmentVertices()} to deform a {@link VertexAttachment}. */
|
||||||
static public class DeformTimeline extends CurveTimeline {
|
static public class DeformTimeline extends CurveTimeline {
|
||||||
|
static private float[] zeros = new float[64];
|
||||||
|
|
||||||
int slotIndex;
|
int slotIndex;
|
||||||
VertexAttachment attachment;
|
VertexAttachment attachment;
|
||||||
private final float[] frames; // time, ...
|
private final float[] frames; // time, ...
|
||||||
@ -923,20 +925,43 @@ public class Animation {
|
|||||||
FloatArray verticesArray = slot.getAttachmentVertices();
|
FloatArray verticesArray = slot.getAttachmentVertices();
|
||||||
float[][] frameVertices = this.frameVertices;
|
float[][] frameVertices = this.frameVertices;
|
||||||
int vertexCount = frameVertices[0].length;
|
int vertexCount = frameVertices[0].length;
|
||||||
if (verticesArray.size != vertexCount && pose != setup) alpha = 1; // Don't mix from uninitialized slot vertices.
|
|
||||||
float[] vertices = verticesArray.setSize(vertexCount);
|
float[] vertices = verticesArray.setSize(vertexCount);
|
||||||
|
|
||||||
float[] frames = this.frames;
|
float[] frames = this.frames;
|
||||||
if (time < frames[0]) { // Time is before first frame.
|
if (time < frames[0]) { // Time is before first frame.
|
||||||
|
VertexAttachment vertexAttachment = (VertexAttachment)slotAttachment;
|
||||||
|
|
||||||
switch (pose) {
|
switch (pose) {
|
||||||
case setup:
|
case setup:
|
||||||
verticesArray.size = 0;
|
break;
|
||||||
return;
|
|
||||||
case current:
|
case current:
|
||||||
alpha = 1 - alpha;
|
if (alpha == 1) break;
|
||||||
for (int i = 0; i < vertexCount; i++)
|
if (vertexAttachment.getBones() == null) {
|
||||||
vertices[i] *= alpha;
|
// Unweighted vertex positions.
|
||||||
|
float[] setupVertices = vertexAttachment.getVertices();
|
||||||
|
for (int i = 0; i < vertexCount; i++)
|
||||||
|
vertices[i] += (setupVertices[i] - vertices[i]) * alpha;
|
||||||
|
} else {
|
||||||
|
// Weighted deform offsets.
|
||||||
|
alpha = 1 - alpha;
|
||||||
|
for (int i = 0; i < vertexCount; i++)
|
||||||
|
vertices[i] *= alpha;
|
||||||
|
}
|
||||||
|
// Fall thru.
|
||||||
|
default:
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
float[] zeroVertices;
|
||||||
|
if (vertexAttachment.getBones() == null) {
|
||||||
|
// Unweighted vertex positions (setup pose).
|
||||||
|
zeroVertices = vertexAttachment.getVertices();
|
||||||
|
} else {
|
||||||
|
// Weighted deform offsets (zeros).
|
||||||
|
zeroVertices = zeros;
|
||||||
|
if (zeroVertices.length < vertexCount) zeros = zeroVertices = new float[vertexCount];
|
||||||
|
}
|
||||||
|
System.arraycopy(zeroVertices, 0, vertices, 0, vertexCount);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user