Bounded column rereads

- Natural cave decoration reads columns in sixteen-row windows and drops the window after each decorated zone
- Perfection reads cells directly after a spike is normalized instead of rereading the column below it
This commit is contained in:
Brian Neumann-Fopiano committed 2026-10-30 21:02:23 -04:00
1 parent ed83c6fdeb
commit 806e847e90
2 files changed
+45 -14

No files matched your search

@@ -1087,23 +1087,21 @@ public class IrisCarveModifier extends EngineAssignedModifier<NativeBlockState>
int height = output.getHeight(); int height = output.getHeight();
ColumnExtent extent = output instanceof ColumnExtent columnExtent ? columnExtent : null; ColumnExtent extent = output instanceof ColumnExtent columnExtent ? columnExtent : null;
SolidMemo solids = new SolidMemo(); SolidMemo solids = new SolidMemo();
NativeBlockState[] column = new NativeBlockState[height]; ColumnWindow column = new ColumnWindow(output, height);
for (int localX = 0; localX < width; localX++) { for (int localX = 0; localX < width; localX++) {
for (int localZ = 0; localZ < depth; localZ++) { for (int localZ = 0; localZ < depth; localZ++) {
int worldX = blockX + localX; int worldX = blockX + localX;
int worldZ = blockZ + localZ; int worldZ = blockZ + localZ;
int floor = -1; int floor = -1;
int top = extent == null ? height - 1 : extent.highestStoredY(localX, localZ); int top = extent == null ? height - 1 : extent.highestStoredY(localX, localZ);
if (top >= 1) { column.begin(localX, localZ, top);
ColumnReadHunk.readColumn(output, localX, localZ, 0, Math.min(top, height - 1), column, 0);
}
boolean previousKnown = false; boolean previousKnown = false;
boolean previousSolid = false; boolean previousSolid = false;
for (int y = 1; y < height; y++) { for (int y = 1; y < height; y++) {
if (y > top) { if (y > top) {
break; break;
} }
boolean solid = solids.test(column[y]); boolean solid = solids.test(column.get(y));
boolean decorated = false; boolean decorated = false;
if (solid) { if (solid) {
if (floor >= 0) { if (floor >= 0) {
@@ -1127,15 +1125,12 @@ public class IrisCarveModifier extends EngineAssignedModifier<NativeBlockState>
if (extent != null) { if (extent != null) {
top = extent.highestStoredY(localX, localZ); top = extent.highestStoredY(localX, localZ);
} }
int refreshTop = Math.min(top, height - 1); column.begin(localX, localZ, top);
if (refreshTop >= y) {
ColumnReadHunk.readColumn(output, localX, localZ, y, refreshTop, column, y);
}
} }
floor = -1; floor = -1;
} }
} else if (floor < 0 && (previousKnown ? previousSolid } else if (floor < 0 && (previousKnown ? previousSolid
: solids.test(column[y - 1]))) { : solids.test(column.get(y - 1)))) {
floor = y; floor = y;
} }
previousSolid = solid; previousSolid = solid;
@@ -1481,6 +1476,43 @@ public class IrisCarveModifier extends EngineAssignedModifier<NativeBlockState>
private record CaveColumn(long key, IrisBiome surface, IrisBiome cave, int surfaceY, int minimumDepth) { private record CaveColumn(long key, IrisBiome surface, IrisBiome cave, int surfaceY, int minimumDepth) {
} }
private static final class ColumnWindow {
private static final int ROWS = 16;
private final Hunk<NativeBlockState> output;
private final NativeBlockState[] states;
private int x;
private int z;
private int limit;
private int from;
private int to;
private ColumnWindow(Hunk<NativeBlockState> output, int height) {
this.output = output;
this.states = new NativeBlockState[height];
}
private void begin(int localX, int localZ, int top) {
x = localX;
z = localZ;
limit = Math.min(top, states.length - 1);
from = 0;
to = -1;
}
private NativeBlockState get(int y) {
if (y < from || y > to) {
if (y > limit) {
return output.getRaw(x, y, z);
}
from = y;
to = Math.min(limit, y + ROWS - 1);
ColumnReadHunk.readColumn(output, x, z, from, to, states, from);
}
return states[y];
}
}
private static final class SolidMemo { private static final class SolidMemo {
private NativeBlockState state; private NativeBlockState state;
private boolean solid; private boolean solid;
@@ -126,8 +126,9 @@ public class IrisPerfectionModifier extends EngineAssignedModifier<NativeBlockSt
surfaces.add(top); surfaces.add(top);
NativeBlockState classified = null; NativeBlockState classified = null;
int classifiedFlags = 0; int classifiedFlags = 0;
boolean columnRead = true;
for (int y = top; y >= 0; y--) { for (int y = top; y >= 0; y--) {
NativeBlockState block = column[y]; NativeBlockState block = columnRead ? column[y] : output.get(x, y, z);
int flags = 0; int flags = 0;
if (block != null) { if (block != null) {
if (block != classified) { if (block != classified) {
@@ -138,9 +139,7 @@ public class IrisPerfectionModifier extends EngineAssignedModifier<NativeBlockSt
if ((flags & SPIKE) != 0) { if ((flags & SPIKE) != 0) {
block = normalizeSpike(block, output, x, z, y, air, water); block = normalizeSpike(block, output, x, z, y, air, water);
flags = block == null ? 0 : states.of(block); flags = block == null ? 0 : states.of(block);
if (y > 0) { columnRead = false;
ColumnReadHunk.readColumn(output, x, z, 0, y - 1, column, 0);
}
} }
} }
boolean now = (flags & SOLID) != 0; boolean now = (flags & SOLID) != 0;