Better conditional flow

This commit is contained in:
Richard Davey 2020-09-01 13:30:22 +01:00
parent 1406f23bd6
commit 8d02da00f2
4 changed files with 47 additions and 39 deletions

View file

@ -35220,6 +35220,8 @@ var SpineContainerWebGLRenderer = function (renderer, container, interpolationPe
if (sceneRenderer.batcher.isDrawing && renderer.finalType) if (sceneRenderer.batcher.isDrawing && renderer.finalType)
{ {
sceneRenderer.end(); sceneRenderer.end();
renderer.rebindPipeline();
} }
return; return;
@ -35248,6 +35250,9 @@ var SpineContainerWebGLRenderer = function (renderer, container, interpolationPe
if (renderer.newType) if (renderer.newType)
{ {
// flush + clear if this is a new type
renderer.clearPipeline();
sceneRenderer.begin(); sceneRenderer.begin();
} }
@ -35337,13 +35342,11 @@ var SpineContainerWebGLRenderer = function (renderer, container, interpolationPe
if (!renderer.nextTypeMatch) if (!renderer.nextTypeMatch)
{ {
// The next object in the display list is not a Spine Game Object or Spine Container, so we end the batch. // The next object in the display list is not a Spine Game Object or Spine Container, so we end the batch
sceneRenderer.end(); sceneRenderer.end();
if (!renderer.finalType) // And rebind the previous pipeline
{ renderer.rebindPipeline();
renderer.rebindPipeline(renderer.pipelines.MultiPipeline);
}
} }
}; };
@ -37335,36 +37338,37 @@ var SpineGameObjectWebGLRenderer = function (renderer, src, interpolationPercent
var childAlpha = skeleton.color.a; var childAlpha = skeleton.color.a;
var sceneRenderer = plugin.sceneRenderer; var sceneRenderer = plugin.sceneRenderer;
if (renderer.newType)
{
// flush + clear if this is a new type, even if it doesn't render
renderer.clearPipeline();
}
var GameObjectRenderMask = 15; var GameObjectRenderMask = 15;
var willRender = !(GameObjectRenderMask !== src.renderFlags || (src.cameraFilter !== 0 && (src.cameraFilter & camera.id)) || childAlpha === 0); var willRender = !(GameObjectRenderMask !== src.renderFlags || (src.cameraFilter !== 0 && (src.cameraFilter & camera.id)) || childAlpha === 0);
if (!skeleton || !willRender) if (!skeleton || !willRender)
{ {
// If there is already a batch running, we need to close it // If there is already a batch running, and the next type isn't a Spine object, or this is the end, we need to close it
if (!renderer.nextTypeMatch)
if (sceneRenderer.batcher.isDrawing && (!renderer.nextTypeMatch || renderer.finalType))
{ {
// The next object in the display list is not a Spine object, so we end the batch // The next object in the display list is not a Spine object, so we end the batch
sceneRenderer.end(); sceneRenderer.end();
if (!renderer.finalType) renderer.rebindPipeline();
{ }
// Reset the current type
renderer.currentType = '';
renderer.rebindPipeline(); if (!renderer.finalType)
} {
// Reset the current type
renderer.currentType = '';
} }
return; return;
} }
if (renderer.newType)
{
// flush + clear previous pipeline if this is a new type
renderer.clearPipeline();
}
var camMatrix = renderer._tempMatrix1; var camMatrix = renderer._tempMatrix1;
var spriteMatrix = renderer._tempMatrix2; var spriteMatrix = renderer._tempMatrix2;
var calcMatrix = renderer._tempMatrix3; var calcMatrix = renderer._tempMatrix3;

File diff suppressed because one or more lines are too long

View file

@ -35,6 +35,8 @@ var SpineContainerWebGLRenderer = function (renderer, container, interpolationPe
if (sceneRenderer.batcher.isDrawing && renderer.finalType) if (sceneRenderer.batcher.isDrawing && renderer.finalType)
{ {
sceneRenderer.end(); sceneRenderer.end();
renderer.rebindPipeline();
} }
return; return;
@ -63,6 +65,9 @@ var SpineContainerWebGLRenderer = function (renderer, container, interpolationPe
if (renderer.newType) if (renderer.newType)
{ {
// flush + clear if this is a new type
renderer.clearPipeline();
sceneRenderer.begin(); sceneRenderer.begin();
} }
@ -152,13 +157,11 @@ var SpineContainerWebGLRenderer = function (renderer, container, interpolationPe
if (!renderer.nextTypeMatch) if (!renderer.nextTypeMatch)
{ {
// The next object in the display list is not a Spine Game Object or Spine Container, so we end the batch. // The next object in the display list is not a Spine Game Object or Spine Container, so we end the batch
sceneRenderer.end(); sceneRenderer.end();
if (!renderer.finalType) // And rebind the previous pipeline
{ renderer.rebindPipeline();
renderer.rebindPipeline(renderer.pipelines.MultiPipeline);
}
} }
}; };

View file

@ -30,36 +30,37 @@ var SpineGameObjectWebGLRenderer = function (renderer, src, interpolationPercent
var childAlpha = skeleton.color.a; var childAlpha = skeleton.color.a;
var sceneRenderer = plugin.sceneRenderer; var sceneRenderer = plugin.sceneRenderer;
if (renderer.newType)
{
// flush + clear if this is a new type, even if it doesn't render
renderer.clearPipeline();
}
var GameObjectRenderMask = 15; var GameObjectRenderMask = 15;
var willRender = !(GameObjectRenderMask !== src.renderFlags || (src.cameraFilter !== 0 && (src.cameraFilter & camera.id)) || childAlpha === 0); var willRender = !(GameObjectRenderMask !== src.renderFlags || (src.cameraFilter !== 0 && (src.cameraFilter & camera.id)) || childAlpha === 0);
if (!skeleton || !willRender) if (!skeleton || !willRender)
{ {
// If there is already a batch running, we need to close it // If there is already a batch running, and the next type isn't a Spine object, or this is the end, we need to close it
if (!renderer.nextTypeMatch)
if (sceneRenderer.batcher.isDrawing && (!renderer.nextTypeMatch || renderer.finalType))
{ {
// The next object in the display list is not a Spine object, so we end the batch // The next object in the display list is not a Spine object, so we end the batch
sceneRenderer.end(); sceneRenderer.end();
if (!renderer.finalType) renderer.rebindPipeline();
{ }
// Reset the current type
renderer.currentType = '';
renderer.rebindPipeline(); if (!renderer.finalType)
} {
// Reset the current type
renderer.currentType = '';
} }
return; return;
} }
if (renderer.newType)
{
// flush + clear previous pipeline if this is a new type
renderer.clearPipeline();
}
var camMatrix = renderer._tempMatrix1; var camMatrix = renderer._tempMatrix1;
var spriteMatrix = renderer._tempMatrix2; var spriteMatrix = renderer._tempMatrix2;
var calcMatrix = renderer._tempMatrix3; var calcMatrix = renderer._tempMatrix3;