Adaptive raster culling #41

Merged
embeddedt merged 9 commits from adaptive-raster-culling into stonecutter 2026-09-17 10:10:54 -04:00
3 changed files with 18 additions and 4 deletions
Showing only changes of commit ca420217e6 - Show all commits

No files matched your search

@@ -33,6 +33,11 @@ public final class VoxelWorld {
/** Fraction of terrain-skin blocks replaced by {@link #CUTOUT}, out of 256. Confined to the surface. */
private static final int CUTOUT_ROLL = 40; // ~16% of the skin
/** Blocks from the camera column at which the CLIFF world's ground steps up; past the standing probe's reach. */
public static final int CLIFF_RADIUS = 8 * 16;
/** Not a multiple of 16: the plateau surface must sit inside a section, or the outward-only search never reaches it. */
public static final int CLIFF_RISE = 36;
private final WorldType type;
private final long seed;
private final double caveWidth;
@@ -93,7 +98,7 @@ public final class VoxelWorld {
/** {@return whether everything below the surface is solid, with no caves and no cutouts} */
private boolean isSolidGround() {
return this.type == WorldType.PLAINS || this.type == WorldType.HILLS;
return this.type == WorldType.PLAINS || this.type == WorldType.HILLS || this.type == WorldType.CLIFF;
}
/** {@return whether this world has no blocks at all} */
@@ -165,9 +170,16 @@ public final class VoxelWorld {
return Integer.MAX_VALUE;
}
if (this.type == WorldType.FLAT || this.type == WorldType.PLAINS) {
if (this.type == WorldType.FLAT || this.type == WorldType.PLAINS || this.type == WorldType.CLIFF) {
// the SURFACE height at the origin, so Cameras.surfaceCameraY(0, 0) is at eye height here too
return (int) Math.floor(sectionHeight(0.0, 0.0) * 16.0);
int base = (int) Math.floor(sectionHeight(0.0, 0.0) * 16.0);
if (this.type == WorldType.CLIFF) {
long dx = bx - 8, dz = bz - 8;
return (dx * dx) + (dz * dz) >= (long) CLIFF_RADIUS * CLIFF_RADIUS ? base + CLIFF_RISE : base;
}
return base;
}
return (int) Math.floor(sectionHeight(bx * (1.0 / 16.0), bz * (1.0 / 16.0)) * 16.0);
@@ -14,7 +14,7 @@ public final class RasterCullReport {
private static final WorldType[] WORLDS = worlds();
private static WorldType[] worlds() {
String list = System.getProperty("report.worlds", "PLAINS,HILLS,FLAT,SURFACE,CAVES");
String list = System.getProperty("report.worlds", "PLAINS,HILLS,CLIFF,FLAT,SURFACE,CAVES");
return java.util.Arrays.stream(list.split(",")).map(String::trim).map(WorldType::valueOf).toArray(WorldType[]::new);
}
@@ -15,6 +15,8 @@ public enum WorldType {
PLAINS,
/** SURFACE heightmap over solid ground, no caves and no cutouts. Hills hide only what lies behind them. */
HILLS,
/** PLAINS with a plateau beyond {@code VoxelWorld.CLIFF_RADIUS}. The cliff hides the plateau surface, from beyond the floor's reach. */
CLIFF,
/** Stone to the top of the world with caves. Heavily occluded. */
CAVES
}