From 98cbc30709049316eabcc15d13b84e7e44c775dd Mon Sep 17 00:00:00 2001 From: Leonardo Date: Wed, 25 Aug 2021 16:12:18 +0200 Subject: [PATCH] Small changes to how number of thread is chosen and returned to old LINEAR system --- .../worldGeneration/LodNodeGenWorker.java | 4 ++-- .../worldGeneration/LodWorldGenerator.java | 12 +++++++----- .../java/com/seibel/lod/handlers/LodConfig.java | 10 +++++----- .../java/com/seibel/lod/render/LodRenderer.java | 2 +- .../com/seibel/lod/util/DetailDistanceUtil.java | 17 +++-------------- 5 files changed, 18 insertions(+), 27 deletions(-) diff --git a/src/main/java/com/seibel/lod/builders/worldGeneration/LodNodeGenWorker.java b/src/main/java/com/seibel/lod/builders/worldGeneration/LodNodeGenWorker.java index ac76b929c..9b90718f4 100644 --- a/src/main/java/com/seibel/lod/builders/worldGeneration/LodNodeGenWorker.java +++ b/src/main/java/com/seibel/lod/builders/worldGeneration/LodNodeGenWorker.java @@ -74,7 +74,7 @@ import net.minecraftforge.common.WorldWorkerManager.IWorker; */ public class LodNodeGenWorker implements IWorker { - public static ExecutorService genThreads = Executors.newFixedThreadPool(LodConfig.CLIENT.numberOfWorldGenerationThreads.get(), new LodThreadFactory(LodNodeGenWorker.class.getSimpleName())); + public static ExecutorService genThreads = Executors.newFixedThreadPool(Runtime.getRuntime().availableProcessors(), new LodThreadFactory(LodNodeGenWorker.class.getSimpleName())); private boolean threadStarted = false; private LodChunkGenThread thread; @@ -635,7 +635,7 @@ public class LodNodeGenWorker implements IWorker { genThreads.shutdownNow(); } - genThreads = Executors.newFixedThreadPool(LodConfig.CLIENT.numberOfWorldGenerationThreads.get(), new LodThreadFactory(LodNodeGenWorker.class.getSimpleName())); + genThreads = Executors.newFixedThreadPool(Runtime.getRuntime().availableProcessors(), new LodThreadFactory(LodNodeGenWorker.class.getSimpleName())); } diff --git a/src/main/java/com/seibel/lod/builders/worldGeneration/LodWorldGenerator.java b/src/main/java/com/seibel/lod/builders/worldGeneration/LodWorldGenerator.java index 368e9cf5a..76371bc74 100644 --- a/src/main/java/com/seibel/lod/builders/worldGeneration/LodWorldGenerator.java +++ b/src/main/java/com/seibel/lod/builders/worldGeneration/LodWorldGenerator.java @@ -84,7 +84,9 @@ public class LodWorldGenerator generatorThreadRunning = true; // just in case the config is changed - maxChunkGenRequests = LodConfig.CLIENT.numberOfWorldGenerationThreads.get() * 8; + + //maxChunkGenRequests = LodConfig.CLIENT.numberOfWorldGenerationThreads.get() * 8; + maxChunkGenRequests = Runtime.getRuntime().availableProcessors() * 8; Thread generatorThread = new Thread(() -> { @@ -132,7 +134,7 @@ public class LodWorldGenerator int farRequesting = maxChunkGenRequests/2; //we firstly make sure that the world is filled with half region wide block - + /* for (byte detailGen = LodConfig.CLIENT.maxGenerationDetail.get().detailLevel; detailGen <= LodUtil.REGION_DETAIL_LEVEL; detailGen++) { if (farRequesting <= 0){ @@ -152,11 +154,11 @@ public class LodWorldGenerator } farRequesting = farRequesting - levelPosListToGen.size(); - } + }*/ // ...then once the world is filled with half-region sized blocks // fill in the rest - + int t = generationRequestList.size(); int nearRequesting = maxChunkGenRequests - maxChunkGenRequests/2 + farRequesting; System.out.println("clear slot " + nearRequesting); //we then fill the world with the rest of the block @@ -177,7 +179,7 @@ public class LodWorldGenerator nearRequesting = nearRequesting - levelPosListToGen.size(); System.out.println("adding " + levelPosListToGen.size()); } - System.out.println("generating " + nearRequesting); + System.out.println("generating " + generationRequestList.size() + " and " + t); //====================================// diff --git a/src/main/java/com/seibel/lod/handlers/LodConfig.java b/src/main/java/com/seibel/lod/handlers/LodConfig.java index 3db12f7df..fa9055231 100644 --- a/src/main/java/com/seibel/lod/handlers/LodConfig.java +++ b/src/main/java/com/seibel/lod/handlers/LodConfig.java @@ -93,7 +93,7 @@ public class LodConfig + " At what distance should Fog be drawn on the LODs? \n" + " If the fog cuts off ubruptly or you are using Optifine's \"fast\" \n" + " fog option set this to " + FogDistance.NEAR.toString() + " or " + FogDistance.FAR.toString() + ". \n") - .defineEnum("fogDistance", FogDistance.NEAR_AND_FAR); + .defineEnum("fogDistance", FogDistance.FAR); fogDrawOverride = builder .comment("\n\n" @@ -130,7 +130,7 @@ public class LodConfig + " " + LodDetail.QUAD.toString() + ": render 16 LODs for each Chunk. \n" + " " + LodDetail.HALF.toString() + ": render 64 LODs for each Chunk. \n" + " " + LodDetail.FULL.toString() + ": render 256 LODs for each Chunk. \n") - .defineEnum("lodDrawQuality", LodDetail.DOUBLE); + .defineEnum("lodDrawQuality", LodDetail.FULL); maxGenerationDetail = builder .comment("\n\n" @@ -140,7 +140,7 @@ public class LodConfig + " " + LodDetail.QUAD.toString() + ": render 16 LODs for each Chunk. \n" + " " + LodDetail.HALF.toString() + ": render 64 LODs for each Chunk. \n" + " " + LodDetail.FULL.toString() + ": render 256 LODs for each Chunk. \n") - .defineEnum("lodGenerationQuality", LodDetail.DOUBLE); + .defineEnum("lodGenerationQuality", LodDetail.FULL); lodDistanceCalculatorType = builder .comment("\n\n" @@ -157,7 +157,7 @@ public class LodConfig + " " + DistanceCalculatorType.RENDER_DEPENDANT + " \n" + " with LINEAR calculator the quality of block decrease \n" + " quadratically to the distance of the player \n") - .defineEnum("lodDistanceComputation", DistanceCalculatorType.RENDER_DEPENDANT); + .defineEnum("lodDistanceComputation", DistanceCalculatorType.LINEAR); lodQuality = builder .comment("\n\n" @@ -168,7 +168,7 @@ public class LodConfig lodChunkRenderDistance = builder .comment("\n\n" + " This is the render distance of the mod \n") - .defineInRange("lodChunkRenderDistane", 128, 32, 128); + .defineInRange("lodChunkRenderDistane", 128, 32, 256); distanceGenerationMode = builder .comment("\n\n" diff --git a/src/main/java/com/seibel/lod/render/LodRenderer.java b/src/main/java/com/seibel/lod/render/LodRenderer.java index 7c12a516d..b2fa72c42 100644 --- a/src/main/java/com/seibel/lod/render/LodRenderer.java +++ b/src/main/java/com/seibel/lod/render/LodRenderer.java @@ -277,7 +277,7 @@ public class LodRenderer // set the required open GL settings GL11.glPolygonMode(GL11.GL_FRONT_AND_BACK, GL11.GL_FILL); //GL11.glPolygonMode(GL11.GL_FRONT_AND_BACK, GL11.GL_LINE); - GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); + //GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); GL11.glDisable(GL11.GL_TEXTURE_2D); GL11.glEnable(GL11.GL_CULL_FACE); GL11.glEnable(GL11.GL_COLOR_MATERIAL); diff --git a/src/main/java/com/seibel/lod/util/DetailDistanceUtil.java b/src/main/java/com/seibel/lod/util/DetailDistanceUtil.java index 36c6a50d9..1a6955295 100644 --- a/src/main/java/com/seibel/lod/util/DetailDistanceUtil.java +++ b/src/main/java/com/seibel/lod/util/DetailDistanceUtil.java @@ -16,7 +16,7 @@ public class DetailDistanceUtil private static int maxDistance = LodConfig.CLIENT.lodChunkRenderDistance.get() * 16; - /*private static DistanceGenerationMode[] distancesGenerators = { + private static DistanceGenerationMode[] distancesGenerators = { DistanceGenerationMode.SURFACE, DistanceGenerationMode.SURFACE, DistanceGenerationMode.SURFACE, @@ -26,7 +26,7 @@ public class DetailDistanceUtil DistanceGenerationMode.SURFACE, DistanceGenerationMode.SURFACE, DistanceGenerationMode.SURFACE, - DistanceGenerationMode.SURFACE};*/ + DistanceGenerationMode.SURFACE}; /*private static DistanceGenerationMode[] distancesGenerators = { DistanceGenerationMode.BIOME_ONLY_SIMULATE_HEIGHT, @@ -39,17 +39,6 @@ public class DetailDistanceUtil DistanceGenerationMode.BIOME_ONLY_SIMULATE_HEIGHT, DistanceGenerationMode.BIOME_ONLY_SIMULATE_HEIGHT, DistanceGenerationMode.BIOME_ONLY_SIMULATE_HEIGHT};*/ - private static DistanceGenerationMode[] distancesGenerators = { - DistanceGenerationMode.SURFACE, - DistanceGenerationMode.SURFACE, - DistanceGenerationMode.SURFACE, - DistanceGenerationMode.SURFACE, - DistanceGenerationMode.BIOME_ONLY_SIMULATE_HEIGHT, - DistanceGenerationMode.BIOME_ONLY_SIMULATE_HEIGHT, - DistanceGenerationMode.BIOME_ONLY_SIMULATE_HEIGHT, - DistanceGenerationMode.BIOME_ONLY_SIMULATE_HEIGHT, - DistanceGenerationMode.BIOME_ONLY_SIMULATE_HEIGHT, - DistanceGenerationMode.BIOME_ONLY_SIMULATE_HEIGHT}; private static LodDetail[] lodDetails = { LodDetail.FULL, @@ -90,7 +79,7 @@ public class DetailDistanceUtil switch (LodConfig.CLIENT.lodDistanceCalculatorType.get()) { case LINEAR: - initial = Math.min(maxDistance*2/maxDetail, 1024); + initial = LodConfig.CLIENT.lodQuality.get() * 128; return (detail * initial); case QUADRATIC: initial = LodConfig.CLIENT.lodQuality.get() * 128;