Эх сурвалжийг харах

Fixed mixing from uninitialized slot vertices.

http://esotericsoftware.com/forum/viewtopic.php?f=9&t=2775
NathanSweet 11 жил өмнө
parent
commit
7f6abc8c00

+ 2 - 5
spine-as3/spine-as3/src/spine/animation/FfdTimeline.as

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

+ 1 - 0
spine-c/src/spine/Animation.c

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

+ 1 - 0
spine-csharp/src/Animation.cs

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

+ 2 - 6
spine-js/spine.js

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

+ 6 - 4
spine-libgdx/src/com/esotericsoftware/spine/Animation.java

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