[c] Ported fix for DeformTimeline, see #932

This commit is contained in:
badlogic 2017-07-04 10:33:16 +02:00
parent 263c6278e2
commit 8b14b18fda

View File

@ -851,22 +851,35 @@ void _spDeformTimeline_apply (const spTimeline* timeline, spSkeleton* skeleton,
slot->attachmentVerticesCapacity = vertexCount; slot->attachmentVerticesCapacity = vertexCount;
} }
} }
if (slot->attachmentVerticesCount != vertexCount && pose != SP_MIX_POSE_SETUP) alpha = 1; /* Don't mix from uninitialized slot vertices. */
slot->attachmentVerticesCount = vertexCount; slot->attachmentVerticesCount = vertexCount;
frameVertices = self->frameVertices; frameVertices = self->frameVertices;
vertices = slot->attachmentVertices; vertices = slot->attachmentVertices;
if (time < frames[0]) { /* Time is before first frame. */ if (time < frames[0]) { /* Time is before first frame. */
spVertexAttachment* vertexAttachment = SUB_CAST(spVertexAttachment, slot->attachment);
switch (pose) { switch (pose) {
case SP_MIX_POSE_SETUP: case SP_MIX_POSE_SETUP:
slot->attachmentVerticesCount = 0; if (!vertexAttachment->bones) {
memcpy(vertices, vertexAttachment->vertices, vertexCount * sizeof(float));
} else {
for (i = 0; i < vertexCount; i++) vertices[i] = 0;
}
return; return;
case SP_MIX_POSE_CURRENT: case SP_MIX_POSE_CURRENT:
case SP_MIX_POSE_CURRENT_LAYERED: /* to appease compiler */ case SP_MIX_POSE_CURRENT_LAYERED: /* to appease compiler */
alpha = 1 - alpha; if (alpha == 1) break;
for (i = 0; i < vertexCount; i++) if (!vertexAttachment->bones) {
vertices[i] *= alpha; float* setupVertices = vertexAttachment->vertices;
for (i = 0; i < vertexCount; i++) {
vertices[i] += (setupVertices[i] - vertices[i]) * alpha;
}
} else {
alpha = 1 - alpha;
for (i = 0; i < vertexCount; i++) {
vertices[i] *= alpha;
}
}
} }
return; return;
} }