Rename and move LodConfig to LodConfigHandler
This commit is contained in:
@@ -13,15 +13,13 @@ import com.mojang.blaze3d.systems.RenderSystem;
|
||||
import com.seibel.lod.builders.LodBufferBuilder;
|
||||
import com.seibel.lod.enums.FogDistance;
|
||||
import com.seibel.lod.enums.FogQuality;
|
||||
import com.seibel.lod.enums.LodDetail;
|
||||
import com.seibel.lod.enums.LodTemplate;
|
||||
import com.seibel.lod.handlers.LodConfigHandler;
|
||||
import com.seibel.lod.handlers.ReflectionHandler;
|
||||
import com.seibel.lod.objects.LodChunk;
|
||||
import com.seibel.lod.objects.LodDimension;
|
||||
import com.seibel.lod.objects.NearFarBuffer;
|
||||
import com.seibel.lod.objects.NearFarFogSetting;
|
||||
import com.seibel.lod.proxy.ClientProxy;
|
||||
import com.seibel.lod.util.LodConfig;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.entity.player.ClientPlayerEntity;
|
||||
@@ -158,14 +156,14 @@ public class LodRender
|
||||
if ((int)player.getPosX() / LodChunk.WIDTH != prevChunkX ||
|
||||
(int)player.getPosZ() / LodChunk.WIDTH != prevChunkZ ||
|
||||
previousChunkRenderDistance != mc.gameSettings.renderDistanceChunks ||
|
||||
prevFogDistance != LodConfig.CLIENT.fogDistance.get())
|
||||
prevFogDistance != LodConfigHandler.CLIENT.fogDistance.get())
|
||||
{
|
||||
// yes
|
||||
regen = true;
|
||||
|
||||
prevChunkX = (int)player.getPosX() / LodChunk.WIDTH;
|
||||
prevChunkZ = (int)player.getPosZ() / LodChunk.WIDTH;
|
||||
prevFogDistance = LodConfig.CLIENT.fogDistance.get();
|
||||
prevFogDistance = LodConfigHandler.CLIENT.fogDistance.get();
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -175,9 +173,9 @@ public class LodRender
|
||||
}
|
||||
|
||||
// did the user change the debug setting?
|
||||
if (LodConfig.CLIENT.debugMode.get() != debugging)
|
||||
if (LodConfigHandler.CLIENT.debugMode.get() != debugging)
|
||||
{
|
||||
debugging = LodConfig.CLIENT.debugMode.get();
|
||||
debugging = LodConfigHandler.CLIENT.debugMode.get();
|
||||
regen = true;
|
||||
}
|
||||
|
||||
@@ -187,7 +185,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 * LodConfig.CLIENT.lodChunkRadiusMultiplier.get() * 2;
|
||||
int totalLength = (int) farPlaneDistance * LodConfigHandler.CLIENT.lodChunkRadiusMultiplier.get() * 2;
|
||||
int numbChunksWide = (totalLength / LodChunk.WIDTH);
|
||||
|
||||
// see if the chunks Minecraft is going to render are the
|
||||
@@ -411,13 +409,13 @@ public class LodRender
|
||||
{
|
||||
if (fogQuality == FogQuality.FANCY)
|
||||
{
|
||||
RenderSystem.fogStart(farPlaneDistance * 0.85f * LodConfig.CLIENT.lodChunkRadiusMultiplier.get());
|
||||
RenderSystem.fogEnd(farPlaneDistance * 1.0f * LodConfig.CLIENT.lodChunkRadiusMultiplier.get());
|
||||
RenderSystem.fogStart(farPlaneDistance * 0.85f * LodConfigHandler.CLIENT.lodChunkRadiusMultiplier.get());
|
||||
RenderSystem.fogEnd(farPlaneDistance * 1.0f * LodConfigHandler.CLIENT.lodChunkRadiusMultiplier.get());
|
||||
}
|
||||
else if(fogQuality == FogQuality.FAST)
|
||||
{
|
||||
RenderSystem.fogStart(farPlaneDistance * 0.5f * LodConfig.CLIENT.lodChunkRadiusMultiplier.get());
|
||||
RenderSystem.fogEnd(farPlaneDistance * 0.75f * LodConfig.CLIENT.lodChunkRadiusMultiplier.get());
|
||||
RenderSystem.fogStart(farPlaneDistance * 0.5f * LodConfigHandler.CLIENT.lodChunkRadiusMultiplier.get());
|
||||
RenderSystem.fogEnd(farPlaneDistance * 0.75f * LodConfigHandler.CLIENT.lodChunkRadiusMultiplier.get());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -497,7 +495,7 @@ public class LodRender
|
||||
getFov(partialTicks, true),
|
||||
(float)this.mc.getMainWindow().getFramebufferWidth() / (float)this.mc.getMainWindow().getFramebufferHeight(),
|
||||
0.5F,
|
||||
this.farPlaneDistance * LodConfig.CLIENT.lodChunkRadiusMultiplier.get() * 2);
|
||||
this.farPlaneDistance * LodConfigHandler.CLIENT.lodChunkRadiusMultiplier.get() * 2);
|
||||
|
||||
// add the screen space distortions
|
||||
projectionMatrix.mul(matrixStack.getLast().getMatrix());
|
||||
@@ -531,24 +529,24 @@ public class LodRender
|
||||
private void setupBuffers(int numbChunksWide)
|
||||
{
|
||||
// calculate the max amount of memory needed (in bytes)
|
||||
int bufferMemory = getBufferMemoryForRadiusMultiplier(LodConfig.CLIENT.lodChunkRadiusMultiplier.get());
|
||||
int bufferMemory = RenderUtil.getBufferMemoryForRadiusMultiplier(LodConfigHandler.CLIENT.lodChunkRadiusMultiplier.get());
|
||||
|
||||
// if the required memory is greater than the
|
||||
// MAX_ALOCATEABLE_DIRECT_MEMORY lower the lodChunkRadiusMultiplier
|
||||
// to fit.
|
||||
if (bufferMemory > MAX_ALOCATEABLE_DIRECT_MEMORY)
|
||||
{
|
||||
int maxRadiusMultiplier = getMaxRadiusMultiplierWithAvaliableMemory(LodConfig.CLIENT.lodTemplate.get(), LodConfig.CLIENT.lodDetail.get());
|
||||
int maxRadiusMultiplier = RenderUtil.getMaxRadiusMultiplierWithAvaliableMemory(LodConfigHandler.CLIENT.lodTemplate.get(), LodConfigHandler.CLIENT.lodDetail.get());
|
||||
|
||||
ClientProxy.LOGGER.warn("The lodChunkRadiusMultiplier was set too high "
|
||||
+ "and had to be lowered to fit memory constraints "
|
||||
+ "from " + LodConfig.CLIENT.lodChunkRadiusMultiplier.get() + " "
|
||||
+ "from " + LodConfigHandler.CLIENT.lodChunkRadiusMultiplier.get() + " "
|
||||
+ "to " + maxRadiusMultiplier);
|
||||
|
||||
LodConfig.CLIENT.lodChunkRadiusMultiplier.set(
|
||||
LodConfigHandler.CLIENT.lodChunkRadiusMultiplier.set(
|
||||
maxRadiusMultiplier);
|
||||
|
||||
bufferMemory = getBufferMemoryForRadiusMultiplier(maxRadiusMultiplier);
|
||||
bufferMemory = RenderUtil.getBufferMemoryForRadiusMultiplier(maxRadiusMultiplier);
|
||||
}
|
||||
|
||||
drawableNearBuffer = new BufferBuilder(bufferMemory);
|
||||
@@ -557,32 +555,6 @@ public class LodRender
|
||||
lodBufferBuilder.setupBuffers(bufferMemory);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get how much buffer memory would be required for the given radius multiplier
|
||||
*/
|
||||
public int getBufferMemoryForRadiusMultiplier(int radiusMultiplier)
|
||||
{
|
||||
int numbChunksWide = mc.gameSettings.renderDistanceChunks *
|
||||
radiusMultiplier * 2;
|
||||
|
||||
// calculate the max amount of buffer memory needed (in bytes)
|
||||
return numbChunksWide * numbChunksWide *
|
||||
LodConfig.CLIENT.lodTemplate.get().
|
||||
getBufferMemoryForSingleLod(LodConfig.CLIENT.lodDetail.get());
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the maxViewDistanceMultiplier for the given LodTemplate
|
||||
* at the given LodDetail level.
|
||||
*/
|
||||
public int getMaxRadiusMultiplierWithAvaliableMemory(LodTemplate lodTemplate, LodDetail lodDetail)
|
||||
{
|
||||
int maxNumberOfLods = MAX_ALOCATEABLE_DIRECT_MEMORY / lodTemplate.getBufferMemoryForSingleLod(lodDetail);
|
||||
int numbLodsWide = (int) Math.sqrt(maxNumberOfLods);
|
||||
|
||||
return numbLodsWide / (2 * mc.gameSettings.renderDistanceChunks);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -649,7 +621,7 @@ public class LodRender
|
||||
{
|
||||
case FANCY:
|
||||
|
||||
switch(LodConfig.CLIENT.fogDistance.get())
|
||||
switch(LodConfigHandler.CLIENT.fogDistance.get())
|
||||
{
|
||||
case NEAR_AND_FAR:
|
||||
fogSetting.nearFogSetting = FogDistance.NEAR;
|
||||
@@ -674,7 +646,7 @@ public class LodRender
|
||||
// and far portion; and fast fog is rendered from the
|
||||
// frustrum's perspective instead of the camera
|
||||
|
||||
switch(LodConfig.CLIENT.fogDistance.get())
|
||||
switch(LodConfigHandler.CLIENT.fogDistance.get())
|
||||
{
|
||||
case NEAR_AND_FAR:
|
||||
fogSetting.nearFogSetting = FogDistance.NEAR;
|
||||
|
||||
@@ -1,5 +1,9 @@
|
||||
package com.seibel.lod.render;
|
||||
|
||||
import com.seibel.lod.enums.LodDetail;
|
||||
import com.seibel.lod.enums.LodTemplate;
|
||||
import com.seibel.lod.handlers.LodConfigHandler;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
|
||||
/**
|
||||
@@ -7,10 +11,12 @@ import net.minecraft.client.Minecraft;
|
||||
* to be used in the rendering process.
|
||||
*
|
||||
* @author James Seibel
|
||||
* @version 2-13-2021
|
||||
* @version 6-17-2021
|
||||
*/
|
||||
public class RenderUtil
|
||||
{
|
||||
private static final Minecraft mc = Minecraft.getInstance();
|
||||
|
||||
/**
|
||||
* Returns if the given coordinate is in the loaded area of the world.
|
||||
* @param centerCoordinate the center of the loaded world
|
||||
@@ -42,4 +48,30 @@ public class RenderUtil
|
||||
&& j <= lodRadius + halfRadius);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get how much buffer memory would be required for the given radius multiplier
|
||||
*/
|
||||
public static int getBufferMemoryForRadiusMultiplier(int radiusMultiplier)
|
||||
{
|
||||
int numbChunksWide = mc.gameSettings.renderDistanceChunks *
|
||||
radiusMultiplier * 2;
|
||||
|
||||
// calculate the max amount of buffer memory needed (in bytes)
|
||||
return numbChunksWide * numbChunksWide *
|
||||
LodConfigHandler.CLIENT.lodTemplate.get().
|
||||
getBufferMemoryForSingleLod(LodConfigHandler.CLIENT.lodDetail.get());
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the maxViewDistanceMultiplier for the given LodTemplate
|
||||
* at the given LodDetail level.
|
||||
*/
|
||||
public static int getMaxRadiusMultiplierWithAvaliableMemory(LodTemplate lodTemplate, LodDetail lodDetail)
|
||||
{
|
||||
int maxNumberOfLods = LodRender.MAX_ALOCATEABLE_DIRECT_MEMORY / lodTemplate.getBufferMemoryForSingleLod(lodDetail);
|
||||
int numbLodsWide = (int) Math.sqrt(maxNumberOfLods);
|
||||
|
||||
return numbLodsWide / (2 * mc.gameSettings.renderDistanceChunks);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user