mirror of
https://github.com/photonstorm/phaser
synced 2024-11-26 22:52:14 +00:00
Much cleaner rendering function, skipping invalid faces
This commit is contained in:
parent
3e133c900a
commit
431eb69b42
1 changed files with 18 additions and 5 deletions
|
@ -22,7 +22,15 @@ var GetCalcMatrix = require('../GetCalcMatrix');
|
||||||
*/
|
*/
|
||||||
var MeshWebGLRenderer = function (renderer, src, camera, parentMatrix)
|
var MeshWebGLRenderer = function (renderer, src, camera, parentMatrix)
|
||||||
{
|
{
|
||||||
var pipeline = renderer.pipelines.set(this.pipeline, src);
|
var faces = src.faces;
|
||||||
|
var totalFaces = faces.length;
|
||||||
|
|
||||||
|
if (totalFaces === 0)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
var pipeline = renderer.pipelines.set(src.pipeline, src);
|
||||||
|
|
||||||
var calcMatrix = GetCalcMatrix(src, camera, parentMatrix).calc;
|
var calcMatrix = GetCalcMatrix(src, camera, parentMatrix).calc;
|
||||||
|
|
||||||
|
@ -33,7 +41,6 @@ var MeshWebGLRenderer = function (renderer, src, camera, parentMatrix)
|
||||||
|
|
||||||
var vertexOffset = (pipeline.vertexCount * pipeline.vertexComponentCount) - 1;
|
var vertexOffset = (pipeline.vertexCount * pipeline.vertexComponentCount) - 1;
|
||||||
|
|
||||||
var faces = src.faces;
|
|
||||||
var tintEffect = src.tintFill;
|
var tintEffect = src.tintFill;
|
||||||
|
|
||||||
var debugCallback = src.debugCallback;
|
var debugCallback = src.debugCallback;
|
||||||
|
@ -48,9 +55,17 @@ var MeshWebGLRenderer = function (renderer, src, camera, parentMatrix)
|
||||||
|
|
||||||
var roundPixels = camera.roundPixels;
|
var roundPixels = camera.roundPixels;
|
||||||
var alpha = camera.alpha * src.alpha;
|
var alpha = camera.alpha * src.alpha;
|
||||||
|
var hideCCW = src.hideCCW;
|
||||||
|
|
||||||
for (var i = 0; i < faces.length; i++)
|
for (var i = 0; i < totalFaces; i++)
|
||||||
{
|
{
|
||||||
|
var face = faces[i];
|
||||||
|
|
||||||
|
if (hideCCW && !face.isCounterClockwise())
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
if (pipeline.shouldFlush(3))
|
if (pipeline.shouldFlush(3))
|
||||||
{
|
{
|
||||||
pipeline.flush();
|
pipeline.flush();
|
||||||
|
@ -58,8 +73,6 @@ var MeshWebGLRenderer = function (renderer, src, camera, parentMatrix)
|
||||||
vertexOffset = 0;
|
vertexOffset = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
var face = faces[i];
|
|
||||||
|
|
||||||
vertexOffset = face.vertex1.load(F32, U32, vertexOffset, textureUnit, tintEffect, alpha, a, b, c, d, e, f, roundPixels);
|
vertexOffset = face.vertex1.load(F32, U32, vertexOffset, textureUnit, tintEffect, alpha, a, b, c, d, e, f, roundPixels);
|
||||||
vertexOffset = face.vertex2.load(F32, U32, vertexOffset, textureUnit, tintEffect, alpha, a, b, c, d, e, f, roundPixels);
|
vertexOffset = face.vertex2.load(F32, U32, vertexOffset, textureUnit, tintEffect, alpha, a, b, c, d, e, f, roundPixels);
|
||||||
vertexOffset = face.vertex3.load(F32, U32, vertexOffset, textureUnit, tintEffect, alpha, a, b, c, d, e, f, roundPixels);
|
vertexOffset = face.vertex3.load(F32, U32, vertexOffset, textureUnit, tintEffect, alpha, a, b, c, d, e, f, roundPixels);
|
||||||
|
|
Loading…
Reference in a new issue