Small changes to how number of thread is chosen and returned to old LINEAR system

This commit is contained in:
Leonardo
2021-08-25 16:12:18 +02:00
parent b44900e3f0
commit 98cbc30709
5 changed files with 18 additions and 27 deletions
@@ -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()));
}
@@ -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);
//====================================//
@@ -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"
@@ -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);
@@ -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;