diff --git a/core/src/main/java/com/seibel/distanthorizons/core/render/LodQuadTree.java b/core/src/main/java/com/seibel/distanthorizons/core/render/LodQuadTree.java index b07dc4f93..c71bd2c03 100644 --- a/core/src/main/java/com/seibel/distanthorizons/core/render/LodQuadTree.java +++ b/core/src/main/java/com/seibel/distanthorizons/core/render/LodQuadTree.java @@ -343,7 +343,11 @@ public class LodQuadTree extends QuadTree implements IDebugRen // prepare this section for rendering - if (!renderSection.gpuUploadInProgress() && renderSection.renderBuffer == null) + if (!renderSection.gpuUploadInProgress() + && renderSection.renderBuffer == null + // this check is specifically for N-sized world generators where the higher quality + // data source may not exist yet + && renderSection.getFullDataSourceExists()) { nodesNeedingLoading.add(renderSection); } @@ -417,20 +421,25 @@ public class LodQuadTree extends QuadTree implements IDebugRen { // the section only needs to be updated if a buffer is currently present LodRenderSection renderSection = this.getValue(pos); - if (renderSection != null - && renderSection.canRender()) + if (renderSection != null) { - if (!renderSection.gpuUploadInProgress()) + // this data source may now exist + renderSection.updateFullDataSourceExists(); + + if (renderSection.canRender()) { - renderSection.uploadRenderDataToGpuAsync(); - } - else - { - // if a section is already loading we need to wait to trigger it again - // if we don't trigger it again the LOD will be out of date - // and may be invisible/missing - positionsToRequeue.add(pos); - break; + if (!renderSection.gpuUploadInProgress()) + { + renderSection.uploadRenderDataToGpuAsync(); + } + else + { + // if a section is already loading we need to wait to trigger it again + // if we don't trigger it again the LOD will be out of date + // and may be invisible/missing + positionsToRequeue.add(pos); + break; + } } } } @@ -716,4 +725,6 @@ public class LodQuadTree extends QuadTree implements IDebugRen LOGGER.info("Finished shutting down " + LodQuadTree.class.getSimpleName()); } + + } diff --git a/core/src/main/java/com/seibel/distanthorizons/core/render/LodRenderSection.java b/core/src/main/java/com/seibel/distanthorizons/core/render/LodRenderSection.java index 04737d943..334cba2cc 100644 --- a/core/src/main/java/com/seibel/distanthorizons/core/render/LodRenderSection.java +++ b/core/src/main/java/com/seibel/distanthorizons/core/render/LodRenderSection.java @@ -104,6 +104,9 @@ public class LodRenderSection implements IDebugRenderable, AutoCloseable /** should be an empty array if no positions need to be generated */ private LongArrayList missingGenerationPos = null; + private boolean checkedIfFullDataSourceExists = false; + private boolean fullDataSourceExists = false; + //=============// @@ -429,6 +432,28 @@ public class LodRenderSection implements IDebugRenderable, AutoCloseable //=================================// public boolean isFullyGenerated() { return this.missingPositionsCalculated && this.missingGenerationPos.isEmpty(); } + /** Returns true if an LOD exists, regardless of what data is in it */ + public boolean getFullDataSourceExists() + { + if (!this.checkedIfFullDataSourceExists) + { + this.fullDataSourceExists = this.fullDataSourceProvider.repo.existsWithKey(this.pos); + this.checkedIfFullDataSourceExists = true; + } + + return this.fullDataSourceExists; + } + public void updateFullDataSourceExists() + { + // we don't have any ability to remove LODs so we only + // need to check if an LOD was previously missing + if (!this.fullDataSourceExists) + { + this.checkedIfFullDataSourceExists = false; + this.getFullDataSourceExists(); + } + } + public boolean missingPositionsCalculated() { return this.missingPositionsCalculated; } public int ungeneratedPositionCount() { return (this.missingGenerationPos != null) ? this.missingGenerationPos.size() : 0; }