diff --git a/src/main/java/com/seibel/lod/core/builders/lodBuilding/LodBuilder.java b/src/main/java/com/seibel/lod/core/builders/lodBuilding/LodBuilder.java index b18fa9e54..f81b1b103 100644 --- a/src/main/java/com/seibel/lod/core/builders/lodBuilding/LodBuilder.java +++ b/src/main/java/com/seibel/lod/core/builders/lodBuilding/LodBuilder.java @@ -360,11 +360,7 @@ public class LodBuilder private boolean hasCliffFace(IChunkWrapper chunk, int x, int y, int z) { for (LodDirection dir : DIRECTIONS) { - int cx = x+dir.getNormal().x; - int cy = y+dir.getNormal().y; - int cz = z+dir.getNormal().z; - if (!chunk.blockPosInsideChunk(cx, cy, cz)) return true; - IBlockDetailWrapper block = chunk.getBlockDetail(cx, cy, cz); + IBlockDetailWrapper block = chunk.getBlockDetailAtFace(x, y, z, dir); if (block == null || !block.hasFaceCullingFor(LodDirection.OPPOSITE_DIRECTIONS[dir.ordinal()])) return true; } diff --git a/src/main/java/com/seibel/lod/core/objects/opengl/LodQuadBuilder.java b/src/main/java/com/seibel/lod/core/objects/opengl/LodQuadBuilder.java index 44660c75e..c6dcc5e8d 100644 --- a/src/main/java/com/seibel/lod/core/objects/opengl/LodQuadBuilder.java +++ b/src/main/java/com/seibel/lod/core/objects/opengl/LodQuadBuilder.java @@ -19,6 +19,8 @@ public class LodQuadBuilder { static final int MAX_QUADS_PER_BUFFER = MAX_BUFFER_SIZE / QUAD_BYTE_SIZE; //static final int MAX_MERGED_QUAD_SIZE = 64; + public boolean skipSkylight0Quads = true; + static class Quad { final short x; final short y; @@ -232,33 +234,40 @@ public class LodQuadBuilder { byte blocklight) { if (dir.ordinal() <= LodDirection.DOWN.ordinal()) throw new IllegalArgumentException("addQuadAdj() is only for adj direction! Not UP or Down!"); + if (skipSkylight0Quads && skylight==0) return; quads[dir.ordinal()].add(new Quad(x, y, z, w0, wy, color, skylight, blocklight, dir)); } // XZ public void addQuadUp(short x, short y, short z, short wx, short wz, int color, byte skylight, byte blocklight) { + if (skipSkylight0Quads && skylight==0) return; quads[LodDirection.UP.ordinal()].add(new Quad(x, y, z, wx, wz, color, skylight, blocklight, LodDirection.UP)); } public void addQuadDown(short x, short y, short z, short wx, short wz, int color, byte skylight, byte blocklight) { + if (skipSkylight0Quads && skylight==0) return; quads[LodDirection.DOWN.ordinal()].add(new Quad(x, y, z, wx, wz, color, skylight, blocklight, LodDirection.DOWN)); } // XY public void addQuadN(short x, short y, short z, short wx, short wy, int color, byte skylight, byte blocklight) { + if (skipSkylight0Quads && skylight==0) return; quads[LodDirection.NORTH.ordinal()].add(new Quad(x, y, z, wx, wy, color, skylight, blocklight, LodDirection.NORTH)); } public void addQuadS(short x, short y, short z, short wx, short wy, int color, byte skylight, byte blocklight) { + if (skipSkylight0Quads && skylight==0) return; quads[LodDirection.SOUTH.ordinal()].add(new Quad(x, y, z, wx, wy, color, skylight, blocklight, LodDirection.SOUTH)); } // ZY public void addQuadW(short x, short y, short z, short wz, short wy, int color, byte skylight, byte blocklight) { + if (skipSkylight0Quads && skylight==0) return; quads[LodDirection.WEST.ordinal()].add(new Quad(x, y, z, wz, wy, color, skylight, blocklight, LodDirection.WEST)); } public void addQuadE(short x, short y, short z, short wz, short wy, int color, byte skylight, byte blocklight) { + if (skipSkylight0Quads && skylight==0) return; quads[LodDirection.EAST.ordinal()].add(new Quad(x, y, z, wz, wy, color, skylight, blocklight, LodDirection.EAST)); } diff --git a/src/main/java/com/seibel/lod/core/wrapperInterfaces/chunk/IChunkWrapper.java b/src/main/java/com/seibel/lod/core/wrapperInterfaces/chunk/IChunkWrapper.java index 85a963c9a..efe6c5c0d 100644 --- a/src/main/java/com/seibel/lod/core/wrapperInterfaces/chunk/IChunkWrapper.java +++ b/src/main/java/com/seibel/lod/core/wrapperInterfaces/chunk/IChunkWrapper.java @@ -19,6 +19,7 @@ package com.seibel.lod.core.wrapperInterfaces.chunk; +import com.seibel.lod.core.enums.LodDirection; import com.seibel.lod.core.handlers.dependencyInjection.IBindable; import com.seibel.lod.core.wrapperInterfaces.block.IBlockDetailWrapper; import com.seibel.lod.core.wrapperInterfaces.world.IBiomeWrapper; @@ -40,6 +41,9 @@ public interface IChunkWrapper extends IBindable IBiomeWrapper getBiome(int x, int y, int z); IBlockDetailWrapper getBlockDetail(int x, int y, int z); + + // Returns null if block doesn't exist. Note that this can cross chunk boundaries. + IBlockDetailWrapper getBlockDetailAtFace(int x, int y, int z, LodDirection dir); int getChunkPosX(); int getChunkPosZ();