This commit is contained in:
cola98765
2021-10-30 17:45:32 +02:00
parent 1962053a2f
commit dee9fa793d
17 changed files with 54 additions and 111 deletions
@@ -325,7 +325,7 @@ public class Box
//Down direction case
singleAdjDataPoint = adjData.get(Direction.DOWN)[0];
if(DataPointUtil.doesItExist(singleAdjDataPoint))
skyLights.get(Direction.DOWN)[0] = (byte) DataPointUtil.getLightSkyAlt(singleAdjDataPoint);
skyLights.get(Direction.DOWN)[0] = DataPointUtil.getLightSkyAlt(singleAdjDataPoint);
else
skyLights.get(Direction.DOWN)[0] = skyLights.get(Direction.UP)[0];
//other sided
@@ -373,12 +373,12 @@ public class Box
{
adjHeight.get(direction)[0] = getMaxY();
adjDepth.get(direction)[0] = getMinY();
skyLights.get(direction)[0] = (byte) DataPointUtil.getLightSkyAlt(singleAdjDataPoint); //skyLights.get(Direction.UP)[0];
skyLights.get(direction)[0] = DataPointUtil.getLightSkyAlt(singleAdjDataPoint); //skyLights.get(Direction.UP)[0];
}
else
{
adjDepth.get(direction)[faceToDraw] = getMinY();
skyLights.get(direction)[faceToDraw] = (byte) DataPointUtil.getLightSkyAlt(singleAdjDataPoint);
skyLights.get(direction)[faceToDraw] = DataPointUtil.getLightSkyAlt(singleAdjDataPoint);
}
faceToDraw++;
toFinish = false;
@@ -404,12 +404,12 @@ public class Box
{
adjHeight.get(direction)[0] = getMaxY();
adjDepth.get(direction)[0] = height;
skyLights.get(direction)[0] = (byte) DataPointUtil.getLightSkyAlt(singleAdjDataPoint); //skyLights.get(Direction.UP)[0];
skyLights.get(direction)[0] = DataPointUtil.getLightSkyAlt(singleAdjDataPoint); //skyLights.get(Direction.UP)[0];
}
else
{
adjDepth.get(direction)[faceToDraw] = height;
skyLights.get(direction)[faceToDraw] = (byte) DataPointUtil.getLightSkyAlt(singleAdjDataPoint);
skyLights.get(direction)[faceToDraw] = DataPointUtil.getLightSkyAlt(singleAdjDataPoint);
}
toFinish = false;
faceToDraw++;
@@ -437,7 +437,7 @@ public class Box
}
adjDepth.get(direction)[faceToDraw] = height;
skyLights.get(direction)[faceToDraw] = (byte) DataPointUtil.getLightSkyAlt(singleAdjDataPoint);
skyLights.get(direction)[faceToDraw] = DataPointUtil.getLightSkyAlt(singleAdjDataPoint);
faceToDraw++;
adjHeight.get(direction)[faceToDraw] = depth;
firstFace = false;
@@ -461,7 +461,7 @@ public class Box
{
singleAdjDataPoint = dataPoint[toFinishIndex];
if (DataPointUtil.doesItExist(singleAdjDataPoint))
skyLights.get(direction)[faceToDraw] = (byte) DataPointUtil.getLightSkyAlt(singleAdjDataPoint);
skyLights.get(direction)[faceToDraw] = DataPointUtil.getLightSkyAlt(singleAdjDataPoint);
else
skyLights.get(direction)[faceToDraw] = skyLights.get(Direction.UP)[0];
}
@@ -36,8 +36,8 @@ public enum BlockToAvoid
BOTH(true, true);
public boolean nonFull;
public boolean noCollision;
public final boolean nonFull;
public final boolean noCollision;
BlockToAvoid(boolean nonFull, boolean noCollision)
{
@@ -26,7 +26,6 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
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;
@@ -755,7 +755,7 @@ public class LodDimension
*/
public boolean doesRegionNeedBufferRegen(int xIndex, int zIndex)
{
return regenRegionBuffer[xIndex][zIndex];
return regenRegionBuffer[xIndex][zIndex] || recreateRegionBuffer[xIndex][zIndex];
}
@@ -787,9 +787,7 @@ public class LodDimension
region.updateArea(detailLevel, posX, posZ);
}
/**
* Returns true if a region exists at the given LevelPos
*/
/** Returns true if a region exists at the given LevelPos */
public boolean doesDataExist(byte detailLevel, int posX, int posZ)
{
LodRegion region = getRegion(detailLevel, posX, posZ);
@@ -806,18 +804,14 @@ public class LodDimension
return fileHandler != null ? fileHandler.loadRegionFromFile(detailLevel, regionPos, generationMode, verticalQuality) : null;
}
/**
* Save all dirty regions in this LodDimension to file.
*/
/** Save all dirty regions in this LodDimension to file. */
public void saveDirtyRegionsToFileAsync()
{
fileHandler.saveDirtyRegionsToFileAsync();
}
/**
* Return true if the chunk has been pregenerated in game
*/
/** Return true if the chunk has been pregenerated in game */
//public boolean isChunkPreGenerated(int xChunkPos, int zChunkPos)
//{
//
@@ -852,9 +846,7 @@ public class LodDimension
return center.z;
}
/**
* returns the width of the dimension in regions
*/
/** returns the width of the dimension in regions */
public int getWidth()
{
// we want to get the length directly from the
@@ -39,15 +39,11 @@ import com.seibel.lod.util.LodUtil;
*/
public class LodRegion
{
/**
* Number of detail level supported by a region
*/
/** 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
*/
/** Holds the lowest (least detailed) detail level in this region */
private byte minDetailLevel;
/**
@@ -55,27 +51,17 @@ public class LodRegion
*/
private final LevelContainer[] dataContainer;
/**
* This chunk Pos has been generated
*/
/** This chunk Pos has been generated */
//private final boolean[] preGeneratedChunkPos;
/**
* the generation mode for this region
*/
private DistanceGenerationMode generationMode;
/**
* the vertical quality of this region
*/
private VerticalQuality verticalQuality;
/** the generation mode for this region */
private final DistanceGenerationMode generationMode;
/** the vertical quality of this region */
private final VerticalQuality verticalQuality;
/**
* this region's x RegionPos
*/
/** this region's x RegionPos */
public final int regionPosX;
/**
* this region's z RegionPos
*/
/** this region's z RegionPos */
public final int regionPosZ;
public LodRegion(byte minDetailLevel, RegionPos regionPos, DistanceGenerationMode generationMode, VerticalQuality verticalQuality)
@@ -152,9 +138,7 @@ public class LodRegion
}
/**
* Return true if the chunk has been pregenerated in game
*/
/** Return true if the chunk has been pregenerated in game */
//public boolean isChunkPreGenerated(int xChunkPos, int zChunkPos)
//{
// xChunkPos = LevelPosUtil.getRegionModule(LodUtil.CHUNK_DETAIL_LEVEL, xChunkPos);
@@ -32,7 +32,6 @@ import com.seibel.lod.util.LodUtil;
public class PosToRenderContainer
{
public byte minDetail;
private final int size;
private int regionPosX;
private int regionPosZ;
private int numberOfPosToRender;
@@ -47,7 +46,7 @@ public class PosToRenderContainer
this.numberOfPosToRender = 0;
this.regionPosX = regionPosX;
this.regionPosZ = regionPosZ;
this.size = 1 << (LodUtil.REGION_DETAIL_LEVEL - minDetail);
int size = 1 << (LodUtil.REGION_DETAIL_LEVEL - minDetail);
posToRender = new int[size * size * 3];
population = new byte[size][size];
}
@@ -46,7 +46,7 @@ public class GlProxy
{
private static GlProxy instance = null;
private static MinecraftWrapper mc = MinecraftWrapper.INSTANCE;
private static final MinecraftWrapper mc = MinecraftWrapper.INSTANCE;
/** Minecraft's GLFW window */
public final long minecraftGlContext;
@@ -124,7 +124,7 @@ public class LodRenderer
public boolean vanillaRenderedChunksEmptySkip = false;
public int vanillaBlockRenderedDistance;
boolean vivecraftDetected = ReflectionHandler.INSTANCE.detectVivecraft();
final boolean vivecraftDetected = ReflectionHandler.INSTANCE.detectVivecraft();
@@ -205,7 +205,7 @@ public class LodRenderer
if ((partialRegen || fullRegen) && !lodBufferBuilder.generatingBuffers && !lodBufferBuilder.newBuffersAvailable())
{
// generate the LODs on a separate thread to prevent stuttering or freezing
lodBufferBuilder.generateLodBuffersAsync(this, lodDim, mc.getPlayer().blockPosition(), true);
lodBufferBuilder.generateLodBuffersAsync(this, lodDim, mc.getPlayer().blockPosition(), fullRegen);
// the regen process has been started,
// it will be done when lodBufferBuilder.newBuffersAvailable()
@@ -564,7 +564,7 @@ public class LodRenderer
{
Matrix4f lodPoj;
float nearClipPlane = LodConfig.CLIENT.graphics.advancedGraphicsOption.useExtendedNearClipPlane.get() ? vanillaBlockRenderedDistance / 5 : 1;
float farClipPlane = farPlaneBlockDistance * LodUtil.CHUNK_WIDTH / 2;
float farClipPlane = farPlaneBlockDistance * LodUtil.CHUNK_WIDTH >> 1;
if (vivecraftDetected)
{
@@ -886,12 +886,6 @@ public class LodRenderer
prevSkyBrightness = skyBrightness;
}
/*if (lightMap != lastLightMap)
{
fullRegen = true;
lastLightMap = lightMap;
}*/
//================//
// partial regens //
//================//
@@ -23,8 +23,6 @@ import static com.seibel.lod.builders.bufferBuilding.LodBufferBuilder.skyLightPl
import com.seibel.lod.enums.DistanceGenerationMode;
import net.minecraft.client.renderer.texture.NativeImage;
/**
*
* @author Leonardo Amato
@@ -171,22 +169,22 @@ public class DataPointUtil
return (short) ((dataPoint >>> BLUE_SHIFT) & BLUE_MASK);
}
public static int getLightSky(long dataPoint)
public static byte getLightSky(long dataPoint)
{
return (int) ((dataPoint >>> SKY_LIGHT_SHIFT) & SKY_LIGHT_MASK);
return (byte) ((dataPoint >>> SKY_LIGHT_SHIFT) & SKY_LIGHT_MASK);
}
public static int getLightSkyAlt(long dataPoint)
public static byte getLightSkyAlt(long dataPoint)
{
if (skyLightPlayer == 0 && ((dataPoint >>> FLAG_SHIFT) & FLAG_MASK) == 1)
return 0;
else
return (int) ((dataPoint >>> SKY_LIGHT_SHIFT) & SKY_LIGHT_MASK);
return (byte) ((dataPoint >>> SKY_LIGHT_SHIFT) & SKY_LIGHT_MASK);
}
public static int getLightBlock(long dataPoint)
public static byte getLightBlock(long dataPoint)
{
return (int) ((dataPoint >>> BLOCK_LIGHT_SHIFT) & BLOCK_LIGHT_MASK);
return (byte) ((dataPoint >>> BLOCK_LIGHT_SHIFT) & BLOCK_LIGHT_MASK);
}
public static boolean getFlag(long dataPoint)
@@ -215,19 +213,6 @@ public class DataPointUtil
return (int) (((dataPoint >>> COLOR_SHIFT) & COLOR_MASK) | (/*((dataPoint >>> (ALPHA_SHIFT - ALPHA_DOWNSIZE_SHIFT)) | 0b1111)*/255 << 24));
}
/** This method apply the lightmap to the color to use */
public static int getLightColor(long dataPoint, NativeImage lightMap)
{
int lightBlock = getLightBlock(dataPoint);
int lightSky = getLightSky(dataPoint);
int color = lightMap.getPixelRGBA(lightBlock, lightSky);
int red = ColorUtil.getBlue(color);
int green = ColorUtil.getGreen(color);
int blue = ColorUtil.getRed(color);
return ColorUtil.multiplyRGBcolors(getColor(dataPoint), ColorUtil.rgbToInt(red, green, blue));
}
/** This is used to convert a dataPoint to string (useful for the print function) */
@SuppressWarnings("unused")
public static String toString(long dataPoint)
@@ -23,7 +23,7 @@ public class BlockColorWrapper
public static final ConcurrentMap<Block, BlockColorWrapper> blockColorWrapperMap = new ConcurrentHashMap<>();
public static final ModelDataMap dataMap = new ModelDataMap.Builder().build();
public static final BlockPos blockPos = new BlockPos(0,0,0);
public static Random random = new Random(0);
public static final Random random = new Random(0);
//public static BlockColourWrapper WATER_COLOR = getBlockColorWrapper(Blocks.WATER);
public static final Direction[] directions = new Direction[] { Direction.UP, Direction.EAST, Direction.SOUTH, Direction.WEST, Direction.NORTH, Direction.DOWN };
@@ -31,7 +31,7 @@ public class BlockColorWrapper
private int color;
private boolean isColored;
private boolean toTint;
private boolean folliageTint;
private boolean foliageTint;
private boolean grassTint;
private boolean waterTint;
@@ -43,7 +43,7 @@ public class BlockColorWrapper
this.color = 0;
this.isColored = true;
this.toTint = false;
this.folliageTint = false;
this.foliageTint = false;
this.grassTint = false;
this.waterTint = false;
setupColorAndTint(blockState,blockPosWrapper);
@@ -186,7 +186,7 @@ public class BlockColorWrapper
// we check which kind of tint we need to apply
this.grassTint = grassInstance() && toTint;
this.folliageTint = leavesInstance() && toTint;
this.foliageTint = leavesInstance() && toTint;
this.waterTint = waterIstance() && toTint;
@@ -249,7 +249,7 @@ public class BlockColorWrapper
public boolean hasFolliageTint()
{
return folliageTint;
return foliageTint;
}
public boolean hasWaterTint()
@@ -18,7 +18,7 @@ import java.util.concurrent.ConcurrentMap;
//This class wraps the minecraft BlockPos.Mutable (and BlockPos) class
public class BlockPosWrapper
{
private BlockPos.Mutable blockPos;
private final BlockPos.Mutable blockPos;
public BlockPosWrapper()
@@ -9,7 +9,7 @@ import java.util.Objects;
//This class wraps the minecraft ChunkPos class
public class ChunkPosWrapper
{
private ChunkPos chunkPos;
private final ChunkPos chunkPos;
public ChunkPosWrapper(ChunkPos chunkPos)
{
@@ -14,8 +14,8 @@ import net.minecraft.world.chunk.IChunk;
public class ChunkWrapper
{
private IChunk chunk;
private ChunkPosWrapper chunkPos;
private final IChunk chunk;
private final ChunkPosWrapper chunkPos;
public int getHeight(){
return chunk.getMaxBuildHeight();
@@ -26,14 +26,9 @@ public class ChunkWrapper
BlockState blockState = chunk.getBlockState(blockPos.getBlockPos());
//This type of block is always in water
if((blockState.getBlock() instanceof ILiquidContainer) && !(blockState.getBlock() instanceof IWaterLoggable))
return true;
//This type of block could be in water
if(blockState.getOptionalValue(BlockStateProperties.WATERLOGGED).isPresent() && blockState.getOptionalValue(BlockStateProperties.WATERLOGGED).get())
return true;
return false;
return ((blockState.getBlock() instanceof ILiquidContainer) && !(blockState.getBlock() instanceof IWaterLoggable))
|| (blockState.getOptionalValue(BlockStateProperties.WATERLOGGED).isPresent() && blockState.getOptionalValue(BlockStateProperties.WATERLOGGED).get());
}
public int getHeightMapValue(int xRel, int zRel){
@@ -78,14 +73,9 @@ public class ChunkWrapper
BlockState blockState = chunk.getBlockState(blockPos.getBlockPos());
//This type of block is always in water
if((blockState.getBlock() instanceof ILiquidContainer) && !(blockState.getBlock() instanceof IWaterLoggable))
return true;
//This type of block could be in water
if(blockState.getOptionalValue(BlockStateProperties.WATERLOGGED).isPresent() && blockState.getOptionalValue(BlockStateProperties.WATERLOGGED).get())
return true;
return false;
return ((blockState.getBlock() instanceof ILiquidContainer) && !(blockState.getBlock() instanceof IWaterLoggable))
|| (blockState.getOptionalValue(BlockStateProperties.WATERLOGGED).isPresent() && blockState.getOptionalValue(BlockStateProperties.WATERLOGGED).get());
}
public int getEmittedBrightness(BlockPosWrapper blockPos)
@@ -3,13 +3,13 @@ package com.seibel.lod.wrappers;
import net.minecraft.client.renderer.texture.NativeImage;
public class LigthMapWrapper
public class LightMapWrapper
{
static NativeImage lightMap = null;
public static void setLightMap(NativeImage lightMap)
public static void setLightMap(NativeImage newlightMap)
{
lightMap = lightMap;
lightMap = newlightMap;
}
public static int getLightValue(int skyLight, int blockLight)
@@ -21,7 +21,7 @@ public class BiomeWrapper
{
public static final ConcurrentMap<Biome, BiomeWrapper> biomeWrapperMap = new ConcurrentHashMap<>();
private Biome biome;
private final Biome biome;
public BiomeWrapper(Biome biome)
{
@@ -8,7 +8,7 @@ import java.util.concurrent.ConcurrentMap;
public class DimensionTypeWrapper
{
private static final ConcurrentMap<DimensionType, DimensionTypeWrapper> dimensionTypeWrapperMap = new ConcurrentHashMap<>();
private DimensionType dimensionType;
private final DimensionType dimensionType;
public DimensionTypeWrapper(DimensionType dimensionType)
{
@@ -9,7 +9,7 @@ import java.util.concurrent.ConcurrentMap;
public class WorldWrapper
{
private static final ConcurrentMap<IWorld, WorldWrapper> worldWrapperMap = new ConcurrentHashMap<>();
private IWorld world;
private final IWorld world;
public WorldWrapper(IWorld world)
{