From 58378ffcbaa1a3bc5df51f877122c90f534e2b90 Mon Sep 17 00:00:00 2001 From: James Seibel Date: Wed, 30 Aug 2023 07:43:59 -0500 Subject: [PATCH] Fix disappearing LOD sections Its still a bit of a duck tape solution, but should be good enough for now --- .../core/render/LodRenderSection.java | 48 ++++++++----------- 1 file changed, 20 insertions(+), 28 deletions(-) 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 6a3f3322a..2778e0286 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 @@ -103,23 +103,7 @@ public class LodRenderSection implements IDebugRenderable // rendering // //===========// - public void enableRendering() - { - // FIXME this is a temporary fix for sections not building the first time, - // this may cause LODs to flash when first loading - // Problem reproduction steps: - // 1. connect to a multiplayer server - // 2. enter spectator - // 3. fly in one direction until section detail levels 7 and 8 appear - // 4. empty LODs should appear - if (!this.isRenderingEnabled) - { - // this only needs to be called when first enabling the section - //this.markBufferDirty(); - } - - this.isRenderingEnabled = true; - } + public void enableRendering() { this.isRenderingEnabled = true; } public void disableRendering() { this.isRenderingEnabled = false; } @@ -141,6 +125,13 @@ public class LodRenderSection implements IDebugRenderable // don't re-load or double load the render source if (this.renderSource != null || this.renderSourceLoadFuture != null) { + // since the render source has been loaded, make sure the render buffers are populated + // FIXME this is a duck tape solution, since the renderBufferRef should be populated elsewhere, but this does fix empty LODs when moving around the world + if (this.activeRenderBufferRef.get() == null) + { + this.markBufferDirty(); // empty LOD fix #3, all solutions revolve around markBufferDirty() + } + return; } @@ -223,16 +214,17 @@ public class LodRenderSection implements IDebugRenderable return this.renderSource != null && ( - ( - // if true; either this section represents empty chunks or un-generated chunks. - // Either way, there isn't any data to render, but this should be considered "loaded" - this.renderSource.isEmpty() - ) - || - ( - // check if the buffers have been loaded - this.activeRenderBufferRef.get() != null - ) + ( + // if true; either this section represents empty chunks or un-generated chunks. + // Either way, there isn't any data to render, but this should be considered "loaded" + this.renderSource.isEmpty() + ) + || + ( + // check if the buffers have been loaded + this.activeRenderBufferRef.get() != null // in the case of missing sections, this is probably null + && this.lastSwapLocalVersion != -1 + ) ); } @@ -283,7 +275,7 @@ public class LodRenderSection implements IDebugRenderable } /** @return true if this section is loaded and set to render */ - public boolean canBuildBuffer() { return this.renderSource != null && this.buildRenderBufferFuture == null && !this.renderSource.isEmpty() && this.isBufferOutdated(); } + public boolean canBuildBuffer() { return this.renderSourceLoadFuture == null && this.renderSource != null && this.buildRenderBufferFuture == null && !this.renderSource.isEmpty() && this.isBufferOutdated(); } private boolean isBufferOutdated() { return this.neighborUpdated || this.renderSource.localVersion.get() != this.lastSwapLocalVersion; } /** @return true if this section is loaded and set to render */