Fixed mixing from uninitialized slot vertices.

http://esotericsoftware.com/forum/viewtopic.php?f=9&t=2775
This commit is contained in:
NathanSweet 2014-06-03 18:37:42 +02:00
parent 6b9d514ca7
commit 7f6abc8c00
5 changed files with 12 additions and 15 deletions

View File

@ -66,11 +66,8 @@ public class FfdTimeline extends CurveTimeline {
var vertexCount:int = frameVertices[0].length; var vertexCount:int = frameVertices[0].length;
var vertices:Vector.<Number> = slot.attachmentVertices; var vertices:Vector.<Number> = slot.attachmentVertices;
if (vertices.length < vertexCount) { if (vertices.length != vertexCount) alpha = 1;
vertices = new Vector.<Number>(vertexCount); vertices.length = vertexCount;
slot.attachmentVertices = vertices;
}
slot.attachmentVertices.length = vertexCount;
var i:int; var i:int;
if (time >= frames[frames.length - 1]) { // Time is after last frame. if (time >= frames[frames.length - 1]) { // Time is after last frame.

View File

@ -652,6 +652,7 @@ void _spFFDTimeline_apply (const spTimeline* timeline, spSkeleton* skeleton, flo
return; /* Time is before first frame. */ return; /* Time is before first frame. */
} }
if (slot->attachmentVerticesCount == 0) alpha = 1;
if (slot->attachmentVerticesCount < self->frameVerticesCount) { if (slot->attachmentVerticesCount < self->frameVerticesCount) {
if (slot->attachmentVerticesCapacity < self->frameVerticesCount) { if (slot->attachmentVerticesCapacity < self->frameVerticesCount) {
FREE(slot->attachmentVertices); FREE(slot->attachmentVertices);

View File

@ -565,6 +565,7 @@ namespace Spine {
int vertexCount = frameVertices[0].Length; int vertexCount = frameVertices[0].Length;
float[] vertices = slot.attachmentVertices; float[] vertices = slot.attachmentVertices;
if (vertices.Length != vertexCount) alpha = 1;
if (vertices.Length < vertexCount) { if (vertices.Length < vertexCount) {
vertices = new float[vertexCount]; vertices = new float[vertexCount];
slot.attachmentVertices = vertices; slot.attachmentVertices = vertices;

View File

@ -631,12 +631,8 @@ spine.FfdTimeline.prototype = {
var vertexCount = frameVertices[0].length; var vertexCount = frameVertices[0].length;
var vertices = slot.attachmentVertices; var vertices = slot.attachmentVertices;
if (vertices.length < vertexCount) { if (vertices.length != vertexCount) alpha = 1;
vertices = []; vertices.length = vertexCount;
vertices.length = vertexCount;
slot.attachmentVertices = vertices;
}
slot.attachmentVertices.length = vertexCount;
if (time >= frames[frames.length - 1]) { // Time is after last frame. if (time >= frames[frames.length - 1]) { // Time is after last frame.
var lastVertices = frameVertices[frames.length - 1]; var lastVertices = frameVertices[frames.length - 1];

View File

@ -31,6 +31,7 @@
package com.esotericsoftware.spine; package com.esotericsoftware.spine;
import com.esotericsoftware.spine.attachments.Attachment; import com.esotericsoftware.spine.attachments.Attachment;
import com.esotericsoftware.spine.attachments.MeshAttachment;
import com.badlogic.gdx.graphics.Color; import com.badlogic.gdx.graphics.Color;
import com.badlogic.gdx.math.MathUtils; import com.badlogic.gdx.math.MathUtils;
@ -655,14 +656,15 @@ public class Animation {
Slot slot = skeleton.slots.get(slotIndex); Slot slot = skeleton.slots.get(slotIndex);
if (slot.getAttachment() != attachment) return; if (slot.getAttachment() != attachment) return;
FloatArray verticesArray = slot.getAttachmentVertices();
verticesArray.size = 0;
float[] frames = this.frames; float[] frames = this.frames;
if (time < frames[0]) return; // Time is before first frame. if (time < frames[0]) return; // Time is before first frame.
float[][] frameVertices = this.frameVertices; float[][] frameVertices = this.frameVertices;
int vertexCount = frameVertices[0].length; int vertexCount = frameVertices[0].length;
FloatArray verticesArray = slot.getAttachmentVertices();
if (verticesArray.size != vertexCount) alpha = 1; // Don't mix from uninitialized slot vertices.
verticesArray.size = 0;
verticesArray.ensureCapacity(vertexCount); verticesArray.ensureCapacity(vertexCount);
verticesArray.size = vertexCount; verticesArray.size = vertexCount;
float[] vertices = verticesArray.items; float[] vertices = verticesArray.items;