Abandon line strips that are of size 0/1

pull/1157/head
Levin Li 2021-11-12 09:40:08 +08:00
parent da5f621a19
commit 2cf37d3e70
1 changed files with 7 additions and 2 deletions

View File

@ -310,13 +310,18 @@ public:
inline void end(bool flushIfNeeded = true) inline void end(bool flushIfNeeded = true)
{ {
#if USE_VERTEX_BUFFER #if USE_VERTEX_BUFFER
if (currentPosition > 1) if (currentStripLength > 1)
{ {
int index = currentPosition * 2; int index = currentPosition * 2;
memcpy(&data[index], &data[index - 4], 2 * sizeof(Vertex)); memcpy(&data[index], &data[index - 4], 2 * sizeof(Vertex));
currentPosition += 1; currentPosition += 1;
stripLengths.push_back(currentStripLength);
}
else
{
// Abandon line strips that only contains zero/one point
currentPosition -= currentStripLength;
} }
stripLengths.push_back(currentStripLength);
currentStripLength = 0; currentStripLength = 0;
if (flushIfNeeded && currentPosition == capacity) if (flushIfNeeded && currentPosition == capacity)
flush(false); flush(false);