From 9a428a02b8155fc016fb70e92ec83331ecfec149 Mon Sep 17 00:00:00 2001 From: badlogic Date: Thu, 9 Aug 2018 14:59:09 +0200 Subject: [PATCH] [c] Fixes #1148, revert changes to spVertexAttachment_computeWorldVertices. Vertex size must be a multiple of 4, which explains why #1148 failed. --- spine-c/spine-c/src/spine/VertexAttachment.c | 2 +- spine-cocos2dx/src/spine/SkeletonRenderer.cpp | 6 ++++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/spine-c/spine-c/src/spine/VertexAttachment.c b/spine-c/spine-c/src/spine/VertexAttachment.c index 14087815e..8b6dfea36 100644 --- a/spine-c/spine-c/src/spine/VertexAttachment.c +++ b/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 >> 1) * stride; + count += offset; skeleton = slot->bone->skeleton; deformLength = slot->attachmentVerticesCount; deform = slot->attachmentVertices; diff --git a/spine-cocos2dx/src/spine/SkeletonRenderer.cpp b/spine-cocos2dx/src/spine/SkeletonRenderer.cpp index 8fac0f5ed..2fd87e351 100644 --- a/spine-cocos2dx/src/spine/SkeletonRenderer.cpp +++ b/spine-cocos2dx/src/spine/SkeletonRenderer.cpp @@ -344,7 +344,8 @@ void SkeletonRenderer::draw (Renderer* renderer, const Mat4& transform, uint32_t 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); - spVertexAttachment_computeWorldVertices(SUPER(attachment), slot, 0, triangles.vertCount * sizeof(cocos2d::V3F_C4B_T2F) / 4, (float*)triangles.verts, 0, 6); + int vertexSizeInFloats = sizeof(cocos2d::V3F_C4B_T2F) / sizeof(float); + spVertexAttachment_computeWorldVertices(SUPER(attachment), slot, 0, triangles.vertCount * vertexSizeInFloats, (float*)triangles.verts, 0, vertexSizeInFloats); } else { trianglesTwoColor.indices = attachmentVertices->_triangles->indices; trianglesTwoColor.indexCount = attachmentVertices->_triangles->indexCount; @@ -353,7 +354,8 @@ void SkeletonRenderer::draw (Renderer* renderer, const Mat4& transform, uint32_t for (int i = 0; i < trianglesTwoColor.vertCount; i++) { trianglesTwoColor.verts[i].texCoords = attachmentVertices->_triangles->verts[i].texCoords; } - spVertexAttachment_computeWorldVertices(SUPER(attachment), slot, 0, trianglesTwoColor.vertCount * sizeof(V3F_C4B_C4B_T2F) / 4, (float*)trianglesTwoColor.verts, 0, 7); + int vertexSizeInFloats = sizeof(V3F_C4B_C4B_T2F) / sizeof(float); + spVertexAttachment_computeWorldVertices(SUPER(attachment), slot, 0, trianglesTwoColor.vertCount * vertexSizeInFloats, (float*)trianglesTwoColor.verts, 0, vertexSizeInFloats); } color.r = attachment->color.r;