Skip floating fields for plain parents

- parent biome lookups read the biome stream directly instead of building the boundary field
- fields are only built where a parent with floating children needs edge distances
This commit is contained in:
Brian Neumann-Fopiano committed 2026-09-28 11:26:41 -04:00
1 parent 1df51b230d
commit f2236a8482
2 files changed
+6 -12

No files matched your search

@@ -48,7 +48,7 @@ public final class FloatingIslandBoundarySampler {
}
public @Nullable IrisBiome parent(int x, int z) {
return parentField(x, z, EDGE_TAPER_WIDTH).parent(x, z);
return source.sample(x, z);
}
public double edgeFade(IrisBiome parent, int x, int z) {
@@ -230,10 +230,6 @@ public final class FloatingIslandBoundarySampler {
build(source);
}
private @Nullable IrisBiome parent(int x, int z) {
return parents[geometry.index(x - minX, z - minZ)];
}
private int edgeDistance(IrisBiome expected, int x, int z) {
int index = geometry.index(x - minX, z - minZ);
if (!sameBiome(expected, parents[index]) || !viable[index]) {
@@ -103,20 +103,18 @@ public class FloatingIslandBoundarySamplerTest {
}
@Test
public void parent_cachesResolvedBiomeColumns() {
public void parent_readsOnlyTheQueriedColumnWithoutBuildingTheBoundaryField() {
IrisBiome parent = new IrisBiome();
IrisBiome other = new IrisBiome();
AtomicInteger calls = new AtomicInteger();
FloatingIslandBoundarySampler sampler = new FloatingIslandBoundarySampler((x, z) -> {
calls.incrementAndGet();
return parent;
return x == 12 && z == -9 ? parent : other;
});
assertSame(parent, sampler.parent(12, -9));
int firstReadCount = calls.get();
assertSame(parent, sampler.parent(12, -9));
assertEquals(firstReadCount, calls.get());
int rawWidth = 16 + (FloatingIslandBoundarySampler.EDGE_FADE_RADIUS * 2) + 2;
assertEquals(rawWidth * rawWidth, firstReadCount);
assertSame(other, sampler.parent(13, -9));
assertEquals(2, calls.get());
}
@Test