Fix hasCliffFace() not crossing chunk boundaries.

Also temp added cave culling. Need logic to provide better cave culling.
This commit is contained in:
TomTheFurry
2022-03-14 15:10:04 +08:00
parent f1eb06bbb1
commit 7da2b90611
3 changed files with 14 additions and 5 deletions
@@ -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;
}
@@ -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));
}
@@ -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();