mirror of
https://github.com/VolmitSoftware/Iris.git
synced 2026-10-23 16:44:06 +00:00
Rarity and capacity checks
- Rarity stream picks are property-tested against the VolmLib rarity selection - Pregen capacity growth scales the bake by the same factor as engine start
This commit is contained in:
1 parent
7408d02bbe
commit
ab69be59c7
2 files changed
+55
-2
No files matched your search
@@ -142,6 +142,7 @@ public class IrisComplex implements DataProvider {
|
||||
private static final int STUDIO_NOISE_CACHE_SIZE = 32_768;
|
||||
private static final int TERRAIN_COLUMN_CACHE_SIZE = 524_288;
|
||||
private static final int SPARSE_BASE_HEIGHT_CAPACITY = 1 << 17;
|
||||
private static final int BAKE_CHUNKS_PER_NOISE_CHUNK = 8;
|
||||
/** One million corners: about 20 MB, roughly a 4000 by 4000 block area at the 4-block grid. */
|
||||
private static final int SHARED_CORNER_BOUNDS_CAPACITY = 1 << 20;
|
||||
/** The slope streams measure the rise across a run of this many blocks, so gradient is slope over run. */
|
||||
@@ -414,7 +415,7 @@ public class IrisComplex implements DataProvider {
|
||||
|
||||
return value;
|
||||
});
|
||||
bakeCache = new ChunkBakeCache(new BakeSource(), cacheSize * 8);
|
||||
bakeCache = new ChunkBakeCache(new BakeSource(), cacheSize * BAKE_CHUNKS_PER_NOISE_CHUNK);
|
||||
rockSource = engine.getDimension().getRockPalette().getLayerGenerator(rng.nextParallelRNG(45), data).stream()
|
||||
.select(engine.getDimension().getRockPalette().getBlockData(data));
|
||||
rockStream = new BakedStream<>(bakeCache, BakePlane.ROCK, rockSource);
|
||||
@@ -579,7 +580,7 @@ public class IrisComplex implements DataProvider {
|
||||
if (minimumChunks <= 0) {
|
||||
throw new IllegalArgumentException("Terrain noise cache size must be positive");
|
||||
}
|
||||
bakeCache.ensureCapacity(minimumChunks);
|
||||
bakeCache.ensureCapacity(minimumChunks * BAKE_CHUNKS_PER_NOISE_CHUNK);
|
||||
}
|
||||
|
||||
void expandHydrologyNoiseCaches() {
|
||||
|
||||
@@ -0,0 +1,52 @@
|
||||
package art.arcane.iris.generation.stream;
|
||||
|
||||
import art.arcane.volmlib.util.math.Rarity;
|
||||
import art.arcane.volmlib.util.stream.ProceduralStream;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.SplittableRandom;
|
||||
|
||||
import static org.junit.Assert.assertNull;
|
||||
import static org.junit.Assert.assertSame;
|
||||
|
||||
public class RarityStreamTest {
|
||||
@Test
|
||||
public void picksMatchRarityStreamSelectionForEveryNoiseValue() {
|
||||
SplittableRandom random = new SplittableRandom(4242L);
|
||||
for (int trial = 0; trial < 200; trial++) {
|
||||
List<Option> options = new ArrayList<>();
|
||||
int count = 1 + random.nextInt(12);
|
||||
for (int index = 0; index < count; index++) {
|
||||
options.add(new Option(random.nextInt(-2, 40)));
|
||||
}
|
||||
double[] value = new double[1];
|
||||
ProceduralStream<Double> noise = ProceduralStream.ofDouble((x, z) -> value[0]);
|
||||
ProceduralStream<Option> expected = noise.selectRarity(options);
|
||||
RarityStream<Option> candidate = new RarityStream<>(noise, options);
|
||||
for (int sample = 0; sample < 2_000; sample++) {
|
||||
value[0] = switch (random.nextInt(5)) {
|
||||
case 0 -> random.nextDouble();
|
||||
case 1 -> random.nextDouble(-0.5D, 1.5D);
|
||||
case 2 -> random.nextInt(0, 64) / 63D;
|
||||
case 3 -> sample % 2 == 0 ? Double.NaN : -0D;
|
||||
default -> Math.nextUp(random.nextInt(0, 16) / 15D);
|
||||
};
|
||||
assertSame(expected.get(sample, -sample), candidate.get(sample, -sample));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void emptyOptionsSelectNothing() {
|
||||
assertNull(new RarityStream<Option>(ProceduralStream.ofDouble((x, z) -> 0.5D), List.of()).get(0D, 0D));
|
||||
}
|
||||
|
||||
private record Option(int rarity) implements Rarity {
|
||||
@Override
|
||||
public int getRarity() {
|
||||
return rarity;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user