Skip to content

Commit

Permalink
fix MaterialID type err
Browse files Browse the repository at this point in the history
  • Loading branch information
StarBeat committed Jun 29, 2020
1 parent 121f8e9 commit f11d51e
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions cocos/renderer/CCRenderer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -568,7 +568,8 @@ void Renderer::drawBatchedTriangles()
_triBatchesToDraw[0].cmd = nullptr;

int batchesTotal = 0;
int prevMaterialID = -1;
unsigned int prevMaterialID = -1;
bool isValidMaterialID = false;
bool firstCommand = true;

_filledVertex = 0;
Expand All @@ -582,7 +583,7 @@ void Renderer::drawBatchedTriangles()
fillVerticesAndIndices(cmd, vertexBufferFillOffset);

// in the same batch ?
if (batchable && (prevMaterialID == currentMaterialID || firstCommand))
if (batchable && ((isValidMaterialID && prevMaterialID == currentMaterialID) || firstCommand))
{
CC_ASSERT((firstCommand || _triBatchesToDraw[batchesTotal].cmd->getMaterialID() == cmd->getMaterialID()) && "argh... error in logic");
_triBatchesToDraw[batchesTotal].indicesToDraw += cmd->getIndexCount();
Expand All @@ -600,10 +601,10 @@ void Renderer::drawBatchedTriangles()

_triBatchesToDraw[batchesTotal].cmd = cmd;
_triBatchesToDraw[batchesTotal].indicesToDraw = (int) cmd->getIndexCount();

isValidMaterialID = true;
// is this a single batch ? Prevent creating a batch group then
if (!batchable)
currentMaterialID = -1;
isValidMaterialID = false;
}

// capacity full ?
Expand Down

0 comments on commit f11d51e

Please sign in to comment.