Try fix concurrency issue with render closing

This commit is contained in:
James Seibel
2026-03-14 10:18:40 -05:00
parent 38e104a9fc
commit cd5a3ce52b
2 changed files with 31 additions and 8 deletions
@@ -34,6 +34,7 @@ import com.seibel.distanthorizons.core.logging.DhLoggerBuilder;
import com.seibel.distanthorizons.core.pos.blockPos.DhBlockPos2D;
import com.seibel.distanthorizons.core.pos.DhSectionPos;
import com.seibel.distanthorizons.core.render.RenderBufferHandler;
import com.seibel.distanthorizons.core.render.RenderThreadTaskHandler;
import com.seibel.distanthorizons.core.render.renderer.AbstractDebugWireframeRenderer;
import com.seibel.distanthorizons.core.render.renderer.BeaconRenderHandler;
import com.seibel.distanthorizons.core.render.renderer.IDebugRenderable;
@@ -371,8 +372,18 @@ public class LodQuadTree extends QuadTree<LodRenderSection> implements IDebugRen
for (QuadNode<LodRenderSection> node : this.tickNodeHolder.getEnableDeleteChildrenNodes())
{
if (node == null || node.value == null) { continue; }
if (node == null
|| node.value == null
// only clear the children if there are children to clear
|| node.getDirectChildCount() == 0)
{
continue;
}
// run this on the render thread to hopefully prevent
// closing render data while rendering is happening
RenderThreadTaskHandler.INSTANCE.queueRunningOnRenderThread("LodQuadTree delayed child cleanup", () ->
{
node.deleteAllChildren((childRenderSection) ->
{
if (childRenderSection != null)
@@ -382,6 +393,7 @@ public class LodQuadTree extends QuadTree<LodRenderSection> implements IDebugRen
childRenderSection.close();
}
});
});
}
//endregion
@@ -86,6 +86,17 @@ public class QuadNode<T>
/** @return the number of non-null direct child nodes */
public int getDirectChildCount()
{
int count = 0;
if (this.nwChild != null) { count++; }
if (this.neChild != null) { count++; }
if (this.swChild != null) { count++; }
if (this.seChild != null) { count++; }
return count;
}
/**
* Use {@link QuadNode#getNonNullChildCount()} if you want the number of non-null child values.
*