Skip to content

Commit 9961636

Browse files
committed
Fixed overflowing of vertex count on particle emitter batcher
1 parent ea0bdce commit 9961636

1 file changed

Lines changed: 18 additions & 4 deletions

File tree

src/renderer/webgl/pipelines/TextureTintPipeline.js

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -401,6 +401,7 @@ var TextureTintPipeline = new Class({
401401
var vertexCapacity = this.vertexCapacity;
402402
var texture = emitterManager.defaultFrame.source.glTexture;
403403
var pca, pcb, pcc, pcd, pce, pcf;
404+
var vertexCount = this.vertexCount;
404405

405406
if (parentMatrix)
406407
{
@@ -445,10 +446,12 @@ var TextureTintPipeline = new Class({
445446

446447
renderer.setBlendMode(emitter.blendMode);
447448

448-
if (this.vertexCount >= vertexCapacity)
449+
if (vertexCount >= vertexCapacity)
449450
{
451+
this.vertexCount = vertexCount;
450452
this.flush();
451453
this.setTexture2D(texture, 0);
454+
vertexCount = 0;
452455
}
453456

454457
for (var batchIndex = 0; batchIndex < batchCount; ++batchIndex)
@@ -493,7 +496,7 @@ var TextureTintPipeline = new Class({
493496
var ty2 = xw * mvb + yh * mvd + mvf;
494497
var tx3 = xw * mva + y * mvc + mve;
495498
var ty3 = xw * mvb + y * mvd + mvf;
496-
var vertexOffset = this.vertexCount * vertexComponentCount;
499+
var vertexOffset = vertexCount * vertexComponentCount;
497500

498501
if (roundPixels)
499502
{
@@ -538,20 +541,31 @@ var TextureTintPipeline = new Class({
538541
vertexViewF32[vertexOffset + 28] = uvs.y3;
539542
vertexViewU32[vertexOffset + 29] = color;
540543

541-
this.vertexCount += 6;
544+
vertexCount += 6;
545+
546+
if (vertexCount >= vertexCapacity)
547+
{
548+
this.vertexCount = vertexCount;
549+
this.flush();
550+
vertexCount = 0;
551+
}
552+
542553
}
543554

544555
particleOffset += batchSize;
545556
aliveLength -= batchSize;
546557

547-
if (this.vertexCount >= vertexCapacity)
558+
if (vertexCount >= vertexCapacity)
548559
{
560+
this.vertexCount = vertexCount;
549561
this.flush();
550562
this.setTexture2D(texture, 0);
563+
vertexCount = 0;
551564
}
552565
}
553566
}
554567

568+
this.vertexCount = vertexCount;
555569
this.setTexture2D(texture, 0);
556570
},
557571

0 commit comments

Comments
 (0)