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

@@ -44,7 +44,7 @@ public class IrisHydrologyTier {
@Description("Blocks the water surface sits below the ground it flows through.")
private int inset = 1;
@Description("Keeps drops shorter than a waterfall as stepped cascades. When false, drops are spread into a gentler slope where the terrain allows, including the step where a channel joins lower water; drops that cannot be spread, such as a junction right below a pond outlet, stay as small cascades below the waterfall minimum.")
@Description("Groups the drops of a run into step-pools: the drops within 2.5 to 5 channel widths, from 6 to 32 blocks, join into one step of up to waterfallMinimumDrop plus 2 blocks, and that limit ends the group early on steep ground. When false, drops are spread into a gentler slope where the terrain allows, including the step where a channel joins lower water; drops that cannot be spread, such as a junction right below a pond outlet, stay as small cascades below the waterfall minimum.")
private boolean cascades = true;
@MinNumber(2)
@@ -1,10 +1,16 @@
package art.arcane.iris.generation.hydrology.raster;
public final class WaterHeads {
private static final int STEP = 2;
private WaterHeads() {
}
public static int snap(int planned, int seaLevel) {
return planned - Math.floorMod(planned - seaLevel, 2);
return planned - Math.floorMod(planned - seaLevel, STEP);
}
public static int lowestAboveSea(int seaLevel) {
return seaLevel + STEP;
}
}
@@ -1,5 +1,7 @@
package art.arcane.iris.generation.hydrology.water;
import art.arcane.iris.generation.hydrology.raster.WaterHeads;
import java.util.Arrays;
import java.util.List;
@@ -63,7 +65,7 @@ final class ReachGrader {
}
int cap = draft.ocean[point] ? seaLevel : draft.target[point] + MAX_POOL;
int floor = lakeFloor[index] ? draft.floor : Math.max(seaLevel, Math.min(draft.floor, (int) Math.floor(draft.bank[point]) + maxFill));
floors[point] = draft.ocean[point] ? floor : Math.max(floor, seaLevel + 1);
floors[point] = draft.ocean[point] ? floor : Math.max(floor, WaterHeads.lowestAboveSea(seaLevel));
level = Math.min(level, Math.max(floor, Math.min(grade[point], cap)));
grade[point] = level;
}
@@ -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,