- Added continent zoom stretch test

Ref.: https://github.com/VolmitSoftware/Iris/issues/1251
This commit is contained in:
CeeVeeR committed 2026-10-02 05:12:43 +02:00
1 parent 622b40f786
commit 788ac06713
1 file changed
+21
@@ -17,22 +17,35 @@ import static org.mockito.Mockito.when;
public class ContinentGeneratorTest {
private static final long WORLD_SEED = 7L;
private static final double POWER_OF_TWO_CONTINENT_ZOOM = 4D;
private static final double SQUARED_CONTINENT_ZOOM = POWER_OF_TWO_CONTINENT_ZOOM * POWER_OF_TWO_CONTINENT_ZOOM;
private static final double[][] SAMPLE_BLOCKS = {{1000D, -2000D}, {12.5D, -7.25D}, {-517D, 333D}};
private static final double[][] BLOCKS_SHRUNK_BY_CONTINENT_ZOOM = shrinkByContinentZoom(SAMPLE_BLOCKS);
private static final double[] CONTINENT_MAP_OF_EXISTING_WORLDS =
{0.21889892332042843D, 0.6984934456740721D, 0.2708759584352327D};
private final IrisData packData = createPackDataThatBelongsToOneRunningEngine();
private final IrisDimension baseZoomDimension = createDimensionWithContinentZoom(POWER_OF_TWO_CONTINENT_ZOOM);
private final IrisDimension squaredZoomDimension = createDimensionWithContinentZoom(SQUARED_CONTINENT_ZOOM);
@Test
public void doesTheContinentMapAtWorldStartMatchExistingWorlds() {
assertArrayEquals(CONTINENT_MAP_OF_EXISTING_WORLDS, sampleContinentMapAtWorldStart(baseZoomDimension), 0D);
}
@Test
public void doesSquaredContinentZoomStretchTheContinentMapByTheBaseZoom() {
assertArrayEquals(sampleBaseContinentMapStretchedByBaseZoom(),
sampleContinentMapAtWorldStart(squaredZoomDimension), 0D);
}
private double[] sampleContinentMapAtWorldStart(IrisDimension dimension) {
return sampleContinentMap(dimension, SAMPLE_BLOCKS);
}
private double[] sampleBaseContinentMapStretchedByBaseZoom() {
return sampleContinentMap(baseZoomDimension, BLOCKS_SHRUNK_BY_CONTINENT_ZOOM);
}
private double[] sampleContinentMap(IrisDimension dimension, double[][] blocks) {
return sampleAtBlocks(ContinentGenerator.create(dimension, new RNG(WORLD_SEED), packData), blocks);
}
@@ -45,6 +58,14 @@ public class ContinentGeneratorTest {
return continentGenerator.noise(block[0], block[1]);
}
private static double[][] shrinkByContinentZoom(double[][] blocks) {
return Arrays.stream(blocks).map(block -> shrinkByContinentZoom(block)).toArray(double[][]::new);
}
private static double[] shrinkByContinentZoom(double[] block) {
return new double[]{block[0] / POWER_OF_TWO_CONTINENT_ZOOM, block[1] / POWER_OF_TWO_CONTINENT_ZOOM};
}
private static IrisDimension createDimensionWithContinentZoom(double zoom) {
return new IrisDimension().setContinentalStyle(createSimplexStyle()).setContinentZoom(zoom);
}