From 39778fe94433a21f8f32fcb5697ebf2a6e7c0fbf Mon Sep 17 00:00:00 2001 From: James Seibel Date: Sat, 8 Apr 2023 13:16:50 -0500 Subject: [PATCH] Fix LodQuadTree out of bounds error --- .../seibel/lod/core/render/LodQuadTree.java | 60 +++++++++---------- 1 file changed, 29 insertions(+), 31 deletions(-) diff --git a/core/src/main/java/com/seibel/lod/core/render/LodQuadTree.java b/core/src/main/java/com/seibel/lod/core/render/LodQuadTree.java index ce886e9f6..3e6fe1f22 100644 --- a/core/src/main/java/com/seibel/lod/core/render/LodQuadTree.java +++ b/core/src/main/java/com/seibel/lod/core/render/LodQuadTree.java @@ -253,50 +253,48 @@ public class LodQuadTree extends QuadTree 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,