mirror of
https://github.com/VolmitSoftware/Iris.git
synced 2026-12-03 19:51:49 +00:00
Sea heads fail closed
- Window plans reject sea inlets off sea level, reaches graded below sea level, mouths not at sea level and ponds below sea level, naming the window and feature - Coastal fractal and cliff coast scenes pin inlet levels, mouth grades, minimum grades and raster mouth and inlet heads at sea level with no sub-sea air - Hand-built plans with off-sea mouths, sub-sea runs and sunken ponds fail closed - The coastal fall raster test also runs with a 32-block bank band - Planned scenes expose their sea inlets and synthetic terrain can be lowered
This commit is contained in:
1 parent
1cdc30e1ca
commit
d341e114b5
5 files changed
+166
-9
No files matched your search
@@ -20,6 +20,7 @@ import art.arcane.iris.generation.hydrology.water.PondKind;
|
|||||||
import art.arcane.iris.generation.hydrology.water.PondPlanner;
|
import art.arcane.iris.generation.hydrology.water.PondPlanner;
|
||||||
import art.arcane.iris.generation.hydrology.water.Reach;
|
import art.arcane.iris.generation.hydrology.water.Reach;
|
||||||
import art.arcane.iris.generation.hydrology.water.ReachShaper;
|
import art.arcane.iris.generation.hydrology.water.ReachShaper;
|
||||||
|
import art.arcane.iris.generation.hydrology.water.ReachStyle;
|
||||||
import art.arcane.iris.generation.hydrology.water.ShapedNetwork;
|
import art.arcane.iris.generation.hydrology.water.ShapedNetwork;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
@@ -120,6 +121,7 @@ public final class WindowPlanner {
|
|||||||
List<Pond> windowPonds = windowPonds(network.ponds());
|
List<Pond> windowPonds = windowPonds(network.ponds());
|
||||||
List<SeaInlet> planned = inlets.plan(raw, samples, drainage.receivers(), drainage.accumulation(), network, settings.seed());
|
List<SeaInlet> planned = inlets.plan(raw, samples, drainage.receivers(), drainage.accumulation(), network, settings.seed());
|
||||||
WindowPlan owned = new WindowPlan(key, ownedReaches(key, reaches), ownedPonds(key, windowPonds), ownedInlets(key, planned));
|
WindowPlan owned = new WindowPlan(key, ownedReaches(key, reaches), ownedPonds(key, windowPonds), ownedInlets(key, planned));
|
||||||
|
requireSeaConnectedHeads(owned, settings.seaLevel());
|
||||||
return new WindowComputation(owned, reaches, windowPonds);
|
return new WindowComputation(owned, reaches, windowPonds);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -319,6 +321,32 @@ public final class WindowPlanner {
|
|||||||
return owned;
|
return owned;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static void requireSeaConnectedHeads(WindowPlan plan, int seaLevel) {
|
||||||
|
for (SeaInlet inlet : plan.inlets()) {
|
||||||
|
if (inlet.waterLevel() != seaLevel) {
|
||||||
|
throw new IllegalStateException("Window " + plan.key() + " sea inlet " + inlet.id() + " holds water at " + inlet.waterLevel()
|
||||||
|
+ ", not at sea level " + seaLevel);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for (Reach reach : plan.reaches()) {
|
||||||
|
for (int point = 0; point < reach.grade().length; point++) {
|
||||||
|
int grade = reach.grade()[point];
|
||||||
|
boolean mouth = reach.style()[point] == ReachStyle.MOUTH;
|
||||||
|
if (grade < seaLevel || mouth && grade != seaLevel) {
|
||||||
|
throw new IllegalStateException("Window " + plan.key() + " reach " + reach.id() + " " + reach.style()[point] + " point "
|
||||||
|
+ point + " at " + reach.xs()[point] + "," + reach.zs()[point] + " is graded " + grade
|
||||||
|
+ (mouth ? ", not at sea level " : ", below sea level ") + seaLevel);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for (Pond pond : plan.ponds()) {
|
||||||
|
if (pond.level() < seaLevel) {
|
||||||
|
throw new IllegalStateException("Window " + plan.key() + " pond " + pond.id() + " at " + pond.floorX() + "," + pond.floorZ()
|
||||||
|
+ " stands at " + pond.level() + ", below sea level " + seaLevel);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private record Drainage(float[] filled, List<Basin> basins, DemGrid surface, int[] receivers, float[] accumulation, BitSet channels) {
|
private record Drainage(float[] filled, List<Basin> basins, DemGrid surface, int[] receivers, float[] accumulation, BitSet channels) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -8,6 +8,7 @@ import art.arcane.iris.generation.hydrology.raster.ChunkRasterizer;
|
|||||||
import art.arcane.iris.generation.hydrology.raster.ChunkWaterRaster;
|
import art.arcane.iris.generation.hydrology.raster.ChunkWaterRaster;
|
||||||
import art.arcane.iris.generation.hydrology.raster.ReachIndex;
|
import art.arcane.iris.generation.hydrology.raster.ReachIndex;
|
||||||
import art.arcane.iris.generation.hydrology.raster.WaterRole;
|
import art.arcane.iris.generation.hydrology.raster.WaterRole;
|
||||||
|
import art.arcane.iris.generation.hydrology.underground.SeaInlet;
|
||||||
import art.arcane.iris.generation.hydrology.water.Pond;
|
import art.arcane.iris.generation.hydrology.water.Pond;
|
||||||
import art.arcane.iris.generation.hydrology.water.PondPlanner;
|
import art.arcane.iris.generation.hydrology.water.PondPlanner;
|
||||||
import art.arcane.iris.generation.hydrology.water.Reach;
|
import art.arcane.iris.generation.hydrology.water.Reach;
|
||||||
@@ -32,6 +33,7 @@ final class PlannedScene {
|
|||||||
private final Function<RegionKey, RegionPlan> regions;
|
private final Function<RegionKey, RegionPlan> regions;
|
||||||
private final List<Reach> reaches;
|
private final List<Reach> reaches;
|
||||||
private final List<Pond> ponds;
|
private final List<Pond> ponds;
|
||||||
|
private final List<SeaInlet> inlets;
|
||||||
private final ChunkRasterizer rasterizer;
|
private final ChunkRasterizer rasterizer;
|
||||||
private final Map<WindowKey, IndexedWindow> windows = new HashMap<>();
|
private final Map<WindowKey, IndexedWindow> windows = new HashMap<>();
|
||||||
private final Map<Long, ChunkWaterRaster> rasters = new HashMap<>();
|
private final Map<Long, ChunkWaterRaster> rasters = new HashMap<>();
|
||||||
@@ -47,12 +49,15 @@ final class PlannedScene {
|
|||||||
this.rasterizer = new ChunkRasterizer(settings, ChannelFluids.TIER);
|
this.rasterizer = new ChunkRasterizer(settings, ChannelFluids.TIER);
|
||||||
List<Reach> ownedReaches = new ArrayList<>();
|
List<Reach> ownedReaches = new ArrayList<>();
|
||||||
List<Pond> ownedPonds = new ArrayList<>();
|
List<Pond> ownedPonds = new ArrayList<>();
|
||||||
|
List<SeaInlet> ownedInlets = new ArrayList<>();
|
||||||
for (WindowPlan plan : plans.values()) {
|
for (WindowPlan plan : plans.values()) {
|
||||||
ownedReaches.addAll(plan.reaches());
|
ownedReaches.addAll(plan.reaches());
|
||||||
ownedPonds.addAll(plan.ponds());
|
ownedPonds.addAll(plan.ponds());
|
||||||
|
ownedInlets.addAll(plan.inlets());
|
||||||
}
|
}
|
||||||
this.reaches = List.copyOf(ownedReaches);
|
this.reaches = List.copyOf(ownedReaches);
|
||||||
this.ponds = List.copyOf(ownedPonds);
|
this.ponds = List.copyOf(ownedPonds);
|
||||||
|
this.inlets = List.copyOf(ownedInlets);
|
||||||
}
|
}
|
||||||
|
|
||||||
static PlannedScene plan(SyntheticTerrain terrain, HydrologySettings settings, int windowsX, int windowsZ) {
|
static PlannedScene plan(SyntheticTerrain terrain, HydrologySettings settings, int windowsX, int windowsZ) {
|
||||||
@@ -114,6 +119,10 @@ final class PlannedScene {
|
|||||||
return ponds;
|
return ponds;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
List<SeaInlet> inlets() {
|
||||||
|
return inlets;
|
||||||
|
}
|
||||||
|
|
||||||
int minX() {
|
int minX() {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -44,6 +44,11 @@ final class SyntheticTerrain implements HydrologyTerrainSource {
|
|||||||
return new SyntheticTerrain(natural, rainfall, area);
|
return new SyntheticTerrain(natural, rainfall, area);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
SyntheticTerrain lowered(double depth) {
|
||||||
|
DoubleBinaryOperator inner = natural;
|
||||||
|
return new SyntheticTerrain((x, z) -> inner.applyAsDouble(x, z) - depth, rainfall, streamsBlocked);
|
||||||
|
}
|
||||||
|
|
||||||
SyntheticTerrain withPit(double centreX, double centreZ, double radius, double depth) {
|
SyntheticTerrain withPit(double centreX, double centreZ, double radius, double depth) {
|
||||||
DoubleBinaryOperator inner = natural;
|
DoubleBinaryOperator inner = natural;
|
||||||
return new SyntheticTerrain((x, z) -> {
|
return new SyntheticTerrain((x, z) -> {
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ package art.arcane.iris.generation.hydrology.plan;
|
|||||||
import art.arcane.iris.generation.hydrology.config.IrisHydrology;
|
import art.arcane.iris.generation.hydrology.config.IrisHydrology;
|
||||||
import art.arcane.iris.generation.hydrology.grid.HeightLattice;
|
import art.arcane.iris.generation.hydrology.grid.HeightLattice;
|
||||||
import art.arcane.iris.generation.hydrology.raster.WaterHeads;
|
import art.arcane.iris.generation.hydrology.raster.WaterHeads;
|
||||||
|
import art.arcane.iris.generation.hydrology.raster.WaterRole;
|
||||||
import art.arcane.iris.generation.hydrology.underground.SeaInlet;
|
import art.arcane.iris.generation.hydrology.underground.SeaInlet;
|
||||||
import art.arcane.iris.generation.hydrology.water.HydrologyTier;
|
import art.arcane.iris.generation.hydrology.water.HydrologyTier;
|
||||||
import art.arcane.iris.generation.hydrology.water.CupSet;
|
import art.arcane.iris.generation.hydrology.water.CupSet;
|
||||||
@@ -31,6 +32,7 @@ import java.util.concurrent.atomic.AtomicInteger;
|
|||||||
import static org.junit.Assert.assertEquals;
|
import static org.junit.Assert.assertEquals;
|
||||||
import static org.junit.Assert.assertFalse;
|
import static org.junit.Assert.assertFalse;
|
||||||
import static org.junit.Assert.assertNotNull;
|
import static org.junit.Assert.assertNotNull;
|
||||||
|
import static org.junit.Assert.assertThrows;
|
||||||
import static org.junit.Assert.assertTrue;
|
import static org.junit.Assert.assertTrue;
|
||||||
import static org.mockito.ArgumentMatchers.any;
|
import static org.mockito.ArgumentMatchers.any;
|
||||||
import static org.mockito.ArgumentMatchers.anyLong;
|
import static org.mockito.ArgumentMatchers.anyLong;
|
||||||
@@ -45,6 +47,9 @@ public class WindowPlannerTest {
|
|||||||
private static final WindowKey ORIGIN = new WindowKey(0, 0);
|
private static final WindowKey ORIGIN = new WindowKey(0, 0);
|
||||||
private static final WindowKey LAND = new WindowKey(4, 4);
|
private static final WindowKey LAND = new WindowKey(4, 4);
|
||||||
private static final int SEAM_DISTANCE = 256;
|
private static final int SEAM_DISTANCE = 256;
|
||||||
|
private static final double COAST_DROP = 20D;
|
||||||
|
private static final double CLIFF_COAST_X = 300D;
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void zeroDensityRemovesLocalChannelsAndPonds() {
|
public void zeroDensityRemovesLocalChannelsAndPonds() {
|
||||||
HydrologySettings settings = settings(new IrisHydrology().setDensity(0D));
|
HydrologySettings settings = settings(new IrisHydrology().setDensity(0D));
|
||||||
@@ -800,6 +805,95 @@ public class WindowPlannerTest {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void seaConnectedHeadsSitAtSeaLevel() {
|
||||||
|
HydrologySettings settings = PlannedScene.packSettings(SEED);
|
||||||
|
PlannedScene fractal = PlannedScene.plan(SyntheticTerrain.openFractal(1L).lowered(COAST_DROP), settings, 2, 2);
|
||||||
|
PlannedScene cliff = PlannedScene.plan(SyntheticTerrain.cliffCoast(CLIFF_COAST_X), settings, 2, 2);
|
||||||
|
SeaColumns fractalColumns = assertSeaConnectedHeads("openFractal(1) lowered " + COAST_DROP, fractal);
|
||||||
|
SeaColumns cliffColumns = assertSeaConnectedHeads("cliffCoast(" + CLIFF_COAST_X + ")", cliff);
|
||||||
|
assertTrue("mouth vertices on the coastal fractal " + fractalColumns.vertices(), fractalColumns.vertices() >= 100);
|
||||||
|
assertTrue("mouth columns on the coastal fractal " + fractalColumns.mouths(), fractalColumns.mouths() >= 1000);
|
||||||
|
assertTrue("mouth columns on the cliff coast " + cliffColumns.mouths(), cliffColumns.mouths() >= 1000);
|
||||||
|
assertTrue("sea inlets on the cliff coast " + cliff.inlets().size(), cliff.inlets().size() >= 2);
|
||||||
|
assertTrue("inlet columns on the cliff coast " + cliffColumns.inlets(), cliffColumns.inlets() >= 500);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void planWithAMouthBelowSeaFailsClosed() {
|
||||||
|
HydrologySettings settings = settings(new IrisHydrology());
|
||||||
|
Reach mouth = coastal(4711L, settings.tiers().get(0), SEA_LEVEL - 1, ReachStyle.MOUTH);
|
||||||
|
assertFailsClosed(settings, List.of(mouth), List.of(), "reach 4711");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void planWithWaterOffTheSeaSurfaceFailsClosed() {
|
||||||
|
HydrologySettings settings = settings(new IrisHydrology());
|
||||||
|
HydrologyTier stream = settings.tiers().get(0);
|
||||||
|
assertFailsClosed(settings, List.of(coastal(4712L, stream, SEA_LEVEL + 1, ReachStyle.MOUTH)), List.of(), "reach 4712");
|
||||||
|
assertFailsClosed(settings, List.of(coastal(4713L, stream, SEA_LEVEL - 1, ReachStyle.RUN)), List.of(), "reach 4713");
|
||||||
|
int width = 9;
|
||||||
|
long[] bits = new long[(width * width + 63) >>> 6];
|
||||||
|
for (int cell = 0; cell < width * width; cell++) {
|
||||||
|
bits[cell >>> 6] |= 1L << cell;
|
||||||
|
}
|
||||||
|
Pond sunken = new Pond(4714L, PondKind.NATURAL, SEA_LEVEL - 1, SEA_LEVEL - 4, 132, 128, SEA_LEVEL,
|
||||||
|
new PondMask(124, 124, 1, width, width, bits), 0L, 0, "water", 128, 128);
|
||||||
|
assertFailsClosed(settings, List.of(), List.of(sunken), "pond 4714");
|
||||||
|
}
|
||||||
|
|
||||||
|
private static Reach coastal(long id, HydrologyTier tier, int mouthGrade, ReachStyle mouthStyle) {
|
||||||
|
return new Reach(id, tier, 0L, new float[]{64f, 80f, 96f}, new float[]{64f, 64f, 64f},
|
||||||
|
new int[]{mouthGrade + 2, mouthGrade + 2, mouthGrade}, new float[]{2f, 2f, 2f}, new float[]{1f, 1f, 1f},
|
||||||
|
new ReachStyle[]{ReachStyle.RUN, ReachStyle.RUN, mouthStyle}, 1000f);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void assertFailsClosed(HydrologySettings settings, List<Reach> reaches, List<Pond> water, String feature) {
|
||||||
|
PondPlanner ponds = spy(new PondPlanner(settings));
|
||||||
|
doReturn(CupSet.EMPTY).when(ponds).subtractCups(any(), any(), any(), any());
|
||||||
|
doReturn(water).when(ponds).ponds(any(), any(), any(), any(), any(), any());
|
||||||
|
ReachShaper shaper = mock(ReachShaper.class);
|
||||||
|
doReturn(new ShapedNetwork(reaches, water)).when(shaper).shape(any(), any(), any(), any(), any(), any(), anyLong());
|
||||||
|
WindowPlanner planner = new WindowPlanner(settings,
|
||||||
|
new HeightLattice(SyntheticTerrain.flat(100D), WindowPlanner.FINE_CELL, false, 1 << 18), ponds, shaper);
|
||||||
|
IllegalStateException failure = assertThrows(feature + " off the sea surface", IllegalStateException.class,
|
||||||
|
() -> planner.compute(ORIGIN, noRegions(ORIGIN)));
|
||||||
|
assertTrue(failure.getMessage(), failure.getMessage().contains(feature) && failure.getMessage().contains("Window " + ORIGIN));
|
||||||
|
}
|
||||||
|
|
||||||
|
private static SeaColumns assertSeaConnectedHeads(String name, PlannedScene scene) {
|
||||||
|
for (SeaInlet inlet : scene.inlets()) {
|
||||||
|
assertEquals(name + " " + inlet, SEA_LEVEL, inlet.waterLevel());
|
||||||
|
}
|
||||||
|
int vertices = 0;
|
||||||
|
for (Reach reach : scene.reaches()) {
|
||||||
|
for (int point = 0; point < reach.grade().length; point++) {
|
||||||
|
assertTrue(name + " " + reach + " point " + point + " grade " + reach.grade()[point], reach.grade()[point] >= SEA_LEVEL);
|
||||||
|
if (reach.style()[point] == ReachStyle.MOUTH) {
|
||||||
|
vertices++;
|
||||||
|
assertEquals(name + " " + reach + " mouth point " + point, SEA_LEVEL, reach.grade()[point]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for (Pond pond : scene.ponds()) {
|
||||||
|
assertTrue(name + " " + pond, pond.level() >= SEA_LEVEL);
|
||||||
|
}
|
||||||
|
int mouths = 0;
|
||||||
|
int inlets = 0;
|
||||||
|
for (int z = scene.minZ() + WaterInvariants.EDGE_MARGIN; z <= scene.maxZ() - WaterInvariants.EDGE_MARGIN; z++) {
|
||||||
|
for (int x = scene.minX() + WaterInvariants.EDGE_MARGIN; x <= scene.maxX() - WaterInvariants.EDGE_MARGIN; x++) {
|
||||||
|
WaterRole role = scene.role(x, z);
|
||||||
|
if (role == WaterRole.MOUTH || role == WaterRole.INLET) {
|
||||||
|
assertEquals(name + " " + role + " head at " + x + "," + z, SEA_LEVEL, scene.head(x, z));
|
||||||
|
mouths += role == WaterRole.MOUTH ? 1 : 0;
|
||||||
|
inlets += role == WaterRole.INLET ? 1 : 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
assertEquals(name + " water below the sea surface", List.of(), WaterInvariants.subSeaAir(scene, SEA_LEVEL));
|
||||||
|
return new SeaColumns(vertices, mouths, inlets);
|
||||||
|
}
|
||||||
|
|
||||||
private static HydrologySettings settings(IrisHydrology config) {
|
private static HydrologySettings settings(IrisHydrology config) {
|
||||||
return HydrologySettings.compile(config, SEED, SEA_LEVEL, SyntheticTerrain.MIN_Y, SyntheticTerrain.MAX_Y);
|
return HydrologySettings.compile(config, SEED, SEA_LEVEL, SyntheticTerrain.MIN_Y, SyntheticTerrain.MAX_Y);
|
||||||
}
|
}
|
||||||
@@ -999,4 +1093,7 @@ public class WindowPlannerTest {
|
|||||||
float seam = Math.max(owner.wz(), other.wz()) * WindowKey.SIZE;
|
float seam = Math.max(owner.wz(), other.wz()) * WindowKey.SIZE;
|
||||||
return Math.abs(z - seam) <= SEAM_DISTANCE;
|
return Math.abs(z - seam) <= SEAM_DISTANCE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private record SeaColumns(int vertices, int mouths, int inlets) {
|
||||||
|
}
|
||||||
}
|
}
|
||||||
+27
-9
@@ -1057,8 +1057,15 @@ public class ChunkWaterRasterTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void coastalFallMarksLipAndMouthSitsAtSeaLevel() {
|
public void coastalFallMarksLipAndMouthSitsAtSeaLevel() {
|
||||||
|
for (int bankBand : new int[]{0, 32}) {
|
||||||
|
assertCoastalFall(bankBand);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void assertCoastalFall(int bankBand) {
|
||||||
|
String banks = "bankBand " + bankBand + ": ";
|
||||||
IntBinaryOperator coast = (x, z) -> x < 40 ? 60 : SEA_LEVEL - 10;
|
IntBinaryOperator coast = (x, z) -> x < 40 ? 60 : SEA_LEVEL - 10;
|
||||||
HydrologyTier stream = tier("stream", 1.5f, 0.5f, 0, IrisBankStyle.SMOOTH);
|
HydrologyTier stream = tier("stream", 1.5f, 0.5f, bankBand, IrisBankStyle.SMOOTH);
|
||||||
Reach drawn = line(121L, stream, 0L, -20f, 8f, 50f, 8f, (x, z) -> x < 40f ? 59 : SEA_LEVEL);
|
Reach drawn = line(121L, stream, 0L, -20f, 8f, 50f, 8f, (x, z) -> x < 40f ? 59 : SEA_LEVEL);
|
||||||
ReachStyle[] style = drawn.style().clone();
|
ReachStyle[] style = drawn.style().clone();
|
||||||
for (int point = 0; point < style.length; point++) {
|
for (int point = 0; point < style.length; point++) {
|
||||||
@@ -1069,22 +1076,33 @@ public class ChunkWaterRasterTest {
|
|||||||
Reach coastal = new Reach(drawn.id(), stream, 0L, drawn.xs(), drawn.zs(), drawn.grade(), drawn.halfWidth(), drawn.depth(), style,
|
Reach coastal = new Reach(drawn.id(), stream, 0L, drawn.xs(), drawn.zs(), drawn.grade(), drawn.halfWidth(), drawn.depth(), style,
|
||||||
drawn.catchment());
|
drawn.catchment());
|
||||||
Scene scene = new Scene(settings(new IrisHydrology()), coast).reach(coastal);
|
Scene scene = new Scene(settings(new IrisHydrology()), coast).reach(coastal);
|
||||||
assertEquals("the lip carries the fall", WaterRole.WATERFALL, scene.role(38, 8));
|
assertEquals(banks + "the lip carries the fall", WaterRole.WATERFALL, scene.role(38, 8));
|
||||||
assertEquals(58, scene.head(38, 8));
|
assertEquals(banks + "lip head", 58, scene.head(38, 8));
|
||||||
|
int minZ = -bankBand;
|
||||||
|
int maxZ = 16 + bankBand;
|
||||||
int mouths = 0;
|
int mouths = 0;
|
||||||
for (int x = -20; x <= 56; x++) {
|
for (int x = -20; x <= 56; x++) {
|
||||||
for (int z = 0; z <= 16; z++) {
|
for (int z = minZ; z <= maxZ; z++) {
|
||||||
if (scene.role(x, z) == WaterRole.MOUTH) {
|
if (scene.role(x, z) == WaterRole.MOUTH) {
|
||||||
mouths++;
|
mouths++;
|
||||||
assertEquals("mouth at sea level at " + x + "," + z, SEA_LEVEL, scene.head(x, z));
|
assertEquals(banks + "mouth at sea level at " + x + "," + z, SEA_LEVEL, scene.head(x, z));
|
||||||
}
|
}
|
||||||
if (x >= 40 && !scene.water(x, z)) {
|
if (scene.water(x, z)) {
|
||||||
assertEquals("no berm is built in the sea at " + x + "," + z, coast.applyAsInt(x, z), scene.terrain(x, z));
|
continue;
|
||||||
|
}
|
||||||
|
int ground = scene.terrain(x, z);
|
||||||
|
if (x < 40) {
|
||||||
|
assertTrue(banks + "dry shore at " + x + "," + z + " is cut to " + ground + ", below the sea surface", ground >= SEA_LEVEL);
|
||||||
|
} else if (bankBand == 0) {
|
||||||
|
assertEquals(banks + "no berm is built in the sea at " + x + "," + z, coast.applyAsInt(x, z), ground);
|
||||||
|
} else {
|
||||||
|
assertTrue(banks + "the sea floor at " + x + "," + z + " is " + ground + ", cut or raised out of the sea",
|
||||||
|
ground >= coast.applyAsInt(x, z) && ground < SEA_LEVEL);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
assertTrue("mouth columns " + mouths, mouths > 20);
|
assertTrue(banks + "mouth columns " + mouths, mouths > 20);
|
||||||
assertEquals(0, scene.leaks(-20, 0, 56, 16));
|
assertEquals(banks + "leaks", 0, scene.leaks(-20, minZ, 56, maxZ));
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void assertContained(String name, Scene scene, int minX, int minZ, int maxX, int maxZ, boolean bermed) {
|
private static void assertContained(String name, Scene scene, int minX, int minZ, int maxX, int maxZ, boolean bermed) {
|
||||||
|
|||||||
Reference in new issue
Block a user