Fix a bug with auto batching logic

This commit is contained in:
Nite Luo 2013-12-04 19:05:17 -08:00
parent e316ac779b
commit 9b0e0d2116
1 changed files with 5 additions and 4 deletions

View File

@ -236,11 +236,9 @@ void Renderer::render()
if(command->getType() == QUAD_COMMAND) if(command->getType() == QUAD_COMMAND)
{ {
QuadCommand* cmd = static_cast<QuadCommand*>(command); QuadCommand* cmd = static_cast<QuadCommand*>(command);
CCASSERT(cmd->getQuadCount()<VBO_SIZE, "VBO is not big enough for quad data, please break the quad data down or use customized render command");
//Batch quads //Batch quads
if(_numQuads + cmd->getQuadCount() < VBO_SIZE) if(_numQuads + cmd->getQuadCount() <= VBO_SIZE)
{ {
memcpy(_quads + _numQuads, cmd->getQuad(), sizeof(V3F_C4B_T2F_Quad) * cmd->getQuadCount()); memcpy(_quads + _numQuads, cmd->getQuad(), sizeof(V3F_C4B_T2F_Quad) * cmd->getQuadCount());
_numQuads += cmd->getQuadCount(); _numQuads += cmd->getQuadCount();
@ -248,8 +246,11 @@ void Renderer::render()
} }
else else
{ {
CCASSERT(cmd->getQuadCount() < VBO_SIZE, "VBO is not big enough for quad data, please break the quad data down or use customized render command");
//Draw batched quads if VBO is full //Draw batched quads if VBO is full
drawBatchedQuads(); drawBatchedQuads();
i--;
} }
} }
else if(command->getType() == CUSTOM_COMMAND) else if(command->getType() == CUSTOM_COMMAND)