Fix LodQuadTree out of bounds error

This commit is contained in:
James Seibel
2023-04-08 13:16:50 -05:00
parent 85a0e75786
commit 39778fe944
@@ -253,50 +253,48 @@ public class LodQuadTree extends QuadTree<LodRenderSection> implements AutoClose
// create new value and update next tick
rootNode.setValue(sectionPos, new LodRenderSection(sectionPos));
}
else
{
LodUtil.assertNotReach(this.getClass().getSimpleName()+" attempted to insert "+LodRenderSection.class.getSimpleName()+" out of bounds at pos: "+sectionPos);
}
nullableQuadNode = rootNode.getNode(sectionPos);
}
// create a new render section if missing
if (nullableRenderSection == null)
if (nullableQuadNode != null)
{
LodRenderSection newRenderSection = new LodRenderSection(sectionPos);
rootNode.setValue(sectionPos, newRenderSection);
nullableRenderSection = newRenderSection;
}
// enable the render section
nullableRenderSection.loadRenderSourceAndEnableRendering(this.renderSourceProvider);
// determine if the section has loaded yet // TODO rename "tick" to check loading future or something?
nullableRenderSection.tick(this.level);
// delete/disable children
if (isSectionLoaded(nullableRenderSection))
{
nullableQuadNode.deleteAllChildren((renderSection) ->
// create a new render section if missing
if (nullableRenderSection == null)
{
if (renderSection != null)
LodRenderSection newRenderSection = new LodRenderSection(sectionPos);
rootNode.setValue(sectionPos, newRenderSection);
nullableRenderSection = newRenderSection;
}
//if (!areParentRenderSectionsLoaded(sectionPos)) // TODO not functional yet
{
// enable the render section
nullableRenderSection.loadRenderSourceAndEnableRendering(this.renderSourceProvider);
// determine if the section has loaded yet // TODO rename "tick" to check loading future or something?
nullableRenderSection.tick(this.level);
}
// delete/disable children
if (isSectionLoaded(nullableRenderSection))
{
nullableQuadNode.deleteAllChildren((renderSection) ->
{
renderSection.disableAndDisposeRendering();
}
});
if (renderSection != null)
{
renderSection.disableAndDisposeRendering();
}
});
}
}
}
}
}
}
}
/**
* Used to determine if a section can unload or not.
* If this returns true, that means there are child render sections ready to render,