mirror of
https://github.com/photonstorm/phaser
synced 2024-11-27 07:01:20 +00:00
Fixed emitter batch. Now to optimize it.
This commit is contained in:
parent
497fa1f2ff
commit
373d01c602
1 changed files with 50 additions and 128 deletions
|
@ -411,11 +411,7 @@ var TextureTintPipeline = new Class({
|
|||
|
||||
var roundPixels = camera.roundPixels;
|
||||
var emitters = emitterManager.emitters.list;
|
||||
var emitterCount = emitters.length;
|
||||
var vertexViewF32 = this.vertexViewF32;
|
||||
var vertexViewU32 = this.vertexViewU32;
|
||||
var renderer = this.renderer;
|
||||
var maxQuads = this.maxQuads;
|
||||
var cameraScrollX = camera.scrollX;
|
||||
var cameraScrollY = camera.scrollY;
|
||||
var cameraMatrix = camera.matrix.matrix;
|
||||
|
@ -427,8 +423,6 @@ var TextureTintPipeline = new Class({
|
|||
var cmf = cameraMatrix[5];
|
||||
var sin = Math.sin;
|
||||
var cos = Math.cos;
|
||||
var vertexComponentCount = this.vertexComponentCount;
|
||||
var vertexCapacity = this.vertexCapacity;
|
||||
var texture = emitterManager.defaultFrame.source.glTexture;
|
||||
var pca, pcb, pcc, pcd, pce, pcf;
|
||||
var pma, pmb, pmc, pmd, pme, pmf;
|
||||
|
@ -445,13 +439,11 @@ var TextureTintPipeline = new Class({
|
|||
|
||||
this.setTexture2D(texture, 0);
|
||||
|
||||
for (var emitterIndex = 0; emitterIndex < emitterCount; ++emitterIndex)
|
||||
for (var e = 0; e < emitters.length; e++)
|
||||
{
|
||||
var emitter = emitters[emitterIndex];
|
||||
var emitter = emitters[e];
|
||||
var particles = emitter.alive;
|
||||
var aliveLength = particles.length;
|
||||
var batchCount = Math.ceil(aliveLength / maxQuads);
|
||||
var particleOffset = 0;
|
||||
var scrollX = cameraScrollX * emitter.scrollFactorX;
|
||||
var scrollY = cameraScrollY * emitter.scrollFactorY;
|
||||
|
||||
|
@ -486,21 +478,11 @@ var TextureTintPipeline = new Class({
|
|||
|
||||
renderer.setBlendMode(emitter.blendMode);
|
||||
|
||||
if (this.vertexCount >= vertexCapacity)
|
||||
{
|
||||
this.flush();
|
||||
this.setTexture2D(texture, 0);
|
||||
}
|
||||
|
||||
var tintEffect = false;
|
||||
|
||||
for (var batchIndex = 0; batchIndex < batchCount; ++batchIndex)
|
||||
for (var i = 0; i < aliveLength; i++)
|
||||
{
|
||||
var batchSize = Math.min(aliveLength, maxQuads);
|
||||
|
||||
for (var index = 0; index < batchSize; ++index)
|
||||
{
|
||||
var particle = particles[particleOffset + index];
|
||||
var particle = particles[i];
|
||||
|
||||
if (particle.alpha <= 0)
|
||||
{
|
||||
|
@ -508,7 +490,6 @@ var TextureTintPipeline = new Class({
|
|||
}
|
||||
|
||||
var frame = particle.frame;
|
||||
var uvs = frame.uvs;
|
||||
var x = -(frame.halfWidth);
|
||||
var y = -(frame.halfHeight);
|
||||
var color = particle.color;
|
||||
|
@ -552,71 +533,12 @@ var TextureTintPipeline = new Class({
|
|||
ty3 |= 0;
|
||||
}
|
||||
|
||||
var vertexOffset = (this.vertexCount * vertexComponentCount) - 1;
|
||||
|
||||
vertexViewF32[++vertexOffset] = tx0;
|
||||
vertexViewF32[++vertexOffset] = ty0;
|
||||
vertexViewF32[++vertexOffset] = uvs.x0;
|
||||
vertexViewF32[++vertexOffset] = uvs.y0;
|
||||
vertexViewF32[++vertexOffset] = tintEffect;
|
||||
vertexViewU32[++vertexOffset] = color;
|
||||
|
||||
vertexViewF32[++vertexOffset] = tx1;
|
||||
vertexViewF32[++vertexOffset] = ty1;
|
||||
vertexViewF32[++vertexOffset] = uvs.x1;
|
||||
vertexViewF32[++vertexOffset] = uvs.y1;
|
||||
vertexViewF32[++vertexOffset] = tintEffect;
|
||||
vertexViewU32[++vertexOffset] = color;
|
||||
|
||||
vertexViewF32[++vertexOffset] = tx2;
|
||||
vertexViewF32[++vertexOffset] = ty2;
|
||||
vertexViewF32[++vertexOffset] = uvs.x2;
|
||||
vertexViewF32[++vertexOffset] = uvs.y2;
|
||||
vertexViewF32[++vertexOffset] = tintEffect;
|
||||
vertexViewU32[++vertexOffset] = color;
|
||||
|
||||
vertexViewF32[++vertexOffset] = tx0;
|
||||
vertexViewF32[++vertexOffset] = ty0;
|
||||
vertexViewF32[++vertexOffset] = uvs.x0;
|
||||
vertexViewF32[++vertexOffset] = uvs.y0;
|
||||
vertexViewF32[++vertexOffset] = tintEffect;
|
||||
vertexViewU32[++vertexOffset] = color;
|
||||
|
||||
vertexViewF32[++vertexOffset] = tx2;
|
||||
vertexViewF32[++vertexOffset] = ty2;
|
||||
vertexViewF32[++vertexOffset] = uvs.x2;
|
||||
vertexViewF32[++vertexOffset] = uvs.y2;
|
||||
vertexViewF32[++vertexOffset] = tintEffect;
|
||||
vertexViewU32[++vertexOffset] = color;
|
||||
|
||||
vertexViewF32[++vertexOffset] = tx3;
|
||||
vertexViewF32[++vertexOffset] = ty3;
|
||||
vertexViewF32[++vertexOffset] = uvs.x3;
|
||||
vertexViewF32[++vertexOffset] = uvs.y3;
|
||||
vertexViewF32[++vertexOffset] = tintEffect;
|
||||
vertexViewU32[++vertexOffset] = color;
|
||||
|
||||
this.vertexCount += 6;
|
||||
|
||||
if (this.vertexCount >= vertexCapacity)
|
||||
if (this.batchVertices(tx0, ty0, tx1, ty1, tx2, ty2, tx3, ty3, frame.u0, frame.v0, frame.u1, frame.v1, color, color, color, color, tintEffect))
|
||||
{
|
||||
this.flush();
|
||||
this.setTexture2D(texture, 0);
|
||||
}
|
||||
}
|
||||
|
||||
particleOffset += batchSize;
|
||||
aliveLength -= batchSize;
|
||||
|
||||
if (this.vertexCount >= vertexCapacity)
|
||||
{
|
||||
this.flush();
|
||||
this.setTexture2D(texture, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
this.setTexture2D(texture, 0);
|
||||
},
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in a new issue