Resolved more warnings. Applied auto format in affected files.
This commit is contained in:
@@ -20,7 +20,10 @@ package com.seibel.lod.handlers;
|
||||
|
||||
import com.seibel.lod.enums.DistanceGenerationMode;
|
||||
import com.seibel.lod.enums.VerticalQuality;
|
||||
import com.seibel.lod.objects.*;
|
||||
import com.seibel.lod.objects.LodDimension;
|
||||
import com.seibel.lod.objects.LodRegion;
|
||||
import com.seibel.lod.objects.RegionPos;
|
||||
import com.seibel.lod.objects.VerticalLevelContainer;
|
||||
import com.seibel.lod.proxy.ClientProxy;
|
||||
import com.seibel.lod.util.LodThreadFactory;
|
||||
import com.seibel.lod.util.LodUtil;
|
||||
@@ -45,7 +48,7 @@ public class LodDimensionFileHandler
|
||||
/** This is the dimension that owns this file handler */
|
||||
private LodDimension lodDimension = null;
|
||||
|
||||
private File dimensionDataSaveFolder;
|
||||
private final File dimensionDataSaveFolder;
|
||||
|
||||
/** lod */
|
||||
private static final String FILE_NAME_PREFIX = "lod";
|
||||
|
||||
@@ -15,19 +15,18 @@
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.seibel.lod.mixin;
|
||||
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
package com.seibel.lod.mixin;
|
||||
|
||||
import com.mojang.blaze3d.matrix.MatrixStack;
|
||||
import com.seibel.lod.LodMain;
|
||||
import com.seibel.lod.config.LodConfig;
|
||||
|
||||
import net.minecraft.client.renderer.RenderType;
|
||||
import net.minecraft.client.renderer.WorldRenderer;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
|
||||
/**
|
||||
* This class is used to mix in my rendering code
|
||||
@@ -35,7 +34,7 @@ import net.minecraft.client.renderer.WorldRenderer;
|
||||
* If this wasn't done and we used Forge's
|
||||
* render last event, the LODs would render on top
|
||||
* of the normal terrain.
|
||||
*
|
||||
*
|
||||
* @author James Seibel
|
||||
* @version 9-19-2021
|
||||
*/
|
||||
@@ -44,7 +43,7 @@ public class MixinWorldRenderer
|
||||
{
|
||||
private static float previousPartialTicks = 0;
|
||||
|
||||
@Inject(at = @At("RETURN"), method = "renderSky(Lcom/mojang/blaze3d/matrix/MatrixStack;F)V", cancellable = false)
|
||||
@Inject(at = @At("RETURN"), method = "renderSky(Lcom/mojang/blaze3d/matrix/MatrixStack;F)V")
|
||||
private void renderSky(MatrixStack matrixStackIn, float partialTicks, CallbackInfo callback)
|
||||
{
|
||||
// get the partial ticks since renderBlockLayer doesn't
|
||||
@@ -52,7 +51,7 @@ public class MixinWorldRenderer
|
||||
previousPartialTicks = partialTicks;
|
||||
}
|
||||
|
||||
@Inject(at = @At("HEAD"), method = "renderChunkLayer(Lnet/minecraft/client/renderer/RenderType;Lcom/mojang/blaze3d/matrix/MatrixStack;DDD)V", cancellable = false)
|
||||
@Inject(at = @At("HEAD"), method = "renderChunkLayer(Lnet/minecraft/client/renderer/RenderType;Lcom/mojang/blaze3d/matrix/MatrixStack;DDD)V")
|
||||
private void renderChunkLayer(RenderType renderType, MatrixStack matrixStackIn, double xIn, double yIn, double zIn, CallbackInfo callback)
|
||||
{
|
||||
// only render if LODs are enabled and
|
||||
|
||||
@@ -18,28 +18,23 @@
|
||||
|
||||
package com.seibel.lod.objects;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.concurrent.ExecutorService;
|
||||
import java.util.concurrent.Executors;
|
||||
|
||||
import com.seibel.lod.config.LodConfig;
|
||||
import com.seibel.lod.enums.DistanceGenerationMode;
|
||||
import com.seibel.lod.enums.GenerationPriority;
|
||||
import com.seibel.lod.enums.VerticalQuality;
|
||||
import com.seibel.lod.handlers.LodDimensionFileHandler;
|
||||
import com.seibel.lod.util.DataPointUtil;
|
||||
import com.seibel.lod.util.DetailDistanceUtil;
|
||||
import com.seibel.lod.util.LevelPosUtil;
|
||||
import com.seibel.lod.util.LodThreadFactory;
|
||||
import com.seibel.lod.util.LodUtil;
|
||||
import com.seibel.lod.util.*;
|
||||
import com.seibel.lod.wrappers.MinecraftWrapper;
|
||||
|
||||
import net.minecraft.util.math.ChunkPos;
|
||||
import net.minecraft.world.DimensionType;
|
||||
import net.minecraft.world.server.ServerChunkProvider;
|
||||
import net.minecraft.world.server.ServerWorld;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.concurrent.ExecutorService;
|
||||
import java.util.concurrent.Executors;
|
||||
|
||||
|
||||
/**
|
||||
* This object holds all loaded LOD regions
|
||||
@@ -251,11 +246,11 @@ public class LodDimension
|
||||
int count = 0;
|
||||
LodRegion region;
|
||||
|
||||
for (int x = 0; x < regions.length; x++)
|
||||
for (LodRegion[] lodRegions : regions)
|
||||
{
|
||||
for (int z = 0; z < regions.length; z++)
|
||||
{
|
||||
region = regions[x][z];
|
||||
region = lodRegions[z];
|
||||
if (region != null)
|
||||
count += region.getMinMemoryNeeded(LodConfig.CLIENT.graphics.lodTemplate.get());
|
||||
}
|
||||
|
||||
@@ -27,18 +27,18 @@ public class LodRegion
|
||||
* Number of detail level supported by a region
|
||||
*/
|
||||
private static final byte POSSIBLE_LOD = 10;
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Holds the lowest (least detailed) detail level in this region
|
||||
*/
|
||||
private byte minDetailLevel;
|
||||
|
||||
|
||||
/**
|
||||
* This holds all data for this region
|
||||
*/
|
||||
private LevelContainer[] dataContainer;
|
||||
|
||||
private final LevelContainer[] dataContainer;
|
||||
|
||||
/**
|
||||
* the generation mode for this region
|
||||
*/
|
||||
@@ -47,7 +47,7 @@ public class LodRegion
|
||||
* the vertical quality of this region
|
||||
*/
|
||||
private VerticalQuality verticalQuality;
|
||||
|
||||
|
||||
/**
|
||||
* this region's x RegionPos
|
||||
*/
|
||||
@@ -56,8 +56,8 @@ public class LodRegion
|
||||
* this region's z RegionPos
|
||||
*/
|
||||
public final int regionPosZ;
|
||||
|
||||
|
||||
|
||||
|
||||
public LodRegion(RegionPos regionPos)
|
||||
{
|
||||
this.minDetailLevel = LodUtil.REGION_DETAIL_LEVEL;
|
||||
@@ -65,7 +65,7 @@ public class LodRegion
|
||||
this.regionPosZ = regionPos.z;
|
||||
dataContainer = new LevelContainer[POSSIBLE_LOD];
|
||||
}
|
||||
|
||||
|
||||
public LodRegion(byte minDetailLevel, RegionPos regionPos, DistanceGenerationMode generationMode, VerticalQuality verticalQuality)
|
||||
{
|
||||
this.minDetailLevel = minDetailLevel;
|
||||
@@ -74,16 +74,16 @@ public class LodRegion
|
||||
this.verticalQuality = verticalQuality;
|
||||
this.generationMode = generationMode;
|
||||
dataContainer = new LevelContainer[POSSIBLE_LOD];
|
||||
|
||||
|
||||
|
||||
|
||||
// Initialize all the different matrices
|
||||
for (byte lod = minDetailLevel; lod <= LodUtil.REGION_DETAIL_LEVEL; lod++)
|
||||
{
|
||||
dataContainer[lod] = new VerticalLevelContainer(lod);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Inserts the data point into the region.
|
||||
* <p>
|
||||
@@ -95,19 +95,19 @@ public class LodRegion
|
||||
{
|
||||
posX = LevelPosUtil.getRegionModule(detailLevel, posX);
|
||||
posZ = LevelPosUtil.getRegionModule(detailLevel, posZ);
|
||||
|
||||
|
||||
// The dataContainer could have null entries if the
|
||||
// detailLevel changes.
|
||||
if (this.dataContainer[detailLevel] == null)
|
||||
{
|
||||
this.dataContainer[detailLevel] = new VerticalLevelContainer(detailLevel);
|
||||
}
|
||||
|
||||
|
||||
this.dataContainer[detailLevel].addData(data, posX, posZ, verticalIndex);
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get the dataPoint at the given relative position.
|
||||
*
|
||||
@@ -118,7 +118,7 @@ public class LodRegion
|
||||
{
|
||||
return dataContainer[detailLevel].getData(posX, posZ, verticalIndex);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get the dataPoint at the given relative position.
|
||||
*
|
||||
@@ -129,7 +129,7 @@ public class LodRegion
|
||||
{
|
||||
return dataContainer[detailLevel].getSingleData(posX, posZ);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Clears the datapoint at the given relative position
|
||||
*/
|
||||
@@ -137,7 +137,7 @@ public class LodRegion
|
||||
{
|
||||
dataContainer[detailLevel].clear(posX, posZ);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* This method will fill the posToGenerate array with all levelPos that
|
||||
* are render-able.
|
||||
@@ -145,12 +145,12 @@ public class LodRegion
|
||||
* TODO why don't we return the posToGenerate, it would make this easier to understand
|
||||
*/
|
||||
public void getPosToGenerate(PosToGenerateContainer posToGenerate,
|
||||
int playerBlockPosX, int playerBlockPosZ)
|
||||
int playerBlockPosX, int playerBlockPosZ)
|
||||
{
|
||||
getPosToGenerate(posToGenerate, LodUtil.REGION_DETAIL_LEVEL, 0, 0, playerBlockPosX, playerBlockPosZ);
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* A recursive method that fills the posToGenerate array with all levelPos that
|
||||
* need to be generated.
|
||||
@@ -158,77 +158,80 @@ public class LodRegion
|
||||
* TODO why don't we return the posToGenerate, it would make this easier to understand
|
||||
*/
|
||||
private void getPosToGenerate(PosToGenerateContainer posToGenerate, byte detailLevel,
|
||||
int childOffsetPosX, int childOffsetPosZ, int playerPosX, int playerPosZ)
|
||||
int childOffsetPosX, int childOffsetPosZ, int playerPosX, int playerPosZ)
|
||||
{
|
||||
// equivalent to 2^(...)
|
||||
int size = 1 << (LodUtil.REGION_DETAIL_LEVEL - detailLevel);
|
||||
|
||||
|
||||
// calculate what LevelPos are in range to generate
|
||||
int maxDistance = LevelPosUtil.maxDistance(detailLevel, childOffsetPosX, childOffsetPosZ, playerPosX, playerPosZ, regionPosX, regionPosZ);
|
||||
|
||||
|
||||
// determine this child's levelPos
|
||||
byte childDetailLevel = (byte) (detailLevel - 1);
|
||||
int childPosX = childOffsetPosX * 2;
|
||||
int childPosZ = childOffsetPosZ * 2;
|
||||
|
||||
|
||||
int childSize = 1 << (LodUtil.REGION_DETAIL_LEVEL - childDetailLevel);
|
||||
|
||||
|
||||
byte targetDetailLevel = DetailDistanceUtil.getLodGenDetail(DetailDistanceUtil.getGenerationDetailFromDistance(maxDistance)).detailLevel;
|
||||
if (targetDetailLevel > detailLevel)
|
||||
if (targetDetailLevel <= detailLevel)
|
||||
{
|
||||
// we have gone beyond the target Detail level
|
||||
// we can stop generating
|
||||
return;
|
||||
} else if (targetDetailLevel == detailLevel)
|
||||
{
|
||||
if (!doesDataExist(detailLevel, childOffsetPosX, childOffsetPosZ))
|
||||
posToGenerate.addPosToGenerate(detailLevel, childOffsetPosX + regionPosX * size, childOffsetPosZ + regionPosZ * size);
|
||||
} else
|
||||
{
|
||||
// we want at max one request per chunk (since the world generator creates chunks).
|
||||
// So for lod smaller than a chunk, only recurse down
|
||||
// the top right child
|
||||
|
||||
if (detailLevel > LodUtil.CHUNK_DETAIL_LEVEL)
|
||||
if (targetDetailLevel == detailLevel)
|
||||
{
|
||||
int ungeneratedChildren = 0;
|
||||
|
||||
// make sure all children are generated to this detailLevel
|
||||
for (int x = 0; x <= 1; x++)
|
||||
if (!doesDataExist(detailLevel, childOffsetPosX, childOffsetPosZ))
|
||||
posToGenerate.addPosToGenerate(detailLevel, childOffsetPosX + regionPosX * size, childOffsetPosZ + regionPosZ * size);
|
||||
}
|
||||
else
|
||||
{
|
||||
// we want at max one request per chunk (since the world generator creates chunks).
|
||||
// So for lod smaller than a chunk, only recurse down
|
||||
// the top right child
|
||||
|
||||
if (detailLevel > LodUtil.CHUNK_DETAIL_LEVEL)
|
||||
{
|
||||
for (int z = 0; z <= 1; z++)
|
||||
int ungeneratedChildren = 0;
|
||||
|
||||
// make sure all children are generated to this detailLevel
|
||||
for (int x = 0; x <= 1; x++)
|
||||
{
|
||||
if (!doesDataExist(childDetailLevel, childPosX + x, childPosZ + z))
|
||||
for (int z = 0; z <= 1; z++)
|
||||
{
|
||||
ungeneratedChildren++;
|
||||
posToGenerate.addPosToGenerate(childDetailLevel, childPosX + x + regionPosX * childSize, childPosZ + z + regionPosZ * childSize);
|
||||
if (!doesDataExist(childDetailLevel, childPosX + x, childPosZ + z))
|
||||
{
|
||||
ungeneratedChildren++;
|
||||
posToGenerate.addPosToGenerate(childDetailLevel, childPosX + x + regionPosX * childSize, childPosZ + z + regionPosZ * childSize);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// only if all the children are correctly generated
|
||||
// should we go deeper
|
||||
if (ungeneratedChildren == 0)
|
||||
for (int x = 0; x <= 1; x++)
|
||||
for (int z = 0; z <= 1; z++)
|
||||
getPosToGenerate(posToGenerate, childDetailLevel, childPosX + x, childPosZ + z, playerPosX, playerPosZ);
|
||||
}
|
||||
|
||||
// only if all the children are correctly generated
|
||||
// should we go deeper
|
||||
if (ungeneratedChildren == 0)
|
||||
for (int x = 0; x <= 1; x++)
|
||||
for (int z = 0; z <= 1; z++)
|
||||
getPosToGenerate(posToGenerate, childDetailLevel, childPosX + x, childPosZ + z, playerPosX, playerPosZ);
|
||||
} else
|
||||
{
|
||||
// The detail Level is smaller than a chunk.
|
||||
// Only recurse down the top right child.
|
||||
|
||||
if (DetailDistanceUtil.getLodGenDetail(childDetailLevel).detailLevel <= (childDetailLevel))
|
||||
else
|
||||
{
|
||||
if (!doesDataExist(childDetailLevel, childPosX, childPosZ))
|
||||
posToGenerate.addPosToGenerate(childDetailLevel, childPosX + regionPosX * childSize, childPosZ + regionPosZ * childSize);
|
||||
else
|
||||
getPosToGenerate(posToGenerate, childDetailLevel, childPosX, childPosZ, playerPosX, playerPosZ);
|
||||
// The detail Level is smaller than a chunk.
|
||||
// Only recurse down the top right child.
|
||||
|
||||
if (DetailDistanceUtil.getLodGenDetail(childDetailLevel).detailLevel <= (childDetailLevel))
|
||||
{
|
||||
if (!doesDataExist(childDetailLevel, childPosX, childPosZ))
|
||||
posToGenerate.addPosToGenerate(childDetailLevel, childPosX + regionPosX * childSize, childPosZ + regionPosZ * childSize);
|
||||
else
|
||||
getPosToGenerate(posToGenerate, childDetailLevel, childPosX, childPosZ, playerPosX, playerPosZ);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// we have gone beyond the target Detail level
|
||||
// we can stop generating
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* This method will fill the posToRender array with all levelPos that
|
||||
* are render-able.
|
||||
@@ -236,11 +239,11 @@ public class LodRegion
|
||||
* TODO why don't we return the posToRender, it would make this easier to understand
|
||||
*/
|
||||
public void getPosToRender(PosToRenderContainer posToRender,
|
||||
int playerPosX, int playerPosZ, boolean requireCorrectDetailLevel)
|
||||
int playerPosX, int playerPosZ, boolean requireCorrectDetailLevel)
|
||||
{
|
||||
getPosToRender(posToRender, LodUtil.REGION_DETAIL_LEVEL, 0, 0, playerPosX, playerPosZ, requireCorrectDetailLevel);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* This method will fill the posToRender array with all levelPos that
|
||||
* are render-able.
|
||||
@@ -249,101 +252,105 @@ public class LodRegion
|
||||
* TODO this needs some more comments, James was only able to figure out part of it
|
||||
*/
|
||||
private void getPosToRender(PosToRenderContainer posToRender,
|
||||
byte detailLevel, int posX, int posZ,
|
||||
int playerPosX, int playerPosZ, boolean requireCorrectDetailLevel)
|
||||
byte detailLevel, int posX, int posZ,
|
||||
int playerPosX, int playerPosZ, boolean requireCorrectDetailLevel)
|
||||
{
|
||||
// equivalent to 2^(...)
|
||||
int size = 1 << (LodUtil.REGION_DETAIL_LEVEL - detailLevel);
|
||||
|
||||
|
||||
byte desiredLevel;
|
||||
int maxDistance;
|
||||
boolean stopNow = false;
|
||||
boolean stopNow;
|
||||
int minDistance;
|
||||
int childLevel;
|
||||
|
||||
|
||||
|
||||
|
||||
// calculate the LevelPos that are in range
|
||||
switch (LodConfig.CLIENT.graphics.detailDropOff.get())
|
||||
{
|
||||
|
||||
case FAST:
|
||||
int playerRegionX = LevelPosUtil.getRegion(LodUtil.BLOCK_DETAIL_LEVEL, playerPosX);
|
||||
int playerRegionZ = LevelPosUtil.getRegion(LodUtil.BLOCK_DETAIL_LEVEL, playerPosZ);
|
||||
if (playerRegionX == regionPosX && playerRegionZ == regionPosZ)
|
||||
{
|
||||
maxDistance = LevelPosUtil.maxDistance(detailLevel, posX, posZ, playerPosX, playerPosZ, regionPosX, regionPosZ);
|
||||
desiredLevel = DetailDistanceUtil.getLodDrawDetail(DetailDistanceUtil.getDrawDetailFromDistance(maxDistance));
|
||||
minDistance = LevelPosUtil.minDistance(detailLevel, posX, posZ, playerPosX, playerPosZ, regionPosX, regionPosZ);
|
||||
childLevel = DetailDistanceUtil.getLodDrawDetail(DetailDistanceUtil.getDrawDetailFromDistance(minDistance));
|
||||
stopNow = detailLevel == childLevel - 1;
|
||||
break;
|
||||
}
|
||||
default:
|
||||
case FANCY:
|
||||
|
||||
case FAST:
|
||||
int playerRegionX = LevelPosUtil.getRegion(LodUtil.BLOCK_DETAIL_LEVEL, playerPosX);
|
||||
int playerRegionZ = LevelPosUtil.getRegion(LodUtil.BLOCK_DETAIL_LEVEL, playerPosZ);
|
||||
if (playerRegionX == regionPosX && playerRegionZ == regionPosZ)
|
||||
{
|
||||
maxDistance = LevelPosUtil.maxDistance(detailLevel, posX, posZ, playerPosX, playerPosZ, regionPosX, regionPosZ);
|
||||
desiredLevel = DetailDistanceUtil.getLodDrawDetail(DetailDistanceUtil.getDrawDetailFromDistance(maxDistance));
|
||||
minDistance = LevelPosUtil.minDistance(detailLevel, posX, posZ, playerPosX, playerPosZ, regionPosX, regionPosZ);
|
||||
childLevel = DetailDistanceUtil.getLodDrawDetail(DetailDistanceUtil.getDrawDetailFromDistance(minDistance));
|
||||
stopNow = detailLevel == childLevel - 1;
|
||||
break;
|
||||
}
|
||||
default:
|
||||
case FANCY:
|
||||
maxDistance = LevelPosUtil.maxDistance(detailLevel, posX, posZ, playerPosX, playerPosZ, regionPosX, regionPosZ);
|
||||
desiredLevel = DetailDistanceUtil.getLodDrawDetail(DetailDistanceUtil.getDrawDetailFromDistance(maxDistance));
|
||||
minDistance = LevelPosUtil.minDistance(detailLevel, posX, posZ, playerPosX, playerPosZ, regionPosX, regionPosZ);
|
||||
childLevel = DetailDistanceUtil.getLodDrawDetail(DetailDistanceUtil.getDrawDetailFromDistance(minDistance));
|
||||
stopNow = detailLevel == childLevel - 1;
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
if (stopNow)
|
||||
{
|
||||
posToRender.addPosToRender(detailLevel,
|
||||
posX + regionPosX * size,
|
||||
posZ + regionPosZ * size);
|
||||
} else if (desiredLevel > detailLevel)
|
||||
{
|
||||
posToRender.addPosToRender(detailLevel,
|
||||
posX + regionPosX * size,
|
||||
posZ + regionPosZ * size);
|
||||
}
|
||||
else
|
||||
//if (desiredLevel > detailLevel)
|
||||
//{
|
||||
// we have gone beyond the target Detail level
|
||||
// we can stop generating
|
||||
return;
|
||||
} else if (desiredLevel == detailLevel)
|
||||
{
|
||||
//} else
|
||||
if (desiredLevel == detailLevel)
|
||||
{
|
||||
posToRender.addPosToRender(detailLevel,
|
||||
posX + regionPosX * size,
|
||||
posZ + regionPosZ * size);
|
||||
} else //case where (detailLevel > desiredLevel)
|
||||
{
|
||||
int childPosX = posX * 2;
|
||||
int childPosZ = posZ * 2;
|
||||
byte childDetailLevel = (byte) (detailLevel - 1);
|
||||
int childrenCount = 0;
|
||||
|
||||
for (int x = 0; x <= 1; x++)
|
||||
}
|
||||
else //case where (detailLevel > desiredLevel)
|
||||
{
|
||||
for (int z = 0; z <= 1; z++)
|
||||
int childPosX = posX * 2;
|
||||
int childPosZ = posZ * 2;
|
||||
byte childDetailLevel = (byte) (detailLevel - 1);
|
||||
int childrenCount = 0;
|
||||
|
||||
for (int x = 0; x <= 1; x++)
|
||||
{
|
||||
if (doesDataExist(childDetailLevel, childPosX + x, childPosZ + z))
|
||||
for (int z = 0; z <= 1; z++)
|
||||
{
|
||||
if (!requireCorrectDetailLevel)
|
||||
childrenCount++;
|
||||
else
|
||||
getPosToRender(posToRender, childDetailLevel, childPosX + x, childPosZ + z, playerPosX, playerPosZ, requireCorrectDetailLevel);
|
||||
if (doesDataExist(childDetailLevel, childPosX + x, childPosZ + z))
|
||||
{
|
||||
if (!requireCorrectDetailLevel)
|
||||
childrenCount++;
|
||||
else
|
||||
getPosToRender(posToRender, childDetailLevel, childPosX + x, childPosZ + z, playerPosX, playerPosZ, requireCorrectDetailLevel);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (!requireCorrectDetailLevel)
|
||||
{
|
||||
// If all the four children exist go deeper
|
||||
if (childrenCount == 4)
|
||||
{
|
||||
for (int x = 0; x <= 1; x++)
|
||||
for (int z = 0; z <= 1; z++)
|
||||
getPosToRender(posToRender, childDetailLevel, childPosX + x, childPosZ + z, playerPosX, playerPosZ, requireCorrectDetailLevel);
|
||||
} else
|
||||
|
||||
|
||||
if (!requireCorrectDetailLevel)
|
||||
{
|
||||
// If all the four children exist go deeper
|
||||
if (childrenCount == 4)
|
||||
{
|
||||
for (int x = 0; x <= 1; x++)
|
||||
for (int z = 0; z <= 1; z++)
|
||||
getPosToRender(posToRender, childDetailLevel, childPosX + x, childPosZ + z, playerPosX, playerPosZ, requireCorrectDetailLevel);
|
||||
}
|
||||
else
|
||||
{
|
||||
posToRender.addPosToRender(detailLevel,
|
||||
posX + regionPosX * size,
|
||||
posZ + regionPosZ * size);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Updates all children.
|
||||
* <p>
|
||||
@@ -354,20 +361,20 @@ public class LodRegion
|
||||
int width;
|
||||
int startX;
|
||||
int startZ;
|
||||
|
||||
|
||||
// TODO what are each of these loops updating?
|
||||
for (byte down = (byte) (minDetailLevel + 1); down <= detailLevel; down++)
|
||||
{
|
||||
startX = LevelPosUtil.convert(detailLevel, posX, down);
|
||||
startZ = LevelPosUtil.convert(detailLevel, posZ, down);
|
||||
width = 1 << (detailLevel - down);
|
||||
|
||||
|
||||
for (int x = 0; x < width; x++)
|
||||
for (int z = 0; z < width; z++)
|
||||
update(down, startX + x, startZ + z);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
for (byte up = (byte) (detailLevel + 1); up <= LodUtil.REGION_DETAIL_LEVEL; up++)
|
||||
{
|
||||
update(up,
|
||||
@@ -375,7 +382,7 @@ public class LodRegion
|
||||
LevelPosUtil.convert(detailLevel, posZ, up));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Update the child at the given relative Pos
|
||||
* <p>
|
||||
@@ -385,8 +392,8 @@ public class LodRegion
|
||||
{
|
||||
dataContainer[detailLevel].updateData(dataContainer[detailLevel - 1], posX, posZ);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Returns if data exists at the given relative Pos.
|
||||
*/
|
||||
@@ -394,16 +401,16 @@ public class LodRegion
|
||||
{
|
||||
if (detailLevel < minDetailLevel)
|
||||
return false;
|
||||
|
||||
|
||||
posX = LevelPosUtil.getRegionModule(detailLevel, posX);
|
||||
posZ = LevelPosUtil.getRegionModule(detailLevel, posZ);
|
||||
|
||||
|
||||
if (dataContainer == null || dataContainer[detailLevel] == null)
|
||||
return false;
|
||||
|
||||
|
||||
return dataContainer[detailLevel].doesItExist(posX, posZ);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Gets the generation mode for the data point at the given relative pos.
|
||||
*/
|
||||
@@ -416,7 +423,7 @@ public class LodRegion
|
||||
else
|
||||
return DistanceGenerationMode.NONE.complexity;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Returns the lowest (least detailed) detail level in this region
|
||||
* TODO is that right?
|
||||
@@ -425,7 +432,7 @@ public class LodRegion
|
||||
{
|
||||
return minDetailLevel;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Returns the LevelContainer for the detailLevel
|
||||
*
|
||||
@@ -435,10 +442,10 @@ public class LodRegion
|
||||
{
|
||||
if (detailLevel < minDetailLevel)
|
||||
throw new IllegalArgumentException("getLevel asked for a detail level that does not exist: minimum: [" + minDetailLevel + "] level requested: [" + detailLevel + "]");
|
||||
|
||||
|
||||
return dataContainer[detailLevel];
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Add the levelContainer to this Region, updating the minDetailLevel
|
||||
* if necessary.
|
||||
@@ -457,17 +464,17 @@ public class LodRegion
|
||||
+ "only allows adding LevelContainers with a "
|
||||
+ "detail level of [" + (minDetailLevel - 1) + "]");
|
||||
}
|
||||
|
||||
|
||||
if (levelContainer.getDetailLevel() == minDetailLevel - 1)
|
||||
minDetailLevel = levelContainer.getDetailLevel();
|
||||
|
||||
|
||||
dataContainer[levelContainer.getDetailLevel()] = levelContainer;
|
||||
}
|
||||
|
||||
|
||||
// TODO James thinks cutTree and growTree (which he renamed to match cutTree)
|
||||
// should have more descriptive names, to make sure the "Tree" portion isn't
|
||||
// confused with Minecraft trees (the plant).
|
||||
|
||||
|
||||
/**
|
||||
* Removes any dataContainers that are higher than
|
||||
* the given detailLevel
|
||||
@@ -478,11 +485,11 @@ public class LodRegion
|
||||
{
|
||||
for (byte detailLevelIndex = 0; detailLevelIndex < detailLevel; detailLevelIndex++)
|
||||
dataContainer[detailLevelIndex] = null;
|
||||
|
||||
|
||||
minDetailLevel = detailLevel;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Make this region more detailed to the detailLevel given.
|
||||
* TODO is that correct?
|
||||
@@ -495,13 +502,13 @@ public class LodRegion
|
||||
{
|
||||
if (dataContainer[detailLevelIndex + 1] == null)
|
||||
dataContainer[detailLevelIndex + 1] = new SingleLevelContainer((byte) (detailLevelIndex + 1));
|
||||
|
||||
|
||||
dataContainer[detailLevelIndex] = dataContainer[detailLevelIndex + 1].expand();
|
||||
}
|
||||
minDetailLevel = detailLevel;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* return RegionPos of this lod region
|
||||
*/
|
||||
@@ -509,7 +516,7 @@ public class LodRegion
|
||||
{
|
||||
return new RegionPos(regionPosX, regionPosZ);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Returns the minimum memory needed in bytes
|
||||
*/
|
||||
@@ -523,7 +530,7 @@ public class LodRegion
|
||||
}
|
||||
return memory;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Returns how many LODs are in this region
|
||||
*/
|
||||
@@ -532,26 +539,26 @@ public class LodRegion
|
||||
int count = 0;
|
||||
for (LevelContainer container : dataContainer)
|
||||
count += container.getMaxNumberOfLods();
|
||||
|
||||
|
||||
return count;
|
||||
}
|
||||
|
||||
|
||||
public VerticalQuality getVerticalQuality()
|
||||
{
|
||||
return verticalQuality;
|
||||
}
|
||||
|
||||
|
||||
public DistanceGenerationMode getGenerationMode()
|
||||
{
|
||||
return generationMode;
|
||||
}
|
||||
|
||||
|
||||
public int getMaxVerticalData(byte detailLevel)
|
||||
{
|
||||
return dataContainer[detailLevel].getMaxVerticalData();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public String toString()
|
||||
{
|
||||
|
||||
@@ -15,15 +15,15 @@
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.seibel.lod.objects;
|
||||
|
||||
import com.seibel.lod.proxy.ClientProxy;
|
||||
import net.minecraft.world.DimensionType;
|
||||
|
||||
import java.util.Hashtable;
|
||||
import java.util.Map;
|
||||
|
||||
import com.seibel.lod.proxy.ClientProxy;
|
||||
|
||||
import net.minecraft.world.DimensionType;
|
||||
|
||||
/**
|
||||
* This stores all LODs for a given world.
|
||||
*
|
||||
@@ -57,10 +57,10 @@ public class LodWorld
|
||||
/**
|
||||
* Set up the LodWorld with the given newWorldName. <br>
|
||||
* This should be done whenever loading a new world. <br><br>
|
||||
*
|
||||
*
|
||||
* Note a System.gc() call may be in order after calling this <Br>
|
||||
* since a lot of LOD data is now homeless. <br>
|
||||
*
|
||||
*
|
||||
* @param newWorldName name of the world
|
||||
*/
|
||||
public void selectWorld(String newWorldName)
|
||||
@@ -77,7 +77,7 @@ public class LodWorld
|
||||
return;
|
||||
|
||||
worldName = newWorldName;
|
||||
lodDimensions = new Hashtable<DimensionType, LodDimension>();
|
||||
lodDimensions = new Hashtable<>();
|
||||
isWorldLoaded = true;
|
||||
}
|
||||
|
||||
@@ -85,7 +85,7 @@ public class LodWorld
|
||||
* Set the worldName to "No world loaded"
|
||||
* and clear the lodDimensions Map. <br>
|
||||
* This should be done whenever unloaded a world. <br><br>
|
||||
*
|
||||
*
|
||||
* Note a System.gc() call may be in order after calling this <Br>
|
||||
* since a lot of LOD data is now homeless. <br>
|
||||
*/
|
||||
|
||||
@@ -15,6 +15,7 @@
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.seibel.lod.objects;
|
||||
|
||||
import com.seibel.lod.enums.FogDistance;
|
||||
@@ -23,7 +24,7 @@ import com.seibel.lod.enums.FogQuality;
|
||||
/**
|
||||
* This object is just a replacement for an array
|
||||
* to make things easier to understand in the LodRenderer.
|
||||
*
|
||||
*
|
||||
* @author James Seibel
|
||||
* @version 7-03-2021
|
||||
*/
|
||||
@@ -47,13 +48,10 @@ public class NearFarFogSettings
|
||||
* This holds all relevant data to rendering fog at either
|
||||
* near or far distances.
|
||||
*/
|
||||
public class NearOrFarSetting
|
||||
public static class NearOrFarSetting
|
||||
{
|
||||
public FogQuality quality = FogQuality.FANCY;
|
||||
public FogDistance distance = FogDistance.FAR;
|
||||
|
||||
/** If true this section should render with fog */
|
||||
public boolean enabled = true;
|
||||
public FogDistance distance;
|
||||
|
||||
public NearOrFarSetting(FogDistance newFogDistance)
|
||||
{
|
||||
|
||||
@@ -2,26 +2,24 @@ package com.seibel.lod.objects;
|
||||
|
||||
import com.seibel.lod.util.LevelPosUtil;
|
||||
|
||||
import javax.swing.*;
|
||||
|
||||
/**
|
||||
* Holds the levelPos that need to be generated.
|
||||
* TODO is that correct?
|
||||
*
|
||||
*
|
||||
* @author Leonardo Amato
|
||||
* @version 9-27-2021
|
||||
*/
|
||||
public class PosToGenerateContainer
|
||||
{
|
||||
private int playerPosX;
|
||||
private int playerPosZ;
|
||||
private byte farMinDetail;
|
||||
private final int playerPosX;
|
||||
private final int playerPosZ;
|
||||
private final byte farMinDetail;
|
||||
private int nearSize;
|
||||
private int farSize;
|
||||
|
||||
// TODO what is the format of these two arrays? [detailLevel][4-children]?
|
||||
private int[][] nearPosToGenerate;
|
||||
private int[][] farPosToGenerate;
|
||||
private final int[][] nearPosToGenerate;
|
||||
private final int[][] farPosToGenerate;
|
||||
|
||||
|
||||
|
||||
@@ -49,9 +47,9 @@ public class PosToGenerateContainer
|
||||
{
|
||||
// We are introducing a position in the far array
|
||||
|
||||
if(farSize < farPosToGenerate.length)
|
||||
if (farSize < farPosToGenerate.length)
|
||||
farSize++;
|
||||
|
||||
|
||||
index = farSize - 1;
|
||||
while (index > 0 && LevelPosUtil.compareDistance(distance, farPosToGenerate[index - 1][3]) <= 0)
|
||||
{
|
||||
@@ -63,7 +61,7 @@ public class PosToGenerateContainer
|
||||
}
|
||||
|
||||
|
||||
if (index != farSize-1 || farSize != farPosToGenerate.length)
|
||||
if (index != farSize - 1 || farSize != farPosToGenerate.length)
|
||||
{
|
||||
farPosToGenerate[index][0] = detailLevel + 1;
|
||||
farPosToGenerate[index][1] = posX;
|
||||
@@ -75,10 +73,10 @@ public class PosToGenerateContainer
|
||||
{
|
||||
//We are introducing a position in the near array
|
||||
|
||||
if(nearSize < nearPosToGenerate.length)
|
||||
if (nearSize < nearPosToGenerate.length)
|
||||
nearSize++;
|
||||
|
||||
index = nearSize-1;
|
||||
index = nearSize - 1;
|
||||
while (index > 0 && LevelPosUtil.compareDistance(distance, nearPosToGenerate[index - 1][3]) <= 0)
|
||||
{
|
||||
nearPosToGenerate[index][0] = nearPosToGenerate[index - 1][0];
|
||||
@@ -89,7 +87,7 @@ public class PosToGenerateContainer
|
||||
}
|
||||
|
||||
|
||||
if (index != nearSize-1 || nearSize != nearPosToGenerate.length)
|
||||
if (index != nearSize - 1 || nearSize != nearPosToGenerate.length)
|
||||
{
|
||||
nearPosToGenerate[index][0] = detailLevel + 1;
|
||||
nearPosToGenerate[index][1] = posX;
|
||||
@@ -103,7 +101,7 @@ public class PosToGenerateContainer
|
||||
|
||||
public int getNumberOfPos()
|
||||
{
|
||||
return nearSize+farSize;
|
||||
return nearSize + farSize;
|
||||
}
|
||||
|
||||
public int getNumberOfNearPos()
|
||||
@@ -124,6 +122,7 @@ public class PosToGenerateContainer
|
||||
else
|
||||
return farPosToGenerate[n][0];
|
||||
}
|
||||
|
||||
public int getNthPosX(int n, boolean near)
|
||||
{
|
||||
if (near)
|
||||
@@ -131,6 +130,7 @@ public class PosToGenerateContainer
|
||||
else
|
||||
return farPosToGenerate[n][1];
|
||||
}
|
||||
|
||||
public int getNthPosZ(int n, boolean near)
|
||||
{
|
||||
if (near)
|
||||
@@ -138,6 +138,7 @@ public class PosToGenerateContainer
|
||||
else
|
||||
return farPosToGenerate[n][2];
|
||||
}
|
||||
|
||||
public int getNthGeneration(int n, boolean near)
|
||||
{
|
||||
if (near)
|
||||
@@ -152,41 +153,41 @@ public class PosToGenerateContainer
|
||||
// TOOD is this commented code still useful?
|
||||
// if so why have it commented out?
|
||||
|
||||
|
||||
|
||||
StringBuilder builder = new StringBuilder();
|
||||
builder.append('\n');
|
||||
builder.append('\n');
|
||||
builder.append('\n');
|
||||
builder.append("near pos to generate");
|
||||
builder.append('\n');
|
||||
for (int i = 0; i < nearPosToGenerate.length; i++)
|
||||
for (int[] ints : nearPosToGenerate)
|
||||
{
|
||||
if(nearPosToGenerate[i][0] == 0)
|
||||
if (ints[0] == 0)
|
||||
break;
|
||||
builder.append(nearPosToGenerate[i][0]-1);
|
||||
builder.append(ints[0] - 1);
|
||||
builder.append(" ");
|
||||
builder.append(nearPosToGenerate[i][1]);
|
||||
builder.append(ints[1]);
|
||||
builder.append(" ");
|
||||
builder.append(nearPosToGenerate[i][2]);
|
||||
builder.append(ints[2]);
|
||||
builder.append(" ");
|
||||
builder.append(nearPosToGenerate[i][3]);
|
||||
builder.append(ints[3]);
|
||||
builder.append('\n');
|
||||
}
|
||||
builder.append('\n');
|
||||
|
||||
|
||||
builder.append("far pos to generate");
|
||||
builder.append('\n');
|
||||
for (int i = 0; i < farPosToGenerate.length; i++)
|
||||
for (int[] ints : farPosToGenerate)
|
||||
{
|
||||
if(farPosToGenerate[i][0] == 0)
|
||||
if (ints[0] == 0)
|
||||
break;
|
||||
builder.append(farPosToGenerate[i][0]-1);
|
||||
builder.append(ints[0] - 1);
|
||||
builder.append(" ");
|
||||
builder.append(farPosToGenerate[i][1]);
|
||||
builder.append(ints[1]);
|
||||
builder.append(" ");
|
||||
builder.append(farPosToGenerate[i][2]);
|
||||
builder.append(ints[2]);
|
||||
builder.append(" ");
|
||||
builder.append(farPosToGenerate[i][3]);
|
||||
builder.append(ints[3]);
|
||||
builder.append('\n');
|
||||
}
|
||||
return builder.toString();
|
||||
|
||||
@@ -7,7 +7,7 @@ import com.seibel.lod.util.LodUtil;
|
||||
import java.util.Arrays;
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
* @author Leonardo Amato
|
||||
* @version 9-18-2021
|
||||
*/
|
||||
@@ -21,7 +21,7 @@ public class PosToRenderContainer
|
||||
private int[] posToRender;
|
||||
/*TODO this population matrix could be converted to boolean to improve memory use*/
|
||||
private byte[][] population;
|
||||
|
||||
|
||||
public PosToRenderContainer(byte minDetail, int regionPosX, int regionPosZ)
|
||||
{
|
||||
this.minDetail = minDetail;
|
||||
@@ -29,10 +29,10 @@ public class PosToRenderContainer
|
||||
this.regionPosX = regionPosX;
|
||||
this.regionPosZ = regionPosZ;
|
||||
this.size = 1 << (LodUtil.REGION_DETAIL_LEVEL - minDetail);
|
||||
posToRender = new int[size*size*3];
|
||||
posToRender = new int[size * size * 3];
|
||||
population = new byte[size][size];
|
||||
}
|
||||
|
||||
|
||||
public void addPosToRender(byte detailLevel, int posX, int posZ)
|
||||
{
|
||||
// When rapidly changing dimensions the bufferBuidler can cause this,
|
||||
@@ -42,82 +42,89 @@ public class PosToRenderContainer
|
||||
{
|
||||
// This is might be due to dimensions having a different width
|
||||
// when first loading in
|
||||
ClientProxy.LOGGER.error("Unable to addPosToRender. numberOfPosToRender [" + numberOfPosToRender +"] detailLevel [" + detailLevel + "] Pos [" + posX + "," + posZ + "]");
|
||||
ClientProxy.LOGGER.error("Unable to addPosToRender. numberOfPosToRender [" + numberOfPosToRender + "] detailLevel [" + detailLevel + "] Pos [" + posX + "," + posZ + "]");
|
||||
numberOfPosToRender++; // incrementing so we can see how many pos over the limit we would go
|
||||
return;
|
||||
}
|
||||
|
||||
//if(numberOfPosToRender >= posToRender.length)
|
||||
// posToRender = Arrays.copyOf(posToRender, posToRender.length*2);
|
||||
posToRender[numberOfPosToRender*3 + 0] = detailLevel;
|
||||
posToRender[numberOfPosToRender*3 + 1] = posX;
|
||||
posToRender[numberOfPosToRender*3 + 2] = posZ;
|
||||
posToRender[numberOfPosToRender * 3] = detailLevel;
|
||||
posToRender[numberOfPosToRender * 3 + 1] = posX;
|
||||
posToRender[numberOfPosToRender * 3 + 2] = posZ;
|
||||
numberOfPosToRender++;
|
||||
population[LevelPosUtil.getRegionModule(minDetail, LevelPosUtil.convert(detailLevel,posX,minDetail))]
|
||||
[LevelPosUtil.getRegionModule(minDetail, LevelPosUtil.convert(detailLevel,posZ,minDetail))] = (byte) (detailLevel + 1);
|
||||
population[LevelPosUtil.getRegionModule(minDetail, LevelPosUtil.convert(detailLevel, posX, minDetail))]
|
||||
[LevelPosUtil.getRegionModule(minDetail, LevelPosUtil.convert(detailLevel, posZ, minDetail))] = (byte) (detailLevel + 1);
|
||||
}
|
||||
|
||||
|
||||
public boolean contains(byte detailLevel, int posX, int posZ)
|
||||
{
|
||||
if(LevelPosUtil.getRegion(detailLevel, posX) == regionPosX && LevelPosUtil.getRegion(detailLevel, posZ) == regionPosZ)
|
||||
if (LevelPosUtil.getRegion(detailLevel, posX) == regionPosX && LevelPosUtil.getRegion(detailLevel, posZ) == regionPosZ)
|
||||
{
|
||||
return (population[LevelPosUtil.getRegionModule(minDetail, LevelPosUtil.convert(detailLevel,posX,minDetail))]
|
||||
[LevelPosUtil.getRegionModule(minDetail, LevelPosUtil.convert(detailLevel,posZ,minDetail))] == (detailLevel + 1));
|
||||
}else
|
||||
return (population[LevelPosUtil.getRegionModule(minDetail, LevelPosUtil.convert(detailLevel, posX, minDetail))]
|
||||
[LevelPosUtil.getRegionModule(minDetail, LevelPosUtil.convert(detailLevel, posZ, minDetail))] == (detailLevel + 1));
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
public void clear(byte minDetail, int regionPosX, int regionPosZ){
|
||||
|
||||
public void clear(byte minDetail, int regionPosX, int regionPosZ)
|
||||
{
|
||||
this.numberOfPosToRender = 0;
|
||||
this.regionPosX = regionPosX;
|
||||
this.regionPosZ = regionPosZ;
|
||||
if(this.minDetail == minDetail)
|
||||
if (this.minDetail == minDetail)
|
||||
{
|
||||
Arrays.fill(posToRender, 0);
|
||||
for(int i = 0; i< population.length; i++)
|
||||
Arrays.fill(population[i], (byte) 0);
|
||||
}else{
|
||||
for (byte[] bytes : population)
|
||||
Arrays.fill(bytes, (byte) 0);
|
||||
}
|
||||
else
|
||||
{
|
||||
this.minDetail = minDetail;
|
||||
int size = 1 << (LodUtil.REGION_DETAIL_LEVEL - minDetail);
|
||||
posToRender = new int[size*size*3];
|
||||
posToRender = new int[size * size * 3];
|
||||
population = new byte[size][size];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public int getNumberOfPos()
|
||||
{
|
||||
return numberOfPosToRender;
|
||||
}
|
||||
|
||||
|
||||
public byte getNthDetailLevel(int n)
|
||||
{
|
||||
return (byte) posToRender[n*3 + 0];
|
||||
return (byte) posToRender[n * 3];
|
||||
}
|
||||
|
||||
public int getNthPosX(int n)
|
||||
{
|
||||
return posToRender[n*3 + 1];
|
||||
return posToRender[n * 3 + 1];
|
||||
}
|
||||
|
||||
public int getNthPosZ(int n)
|
||||
{
|
||||
return posToRender[n*3 + 2];
|
||||
return posToRender[n * 3 + 2];
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public String toString()
|
||||
{
|
||||
|
||||
|
||||
StringBuilder builder = new StringBuilder();
|
||||
builder.append("To render ");
|
||||
builder.append(numberOfPosToRender);
|
||||
builder.append('\n');
|
||||
for(int i = 0; i < numberOfPosToRender; i++)
|
||||
for (int i = 0; i < numberOfPosToRender; i++)
|
||||
{
|
||||
builder.append(posToRender[i*3 + 0]);
|
||||
builder.append(posToRender[i * 3]);
|
||||
builder.append(" ");
|
||||
builder.append(posToRender[i*3 + 1]);
|
||||
builder.append(posToRender[i * 3 + 1]);
|
||||
builder.append(" ");
|
||||
builder.append(posToRender[i*3 + 2]);
|
||||
builder.append(posToRender[i * 3 + 2]);
|
||||
builder.append('\n');
|
||||
}
|
||||
builder.append('\n');
|
||||
|
||||
@@ -1,15 +1,15 @@
|
||||
package com.seibel.lod.objects;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
import com.seibel.lod.util.DataPointUtil;
|
||||
import com.seibel.lod.util.LevelPosUtil;
|
||||
import com.seibel.lod.util.LodUtil;
|
||||
import com.seibel.lod.util.ThreadMapUtil;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
/**
|
||||
* This object holds the LOD data for a single dataPoint.
|
||||
*
|
||||
*
|
||||
* @author Leonardo Amato
|
||||
* @version 9-28-2021
|
||||
*/
|
||||
@@ -195,11 +195,13 @@ public class SingleLevelContainer implements LevelContainer
|
||||
{
|
||||
tempData[index] = 0;
|
||||
index++;
|
||||
} else if (dataContainer[x][z] == 3)
|
||||
}
|
||||
else if (dataContainer[x][z] == 3)
|
||||
{
|
||||
tempData[index] = 3;
|
||||
index++;
|
||||
} else
|
||||
}
|
||||
else
|
||||
{
|
||||
for (tempIndex = 0; tempIndex < 8; tempIndex++)
|
||||
tempData[index + tempIndex] = (byte) (dataContainer[x][z] >>> (8 * tempIndex));
|
||||
@@ -213,9 +215,7 @@ public class SingleLevelContainer implements LevelContainer
|
||||
@Override
|
||||
public String toString()
|
||||
{
|
||||
StringBuilder stringBuilder = new StringBuilder();
|
||||
stringBuilder.append(detailLevel);
|
||||
return stringBuilder.toString();
|
||||
return String.valueOf(detailLevel);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -15,11 +15,8 @@
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.seibel.lod.proxy;
|
||||
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.lwjgl.glfw.GLFW;
|
||||
package com.seibel.lod.proxy;
|
||||
|
||||
import com.mojang.blaze3d.matrix.MatrixStack;
|
||||
import com.seibel.lod.builders.bufferBuilding.LodBufferBuilder;
|
||||
@@ -37,7 +34,6 @@ import com.seibel.lod.util.DetailDistanceUtil;
|
||||
import com.seibel.lod.util.LodUtil;
|
||||
import com.seibel.lod.util.ThreadMapUtil;
|
||||
import com.seibel.lod.wrappers.MinecraftWrapper;
|
||||
|
||||
import net.minecraft.profiler.IProfiler;
|
||||
import net.minecraft.util.text.StringTextComponent;
|
||||
import net.minecraftforge.client.event.InputEvent;
|
||||
@@ -46,6 +42,9 @@ import net.minecraftforge.event.world.BlockEvent;
|
||||
import net.minecraftforge.event.world.ChunkEvent;
|
||||
import net.minecraftforge.event.world.WorldEvent;
|
||||
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.lwjgl.glfw.GLFW;
|
||||
|
||||
/**
|
||||
* This handles all events sent to the client,
|
||||
@@ -58,7 +57,7 @@ public class ClientProxy
|
||||
{
|
||||
public static final Logger LOGGER = LogManager.getLogger("LOD");
|
||||
|
||||
/**
|
||||
/**
|
||||
* there is some setup that should only happen once,
|
||||
* once this is true that setup has completed
|
||||
*/
|
||||
@@ -99,8 +98,8 @@ public class ClientProxy
|
||||
/**
|
||||
* Do any setup that is required to draw LODs
|
||||
* and then tell the LodRenderer to draw.
|
||||
*
|
||||
* @param mcMatrixStack
|
||||
*
|
||||
* @param mcMatrixStack
|
||||
*/
|
||||
public void renderLods(MatrixStack mcMatrixStack, float partialTicks)
|
||||
{
|
||||
@@ -140,7 +139,7 @@ public class ClientProxy
|
||||
profiler.pop(); // get out of "terrain"
|
||||
profiler.push("LOD");
|
||||
|
||||
renderer.drawLODs(lodDim, mcMatrixStack, partialTicks, mc.getProfiler());
|
||||
renderer.drawLODs(lodDim, mcMatrixStack, partialTicks, mc.getProfiler());
|
||||
|
||||
profiler.pop(); // end LOD
|
||||
profiler.push("terrain"); // go back into "terrain"
|
||||
@@ -170,23 +169,23 @@ public class ClientProxy
|
||||
mc.getPlayer().sendMessage(new StringTextComponent("Debug settings enabled!"), mc.getPlayer().getUUID());
|
||||
configOverrideReminderPrinted = true;
|
||||
}
|
||||
|
||||
|
||||
// LodConfig.CLIENT.graphics.drawResolution.set(HorizontalResolution.BLOCK);
|
||||
// LodConfig.CLIENT.worldGenerator.generationResolution.set(HorizontalResolution.BLOCK);
|
||||
// requires a world restart?
|
||||
// LodConfig.CLIENT.worldGenerator.lodQualityMode.set(VerticalQuality.VOXEL);
|
||||
|
||||
|
||||
// LodConfig.CLIENT.graphics.fogDistance.set(FogDistance.FAR);
|
||||
// LodConfig.CLIENT.graphics.fogDrawOverride.set(FogDrawOverride.ALWAYS_DRAW_FOG_FANCY);
|
||||
// LodConfig.CLIENT.graphics.shadingMode.set(ShadingMode.DARKEN_SIDES);
|
||||
// LodConfig.CLIENT.graphics.brightnessMultiplier.set(1.0);
|
||||
// LodConfig.CLIENT.graphics.saturationMultiplier.set(1.0);
|
||||
|
||||
|
||||
// LodConfig.CLIENT.worldGenerator.distanceGenerationMode.set(DistanceGenerationMode.SURFACE);
|
||||
// LodConfig.CLIENT.graphics.lodChunkRenderDistance.set(64);
|
||||
// LodConfig.CLIENT.worldGenerator.lodDistanceCalculatorType.set(DistanceCalculatorType.LINEAR);
|
||||
// LodConfig.CLIENT.worldGenerator.allowUnstableFeatureGeneration.set(false);
|
||||
|
||||
|
||||
// LodConfig.CLIENT.buffers.bufferRebuildPlayerMoveTimeout.set(2000); // 2000
|
||||
// LodConfig.CLIENT.buffers.bufferRebuildChunkChangeTimeout.set(1000); // 1000
|
||||
// LodConfig.CLIENT.buffers.bufferRebuildLodChangeTimeout.set(5000); // 5000
|
||||
@@ -291,15 +290,15 @@ public class ClientProxy
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public void onKeyInput(InputEvent.KeyInputEvent event)
|
||||
public void onKeyInput(InputEvent.KeyInputEvent event)
|
||||
{
|
||||
if(LodConfig.CLIENT.debugging.enableDebugKeybindings.get()
|
||||
if (LodConfig.CLIENT.debugging.enableDebugKeybindings.get()
|
||||
&& event.getKey() == GLFW.GLFW_KEY_F4 && event.getAction() == GLFW.GLFW_PRESS)
|
||||
{
|
||||
LodConfig.CLIENT.debugging.debugMode.set(LodConfig.CLIENT.debugging.debugMode.get().getNext());
|
||||
}
|
||||
|
||||
if(LodConfig.CLIENT.debugging.enableDebugKeybindings.get()
|
||||
if (LodConfig.CLIENT.debugging.enableDebugKeybindings.get()
|
||||
&& event.getKey() == GLFW.GLFW_KEY_F6 && event.getAction() == GLFW.GLFW_PRESS)
|
||||
{
|
||||
LodConfig.CLIENT.graphics.drawLods.set(!LodConfig.CLIENT.graphics.drawLods.get());
|
||||
@@ -334,13 +333,17 @@ public class ClientProxy
|
||||
{
|
||||
// calculate how wide the dimension(s) should be in regions
|
||||
int chunksWide;
|
||||
if(mc.getClientWorld().dimensionType().hasCeiling())
|
||||
chunksWide = Math.max(LodConfig.CLIENT.graphics.lodChunkRenderDistance.get(),64) * 2 + 1;
|
||||
if (mc.getClientWorld().dimensionType().hasCeiling())
|
||||
chunksWide = Math.max(LodConfig.CLIENT.graphics.lodChunkRenderDistance.get(), 64) * 2 + 1;
|
||||
else
|
||||
chunksWide = LodConfig.CLIENT.graphics.lodChunkRenderDistance.get() * 2 + 1;
|
||||
|
||||
|
||||
int newWidth = (int) Math.ceil(chunksWide / (float) LodUtil.REGION_WIDTH_IN_CHUNKS);
|
||||
newWidth = (newWidth % 2 == 0) ? (newWidth += 1) : (newWidth += 2); // make sure we have a odd number of regions
|
||||
// make sure we have a odd number of regions
|
||||
if ((newWidth & 1) == 0)
|
||||
newWidth += 1;
|
||||
else
|
||||
newWidth += 2;
|
||||
|
||||
// do the dimensions need to change in size?
|
||||
if (lodBuilder.defaultDimensionWidthInRegions != newWidth || recalculateWidths)
|
||||
@@ -372,7 +375,7 @@ public class ClientProxy
|
||||
|
||||
firstTimeSetupComplete = true;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* this method reset some of the static data everytime we change world
|
||||
**/
|
||||
@@ -380,7 +383,7 @@ public class ClientProxy
|
||||
{
|
||||
ThreadMapUtil.clearMaps();
|
||||
LodNodeGenWorker.restartExecuterService();
|
||||
|
||||
|
||||
}
|
||||
|
||||
//================//
|
||||
|
||||
@@ -1,24 +1,23 @@
|
||||
package com.seibel.lod.proxy;
|
||||
|
||||
import com.mojang.blaze3d.systems.RenderSystem;
|
||||
import com.seibel.lod.enums.GlProxyContext;
|
||||
import org.lwjgl.glfw.GLFW;
|
||||
import org.lwjgl.opengl.GL;
|
||||
import org.lwjgl.opengl.GLCapabilities;
|
||||
|
||||
import com.mojang.blaze3d.systems.RenderSystem;
|
||||
import com.seibel.lod.enums.GlProxyContext;
|
||||
|
||||
/**
|
||||
* A singleton that holds references to different openGL contexts
|
||||
* and GPU capabilities.
|
||||
*
|
||||
*
|
||||
* <p>
|
||||
* Helpful OpenGL resources: <br><br>
|
||||
*
|
||||
*
|
||||
* https://www.seas.upenn.edu/~pcozzi/OpenGLInsights/OpenGLInsights-AsynchronousBufferTransfers.pdf <br>
|
||||
* https://learnopengl.com/Advanced-OpenGL/Advanced-Data <br>
|
||||
* https://gamedev.stackexchange.com/questions/91995/edit-vbo-data-or-create-a-new-one <br><br>
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
* @author James Seibel
|
||||
* @version 10-2-2021
|
||||
*/
|
||||
@@ -67,7 +66,7 @@ public class GlProxy
|
||||
|
||||
// Hopefully this shouldn't cause any issues with other mods that need custom contexts
|
||||
// (although the number that do should be relatively few)
|
||||
GLFW.glfwWindowHint(GLFW.GLFW_VISIBLE, GLFW.GLFW_FALSE);
|
||||
GLFW.glfwWindowHint(GLFW.GLFW_VISIBLE, GLFW.GLFW_FALSE);
|
||||
|
||||
// create an invisible window to hold the context
|
||||
lodBuilderGlContext = GLFW.glfwCreateWindow(640, 480, "LOD window", 0L, minecraftGlContext);
|
||||
@@ -87,7 +86,7 @@ public class GlProxy
|
||||
|
||||
// see if this GPU can run fancy fog
|
||||
fancyFogAvailable = GL.getCapabilities().GL_NV_fog_distance;
|
||||
|
||||
|
||||
if (!fancyFogAvailable)
|
||||
{
|
||||
ClientProxy.LOGGER.info("This GPU does not support GL_NV_fog_distance. This means that the fancy fog option will not be available.");
|
||||
@@ -114,7 +113,7 @@ public class GlProxy
|
||||
GLCapabilities newGlCapabilities = null;
|
||||
|
||||
// get the pointer(s) for this context
|
||||
switch(newContext)
|
||||
switch (newContext)
|
||||
{
|
||||
case LOD_BUILDER:
|
||||
contextPointer = lodBuilderGlContext;
|
||||
@@ -129,9 +128,6 @@ public class GlProxy
|
||||
default: // default should never happen, it is just here to make the compiler happy
|
||||
case NONE:
|
||||
// 0L is equivalent to null
|
||||
|
||||
contextPointer = 0L;
|
||||
newGlCapabilities = null;
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -158,9 +154,9 @@ public class GlProxy
|
||||
long currentContext = GLFW.glfwGetCurrentContext();
|
||||
|
||||
|
||||
if(currentContext == lodBuilderGlContext)
|
||||
if (currentContext == lodBuilderGlContext)
|
||||
return GlProxyContext.LOD_BUILDER;
|
||||
else if(currentContext == minecraftGlContext)
|
||||
else if (currentContext == minecraftGlContext)
|
||||
return GlProxyContext.MINECRAFT;
|
||||
else if (currentContext == 0L)
|
||||
return GlProxyContext.NONE;
|
||||
|
||||
@@ -15,26 +15,16 @@
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.seibel.lod.render;
|
||||
|
||||
import java.util.HashSet;
|
||||
|
||||
import org.lwjgl.opengl.GL11;
|
||||
import org.lwjgl.opengl.GL15;
|
||||
import org.lwjgl.opengl.GL15C;
|
||||
import org.lwjgl.opengl.NVFogDistance;
|
||||
|
||||
import com.mojang.blaze3d.matrix.MatrixStack;
|
||||
import com.mojang.blaze3d.platform.GlStateManager;
|
||||
import com.mojang.blaze3d.systems.RenderSystem;
|
||||
import com.seibel.lod.builders.bufferBuilding.LodBufferBuilder;
|
||||
import com.seibel.lod.builders.bufferBuilding.LodBufferBuilder.VertexBuffersAndOffset;
|
||||
import com.seibel.lod.config.LodConfig;
|
||||
import com.seibel.lod.enums.DebugMode;
|
||||
import com.seibel.lod.enums.DetailDropOff;
|
||||
import com.seibel.lod.enums.FogDistance;
|
||||
import com.seibel.lod.enums.FogDrawOverride;
|
||||
import com.seibel.lod.enums.FogQuality;
|
||||
import com.seibel.lod.enums.*;
|
||||
import com.seibel.lod.handlers.ReflectionHandler;
|
||||
import com.seibel.lod.objects.LodDimension;
|
||||
import com.seibel.lod.objects.NearFarFogSettings;
|
||||
@@ -45,7 +35,6 @@ import com.seibel.lod.util.DetailDistanceUtil;
|
||||
import com.seibel.lod.util.LevelPosUtil;
|
||||
import com.seibel.lod.util.LodUtil;
|
||||
import com.seibel.lod.wrappers.MinecraftWrapper;
|
||||
|
||||
import net.minecraft.client.renderer.ActiveRenderInfo;
|
||||
import net.minecraft.client.renderer.FogRenderer;
|
||||
import net.minecraft.client.renderer.GameRenderer;
|
||||
@@ -56,6 +45,12 @@ import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.ChunkPos;
|
||||
import net.minecraft.util.math.vector.Matrix4f;
|
||||
import net.minecraft.util.math.vector.Vector3d;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
import org.lwjgl.opengl.GL15;
|
||||
import org.lwjgl.opengl.GL15C;
|
||||
import org.lwjgl.opengl.NVFogDistance;
|
||||
|
||||
import java.util.HashSet;
|
||||
|
||||
|
||||
/**
|
||||
@@ -90,7 +85,7 @@ public class LodRenderer
|
||||
|
||||
/** Each VertexBuffer represents 1 region */
|
||||
private VertexBuffer[][][] vbos;
|
||||
/**
|
||||
/**
|
||||
* the OpenGL IDs for the vbos of the same indices.
|
||||
* These have to be separate because we can't override the
|
||||
* buffers in the VBOs (and we don't want too)
|
||||
@@ -101,7 +96,7 @@ public class LodRenderer
|
||||
|
||||
|
||||
/** This is used to determine if the LODs should be regenerated */
|
||||
private int[] previousPos = new int[]{0, 0, 0};
|
||||
private int[] previousPos = new int[] { 0, 0, 0 };
|
||||
|
||||
public NativeImage lightMap = null;
|
||||
|
||||
@@ -227,7 +222,7 @@ public class LodRenderer
|
||||
|
||||
// enable transparent rendering
|
||||
GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
|
||||
GL11.glEnable( GL11.GL_BLEND );
|
||||
GL11.glEnable(GL11.GL_BLEND);
|
||||
|
||||
// disable the lights Minecraft uses
|
||||
GL11.glDisable(GL11.GL_LIGHT0);
|
||||
@@ -310,7 +305,7 @@ public class LodRenderer
|
||||
GL11.glPolygonMode(GL11.GL_FRONT_AND_BACK, GL11.GL_FILL);
|
||||
GL11.glEnable(GL11.GL_TEXTURE_2D);
|
||||
GL11.glDisable(LOD_GL_LIGHT_NUMBER);
|
||||
GL11.glDisable( GL11.GL_BLEND );
|
||||
GL11.glDisable(GL11.GL_BLEND);
|
||||
// re-enable the lights Minecraft uses
|
||||
GL11.glEnable(GL11.GL_LIGHT0);
|
||||
GL11.glEnable(GL11.GL_LIGHT1);
|
||||
@@ -378,7 +373,8 @@ public class LodRenderer
|
||||
{
|
||||
// fancy fog (fragment distance based fog)
|
||||
glFogDistanceMode = NVFogDistance.GL_EYE_RADIAL_NV;
|
||||
} else
|
||||
}
|
||||
else
|
||||
{
|
||||
// fast fog (frustum distance based fog)
|
||||
glFogDistanceMode = NVFogDistance.GL_EYE_PLANE_ABSOLUTE_NV;
|
||||
@@ -400,12 +396,14 @@ public class LodRenderer
|
||||
{
|
||||
RenderSystem.fogStart(farPlaneBlockDistance * 0.9f);
|
||||
RenderSystem.fogEnd(farPlaneBlockDistance * 1.0f);
|
||||
} else
|
||||
}
|
||||
else
|
||||
{
|
||||
RenderSystem.fogStart(farPlaneBlockDistance * 0.1f);
|
||||
RenderSystem.fogEnd(farPlaneBlockDistance * 1.0f);
|
||||
}
|
||||
} else if (fogQuality == FogQuality.FAST)
|
||||
}
|
||||
else if (fogQuality == FogQuality.FAST)
|
||||
{
|
||||
// for the far fog of the normal chunks
|
||||
// to start right where the LODs' end use:
|
||||
@@ -413,13 +411,15 @@ public class LodRenderer
|
||||
RenderSystem.fogStart(farPlaneBlockDistance * 1.5f);
|
||||
RenderSystem.fogEnd(farPlaneBlockDistance * 2.0f);
|
||||
}
|
||||
} else if (fogDistance == FogDistance.NEAR)
|
||||
}
|
||||
else if (fogDistance == FogDistance.NEAR)
|
||||
{
|
||||
if (fogQuality == FogQuality.FANCY)
|
||||
{
|
||||
RenderSystem.fogEnd(mc.getRenderDistance() * 16 * 1.41f);
|
||||
RenderSystem.fogStart(mc.getRenderDistance() * 16 * 1.6f);
|
||||
} else if (fogQuality == FogQuality.FAST)
|
||||
}
|
||||
else if (fogQuality == FogQuality.FAST)
|
||||
{
|
||||
RenderSystem.fogEnd(mc.getRenderDistance() * 16 * 1.0f);
|
||||
RenderSystem.fogStart(mc.getRenderDistance() * 16 * 1.5f);
|
||||
@@ -450,7 +450,7 @@ public class LodRenderer
|
||||
// but we were
|
||||
if (!fogSettings.vanillaIsRenderingFog &&
|
||||
(fogSettings.near.quality != FogQuality.OFF ||
|
||||
fogSettings.far.quality != FogQuality.OFF))
|
||||
fogSettings.far.quality != FogQuality.OFF))
|
||||
{
|
||||
GL11.glDisable(GL11.GL_FOG);
|
||||
}
|
||||
@@ -528,7 +528,7 @@ public class LodRenderer
|
||||
getFov(partialTicks, true),
|
||||
(float) this.mc.getWindow().getScreenWidth() / (float) this.mc.getWindow().getScreenHeight(),
|
||||
mc.getRenderDistance() / 2,
|
||||
farPlaneBlockDistance * LodUtil.CHUNK_WIDTH * 2 / 4);
|
||||
farPlaneBlockDistance * LodUtil.CHUNK_WIDTH / 2);
|
||||
|
||||
// get Minecraft's un-edited projection matrix
|
||||
// (this is before it is zoomed, distorted, etc.)
|
||||
@@ -671,15 +671,15 @@ public class LodRenderer
|
||||
case ALWAYS_DRAW_FOG_FANCY:
|
||||
quality = FogQuality.FANCY;
|
||||
break;
|
||||
|
||||
|
||||
case NEVER_DRAW_FOG:
|
||||
quality = FogQuality.OFF;
|
||||
break;
|
||||
|
||||
|
||||
case ALWAYS_DRAW_FOG_FAST:
|
||||
quality = FogQuality.FAST;
|
||||
break;
|
||||
|
||||
|
||||
case USE_OPTIFINE_FOG_SETTING:
|
||||
// don't override anything
|
||||
break;
|
||||
@@ -706,19 +706,19 @@ public class LodRenderer
|
||||
fogSettings.near.distance = FogDistance.NEAR;
|
||||
fogSettings.far.distance = FogDistance.FAR;
|
||||
break;
|
||||
|
||||
|
||||
case NEAR:
|
||||
fogSettings.near.distance = FogDistance.NEAR;
|
||||
fogSettings.far.distance = FogDistance.NEAR;
|
||||
break;
|
||||
|
||||
|
||||
case FAR:
|
||||
fogSettings.near.distance = FogDistance.FAR;
|
||||
fogSettings.far.distance = FogDistance.FAR;
|
||||
break;
|
||||
}
|
||||
break;
|
||||
|
||||
|
||||
case FAST:
|
||||
fogSettings.near.quality = FogQuality.FAST;
|
||||
fogSettings.far.quality = FogQuality.FAST;
|
||||
@@ -733,19 +733,19 @@ public class LodRenderer
|
||||
fogSettings.near.distance = FogDistance.NEAR;
|
||||
fogSettings.far.distance = FogDistance.NEAR;
|
||||
break;
|
||||
|
||||
|
||||
case NEAR:
|
||||
fogSettings.near.distance = FogDistance.NEAR;
|
||||
fogSettings.far.distance = FogDistance.NEAR;
|
||||
break;
|
||||
|
||||
|
||||
case FAR:
|
||||
fogSettings.near.distance = FogDistance.FAR;
|
||||
fogSettings.far.distance = FogDistance.FAR;
|
||||
break;
|
||||
}
|
||||
break;
|
||||
|
||||
|
||||
case OFF:
|
||||
|
||||
fogSettings.near.quality = FogQuality.OFF;
|
||||
@@ -884,7 +884,7 @@ public class LodRenderer
|
||||
|
||||
|
||||
// if the player is high enough, draw all LODs
|
||||
if(chunkPosToSkip.isEmpty() && mc.getPlayer().position().y > 256)
|
||||
if (chunkPosToSkip.isEmpty() && mc.getPlayer().position().y > 256)
|
||||
{
|
||||
vanillaRenderedChunks = new boolean[vanillaRenderedChunksWidth][vanillaRenderedChunksWidth];
|
||||
vanillaRenderedChunksChanged = true;
|
||||
|
||||
@@ -2,21 +2,22 @@ package com.seibel.lod.util;
|
||||
|
||||
import com.seibel.lod.config.LodConfig;
|
||||
import com.seibel.lod.enums.DistanceGenerationMode;
|
||||
import com.seibel.lod.enums.HorizontalQuality;
|
||||
import com.seibel.lod.enums.HorizontalResolution;
|
||||
|
||||
public class DetailDistanceUtil
|
||||
{
|
||||
private static double genMultiplier = 1.0;
|
||||
private static double treeGenMultiplier = 1.0;
|
||||
private static double treeCutMultiplier = 1.0;
|
||||
private static final double genMultiplier = 1.0;
|
||||
private static final double treeGenMultiplier = 1.0;
|
||||
private static final double treeCutMultiplier = 1.0;
|
||||
private static int minGenDetail = LodConfig.CLIENT.worldGenerator.generationResolution.get().detailLevel;
|
||||
private static int minDrawDetail = Math.max(LodConfig.CLIENT.graphics.drawResolution.get().detailLevel,LodConfig.CLIENT.worldGenerator.generationResolution.get().detailLevel);
|
||||
private static int maxDetail = LodUtil.REGION_DETAIL_LEVEL + 1;
|
||||
private static int minDistance = 0;
|
||||
private static int minDrawDetail = Math.max(LodConfig.CLIENT.graphics.drawResolution.get().detailLevel, LodConfig.CLIENT.worldGenerator.generationResolution.get().detailLevel);
|
||||
private static final int maxDetail = LodUtil.REGION_DETAIL_LEVEL + 1;
|
||||
private static final int minDistance = 0;
|
||||
private static int maxDistance = LodConfig.CLIENT.graphics.lodChunkRenderDistance.get() * 16 * 2;
|
||||
|
||||
|
||||
private static int[] maxVerticalData = {
|
||||
private static final int[] maxVerticalData = {
|
||||
4,
|
||||
4,
|
||||
4,
|
||||
@@ -27,10 +28,10 @@ public class DetailDistanceUtil
|
||||
1,
|
||||
1,
|
||||
1,
|
||||
1};
|
||||
1 };
|
||||
|
||||
|
||||
private static HorizontalResolution[] lodGenDetails = {
|
||||
private static final HorizontalResolution[] lodGenDetails = {
|
||||
HorizontalResolution.BLOCK,
|
||||
HorizontalResolution.TWO_BLOCKS,
|
||||
HorizontalResolution.FOUR_BLOCKS,
|
||||
@@ -41,13 +42,14 @@ public class DetailDistanceUtil
|
||||
HorizontalResolution.CHUNK,
|
||||
HorizontalResolution.CHUNK,
|
||||
HorizontalResolution.CHUNK,
|
||||
HorizontalResolution.CHUNK};
|
||||
HorizontalResolution.CHUNK };
|
||||
|
||||
|
||||
|
||||
public static void updateSettings(){
|
||||
public static void updateSettings()
|
||||
{
|
||||
minGenDetail = LodConfig.CLIENT.worldGenerator.generationResolution.get().detailLevel;
|
||||
minDrawDetail = Math.max(LodConfig.CLIENT.graphics.drawResolution.get().detailLevel,LodConfig.CLIENT.worldGenerator.generationResolution.get().detailLevel);
|
||||
minDrawDetail = Math.max(LodConfig.CLIENT.graphics.drawResolution.get().detailLevel, LodConfig.CLIENT.worldGenerator.generationResolution.get().detailLevel);
|
||||
maxDistance = LodConfig.CLIENT.graphics.lodChunkRenderDistance.get() * 16 * 8;
|
||||
}
|
||||
|
||||
@@ -59,11 +61,10 @@ public class DetailDistanceUtil
|
||||
return maxDistance;
|
||||
|
||||
int distanceUnit = LodConfig.CLIENT.worldGenerator.horizontalScale.get().distanceUnit;
|
||||
switch (LodConfig.CLIENT.worldGenerator.horizontalQuality.get())
|
||||
{
|
||||
case LINEAR:
|
||||
if (LodConfig.CLIENT.worldGenerator.horizontalQuality.get() == HorizontalQuality.LINEAR)
|
||||
return (detail * distanceUnit);
|
||||
default:
|
||||
else
|
||||
{
|
||||
double base = LodConfig.CLIENT.worldGenerator.horizontalQuality.get().quadraticBase;
|
||||
return (int) (Math.pow(base, detail) * distanceUnit);
|
||||
}
|
||||
@@ -77,21 +78,19 @@ public class DetailDistanceUtil
|
||||
public static byte baseInverseFunction(int distance, int minDetail)
|
||||
{
|
||||
|
||||
int detail = 0;
|
||||
int detail;
|
||||
if (distance == 0)
|
||||
return (byte) minDetail;
|
||||
int distanceUnit = LodConfig.CLIENT.worldGenerator.horizontalScale.get().distanceUnit;
|
||||
switch (LodConfig.CLIENT.worldGenerator.horizontalQuality.get()){
|
||||
case LINEAR:
|
||||
if (LodConfig.CLIENT.worldGenerator.horizontalQuality.get() == HorizontalQuality.LINEAR)
|
||||
detail = (byte) Math.floorDiv(distance, distanceUnit);
|
||||
break;
|
||||
default:
|
||||
else
|
||||
{
|
||||
double base = LodConfig.CLIENT.worldGenerator.horizontalQuality.get().quadraticBase;
|
||||
double logBase = Math.log(base);
|
||||
detail = (byte) (Math.log(Math.floorDiv(distance, distanceUnit))/logBase);
|
||||
break;
|
||||
detail = (byte) (Math.log(Math.floorDiv(distance, distanceUnit)) / logBase);
|
||||
}
|
||||
return (byte) LodUtil.clamp(minDetail, detail, maxDetail-1);
|
||||
return (byte) LodUtil.clamp(minDetail, detail, maxDetail - 1);
|
||||
}
|
||||
|
||||
public static byte getDrawDetailFromDistance(int distance)
|
||||
@@ -124,14 +123,14 @@ public class DetailDistanceUtil
|
||||
{
|
||||
if (detail < minDrawDetail)
|
||||
{
|
||||
if(LodConfig.CLIENT.graphics.alwaysDrawAtMaxQuality.get())
|
||||
if (LodConfig.CLIENT.graphics.alwaysDrawAtMaxQuality.get())
|
||||
return getLodGenDetail(minDrawDetail).detailLevel;
|
||||
else
|
||||
return (byte) minDrawDetail;
|
||||
}
|
||||
else
|
||||
{
|
||||
if(LodConfig.CLIENT.graphics.alwaysDrawAtMaxQuality.get())
|
||||
if (LodConfig.CLIENT.graphics.alwaysDrawAtMaxQuality.get())
|
||||
return getLodGenDetail(detail).detailLevel;
|
||||
else
|
||||
return (byte) detail;
|
||||
@@ -143,7 +142,8 @@ public class DetailDistanceUtil
|
||||
if (detail < minGenDetail)
|
||||
{
|
||||
return lodGenDetails[minGenDetail];
|
||||
} else
|
||||
}
|
||||
else
|
||||
{
|
||||
return lodGenDetails[detail];
|
||||
}
|
||||
@@ -155,10 +155,12 @@ public class DetailDistanceUtil
|
||||
if (detail < minGenDetail)
|
||||
{
|
||||
return lodGenDetails[minGenDetail].detailLevel;
|
||||
} else if (detail == maxDetail)
|
||||
}
|
||||
else if (detail == maxDetail)
|
||||
{
|
||||
return LodUtil.REGION_DETAIL_LEVEL;
|
||||
} else
|
||||
}
|
||||
else
|
||||
{
|
||||
return lodGenDetails[detail].detailLevel;
|
||||
}
|
||||
|
||||
@@ -1,14 +1,12 @@
|
||||
package com.seibel.lod.util;
|
||||
|
||||
import com.seibel.lod.config.LodConfig;
|
||||
|
||||
public class LevelPosUtil
|
||||
{
|
||||
public static int[] convert(int[] levelPos, byte newDetailLevel)
|
||||
{
|
||||
return convert(getDetailLevel(levelPos), getPosX(levelPos), getPosZ(levelPos), newDetailLevel);
|
||||
}
|
||||
|
||||
|
||||
public static int[] convert(byte detailLevel, int posX, int posZ, byte newDetailLevel)
|
||||
{
|
||||
int width;
|
||||
@@ -19,7 +17,8 @@ public class LevelPosUtil
|
||||
newDetailLevel,
|
||||
Math.floorDiv(posX, width),
|
||||
Math.floorDiv(posZ, width));
|
||||
} else
|
||||
}
|
||||
else
|
||||
{
|
||||
width = 1 << (detailLevel - newDetailLevel);
|
||||
return createLevelPos(
|
||||
@@ -28,12 +27,12 @@ public class LevelPosUtil
|
||||
posZ * width);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public static int[] createLevelPos(byte detailLevel, int posX, int posZ)
|
||||
{
|
||||
return new int[]{detailLevel, posX, posZ};
|
||||
return new int[] { detailLevel, posX, posZ };
|
||||
}
|
||||
|
||||
|
||||
public static int convert(byte detailLevel, int pos, byte newDetailLevel)
|
||||
{
|
||||
int width;
|
||||
@@ -41,48 +40,49 @@ public class LevelPosUtil
|
||||
{
|
||||
width = 1 << (newDetailLevel - detailLevel);
|
||||
return Math.floorDiv(pos, width);
|
||||
} else
|
||||
}
|
||||
else
|
||||
{
|
||||
width = 1 << (detailLevel - newDetailLevel);
|
||||
return pos * width;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public static int getRegion(byte detailLevel, int pos)
|
||||
{
|
||||
return Math.floorDiv(pos, 1 << (LodUtil.REGION_DETAIL_LEVEL - detailLevel));
|
||||
}
|
||||
|
||||
|
||||
public static int getRegionModule(byte detailLevel, int pos)
|
||||
{
|
||||
return Math.floorMod(pos, 1 << (LodUtil.REGION_DETAIL_LEVEL - detailLevel));
|
||||
}
|
||||
|
||||
|
||||
public static byte getDetailLevel(int[] levelPos)
|
||||
{
|
||||
return (byte) levelPos[0];
|
||||
}
|
||||
|
||||
|
||||
public static int getPosX(int[] levelPos)
|
||||
{
|
||||
return levelPos[1];
|
||||
}
|
||||
|
||||
|
||||
public static int getPosZ(int[] levelPos)
|
||||
{
|
||||
return levelPos[2];
|
||||
}
|
||||
|
||||
|
||||
public static int getDistance(int[] levelPos)
|
||||
{
|
||||
return levelPos[3];
|
||||
}
|
||||
|
||||
|
||||
public static int[] getRegionModule(int[] levelPos)
|
||||
{
|
||||
return getRegionModule(getDetailLevel(levelPos), getPosX(levelPos), getPosZ(levelPos));
|
||||
}
|
||||
|
||||
|
||||
public static int[] getRegionModule(byte detailLevel, int posX, int posZ)
|
||||
{
|
||||
int width = 1 << (LodUtil.REGION_DETAIL_LEVEL - detailLevel);
|
||||
@@ -91,7 +91,7 @@ public class LevelPosUtil
|
||||
Math.floorMod(posX, width),
|
||||
Math.floorMod(posZ, width));
|
||||
}
|
||||
|
||||
|
||||
public static int[] applyOffset(int[] levelPos, int xOffset, int zOffset)
|
||||
{
|
||||
return createLevelPos(
|
||||
@@ -99,7 +99,7 @@ public class LevelPosUtil
|
||||
getPosX(levelPos) + xOffset,
|
||||
getPosZ(levelPos) + zOffset);
|
||||
}
|
||||
|
||||
|
||||
public static int[] applyLevelOffset(int[] levelPos, byte detailOffset, int xOffset, int zOffset)
|
||||
{
|
||||
return createLevelPos(
|
||||
@@ -107,42 +107,42 @@ public class LevelPosUtil
|
||||
getPosX(levelPos) + xOffset * (1 << detailOffset),
|
||||
getPosZ(levelPos) + zOffset * (1 << detailOffset));
|
||||
}
|
||||
|
||||
|
||||
public static int getRegionPosX(int[] levelPos)
|
||||
{
|
||||
int width = 1 << (LodUtil.REGION_DETAIL_LEVEL - getDetailLevel(levelPos));
|
||||
return Math.floorDiv(getPosX(levelPos), width);
|
||||
}
|
||||
|
||||
|
||||
public static int getRegionPosZ(int[] levelPos)
|
||||
{
|
||||
int width = 1 << (LodUtil.REGION_DETAIL_LEVEL - getDetailLevel(levelPos));
|
||||
return Math.floorDiv(getPosZ(levelPos), width);
|
||||
}
|
||||
|
||||
|
||||
public static int getChunkPos(byte detailLevel, int pos)
|
||||
{
|
||||
return convert(detailLevel,pos, LodUtil.CHUNK_DETAIL_LEVEL);
|
||||
return convert(detailLevel, pos, LodUtil.CHUNK_DETAIL_LEVEL);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
public static int maxDistance(byte detailLevel, int posX, int posZ, int playerPosX, int playerPosZ)
|
||||
{
|
||||
int width = 1 << detailLevel;
|
||||
|
||||
|
||||
int startPosX = posX * width;
|
||||
int startPosZ = posZ * width;
|
||||
int endPosX = startPosX + width;
|
||||
int endPosZ = startPosZ + width;
|
||||
|
||||
|
||||
int maxDistance = (int) Math.sqrt(Math.pow(playerPosX - startPosX, 2) + Math.pow(playerPosZ - startPosZ, 2));
|
||||
maxDistance = Math.max(maxDistance, (int) Math.sqrt(Math.pow(playerPosX - startPosX, 2) + Math.pow(playerPosZ - endPosZ, 2)));
|
||||
maxDistance = Math.max(maxDistance, (int) Math.sqrt(Math.pow(playerPosX - endPosX, 2) + Math.pow(playerPosZ - startPosZ, 2)));
|
||||
maxDistance = Math.max(maxDistance, (int) Math.sqrt(Math.pow(playerPosX - endPosX, 2) + Math.pow(playerPosZ - endPosZ, 2)));
|
||||
|
||||
|
||||
return maxDistance;
|
||||
}
|
||||
|
||||
|
||||
public static int maxDistance(byte detailLevel, int posX, int posZ, int playerPosX, int playerPosZ, int xRegion, int zRegion)
|
||||
{
|
||||
int width = 1 << (LodUtil.REGION_DETAIL_LEVEL - detailLevel);
|
||||
@@ -150,35 +150,38 @@ public class LevelPosUtil
|
||||
int newPosZ = zRegion * width + posZ;
|
||||
return maxDistance(detailLevel, newPosX, newPosZ, playerPosX, playerPosZ);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
public static int minDistance(byte detailLevel, int posX, int posZ, int playerPosX, int playerPosZ)
|
||||
{
|
||||
int width = 1 << detailLevel;
|
||||
|
||||
|
||||
int startPosX = posX * width;
|
||||
int startPosZ = posZ * width;
|
||||
int endPosX = startPosX + width;
|
||||
int endPosZ = startPosZ + width;
|
||||
|
||||
|
||||
boolean inXArea = playerPosX >= startPosX && playerPosX <= endPosX;
|
||||
boolean inZArea = playerPosZ >= startPosZ && playerPosZ <= endPosZ;
|
||||
if (inXArea && inZArea)
|
||||
{
|
||||
return 0;
|
||||
} else if (inXArea)
|
||||
}
|
||||
else if (inXArea)
|
||||
{
|
||||
return Math.min(
|
||||
Math.abs(playerPosZ - startPosZ),
|
||||
Math.abs(playerPosZ - endPosZ)
|
||||
);
|
||||
} else if (inZArea)
|
||||
}
|
||||
else if (inZArea)
|
||||
{
|
||||
return Math.min(
|
||||
Math.abs(playerPosX - startPosX),
|
||||
Math.abs(playerPosX - endPosX)
|
||||
);
|
||||
} else
|
||||
}
|
||||
else
|
||||
{
|
||||
int minDistance = (int) Math.sqrt(Math.pow(playerPosX - startPosX, 2) + Math.pow(playerPosZ - startPosZ, 2));
|
||||
minDistance = Math.min(minDistance, (int) Math.sqrt(Math.pow(playerPosX - startPosX, 2) + Math.pow(playerPosZ - endPosZ, 2)));
|
||||
@@ -187,7 +190,7 @@ public class LevelPosUtil
|
||||
return minDistance;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public static int minDistance(byte detailLevel, int posX, int posZ, int playerPosX, int playerPosZ, int xRegion, int zRegion)
|
||||
{
|
||||
int width = 1 << (LodUtil.REGION_DETAIL_LEVEL - detailLevel);
|
||||
@@ -195,15 +198,15 @@ public class LevelPosUtil
|
||||
int newPosZ = zRegion * width + posZ;
|
||||
return minDistance(detailLevel, newPosX, newPosZ, playerPosX, playerPosZ);
|
||||
}
|
||||
|
||||
|
||||
public static int compareDistance(int firstDistance, int secondDistance)
|
||||
{
|
||||
return Integer.compare(
|
||||
firstDistance,
|
||||
secondDistance);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
public static int compareLevelAndDistance(byte firstDetail, int firstDistance, byte secondDetail, int secondDistance)
|
||||
{
|
||||
int compareResult = Integer.compare(
|
||||
@@ -217,11 +220,12 @@ public class LevelPosUtil
|
||||
}
|
||||
return compareResult;
|
||||
}
|
||||
|
||||
|
||||
public static String toString(int[] levelPos)
|
||||
{
|
||||
return (getDetailLevel(levelPos) + " " + getPosX(levelPos) + " " + getPosZ(levelPos));
|
||||
}
|
||||
|
||||
public static String toString(byte detailLevel, int posX, int posZ)
|
||||
{
|
||||
return (detailLevel + " " + posX + " " + posZ);
|
||||
|
||||
@@ -15,18 +15,14 @@
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.seibel.lod.util;
|
||||
|
||||
import java.awt.Color;
|
||||
import java.io.File;
|
||||
import java.util.HashSet;
|
||||
package com.seibel.lod.util;
|
||||
|
||||
import com.seibel.lod.builders.bufferBuilding.lodTemplates.Box;
|
||||
import com.seibel.lod.enums.LodTemplate;
|
||||
import com.seibel.lod.objects.LodDimension;
|
||||
import com.seibel.lod.objects.RegionPos;
|
||||
import com.seibel.lod.wrappers.MinecraftWrapper;
|
||||
|
||||
import net.minecraft.client.multiplayer.ServerData;
|
||||
import net.minecraft.client.renderer.WorldRenderer;
|
||||
import net.minecraft.client.renderer.chunk.ChunkRenderDispatcher.CompiledChunk;
|
||||
@@ -44,6 +40,10 @@ import net.minecraft.world.gen.Heightmap;
|
||||
import net.minecraft.world.server.ServerChunkProvider;
|
||||
import net.minecraft.world.server.ServerWorld;
|
||||
|
||||
import java.awt.*;
|
||||
import java.io.File;
|
||||
import java.util.HashSet;
|
||||
|
||||
/**
|
||||
* This class holds methods and constants that may be used in multiple places.
|
||||
*
|
||||
@@ -52,7 +52,7 @@ import net.minecraft.world.server.ServerWorld;
|
||||
*/
|
||||
public class LodUtil
|
||||
{
|
||||
private static MinecraftWrapper mc = MinecraftWrapper.INSTANCE;
|
||||
private static final MinecraftWrapper mc = MinecraftWrapper.INSTANCE;
|
||||
|
||||
|
||||
/** The maximum number of LODs that can be rendered vertically */
|
||||
@@ -71,7 +71,7 @@ public class LodUtil
|
||||
* In order of nearest to farthest: <br>
|
||||
* Red, Orange, Yellow, Green, Cyan, Blue, Magenta, white, gray, black
|
||||
*/
|
||||
public static final Color DEBUG_DETAIL_LEVEL_COLORS[] = new Color[]{Color.RED, Color.ORANGE, Color.YELLOW, Color.GREEN, Color.CYAN, Color.BLUE, Color.MAGENTA, Color.WHITE, Color.GRAY, Color.BLACK};
|
||||
public static final Color[] DEBUG_DETAIL_LEVEL_COLORS = new Color[] { Color.RED, Color.ORANGE, Color.YELLOW, Color.GREEN, Color.CYAN, Color.BLUE, Color.MAGENTA, Color.WHITE, Color.GRAY, Color.BLACK };
|
||||
|
||||
|
||||
/**
|
||||
@@ -124,7 +124,7 @@ public class LodUtil
|
||||
* This regex finds any characters that are invalid for use in a windows
|
||||
* (and by extension mac and linux) file path
|
||||
*/
|
||||
public static final String INVALID_FILE_CHARACTERS_REGEX = "[\\\\\\/:*?\\\"<>|]";
|
||||
public static final String INVALID_FILE_CHARACTERS_REGEX = "[\\\\/:*?\"<>|]";
|
||||
|
||||
/**
|
||||
* 64 MB by default is the maximum amount of memory that
|
||||
@@ -139,7 +139,7 @@ public class LodUtil
|
||||
*/
|
||||
public static final int MAX_ALOCATEABLE_DIRECT_MEMORY = 64 * 1024 * 1024;
|
||||
|
||||
|
||||
|
||||
public static final VertexFormat LOD_VERTEX_FORMAT = DefaultVertexFormats.POSITION_COLOR;
|
||||
|
||||
|
||||
@@ -206,9 +206,7 @@ public class LodUtil
|
||||
*/
|
||||
public static int convertLevelPos(int pos, int currectDetailLevel, int targetDetailLevel)
|
||||
{
|
||||
int newPos = Math.floorDiv(pos, (int) Math.pow(2, targetDetailLevel - currectDetailLevel));
|
||||
|
||||
return newPos;
|
||||
return Math.floorDiv(pos, (int) Math.pow(2, targetDetailLevel - currectDetailLevel));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -248,7 +246,8 @@ public class LodUtil
|
||||
int slashIndex = dimId.indexOf(File.separatorChar, saveIndex);
|
||||
dimId = dimId.substring(saveIndex, slashIndex);
|
||||
return dimId;
|
||||
} else
|
||||
}
|
||||
else
|
||||
{
|
||||
return getServerId();
|
||||
}
|
||||
@@ -279,7 +278,8 @@ public class LodUtil
|
||||
throw new NullPointerException("getDimensionIDFromWorld wasn't able to get the ServerChunkProvider for the dimension " + world.dimensionType().effectsLocation().getPath());
|
||||
|
||||
return provider.dataStorage.dataFolder.toString();
|
||||
} else
|
||||
}
|
||||
else
|
||||
{
|
||||
return getServerId() + File.separatorChar + "dim_" + world.dimensionType().effectsLocation().getPath() + File.separatorChar;
|
||||
}
|
||||
@@ -296,9 +296,7 @@ public class LodUtil
|
||||
String serverIp = server.ip.replaceAll(INVALID_FILE_CHARACTERS_REGEX, "");
|
||||
String serverMcVersion = server.version.getString().replaceAll(INVALID_FILE_CHARACTERS_REGEX, "");
|
||||
|
||||
String serverId = serverName + ", IP " + serverIp + ", GameVersion " + serverMcVersion;
|
||||
|
||||
return serverId;
|
||||
return serverName + ", IP " + serverIp + ", GameVersion " + serverMcVersion;
|
||||
}
|
||||
|
||||
|
||||
@@ -413,7 +411,7 @@ public class LodUtil
|
||||
int maxVerticalData = DetailDistanceUtil.getMaxVerticalData(detailLevel);
|
||||
|
||||
count *= maxVerticalData;
|
||||
memoryUse += template.getBufferMemoryForSingleLod(maxVerticalData) * count;
|
||||
memoryUse += (long) template.getBufferMemoryForSingleLod(maxVerticalData) * count;
|
||||
}
|
||||
|
||||
return memoryUse;
|
||||
@@ -512,7 +510,8 @@ public class LodUtil
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}else
|
||||
}
|
||||
else
|
||||
{
|
||||
if (vanillaRenderedChunks[x][z])
|
||||
{
|
||||
|
||||
@@ -38,8 +38,7 @@ public class ThreadMapUtil
|
||||
public static final ConcurrentMap<String, Map<Direction, long[]>> adjDataMap = new ConcurrentHashMap<>();
|
||||
public static final ConcurrentMap<String, Box> boxMap = new ConcurrentHashMap<>();
|
||||
|
||||
/** returns the array NOT cleared every time
|
||||
* @return*/
|
||||
/** returns the array NOT cleared every time */
|
||||
public static boolean[] getAdjShadeDisabledArray()
|
||||
{
|
||||
if (!adjShadeDisabled.containsKey(Thread.currentThread().getName())
|
||||
@@ -160,21 +159,6 @@ public class ThreadMapUtil
|
||||
|
||||
|
||||
|
||||
/** returns the array filled with 0's */
|
||||
public static short[] getProjectionArray(int arrayLength)
|
||||
{
|
||||
if (!projectionArrayMap.containsKey(Thread.currentThread().getName()) || (projectionArrayMap.get(Thread.currentThread().getName()) == null))
|
||||
{
|
||||
projectionArrayMap.put(Thread.currentThread().getName(), new short[arrayLength]);
|
||||
}
|
||||
else
|
||||
{
|
||||
Arrays.fill(projectionArrayMap.get(Thread.currentThread().getName()), (short) 0);
|
||||
}
|
||||
return projectionArrayMap.get(Thread.currentThread().getName());
|
||||
}
|
||||
|
||||
|
||||
/** returns the array NOT cleared every time */
|
||||
public static short[] getHeightAndDepth(int arrayLength)
|
||||
{
|
||||
@@ -221,28 +205,6 @@ public class ThreadMapUtil
|
||||
return verticalUpdate.get(Thread.currentThread().getName())[detailLevel];
|
||||
}
|
||||
|
||||
|
||||
/** returns the array filled with 0's */
|
||||
public static long[] getSingleAddDataToMerge(int arrayLength)
|
||||
{
|
||||
if (!singleDataToMergeMap.containsKey(Thread.currentThread().getName()) || (singleDataToMergeMap.get(Thread.currentThread().getName()) == null))
|
||||
{
|
||||
singleDataToMergeMap.put(Thread.currentThread().getName(), new long[arrayLength]);
|
||||
}
|
||||
else if (singleDataToMergeMap.get(Thread.currentThread().getName()).length != arrayLength)
|
||||
{
|
||||
singleDataToMergeMap.replace(Thread.currentThread().getName(), new long[arrayLength]);
|
||||
}
|
||||
else
|
||||
{
|
||||
Arrays.fill(singleDataToMergeMap.get(Thread.currentThread().getName()), 0);
|
||||
}
|
||||
return singleDataToMergeMap.get(Thread.currentThread().getName());
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/** clears all arrays so they will have to be rebuilt */
|
||||
public static void clearMaps()
|
||||
{
|
||||
|
||||
@@ -34,7 +34,7 @@ public class MinecraftWrapper
|
||||
{
|
||||
public static MinecraftWrapper INSTANCE = new MinecraftWrapper();
|
||||
|
||||
private Minecraft mc = Minecraft.getInstance();
|
||||
private final Minecraft mc = Minecraft.getInstance();
|
||||
|
||||
/** The lightmap for the current:
|
||||
* Time, dimension, brightness setting, etc. */
|
||||
@@ -99,8 +99,7 @@ public class MinecraftWrapper
|
||||
if (lightMap == null)
|
||||
{
|
||||
LightTexture tex = mc.gameRenderer.lightTexture();
|
||||
NativeImage lightPixels = tex.lightPixels;
|
||||
lightMap = lightPixels;
|
||||
lightMap = tex.lightPixels;
|
||||
}
|
||||
|
||||
// // hotswap this to true, then back to false to write a file
|
||||
|
||||
Reference in New Issue
Block a user