mirror of
https://github.com/VolmitSoftware/Iris.git
synced 2026-11-27 00:04:42 +00:00
Skip the boundary field for plain floating-island parent lookups
Parent lookups built the whole boundary field per column even where no floating child needs edge distances, and the noise biome cache bound was checked on every insert. Parent lookups now read the biome source directly, and the cache bound is checked only at quart y multiples of 64. Upstream:f2236a8488b5c109d5
This commit is contained in:
1 parent
39e4015b44
commit
8c489e4a26
3 files changed
+8
-13
No files matched your search
+2
-1
@@ -48,6 +48,7 @@ import java.util.stream.Stream;
|
||||
|
||||
public class CustomBiomeSource extends BiomeSource {
|
||||
private static final int NOISE_BIOME_CACHE_MAX = 262144;
|
||||
private static final int NOISE_BIOME_CACHE_CHECK_Y_MASK = 63;
|
||||
private static final int STRONGHOLD_RING_SEARCH_Y = 0;
|
||||
private static final int STRONGHOLD_RING_SEARCH_RADIUS = 112;
|
||||
private static final int STRONGHOLD_RING_SEARCH_QUART_STEP = 4;
|
||||
@@ -452,7 +453,7 @@ public class CustomBiomeSource extends BiomeSource {
|
||||
return existingHolder;
|
||||
}
|
||||
|
||||
if (noiseBiomeCache.size() > NOISE_BIOME_CACHE_MAX) {
|
||||
if ((y & NOISE_BIOME_CACHE_CHECK_Y_MASK) == 0 && noiseBiomeCache.size() > NOISE_BIOME_CACHE_MAX) {
|
||||
noiseBiomeCache.clear();
|
||||
}
|
||||
|
||||
|
||||
+5
-7
@@ -93,20 +93,18 @@ public class FloatingIslandBoundarySamplerTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void parent_cachesResolvedBiomeColumns() {
|
||||
public void parent_readsOnlyTheQueriedColumnWithoutBuildingTheBoundaryField() {
|
||||
ResourceId parent = ResourceId.parse("ns:parent");
|
||||
ResourceId other = ResourceId.parse("ns:other");
|
||||
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
|
||||
|
||||
+1
-5
@@ -47,7 +47,7 @@ public final class FloatingIslandBoundarySampler {
|
||||
}
|
||||
|
||||
public ResourceId parent(int x, int z) {
|
||||
return parentField(x, z, EDGE_TAPER_WIDTH).parent(x, z);
|
||||
return source.sample(x, z);
|
||||
}
|
||||
|
||||
public double edgeFade(ResourceId parent, int x, int z) {
|
||||
@@ -229,10 +229,6 @@ public final class FloatingIslandBoundarySampler {
|
||||
build(source);
|
||||
}
|
||||
|
||||
private ResourceId parent(int x, int z) {
|
||||
return parents[geometry.index(x - minX, z - minZ)];
|
||||
}
|
||||
|
||||
private int edgeDistance(ResourceId expected, int x, int z) {
|
||||
int index = geometry.index(x - minX, z - minZ);
|
||||
if (!sameBiome(expected, parents[index]) || !viable[index]) {
|
||||
|
||||
Reference in new issue
Block a user