Jelajahi Sumber

Merge branch '3.7-beta' into 3.7-beta-cpp

badlogic 7 tahun lalu
induk
melakukan
253bda4ee4

+ 1 - 1
spine-c/spine-c/src/spine/VertexAttachment.c

@@ -51,7 +51,7 @@ void spVertexAttachment_computeWorldVertices (spVertexAttachment* self, spSlot*
 	float* vertices;
 	int* bones;
 
-	count += offset;
+	count = offset + (count >> 1) * stride;
 	skeleton = slot->bone->skeleton;
 	deformLength = slot->attachmentVerticesCount;
 	deform = slot->attachmentVertices;

+ 21 - 0
spine-cocos2dx/src/spine/SkeletonRenderer.cpp

@@ -305,10 +305,31 @@ namespace spine {
 				continue;
 			}
 			
+<<<<<<< HEAD
 			// Early exit if slot is invisible
 			if (slot->getColor().a == 0) {
 				_clipper->clipEnd(*slot);
 				continue;
+=======
+			if (!isTwoColorTint) {
+				triangles.indices = attachmentVertices->_triangles->indices;
+				triangles.indexCount = attachmentVertices->_triangles->indexCount;
+				triangles.verts = batch->allocateVertices(attachmentVertices->_triangles->vertCount);
+				triangles.vertCount = attachmentVertices->_triangles->vertCount;
+				memcpy(triangles.verts, attachmentVertices->_triangles->verts, sizeof(cocos2d::V3F_C4B_T2F) * attachmentVertices->_triangles->vertCount);
+				int vertexSizeInFloats = sizeof(cocos2d::V3F_C4B_T2F) / sizeof(float);
+				spVertexAttachment_computeWorldVertices(SUPER(attachment), slot, 0, attachment->super.worldVerticesLength, (float*)triangles.verts, 0, vertexSizeInFloats);
+			} else {
+				trianglesTwoColor.indices = attachmentVertices->_triangles->indices;
+				trianglesTwoColor.indexCount = attachmentVertices->_triangles->indexCount;
+				trianglesTwoColor.verts = twoColorBatch->allocateVertices(attachmentVertices->_triangles->vertCount);
+				trianglesTwoColor.vertCount = attachmentVertices->_triangles->vertCount;
+				for (int i = 0; i < trianglesTwoColor.vertCount; i++) {
+					trianglesTwoColor.verts[i].texCoords = attachmentVertices->_triangles->verts[i].texCoords;
+				}
+				int vertexSizeInFloats = sizeof(V3F_C4B_C4B_T2F) / sizeof(float);
+				spVertexAttachment_computeWorldVertices(SUPER(attachment), slot, 0, attachment->super.worldVerticesLength, (float*)trianglesTwoColor.verts, 0, vertexSizeInFloats);
+>>>>>>> 3.7-beta
 			}
 			
 			cocos2d::TrianglesCommand::Triangles triangles;

+ 8 - 1
spine-cpp/spine-cpp/include/spine/Vector.h

@@ -99,11 +99,18 @@ public:
 
 	inline void add(const T &inValue) {
 		if (_size == _capacity) {
+			// inValue might reference an element in this buffer
+			// When we reallocate, the reference becomes invalid.
+			// We thus need to create a defensive copy before
+			// reallocating.
+			T valueCopy = inValue;
 			_capacity = (int) (_size * 1.75f);
 			if (_capacity < 8) _capacity = 8;
 			_buffer = spine::SpineExtension::realloc<T>(_buffer, _capacity, __FILE__, __LINE__);
+			construct(_buffer + _size++, valueCopy);
+		} else {
+			construct(_buffer + _size++, inValue);
 		}
-		construct(_buffer + _size++, inValue);
 	}
 
 	inline void addAll(Vector<T> &inValue) {