From 4de5c287fc4aef06f0c233ec89de7d5a87223e8c Mon Sep 17 00:00:00 2001 From: James Seibel Date: Mon, 31 May 2021 15:29:26 -0500 Subject: [PATCH] Close #20 (allow the LOD distance to be changed in the config) --- .../com/backsun/lod/proxy/ClientProxy.java | 1 + .../com/backsun/lod/render/LodRender.java | 19 ++++++++----------- .../java/com/backsun/lod/util/LodConfig.java | 16 ++++++++++++++-- 3 files changed, 23 insertions(+), 13 deletions(-) diff --git a/src/main/java/com/backsun/lod/proxy/ClientProxy.java b/src/main/java/com/backsun/lod/proxy/ClientProxy.java index 1f52dcade..3de9087f6 100644 --- a/src/main/java/com/backsun/lod/proxy/ClientProxy.java +++ b/src/main/java/com/backsun/lod/proxy/ClientProxy.java @@ -93,6 +93,7 @@ public class ClientProxy // LodConfig.CLIENT.debugMode.set(false); // LodConfig.CLIENT.lodDetail.set(LodDetail.DOUBLE); // LodConfig.CLIENT.lodColorStyle.set(LodColorStyle.TOP); +// LodConfig.CLIENT.lodChunkRadiusMultiplier.set(12); // Note to self: // if "unspecified" shows up in the pie chart, it is diff --git a/src/main/java/com/backsun/lod/render/LodRender.java b/src/main/java/com/backsun/lod/render/LodRender.java index c87c55ccb..fbe394dbf 100644 --- a/src/main/java/com/backsun/lod/render/LodRender.java +++ b/src/main/java/com/backsun/lod/render/LodRender.java @@ -57,9 +57,6 @@ public class LodRender private GameRenderer gameRender; private IProfiler profiler; private float farPlaneDistance; - /** this is the radius of the LODs */ - private static final int LOD_CHUNK_DISTANCE_RADIUS = 6; - private ReflectionHandler reflectionHandler; @@ -167,7 +164,7 @@ public class LodRender farPlaneDistance = renderDistWidth * LodChunk.WIDTH; // set how big the LODs will be and how far they will go - int totalLength = (int) farPlaneDistance * LOD_CHUNK_DISTANCE_RADIUS * 2; + int totalLength = (int) farPlaneDistance * LodConfig.CLIENT.lodChunkRadiusMultiplier.get() * 2; int numbChunksWide = (totalLength / LodChunk.WIDTH); @@ -363,8 +360,8 @@ public class LodRender if (fogQuality == FogQuality.FANCY) { - RenderSystem.fogEnd(farPlaneDistance * 0.3f * LOD_CHUNK_DISTANCE_RADIUS); - RenderSystem.fogStart(farPlaneDistance * 0.35f * LOD_CHUNK_DISTANCE_RADIUS); + RenderSystem.fogEnd(farPlaneDistance * 1.75f); + RenderSystem.fogStart(farPlaneDistance * 1.95f); } else if(fogQuality == FogQuality.FAST) { @@ -380,13 +377,13 @@ public class LodRender { if (fogQuality == FogQuality.FANCY) { - RenderSystem.fogStart(farPlaneDistance * 0.78f * LOD_CHUNK_DISTANCE_RADIUS); - RenderSystem.fogEnd(farPlaneDistance * 1.0f * LOD_CHUNK_DISTANCE_RADIUS); + RenderSystem.fogStart(farPlaneDistance * 0.78f * LodConfig.CLIENT.lodChunkRadiusMultiplier.get()); + RenderSystem.fogEnd(farPlaneDistance * 1.0f * LodConfig.CLIENT.lodChunkRadiusMultiplier.get()); } else if(fogQuality == FogQuality.FAST) { - RenderSystem.fogStart(farPlaneDistance * 0.5f * LOD_CHUNK_DISTANCE_RADIUS); - RenderSystem.fogEnd(farPlaneDistance * 0.75f * LOD_CHUNK_DISTANCE_RADIUS); + RenderSystem.fogStart(farPlaneDistance * 0.5f * LodConfig.CLIENT.lodChunkRadiusMultiplier.get()); + RenderSystem.fogEnd(farPlaneDistance * 0.75f * LodConfig.CLIENT.lodChunkRadiusMultiplier.get()); } } @@ -466,7 +463,7 @@ public class LodRender getFov(partialTicks, true), (float)this.mc.getMainWindow().getFramebufferWidth() / (float)this.mc.getMainWindow().getFramebufferHeight(), 0.5F, - this.farPlaneDistance * LOD_CHUNK_DISTANCE_RADIUS * 2); + this.farPlaneDistance * LodConfig.CLIENT.lodChunkRadiusMultiplier.get() * 2); // add the screen space distortions projectionMatrix.mul(matrixStack.getLast().getMatrix()); diff --git a/src/main/java/com/backsun/lod/util/LodConfig.java b/src/main/java/com/backsun/lod/util/LodConfig.java index f77cd7ff5..f1ace7b4b 100644 --- a/src/main/java/com/backsun/lod/util/LodConfig.java +++ b/src/main/java/com/backsun/lod/util/LodConfig.java @@ -22,7 +22,7 @@ import net.minecraftforge.fml.config.ModConfig; /** * * @author James Seibel - * @version 05-05-2021 + * @version 05-31-2021 */ @Mod.EventBusSubscriber public class LodConfig @@ -38,9 +38,13 @@ public class LodConfig public ForgeConfigSpec.EnumValue lodTemplate; public ForgeConfigSpec.EnumValue lodDetail; - + public ForgeConfigSpec.EnumValue lodColorStyle; + /** this is multiplied by the default view distance + * to determine how far out to generate/render LODs */ + public ForgeConfigSpec.IntValue lodChunkRadiusMultiplier; + Client(ForgeConfigSpec.Builder builder) { builder.comment(ModInfo.MODNAME + " configuration settings").push("client"); @@ -90,6 +94,14 @@ public class LodConfig + " " + LodColorStyle.INDIVIDUAL_SIDES.toString() + ": For each side of the LOD use the color corresponding to that side. ") .defineEnum("lodColorStyle", LodColorStyle.TOP); + lodChunkRadiusMultiplier = builder + .comment("\n" + + " This is multiplied by the default view distance \n" + + " to determine how far out to generate/render LODs. \n" + + " A value of 2 means that there is 1 render distance worth \n" + + " of LODs in each cardinal direction.") + .defineInRange("lodChunkRadiusMultiplier", 6, 2, 1023); + builder.pop(); } }