Add config options for debug wireframe rendering

This commit is contained in:
James Seibel
2023-09-16 10:10:11 -05:00
parent b1c07c6204
commit b4fe07643e
12 changed files with 196 additions and 66 deletions
@@ -46,6 +46,6 @@ public class DhApiDebuggingConfig implements IDhApiDebuggingConfig
{ return new DhApiConfigValue<Boolean, Boolean>(Config.Client.Advanced.Debugging.lodOnlyMode); }
public IDhApiConfigValue<Boolean> debugWireframeRendering()
{ return new DhApiConfigValue<Boolean, Boolean>(Config.Client.Advanced.Debugging.debugWireframeRendering); }
{ return new DhApiConfigValue<Boolean, Boolean>(Config.Client.Advanced.Debugging.DebugWireframe.enableRendering); }
}
@@ -1120,16 +1120,6 @@ public class Config
+ " Mod compatibility is not guaranteed.")
.build();
public static ConfigEntry<Boolean> debugWireframeRendering = new ConfigEntry.Builder<Boolean>()
.set(false)
.comment(""
+ "If enabled, various wireframes for debugging internal functions will be drawn. \n"
+ "\n"
+ "NOTE: There WILL be performance hit! \n"
+ " Additionally, only stuff that's loaded after you enable this \n"
+ " will render their debug wireframes.")
.build();
public static ConfigEntry<Boolean> enableWhiteWorld = new ConfigEntry.Builder<Boolean>()
.set(false)
.comment(""
@@ -1197,12 +1187,57 @@ public class Config
public static ConfigCategory debugWireframe = new ConfigCategory.Builder()
.set(DebugWireframe.class)
.build();
public static class DebugWireframe
{
public static ConfigEntry<Boolean> enableRendering = new ConfigEntry.Builder<Boolean>()
.set(false)
.comment(""
+ "If enabled, various wireframes for debugging internal functions will be drawn. \n"
+ "\n"
+ "NOTE: There WILL be performance hit! \n"
+ " Additionally, only stuff that's loaded after you enable this \n"
+ " will render their debug wireframes.")
.build();
public static ConfigEntry<Boolean> showWorldGenQueue = new ConfigEntry.Builder<Boolean>()
.set(false)
.comment("Render queued world gen tasks?")
.build();
public static ConfigEntry<Boolean> showRenderSectionStatus = new ConfigEntry.Builder<Boolean>()
.set(false)
.comment("Render LOD section status?")
.build();
public static ConfigEntry<Boolean> showFullDataFileStatus = new ConfigEntry.Builder<Boolean>()
.set(false)
.comment("Render full data file status?")
.build();
public static ConfigEntry<Boolean> showFullDataFileSampling = new ConfigEntry.Builder<Boolean>()
.set(false)
.comment("Render full data file sampling progress?")
.build();
public static ConfigEntry<Boolean> showRenderDataFileStatus = new ConfigEntry.Builder<Boolean>()
.set(false)
.comment("Render render data file status?")
.build();
}
// can be set to public inorder to show in the config file and UI
public static ConfigCategory exampleConfigScreen = new ConfigCategory.Builder()
.set(ExampleConfigScreen.class)
.build();
/** This class is used to debug the different features of the config GUI */
// FIXME: WARNING: Some of the options in this class dont get show n in the default UI
// This will throw a warning when opened in the default ui to tell you about it not showing
@@ -76,14 +76,16 @@ public class ColumnRenderBuffer extends AbstractRenderBuffer implements IDebugRe
DebugRenderer.register(this);
}
public void debugRender(DebugRenderer r)
@Override
public void debugRender(DebugRenderer renderer)
{
if (closed || vbos == null)
if (this.closed || this.vbos == null)
{
return;
}
Color c = Color.green;
//r.renderBox(debugPos, 128, 128, 0.05f, c);
//renderer.renderBox(debugPos, 128, 128, 0.05f, c);
}
@@ -32,12 +32,14 @@ import com.seibel.distanthorizons.core.logging.DhLoggerBuilder;
import com.seibel.distanthorizons.core.pos.DhLodPos;
import com.seibel.distanthorizons.core.pos.DhSectionPos;
import com.seibel.distanthorizons.core.dataObjects.fullData.sources.CompleteFullDataSource;
import com.seibel.distanthorizons.core.render.renderer.DebugRenderer;
import com.seibel.distanthorizons.core.util.MetaFileScanUtil;
import com.seibel.distanthorizons.core.util.FileUtil;
import com.seibel.distanthorizons.core.util.LodUtil;
import com.seibel.distanthorizons.core.util.ThreadUtil;
import org.apache.logging.log4j.Logger;
import java.awt.*;
import java.io.File;
import java.io.IOException;
import java.util.*;
@@ -377,6 +379,14 @@ public class FullDataFileHandler implements IFullDataSourceProvider
/** populates the given data source using the given array of files */
protected CompletableFuture<IIncompleteFullDataSource> sampleFromFileArray(IIncompleteFullDataSource recipientFullDataSource, ArrayList<FullDataMetaFile> existingFiles)
{
boolean showFullDataFileSampling = Config.Client.Advanced.Debugging.DebugWireframe.showFullDataFileSampling.get();
if (showFullDataFileSampling)
{
DebugRenderer.makeParticle(new DebugRenderer.BoxParticle(
new DebugRenderer.Box(recipientFullDataSource.getSectionPos(), 64f, 72f, 0.03f, Color.MAGENTA),
0.2, 32f));
}
// read in the existing data
final ArrayList<CompletableFuture<Void>> loadDataFutures = new ArrayList<>(existingFiles.size());
for (FullDataMetaFile existingFile : existingFiles)
@@ -390,6 +400,13 @@ public class FullDataFileHandler implements IFullDataSourceProvider
return;
}
if (showFullDataFileSampling)
{
DebugRenderer.makeParticle(new DebugRenderer.BoxParticle(
new DebugRenderer.Box(recipientFullDataSource.getSectionPos(), 64f, 72f, 0.03f, Color.MAGENTA.darker()),
0.2, 32f));
}
//LOGGER.info("Merging data from {} into {}", data.getSectionPos(), pos);
recipientFullDataSource.sampleFrom(existingFullDataSource);
})
@@ -431,21 +431,32 @@ public class FullDataMetaFile extends AbstractMetaDataContainerFile implements I
@Override
public void debugRender(DebugRenderer debugRenderer)
{
if (this.pos.getDetailLevel() > DhSectionPos.SECTION_MINIMUM_DETAIL_LEVEL)
boolean showFullDataFileStatus = Config.Client.Advanced.Debugging.DebugWireframe.showFullDataFileStatus.get();
if (!showFullDataFileStatus)
{
return;
}
else if (this.pos.getDetailLevel() > DhSectionPos.SECTION_MINIMUM_DETAIL_LEVEL)
{
return;
}
IFullDataSource cached = this.cachedFullDataSourceRef.get();
if (this.needsUpdate)
{
debugRenderer.renderBox(new DebugRenderer.Box(this.pos, 80f, 96f, 0.05f, Color.red));
}
IFullDataSource cachedDataSource = this.cachedFullDataSourceRef.get();
boolean needsUpdate = !this.writeQueueRef.get().queue.isEmpty() || this.needsUpdate;
// determine the color
Color color = Color.black;
if (cached != null)
if (cachedDataSource != null)
{
if (cached instanceof CompleteFullDataSource)
if (cachedDataSource instanceof CompleteFullDataSource)
{
color = Color.GREEN;
}
@@ -453,7 +464,6 @@ public class FullDataMetaFile extends AbstractMetaDataContainerFile implements I
{
color = Color.YELLOW;
}
}
else if (this.dataSourceLoadFutureRef.get() != null)
{
@@ -463,9 +473,7 @@ public class FullDataMetaFile extends AbstractMetaDataContainerFile implements I
{
color = Color.RED;
}
boolean needsUpdate = !this.writeQueueRef.get().queue.isEmpty() || this.needsUpdate;
if (needsUpdate)
else if (needsUpdate)
{
color = color.darker().darker();
}
@@ -555,11 +563,24 @@ public class FullDataMetaFile extends AbstractMetaDataContainerFile implements I
new DataObjSoftTracker(this, fullDataSource);
}
if (this.pos.getDetailLevel() == DhSectionPos.SECTION_MINIMUM_DETAIL_LEVEL)
boolean showFullDataFileStatus = Config.Client.Advanced.Debugging.DebugWireframe.showFullDataFileStatus.get();
boolean showFullDataFileSampling = Config.Client.Advanced.Debugging.DebugWireframe.showFullDataFileSampling.get();
if (showFullDataFileStatus || showFullDataFileSampling)
{
Color color;
if (this.pos.getDetailLevel() == DhSectionPos.SECTION_MINIMUM_DETAIL_LEVEL)
{
color = Color.GREEN;
}
else
{
color = Color.GREEN.darker().darker();
}
DebugRenderer.makeParticle(new DebugRenderer.BoxParticle(
new DebugRenderer.Box(this.pos, 64f, 72f, 0.03f, Color.green.darker()),
0.2, 32f));
new DebugRenderer.Box(this.pos, 64f, 72f, 0.03f, color),
0.2, 32f));
}
@@ -186,7 +186,8 @@ public class GeneratedFullDataFileHandler extends FullDataFileHandler
{
// There are other data source files to sample from.
this.makeFiles(missingPositions, existingFiles);
return this.sampleFromFileArray(data, existingFiles).thenApply(this::tryPromoteDataSource)
return this.sampleFromFileArray(data, existingFiles)
.thenApply(this::tryPromoteDataSource)
.exceptionally((e) ->
{
this.removeCorruptedFile(pos, file, e);
@@ -66,7 +66,7 @@ public class RenderDataMetaFile extends AbstractMetaDataContainerFile implements
* When clearing, don't set to null, instead create a SoftReference containing null.
* This makes null checks simpler.
*/
private DataSourceReferenceTracker.RenderDataSourceSoftRef cachedRenderDataSource = new DataSourceReferenceTracker.RenderDataSourceSoftRef(this, null);
private DataSourceReferenceTracker.RenderDataSourceSoftRef cachedRenderDataSourceRef = new DataSourceReferenceTracker.RenderDataSourceSoftRef(this, null);
private final AtomicReference<CompletableFuture<ColumnRenderSource>> renderSourceLoadFutureRef = new AtomicReference<>(null);
private final IDhClientLevel clientLevel;
@@ -148,9 +148,15 @@ public class RenderDataMetaFile extends AbstractMetaDataContainerFile implements
renderSourceLoadFuture.thenAccept((renderSource) ->
{
boolean dataUpdated = renderSource.updateWithChunkData(chunkDataView, clientLevel);
boolean showRenderDataFileStatus = Config.Client.Advanced.Debugging.DebugWireframe.showRenderDataFileStatus.get();
if (!showRenderDataFileStatus)
{
return;
}
// add a debug renderer
boolean dataUpdated = renderSource.updateWithChunkData(chunkDataView, this.clientLevel);
float offset = new Random(System.nanoTime() ^ Thread.currentThread().getId()).nextFloat() * 16f;
Color debugColor = dataUpdated ? Color.blue : Color.red;
DebugRenderer.makeParticle(
@@ -208,7 +214,7 @@ public class RenderDataMetaFile extends AbstractMetaDataContainerFile implements
this.updateRenderCacheAsync(newColumnRenderSource).whenComplete((voidObj, ex) ->
{
this.cachedRenderDataSource = new DataSourceReferenceTracker.RenderDataSourceSoftRef(this, newColumnRenderSource);
this.cachedRenderDataSourceRef = new DataSourceReferenceTracker.RenderDataSourceSoftRef(this, newColumnRenderSource);
this.renderSourceLoadFutureRef.set(null);
getSourceFuture.complete(newColumnRenderSource);
@@ -256,7 +262,7 @@ public class RenderDataMetaFile extends AbstractMetaDataContainerFile implements
this.renderSourceLoadFutureRef.set(null);
this.cachedRenderDataSource = new DataSourceReferenceTracker.RenderDataSourceSoftRef(this, renderSource);
this.cachedRenderDataSourceRef = new DataSourceReferenceTracker.RenderDataSourceSoftRef(this, renderSource);
getSourceFuture.complete(renderSource);
});
}
@@ -438,14 +444,23 @@ public class RenderDataMetaFile extends AbstractMetaDataContainerFile implements
@Override
public void debugRender(DebugRenderer debugRenderer)
{
Color color = Color.black;
ColumnRenderSource cached = this.cachedRenderDataSource.get();
if (cached != null)
boolean showRenderDataFileStatus = Config.Client.Advanced.Debugging.DebugWireframe.showRenderDataFileStatus.get();
if (!showRenderDataFileStatus)
{
color = Color.GREEN;
return;
}
else if (this.renderSourceLoadFutureRef.get() != null)
if (this.cachedRenderDataSourceRef.get() != null)
{
return;
//color = Color.GREEN;
}
// determine the color
Color color = Color.black;
if (this.renderSourceLoadFutureRef.get() != null)
{
color = Color.BLUE;
}
@@ -476,7 +491,7 @@ public class RenderDataMetaFile extends AbstractMetaDataContainerFile implements
// attempt to get the cached render source
ColumnRenderSource cachedRenderDataSource = this.cachedRenderDataSource.get();
ColumnRenderSource cachedRenderDataSource = this.cachedRenderDataSourceRef.get();
if (cachedRenderDataSource == null)
{
// no cached data exists and no one is trying to load it
@@ -720,16 +720,17 @@ public class WorldGenerationQueue implements IWorldGenerationQueue, IDebugRender
//=======//
@Override
public void debugRender(DebugRenderer r)
public void debugRender(DebugRenderer renderer)
{
//if (true) return;
waitingTasks.keySet().forEach((pos) -> {
//DhLodPos pos = t.pos;
r.renderBox(new DebugRenderer.Box(pos, -32f, 64f, 0.05f, Color.blue));
});
this.inProgressGenTasksByLodPos.forEach((pos, t) -> {
r.renderBox(new DebugRenderer.Box(pos, -32f, 64f, 0.05f, Color.red));
});
boolean showWorldGenQueue = Config.Client.Advanced.Debugging.DebugWireframe.showWorldGenQueue.get();
if (!showWorldGenQueue)
{
return;
}
this.waitingTasks.keySet().forEach((pos) -> { renderer.renderBox(new DebugRenderer.Box(pos, -32f, 64f, 0.05f, Color.blue)); });
this.inProgressGenTasksByLodPos.forEach((pos, t) -> { renderer.renderBox(new DebugRenderer.Box(pos, -32f, 64f, 0.05f, Color.red)); });
}
}
@@ -19,6 +19,7 @@
package com.seibel.distanthorizons.core.render;
import com.seibel.distanthorizons.core.config.Config;
import com.seibel.distanthorizons.core.dataObjects.render.ColumnRenderSource;
import com.seibel.distanthorizons.core.dataObjects.render.bufferBuilding.ColumnRenderBufferBuilder;
import com.seibel.distanthorizons.core.enums.EDhDirection;
@@ -97,20 +98,40 @@ public class LodRenderSection implements IDebugRenderable
DebugRenderer.register(this);
}
@Override
public void debugRender(DebugRenderer debugRenderer)
{
boolean showRenderSectionStatus = Config.Client.Advanced.Debugging.DebugWireframe.showRenderSectionStatus.get();
if (!showRenderSectionStatus)
{
return;
}
Color color = Color.red;
if (this.renderSourceProvider == null) color = Color.black;
if (this.renderSourceLoadFuture != null) color = Color.yellow;
if (renderSource != null)
if (this.renderSourceProvider == null)
{
color = Color.black;
}
else if (this.renderSourceLoadFuture != null)
{
color = Color.yellow;
}
else if (this.renderSource != null)
{
color = Color.blue;
if (buildRenderBufferFuture != null) color = Color.magenta;
if (canRenderNow()) color = Color.cyan;
if (canRenderNow() && isRenderingEnabled) color = Color.green;
if (this.buildRenderBufferFuture != null)
{
color = Color.magenta;
}
else if (this.canRenderNow())
{
color = Color.cyan;
}
else if (this.canRenderNow() && this.isRenderingEnabled)
{
color = Color.green;
}
}
debugRenderer.renderBox(new DebugRenderer.Box(this.pos, 400, 8f, Objects.hashCode(this), 0.1f, color));
@@ -160,7 +181,8 @@ public class LodRenderSection implements IDebugRenderable
public void reload(ILodRenderSourceProvider renderDataProvider)
{
// debug rendering
if (this.pos.getDetailLevel() == DhSectionPos.SECTION_MINIMUM_DETAIL_LEVEL)
boolean showRenderSectionStatus = Config.Client.Advanced.Debugging.DebugWireframe.showRenderSectionStatus.get();
if (showRenderSectionStatus && this.pos.getDetailLevel() == DhSectionPos.SECTION_MINIMUM_DETAIL_LEVEL)
{
DebugRenderer.makeParticle(
new DebugRenderer.BoxParticle(
@@ -324,7 +346,8 @@ public class LodRenderSection implements IDebugRenderable
if (this.canBuildBuffer())
{
// debug
if (this.pos.getDetailLevel() == DhSectionPos.SECTION_MINIMUM_DETAIL_LEVEL)
boolean showRenderSectionStatus = Config.Client.Advanced.Debugging.DebugWireframe.showRenderSectionStatus.get();
if (showRenderSectionStatus && this.pos.getDetailLevel() == DhSectionPos.SECTION_MINIMUM_DETAIL_LEVEL)
{
DebugRenderer.makeParticle(
new DebugRenderer.BoxParticle(
@@ -254,7 +254,7 @@ public class DebugRenderer
public static void makeParticle(BoxParticle particle)
{
if (INSTANCE == null) return;
if (!Config.Client.Advanced.Debugging.debugWireframeRendering.get()) return;
if (!Config.Client.Advanced.Debugging.DebugWireframe.enableRendering.get()) return;
INSTANCE.particles.add(particle);
}
@@ -317,7 +317,7 @@ public class DebugRenderer
public void addRenderer(IDebugRenderable r)
{
if (!Config.Client.Advanced.Debugging.debugWireframeRendering.get()) return;
if (!Config.Client.Advanced.Debugging.DebugWireframe.enableRendering.get()) return;
synchronized (renderers)
{
renderers.add(new WeakReference<>(r));
@@ -350,7 +350,7 @@ public class LodRenderer
this.shaderProgram.unbind();
if (Config.Client.Advanced.Debugging.debugWireframeRendering.get())
if (Config.Client.Advanced.Debugging.DebugWireframe.enableRendering.get())
{
profiler.popPush("Debug wireframes");
// Note: this can be very slow if a lot of boxes are being rendered
@@ -405,10 +405,6 @@
"Only Render LODs",
"distanthorizons.config.client.advanced.debugging.lodOnlyMode.@tooltip":
"If enabled this will disable (most) vanilla Minecraft rendering. \n\nNOTE: Do not report any issues when this mode is on! \nThis setting is only for fun and debugging. \nMod compatibility is not guaranteed.",
"distanthorizons.config.client.advanced.debugging.debugWireframeRendering":
"Enable Debug Wireframe Rendering",
"distanthorizons.config.client.advanced.debugging.debugWireframeRendering.@tooltip":
"If enabled, various wireframes for debugging internal functions will be drawn.",
"distanthorizons.config.client.advanced.debugging.enableWhiteWorld":
"Enable white world",
"distanthorizons.config.client.advanced.debugging.enableWhiteWorld.@tooltip":
@@ -518,7 +514,26 @@
"Linkable test",
"distanthorizons.config.client.advanced.debugging.exampleConfigScreen.linkableTest.@tooltip":
"The value of this should be the same as in Category Test",
"distanthorizons.config.client.advanced.debugging.debugWireframe":
"Debug Wireframe",
"distanthorizons.config.client.advanced.debugging.debugWireframe.enableRendering":
"Enable Debug Wireframe Rendering",
"distanthorizons.config.client.advanced.debugging.debugWireframe.enableRendering.@tooltip":
"If enabled, various wireframes for debugging internal functions will be drawn.",
"distanthorizons.config.client.advanced.debugging.debugWireframe.showWorldGenQueue":
"Show World Gen Queue",
"distanthorizons.config.client.advanced.debugging.debugWireframe.showRenderSectionStatus":
"Show Render Section Status",
"distanthorizons.config.client.advanced.debugging.debugWireframe.showFullDataFileStatus":
"Show Full Data file Status",
"distanthorizons.config.client.advanced.debugging.debugWireframe.showFullDataFileSampling":
"Show Full Data file Sampling",
"distanthorizons.config.client.advanced.debugging.debugWireframe.showRenderDataFileStatus":
"Show Render Data file Status",
"distanthorizons.config.client.resetSettingsConfirmation":
"Reset All Settings?",