Step-pool review fixes

- Floor non-estuary pools at the lowest grade whose snapped head is above the sea
- Add WaterHeads.lowestAboveSea beside the snap rule it follows
- Restore the strict delta branch check on grouped settings
- Assert grouping moves no sea-level head upstream on the delta fixture
- Update the cascades schema description and recapture the schema digest
- Measure pools by arc on a gentler run
- Test close falls stay separate when the lower lands on the end level
This commit is contained in:
Brian Fopiano committed 2026-11-02 17:27:15 -05:00
1 parent 394eb6b8c1
commit 618a52952d
6 files changed
+65 -11

No files matched your search

@@ -47,7 +47,6 @@ import static org.junit.Assert.assertThrows;
import static org.junit.Assert.assertTrue;
public class ChunkWaterRasterTest {
private static final double STEP_POOL_MAX = 32D;
private static final long SEED = 1337L;
private static final int SEA_LEVEL = 40;
private static final int MIN_Y = -64;
@@ -1255,12 +1254,22 @@ public class ChunkWaterRasterTest {
@Test
public void deltaChannelsRenderAsSeaLevelMouthWaterWithoutAGapAtTheBranch() {
assertDeltaRendersAtSeaLevel(DeltaCoast.settings(2), DeltaCoast::ground, -1D);
assertDeltaRendersAtSeaLevel(DeltaCoast.settings(2), DeltaCoast::cliffBacked, STEP_POOL_MAX);
assertDeltaRendersAtSeaLevel(DeltaCoast.ungroupedSettings(2), DeltaCoast::cliffBacked, 0D);
assertDeltaRendersAtSeaLevel(DeltaCoast.settings(2), DeltaCoast::ground, false);
assertDeltaRendersAtSeaLevel(DeltaCoast.settings(2), DeltaCoast::cliffBacked, true);
assertDeltaRendersAtSeaLevel(DeltaCoast.ungroupedSettings(2), DeltaCoast::cliffBacked, true);
assertEquals("grouping moves no sea-level head upstream", firstSeaLevelHead(DeltaCoast.ungroupedSettings(2)), firstSeaLevelHead(DeltaCoast.settings(2)), 0f);
}
private static void assertDeltaRendersAtSeaLevel(HydrologySettings settings, DoubleBinaryOperator ground, double raisedSlack) {
private static float firstSeaLevelHead(HydrologySettings settings) {
Reach river = DeltaCoast.river(DeltaCoast.shape(settings, 0, 0, List.of(), DeltaCoast.NO_NEIGHBOUR, DeltaCoast.SEED, DeltaCoast::cliffBacked), DeltaCoast.ROW);
int point = 0;
while (WaterHeads.snap(river.grade()[point], SEA_LEVEL) > SEA_LEVEL) {
point++;
}
return river.xs()[point];
}
private static void assertDeltaRendersAtSeaLevel(HydrologySettings settings, DoubleBinaryOperator ground, boolean raisedAboveTheEstuary) {
ShapedNetwork shaped = DeltaCoast.shape(settings, 0, 0, List.of(), DeltaCoast.NO_NEIGHBOUR, DeltaCoast.SEED, ground);
Reach river = DeltaCoast.river(shaped, DeltaCoast.ROW);
List<Reach> fan = DeltaCoast.deltaChannels(shaped);
@@ -1293,13 +1302,13 @@ public class ChunkWaterRasterTest {
assertTrue("the river stays wet at " + x + "," + z, delta.water(x, z));
if (plain.head(x, z) > SEA_LEVEL) {
assertEquals("the river above its estuary keeps its head at " + x + "," + z, plain.head(x, z), delta.head(x, z));
raised += Math.hypot(x - fan.get(0).xs()[0], z - fan.get(0).zs()[0]) <= 2D * fan.get(0).halfWidth()[0] + 8D + Math.max(0D, raisedSlack) ? 1 : 0;
raised += Math.hypot(x - fan.get(0).xs()[0], z - fan.get(0).zs()[0]) <= 2D * fan.get(0).halfWidth()[0] + 8D ? 1 : 0;
}
}
}
}
assertTrue("delta water beyond the estuary " + added, added > 100);
assertTrue("river water above the sea next to the branch " + raised, raisedSlack < 0D || raised > 0);
assertTrue("river water above the sea next to the branch " + raised, !raisedAboveTheEstuary || raised > 0);
assertEquals("delta leaks", 0, delta.leaks(minX, minZ, maxX, maxZ));
Set<Long> reached = wetFrom(delta, Math.round(river.xs()[estuary]) - 16, Math.round(river.zs()[estuary]), minX, minZ, maxX, maxZ);
for (Reach channel : fan) {
@@ -370,6 +370,43 @@ public class ReachShaperTest {
assertTrue(label + " level below the fall from " + foot + " to " + end, STATION * (end - foot) >= StepPools.PLUNGE_MIN);
}
@Test
public void gentlerRunsHoldPoolsMeasuredAlongTheChannel() {
HydrologyTier tier = settings(config -> {
}).tiers().get(2);
float[] ground = new float[48];
for (int index = 0; index < ground.length; index++) {
ground[index] = 200f - 2f * index;
}
int[] grade = graded(tier, ground);
int pools = 0;
int first = 0;
for (int index = 1; index <= grade.length; index++) {
if (index == grade.length || grade[index] < grade[first]) {
pools += STATION * (index - 1 - first) >= 8 ? 1 : 0;
first = index;
}
}
assertTrue(Arrays.toString(grade) + " pools " + pools, pools >= 3);
}
@Test
public void closeFallsStaySeparateWhenTheLowerLandsOnTheEndLevel() {
HydrologyTier tier = settings(config -> {
}).tiers().get(0);
float[] ground = new float[24];
for (int index = 0; index < ground.length; index++) {
ground[index] = index < 10 ? 160f : index < 12 ? 140f : 130f;
}
int[] baseline = graded(withSteps(tier, false, 2), ground);
int[] grade = graded(tier, ground);
String label = Arrays.toString(baseline) + " grouped " + Arrays.toString(grade);
assertEquals(label, baseline[10], grade[10]);
assertEquals(label, baseline[11], grade[11]);
assertEquals(label, baseline[12], grade[12]);
assertEquals(label, baseline[23], grade[12]);
}
@Test
public void tallFallsRollOverAtTheBrinkAndKeepEveryFall() {
HydrologyTier tier = settings(config -> {
@@ -84,7 +84,7 @@ public class SchemaBuilderIdentityTest {
@ClassRule
public static final PlatformLeakGuard PLATFORM_GUARD = PlatformLeakGuard.clean();
private static final String EXPECTED_SCHEMA_DIGEST = "3377c4bd7994ef223bbb054391c191e6dc202475232d19c5c3fe4f43402ffed1";
private static final String EXPECTED_SCHEMA_DIGEST = "42f9e4edec478cc309119c8d90e15ed38f50a500f2e7d4fb870523be6c4fe10d";
private static final List<Class<?>> SCHEMA_ROOTS = List.of(
IrisDimension.class,