Tongue scan holds outlet zone steps

- WaterInvariants.held mirrors LinkBlend.fixed after R72: a CASCADE whose 1-block drop leaves a held point stays held, and a fed start feeds that chain.
- Seed 4 on lane B's cup layout has a CHAINED pond outlet zone that steps 56 to 55 (shown 56 to 54, restyled CASCADE by Task 15) and continues held at 55 before cascading into the junction; the scan flagged that one step point as a tongue.
- PlannedSceneTest.outletZoneStepThatShowsAsTwoBlocksStaysHeld pins the styled zone step as held and the same step left unstyled as a tongue.
This commit is contained in:
Brian Neumann-Fopiano committed 2026-11-02 06:47:48 -05:00
1 parent f76bb19597
commit f4bd105157
2 files changed
+40 -6

No files matched your search

@@ -6,6 +6,7 @@ import art.arcane.iris.generation.hydrology.water.Pond;
import art.arcane.iris.generation.hydrology.water.PondKind;
import art.arcane.iris.generation.hydrology.water.PondMask;
import art.arcane.iris.generation.hydrology.water.Reach;
import art.arcane.iris.generation.hydrology.water.ReachShaper;
import art.arcane.iris.generation.hydrology.water.ReachStyle;
import org.junit.AfterClass;
import org.junit.Test;
@@ -184,6 +185,21 @@ public class PlannedSceneTest {
tongues(settings, above, 66, true, List.of(source(70, above))));
}
@Test
public void outletZoneStepThatShowsAsTwoBlocksStaysHeld() {
HydrologySettings settings = PlannedScene.packSettings(SEED);
int[] lip = {144, 120};
int[] junction = {144, 136};
IntBinaryOperator grade = (x, z) -> z >= 130 ? 66 : z >= 126 ? 69 : 70;
Reach styled = zoneStyled(tributary(settings, lip, junction, 2f, grade), settings.seaLevel());
assertEquals("the 1-block drop inside the outlet zone shows as 2 blocks", ReachStyle.CASCADE, styled.style()[3]);
assertEquals("outlet zone stepping 1 block inside the zone, then cascading into the junction", List.of(),
tongues(settings, styled, 66, true, List.of(pond(21L, 70, disk(144, 106, 8), styled.id()))));
Reach unstyled = outlet(tributary(settings, lip, junction, 2f, grade));
assertEquals("the same outlet zone with the step left unstyled", List.of(unstyled.id()),
tongues(settings, unstyled, 66, true, List.of(pond(21L, 70, disk(144, 106, 8), unstyled.id()))));
}
@Test
public void pondOutletWithAPerchedUnheldTailIsATongue() {
HydrologySettings settings = PlannedScene.packSettings(SEED);
@@ -283,6 +299,20 @@ public class PlannedSceneTest {
style, reach.catchment());
}
private static Reach zoneStyled(Reach reach, int seaLevel) {
boolean[] zone = new boolean[reach.xs().length];
float along = 0f;
for (int point = 0; point < zone.length; point++) {
if (point > 0) {
along += (float) Math.hypot(reach.xs()[point] - reach.xs()[point - 1], reach.zs()[point] - reach.zs()[point - 1]);
}
zone[point] = along <= OUTLET_LENGTH;
}
ReachStyle[] style = ReachShaper.styles(reach.grade(), new boolean[zone.length], zone, reach.tier().waterfallMinimumDrop(), seaLevel);
return new Reach(reach.id(), reach.tier(), reach.downstreamId(), reach.xs(), reach.zs(), reach.grade(), reach.halfWidth(), reach.depth(),
style, reach.catchment());
}
private static Pond source(int level, Reach outlet) {
return pond(21L, level, disk(144, 112, 10), outlet.id());
}
@@ -149,8 +149,7 @@ final class WaterInvariants {
boolean[] pool = pool(feeder, receiving(feeder, downstream, feeders.get(downstream.id())), level);
int[] box = interior(scene, poolBox(feeder, pool));
if (box != null) {
boolean[] held = held(feeder, lips.getOrDefault(feeder.id(), List.of()));
held[0] |= feeders.containsKey(feeder.id());
boolean[] held = held(feeder, lips.getOrDefault(feeder.id(), List.of()), feeders.containsKey(feeder.id()));
junctions.add(new Junction(feeder, WaterHeads.snap(level, seaLevel), pool, held, box));
}
}
@@ -205,16 +204,21 @@ final class WaterInvariants {
return lips;
}
private static boolean[] held(Reach outlet, List<PondMask> lips) {
private static boolean[] held(Reach outlet, List<PondMask> lips, boolean fed) {
boolean[] held = new boolean[outlet.xs().length];
boolean lip = !lips.isEmpty();
for (int point = 0; point < held.length; point++) {
lip = lip && (point == 0 || nearLip(lips, outlet.xs()[point], outlet.zs()[point], outlet.halfWidth()[point]));
held[point] = lip || outlet.style()[point] == ReachStyle.POND_OUTLET;
held[0] = lip || fed || outlet.style()[0] == ReachStyle.POND_OUTLET;
for (int point = 1; point < held.length; point++) {
lip = lip && nearLip(lips, outlet.xs()[point], outlet.zs()[point], outlet.halfWidth()[point]);
held[point] = lip || outlet.style()[point] == ReachStyle.POND_OUTLET || zoneStep(outlet, held, point);
}
return held;
}
private static boolean zoneStep(Reach outlet, boolean[] held, int point) {
return held[point - 1] && outlet.style()[point] == ReachStyle.CASCADE && outlet.grade()[point - 1] - outlet.grade()[point] == 1;
}
private static boolean nearLip(List<PondMask> lips, float x, float z, float halfWidth) {
for (PondMask lip : lips) {
if (ReachShaper.nearLip(lip, x, z, halfWidth)) {