Fix Overdraw Circles & Void chunk error spam due to genMode+1
This commit is contained in:
+2
-2
@@ -54,8 +54,8 @@ import com.seibel.lod.core.wrapperInterfaces.minecraft.IMinecraftWrapper;
|
||||
public class LodBufferBuilderFactory {
|
||||
|
||||
// TODO: Do some Perf logging of Buffer Building
|
||||
public static final boolean ENABLE_BUFFER_PERF_LOGGING = true;
|
||||
public static final boolean ENABLE_EVENT_LOGGING = true;
|
||||
public static final boolean ENABLE_BUFFER_PERF_LOGGING = false;
|
||||
public static final boolean ENABLE_EVENT_LOGGING = false;
|
||||
public static final boolean ENABLE_LAG_SPIKE_LOGGING = false;
|
||||
public static final long LAG_SPIKE_THRESOLD_NS = TimeUnit.NANOSECONDS.convert(16, TimeUnit.MILLISECONDS);
|
||||
|
||||
|
||||
@@ -20,6 +20,7 @@
|
||||
package com.seibel.lod.core.objects.lod;
|
||||
|
||||
import java.util.ConcurrentModificationException;
|
||||
import java.util.Iterator;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
|
||||
import com.seibel.lod.core.enums.config.DistanceGenerationMode;
|
||||
@@ -176,7 +177,7 @@ public class LodRegion {
|
||||
);*/
|
||||
|
||||
}
|
||||
if (!doesDataExist(detailLevel, posX, posZ, DistanceGenerationMode.values()[DataPointUtil.getGenerationMode(data[0]) - 1])) { //fixme -1 casue NONE has value of 1 but slot of 0
|
||||
if (!doesDataExist(detailLevel, posX, posZ, DistanceGenerationMode.values()[DataPointUtil.getGenerationMode(data[0]) - 1])) { //FIXME: -1 casue NONE has value of 1 but slot of 0
|
||||
throw new RuntimeException("Data still doesn't exist after addChunkOfData!");
|
||||
}
|
||||
|
||||
@@ -429,6 +430,55 @@ public class LodRegion {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public static final class LevelPos {
|
||||
public final byte detail;
|
||||
public final int posX;
|
||||
public final int posZ;
|
||||
LevelPos(byte d, int x, int z) {
|
||||
detail = d;
|
||||
posX = x;
|
||||
posZ = z;
|
||||
}
|
||||
}
|
||||
|
||||
public Iterator<LevelPos> posToRenderIterator() {
|
||||
return new Iterator<LevelPos>() {
|
||||
final byte minDetail = minDetailLevel;
|
||||
int offsetX = 0;
|
||||
int offsetZ = 0;
|
||||
final int size = 1 << (LodUtil.REGION_DETAIL_LEVEL - minDetail);
|
||||
|
||||
private void advance() {
|
||||
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasNext()
|
||||
{
|
||||
|
||||
|
||||
return (offsetZ >= size);
|
||||
}
|
||||
|
||||
@Override
|
||||
public LevelPos next()
|
||||
{
|
||||
|
||||
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Updates all children.
|
||||
* <p>
|
||||
|
||||
@@ -355,6 +355,7 @@ public class VerticalLevelContainer implements LevelContainer
|
||||
if ((!DataPointUtil.doesItExist(data[0])) && anyDataExist)
|
||||
throw new RuntimeException("Update data called but higher level datapoint doesn't exist even though child data does exist!");
|
||||
|
||||
//FIXME: Disabled check if genMode for old data is already invalid due to having genMode 0.
|
||||
if (DataPointUtil.getGenerationMode(data[0]) != DataPointUtil.getGenerationMode(lowerLevelContainer.getSingleData(posX*2, posZ*2)))
|
||||
throw new RuntimeException("Update data called but higher level datapoint does not have the same GenerationMode as the top left corner child datapoint!");
|
||||
|
||||
|
||||
@@ -21,6 +21,7 @@ package com.seibel.lod.core.util;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
import com.seibel.lod.core.api.ApiShared;
|
||||
import com.seibel.lod.core.enums.config.DistanceGenerationMode;
|
||||
|
||||
|
||||
@@ -89,6 +90,8 @@ public class DataPointUtil
|
||||
|
||||
public static long createVoidDataPoint(byte generationMode)
|
||||
{
|
||||
if (generationMode == 0)
|
||||
throw new IllegalArgumentException("Trying to create void datapoint with genMode 0, which is NOT allowed in DataPoint version 10!");
|
||||
return (generationMode & GEN_TYPE_MASK) << GEN_TYPE_SHIFT;
|
||||
}
|
||||
|
||||
@@ -104,6 +107,8 @@ public class DataPointUtil
|
||||
|
||||
public static long createDataPoint(int alpha, int red, int green, int blue, int height, int depth, int lightSky, int lightBlock, int generationMode)
|
||||
{
|
||||
if (generationMode == 0)
|
||||
throw new IllegalArgumentException("Trying to create datapoint with genMode 0, which is NOT allowed in DataPoint version 10!");
|
||||
return (long) (alpha >>> ALPHA_DOWNSIZE_SHIFT) << ALPHA_SHIFT
|
||||
| (red & RED_MASK) << RED_SHIFT
|
||||
| (green & GREEN_MASK) << GREEN_SHIFT
|
||||
@@ -193,7 +198,13 @@ public class DataPointUtil
|
||||
|
||||
public static byte getGenerationMode(long dataPoint)
|
||||
{
|
||||
return (byte) ((dataPoint >>> GEN_TYPE_SHIFT) & GEN_TYPE_MASK);
|
||||
byte genMode = (byte) ((dataPoint >>> GEN_TYPE_SHIFT) & GEN_TYPE_MASK);
|
||||
if (doesItExist(dataPoint) && genMode==0) {
|
||||
ApiShared.LOGGER.warn("Existing datapoint with genMode 0 detected! This is invalid in DataPoint version 10!"
|
||||
+ " This may be caused by old data that has not been updated correctly.");
|
||||
return 1;
|
||||
}
|
||||
return genMode == 0 ? 1 : genMode;
|
||||
}
|
||||
|
||||
|
||||
@@ -373,6 +384,7 @@ public class DataPointUtil
|
||||
} else Arrays.fill(dataPoint, 0);
|
||||
|
||||
byte genMode = getGenerationMode(dataToMerge[0]);
|
||||
if (genMode == 0) genMode = 1; // FIXME: Hack to make the version 10 genMode never be 0.
|
||||
boolean allEmpty = true;
|
||||
boolean allVoid = true;
|
||||
boolean limited = false;
|
||||
@@ -604,7 +616,7 @@ public class DataPointUtil
|
||||
if (!doesItExist(data))
|
||||
{
|
||||
singleData = dataToMerge[index * inputVerticalData];
|
||||
data = createVoidDataPoint(getGenerationMode(singleData));
|
||||
data = createVoidDataPoint(genMode);
|
||||
}
|
||||
|
||||
if (doesItExist(data))
|
||||
|
||||
@@ -31,6 +31,7 @@ import com.seibel.lod.core.objects.lod.LodDimension;
|
||||
import com.seibel.lod.core.objects.lod.RegionPos;
|
||||
import com.seibel.lod.core.objects.opengl.DefaultLodVertexFormats;
|
||||
import com.seibel.lod.core.objects.opengl.LodVertexFormat;
|
||||
import com.seibel.lod.core.wrapperInterfaces.IVersionConstants;
|
||||
import com.seibel.lod.core.wrapperInterfaces.IWrapperFactory;
|
||||
import com.seibel.lod.core.wrapperInterfaces.block.AbstractBlockPosWrapper;
|
||||
import com.seibel.lod.core.wrapperInterfaces.chunk.AbstractChunkPosWrapper;
|
||||
@@ -53,6 +54,7 @@ public class LodUtil
|
||||
private static final ILodConfigWrapperSingleton CONFIG = SingletonHandler.get(ILodConfigWrapperSingleton.class);
|
||||
private static final IWrapperFactory FACTORY = SingletonHandler.get(IWrapperFactory.class);
|
||||
private static final IReflectionHandler REFLECTION_HANDLER = SingletonHandler.get(IReflectionHandler.class);
|
||||
private static final IVersionConstants VERSION_CONSTANTS = SingletonHandler.get(IVersionConstants.class);
|
||||
|
||||
/**
|
||||
* Vanilla render distances less than or equal to this will not allow partial
|
||||
@@ -308,7 +310,6 @@ public class LodUtil
|
||||
public static HashSet<AbstractChunkPosWrapper> getNearbyLodChunkPosToSkip(LodDimension lodDim, AbstractBlockPosWrapper blockPosWrapper)
|
||||
{
|
||||
int chunkRenderDist = MC_RENDER.getRenderDistance();
|
||||
AbstractChunkPosWrapper centerChunk = FACTORY.createChunkPos(blockPosWrapper);
|
||||
|
||||
int skipRadius;
|
||||
VanillaOverdraw overdraw = CONFIG.client().graphics().advancedGraphics().getVanillaOverdraw();
|
||||
@@ -381,10 +382,25 @@ public class LodUtil
|
||||
// if the skipRadius is being used
|
||||
if (skipRadius != 0)
|
||||
{
|
||||
posToSkip.removeIf((pos) -> {
|
||||
return (pos.getX() < centerChunk.getX() - skipRadius || pos.getX() > centerChunk.getX() + skipRadius
|
||||
|| pos.getZ() < centerChunk.getZ() - skipRadius || pos.getZ() > centerChunk.getZ() + skipRadius);
|
||||
});
|
||||
int centerCX = LevelPosUtil.getChunkPos(BLOCK_DETAIL_LEVEL, blockPosWrapper.getX());
|
||||
int centerCZ = LevelPosUtil.getChunkPos(BLOCK_DETAIL_LEVEL, blockPosWrapper.getZ());
|
||||
|
||||
if (VERSION_CONSTANTS.isVanillaRenderedChunkSquare()) {
|
||||
int minX = centerCX-skipRadius;
|
||||
int maxX = centerCX+skipRadius+1;
|
||||
int minZ = centerCZ-skipRadius;
|
||||
int maxZ = centerCZ+skipRadius+1;
|
||||
posToSkip.removeIf((pos) -> {
|
||||
return (pos.getX() < minX || pos.getX() > maxX || pos.getZ() < minZ || pos.getZ() > maxZ);
|
||||
});
|
||||
} else {
|
||||
int skipRadius2 = skipRadius*skipRadius;
|
||||
posToSkip.removeIf((pos) -> {
|
||||
int dx = pos.getX()-centerCX;
|
||||
int dz = pos.getZ()-centerCZ;
|
||||
return (dx*dx + dz*dz > skipRadius2);
|
||||
});
|
||||
}
|
||||
}
|
||||
return posToSkip;
|
||||
}
|
||||
|
||||
@@ -33,5 +33,7 @@ public interface IVersionConstants {
|
||||
default int getWorldGenerationCountPerThread() {
|
||||
return 8;
|
||||
}
|
||||
|
||||
boolean isVanillaRenderedChunkSquare();
|
||||
|
||||
}
|
||||
|
||||
+14
-7
@@ -27,6 +27,7 @@ import com.seibel.lod.core.objects.math.Mat4f;
|
||||
import com.seibel.lod.core.objects.math.Vec3d;
|
||||
import com.seibel.lod.core.objects.math.Vec3f;
|
||||
import com.seibel.lod.core.util.SingletonHandler;
|
||||
import com.seibel.lod.core.wrapperInterfaces.IVersionConstants;
|
||||
import com.seibel.lod.core.wrapperInterfaces.IWrapperFactory;
|
||||
import com.seibel.lod.core.wrapperInterfaces.block.AbstractBlockPosWrapper;
|
||||
import com.seibel.lod.core.wrapperInterfaces.chunk.AbstractChunkPosWrapper;
|
||||
@@ -41,6 +42,8 @@ import com.seibel.lod.core.wrapperInterfaces.modAccessor.ISodiumAccessor;
|
||||
*/
|
||||
public interface IMinecraftRenderWrapper
|
||||
{
|
||||
static final IVersionConstants VERSION_CONSTANTS = SingletonHandler.get(IVersionConstants.class);
|
||||
|
||||
Vec3f getLookAtVector();
|
||||
|
||||
AbstractBlockPosWrapper getCameraBlockPosition();
|
||||
@@ -90,22 +93,26 @@ public interface IMinecraftRenderWrapper
|
||||
IMinecraftWrapper mcWrapper = SingletonHandler.get(IMinecraftWrapper.class);
|
||||
IWrapperFactory factory = SingletonHandler.get(IWrapperFactory.class);
|
||||
|
||||
int chunkRenderDist = this.getRenderDistance();
|
||||
int chunkDist = this.getRenderDistance();
|
||||
|
||||
AbstractChunkPosWrapper centerChunkPos = mcWrapper.getPlayerChunkPos();
|
||||
int startChunkX = centerChunkPos.getX() - chunkRenderDist;
|
||||
int startChunkZ = centerChunkPos.getZ() - chunkRenderDist;
|
||||
int centerChunkX = centerChunkPos.getX();
|
||||
int centerChunkZ = centerChunkPos.getZ();
|
||||
int chunkDist2 = chunkDist*chunkDist;
|
||||
|
||||
// add every position within render distance
|
||||
HashSet<AbstractChunkPosWrapper> renderedPos = new HashSet<AbstractChunkPosWrapper>();
|
||||
for (int chunkX = 0; chunkX < (chunkRenderDist * 2+1); chunkX++)
|
||||
for (int deltaChunkX = -chunkDist; deltaChunkX <= chunkDist; deltaChunkX++)
|
||||
{
|
||||
for(int chunkZ = 0; chunkZ < (chunkRenderDist * 2+1); chunkZ++)
|
||||
for(int deltaChunkZ = -chunkDist; deltaChunkZ <= chunkDist; deltaChunkZ++)
|
||||
{
|
||||
renderedPos.add(factory.createChunkPos(startChunkX + chunkX, startChunkZ + chunkZ));
|
||||
if (!VERSION_CONSTANTS.isVanillaRenderedChunkSquare() &&
|
||||
deltaChunkX*deltaChunkX+deltaChunkZ*deltaChunkZ>chunkDist2) {
|
||||
continue;
|
||||
}
|
||||
renderedPos.add(factory.createChunkPos(centerChunkX + deltaChunkX, centerChunkZ + deltaChunkZ));
|
||||
}
|
||||
}
|
||||
|
||||
return renderedPos;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user