From 999e836ba00411b316e9b0399fb784469cbd5577 Mon Sep 17 00:00:00 2001 From: badlogic Date: Fri, 12 Jan 2018 13:44:58 +0100 Subject: [PATCH] [cocos2dx] Closes #1062, proper handling of batch boundaries. --- spine-cocos2dx/src/spine/SkeletonTwoColorBatch.cpp | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/spine-cocos2dx/src/spine/SkeletonTwoColorBatch.cpp b/spine-cocos2dx/src/spine/SkeletonTwoColorBatch.cpp index fa3e55149..41b323494 100644 --- a/spine-cocos2dx/src/spine/SkeletonTwoColorBatch.cpp +++ b/spine-cocos2dx/src/spine/SkeletonTwoColorBatch.cpp @@ -269,6 +269,11 @@ void SkeletonTwoColorBatch::batch (TwoColorTrianglesCommand* command) { flush(_lastCommand); } + uint32_t materialID = command->getMaterialID(); + if (_lastCommand && _lastCommand->getMaterialID() != materialID) { + flush(_lastCommand); + } + memcpy(_vertexBuffer + _numVerticesBuffer, command->getTriangles().verts, sizeof(V3F_C4B_C4B_T2F) * command->getTriangles().vertCount); const Mat4& modelView = command->getModelView(); for (int i = _numVerticesBuffer; i < _numVerticesBuffer + command->getTriangles().vertCount; i++) { @@ -284,10 +289,8 @@ void SkeletonTwoColorBatch::batch (TwoColorTrianglesCommand* command) { _numVerticesBuffer += command->getTriangles().vertCount; _numIndicesBuffer += command->getTriangles().indexCount; - uint32_t materialID = command->getMaterialID(); - - if ((_lastCommand && _lastCommand->getMaterialID() != materialID) || command->isForceFlush()) { - flush(_lastCommand); + if (command->isForceFlush()) { + flush(command); } _lastCommand = command; }