Fix flashing when moving over root node boundaries

This commit is contained in:
James Seibel
2026-04-22 18:36:09 -05:00
parent 225385a43f
commit e465ef5325
2 changed files with 25 additions and 23 deletions
@@ -598,24 +598,21 @@ public class LodQuadTree extends QuadTree<LodRenderSection> implements IDebugRen
}
}
if (childNodeRenderCount >= 4)
boolean isRootNode = (quadNode == rootNode);
if (isRootNode)
{
// Never render the root node.
// This is done to prevent flashing when moving across root node
// boundaries.
// Otherwise, when moving, new empty nodes will be added at the edge of the tree
// which will require the root node to render to cover the "empty" area.
this.tickNodeHolder.addDisableNode(quadNode);
return false;
}
else if (childNodeRenderCount >= 4)
{
this.tickNodeHolder.addDisableNode(quadNode);
/*
DEBUG_RENDERER.makeParticle(
new AbstractDebugWireframeRenderer.BoxParticle(
new AbstractDebugWireframeRenderer.Box(
quadNode.sectionPos
, -64, 80,
0.0f,
Color.BLUE),
0.25, 0f
));
*/
// all children can render,
// the area will be filled when rendering
return true;
@@ -623,7 +620,7 @@ public class LodQuadTree extends QuadTree<LodRenderSection> implements IDebugRen
else
{
boolean nodeCanRender = quadNode.value != null
&& quadNode.value.gpuUploadComplete();
&& quadNode.value.canRender();
if (nodeCanRender)
{
// not all child positions are loaded yet, this one should be rendered instead
@@ -635,7 +632,6 @@ public class LodQuadTree extends QuadTree<LodRenderSection> implements IDebugRen
this.tickNodeHolder.addDisableNode(quadNode);
}
return nodeCanRender;
}
}
@@ -654,14 +650,18 @@ public class LodQuadTree extends QuadTree<LodRenderSection> implements IDebugRen
}
if (quadNode.value != null
&& quadNode.value.gpuUploadComplete())
&& quadNode.value.canRender())
{
if (!this.tickNodeHolder.getEnabledNodes().contains(parentNode))
{
this.tickNodeHolder.addEnableDeleteChildrenNode(quadNode);
return true;
}
else
{
this.tickNodeHolder.addDisableNode(quadNode);
return true; // TODO broken, will enable sections even if parent is enabled
return false;
}
}
else
{
@@ -1211,7 +1211,7 @@ public class LodQuadTree extends QuadTree<LodRenderSection> implements IDebugRen
{
color = Color.ORANGE;
}
else if (!renderSection.gpuUploadComplete())
else if (!renderSection.canRender())
{
// uploaded but the buffer is missing
color = Color.PINK;
@@ -349,10 +349,12 @@ public class LodRenderSection implements IDebugRenderable, AutoCloseable
//=================//
//region
/** aka "canRender()" */
public boolean canRender() { return this.renderBufferContainer != null; }
public boolean gpuUploadComplete()
{
return this.renderBufferContainer != null
// render dirty is here so we can trigger new GPU uploads
// even if the render data is present
&& !this.renderDataDirty;
}
@@ -383,7 +385,7 @@ public class LodRenderSection implements IDebugRenderable, AutoCloseable
{
color = Color.yellow;
}
else if (this.gpuUploadComplete())
else if (this.canRender())
{
//color = Color.cyan;
return;