diff --git a/api/src/main/java/com/seibel/lod/api/enums/config/EVerticalQuality.java b/api/src/main/java/com/seibel/lod/api/enums/config/EVerticalQuality.java
index 4be9c462c..5ceeeb522 100644
--- a/api/src/main/java/com/seibel/lod/api/enums/config/EVerticalQuality.java
+++ b/api/src/main/java/com/seibel/lod/api/enums/config/EVerticalQuality.java
@@ -20,8 +20,10 @@
package com.seibel.lod.api.enums.config;
/**
- * heightmap
- * multi_lod
+ * LOW
+ * MEDIUM
+ * HIGH
+ * ULTRA
*
* @author Leonardo Amato
* @version 2023-2-5
@@ -34,6 +36,7 @@ public enum EVerticalQuality
HIGH(new int[] { 8, 6, 4, 2, 2, 2, 2, 1, 1, 1, 1 }),
ULTRA(new int[] { 16, 8, 4, 2, 2, 2, 2, 1, 1, 1, 1 });
+ /** represents how many LODs can be rendered in a single vertical slice */
public final int[] maxVerticalData;
@@ -42,40 +45,6 @@ public enum EVerticalQuality
- /** returns null if out of range */
- public static EVerticalQuality previous(EVerticalQuality mode)
- {
- switch (mode)
- {
- case ULTRA:
- return EVerticalQuality.HIGH;
- case HIGH:
- return EVerticalQuality.MEDIUM;
- case MEDIUM:
- return EVerticalQuality.LOW;
- case LOW:
- default:
- return null;
- }
- }
-
- /** returns null if out of range */
- public static EVerticalQuality next(EVerticalQuality mode)
- {
- switch (mode)
- {
- case MEDIUM:
- return EVerticalQuality.HIGH;
- case LOW:
- return EVerticalQuality.MEDIUM;
- case HIGH:
- return EVerticalQuality.ULTRA;
- case ULTRA:
- default:
- return null;
- }
- }
-
public int calculateMaxVerticalData(byte dataDetail)
{
if (dataDetail >= this.maxVerticalData.length)
diff --git a/core/src/main/java/com/seibel/lod/core/config/Config.java b/core/src/main/java/com/seibel/lod/core/config/Config.java
index ab394e8ac..161386a55 100644
--- a/core/src/main/java/com/seibel/lod/core/config/Config.java
+++ b/core/src/main/java/com/seibel/lod/core/config/Config.java
@@ -104,6 +104,7 @@ public class Config
+ "\n"
+ "Lowest Quality: " + EHorizontalResolution.CHUNK + "\n"
+ "Highest Quality: " + EHorizontalResolution.BLOCK)
+ .addListener(RenderCacheConfigEventHandler.INSTANCE)
.build();
public static ConfigEntry lodChunkRenderDistance = new ConfigEntry.Builder()
diff --git a/core/src/main/java/com/seibel/lod/core/config/eventHandlers/RenderCacheConfigEventHandler.java b/core/src/main/java/com/seibel/lod/core/config/eventHandlers/RenderCacheConfigEventHandler.java
index 427140940..74b3af9d0 100644
--- a/core/src/main/java/com/seibel/lod/core/config/eventHandlers/RenderCacheConfigEventHandler.java
+++ b/core/src/main/java/com/seibel/lod/core/config/eventHandlers/RenderCacheConfigEventHandler.java
@@ -1,9 +1,11 @@
package com.seibel.lod.core.config.eventHandlers;
import com.seibel.lod.api.DhApiMain;
+import com.seibel.lod.api.enums.config.EHorizontalResolution;
import com.seibel.lod.api.enums.config.EVerticalQuality;
import com.seibel.lod.core.config.Config;
import com.seibel.lod.core.config.types.ConfigEntry;
+import com.seibel.lod.core.util.DetailDistanceUtil;
/**
* Listens to the config and will automatically
@@ -18,7 +20,9 @@ public class RenderCacheConfigEventHandler implements ConfigEntry.Listener
{
public static RenderCacheConfigEventHandler INSTANCE = new RenderCacheConfigEventHandler();
+ // previous values used to check if a watched setting was actually modified
private EVerticalQuality previousVerticalQualitySetting = null;
+ private EHorizontalResolution previousHorizontalResolution = null;
@@ -29,19 +33,32 @@ public class RenderCacheConfigEventHandler implements ConfigEntry.Listener
@Override
public void onModify()
- {
- // check if the vertical quality changed
+ {
+ // confirm a setting was actually changed
+ boolean refreshRenderData = false;
+
+
EVerticalQuality newVerticalQuality = Config.Client.Graphics.Quality.verticalQuality.get();
if (this.previousVerticalQualitySetting != newVerticalQuality)
{
- // TODO add a cancelable delay between the method being fired and any data getting cleared,
- // this would be to prevent clearing the same data 5 times in rapid succession
- // when the user is switching through settings in the config UI
-
- if (DhApiMain.Delayed.renderProxy.clearRenderDataCache().success)
- {
- this.previousVerticalQualitySetting = newVerticalQuality;
- }
+ this.previousVerticalQualitySetting = newVerticalQuality;
+ refreshRenderData = true;
+ }
+
+ EHorizontalResolution newHorizontalResolution = Config.Client.Graphics.Quality.drawResolution.get();
+ if (this.previousHorizontalResolution != newHorizontalResolution)
+ {
+ this.previousHorizontalResolution = newHorizontalResolution;
+ refreshRenderData = true;
+ }
+
+
+
+ if (refreshRenderData)
+ {
+ // TODO add a timeout to prevent rapidly changing settings causing the render data thrashing.
+ DetailDistanceUtil.minDetail = newHorizontalResolution.detailLevel;
+ DhApiMain.Delayed.renderProxy.clearRenderDataCache();
}
}
diff --git a/core/src/main/java/com/seibel/lod/core/util/DetailDistanceUtil.java b/core/src/main/java/com/seibel/lod/core/util/DetailDistanceUtil.java
index 782501a95..03e9d4a83 100644
--- a/core/src/main/java/com/seibel/lod/core/util/DetailDistanceUtil.java
+++ b/core/src/main/java/com/seibel/lod/core/util/DetailDistanceUtil.java
@@ -31,7 +31,8 @@ import com.seibel.lod.coreapi.util.MathUtil;
@Deprecated
public class DetailDistanceUtil
{
- private static byte minDetail = Config.Client.Graphics.Quality.drawResolution.get().detailLevel;
+ public static byte minDetail = Config.Client.Graphics.Quality.drawResolution.get().detailLevel;
+
private static final byte maxDetail = Byte.MAX_VALUE;
private static final double minDistance = 0;
private static double distanceUnit = 16 * Config.Client.Graphics.Quality.horizontalScale.get();
@@ -93,12 +94,4 @@ public class DetailDistanceUtil
return baseInverseFunction(distance);
}
- // NOTE: The recent LodWorldGenerator changes assumes that this value doesn't change with 'detail'.
- // If this is changed, LodWorldGenerator needs to be fixed!
- /*
- public static DistanceGenerationMode getDistanceGenerationMode(int detail)
- {
- return CONFIG.client().worldGenerator().getDistanceGenerationMode();
- }*/
-
}