From 90205dc5fe6bba277be9b33baa46fe4cf8b71995 Mon Sep 17 00:00:00 2001 From: Brian Neumann-Fopiano Date: Mon, 2 Nov 2026 06:21:21 -0500 Subject: [PATCH] Outlet zone step hold - LinkBlend holds a cross-window feeder point that steps one block down as a CASCADE out of a held point, so the restyled last point of an outlet zone keeps its grade as in-window grading does - Plunge distance fields stop at the bowl radius instead of LIMIT, with identical beds - Test: cross-window settling keeps a one-block step at the end of an outlet zone --- .../hydrology/raster/LinkBlend.java | 6 ++++- .../hydrology/raster/RiffleProfile.java | 16 ++++++++---- .../raster/ChunkWaterRasterTest.java | 25 +++++++++++++++++++ 3 files changed, 41 insertions(+), 6 deletions(-) diff --git a/core/src/main/java/art/arcane/iris/generation/hydrology/raster/LinkBlend.java b/core/src/main/java/art/arcane/iris/generation/hydrology/raster/LinkBlend.java index ebc6fd741..c03ced239 100644 --- a/core/src/main/java/art/arcane/iris/generation/hydrology/raster/LinkBlend.java +++ b/core/src/main/java/art/arcane/iris/generation/hydrology/raster/LinkBlend.java @@ -82,11 +82,15 @@ public final class LinkBlend { fixed[0] = held || heldStart || style[0] == ReachStyle.POND_OUTLET; for (int point = 1; point < style.length; point++) { held = held && nearLip(lips, feeder.xs()[point], feeder.zs()[point], feeder.halfWidth()[point]); - fixed[point] = held || style[point] == ReachStyle.POND_OUTLET; + fixed[point] = held || style[point] == ReachStyle.POND_OUTLET || zoneStep(feeder, fixed, point); } return fixed; } + private static boolean zoneStep(Reach feeder, boolean[] fixed, int point) { + return fixed[point - 1] && feeder.style()[point] == ReachStyle.CASCADE && feeder.grade()[point - 1] - feeder.grade()[point] == 1; + } + private static boolean nearLip(List lips, float x, float z, float halfWidth) { for (PondMask lip : lips) { if (ReachShaper.nearLip(lip, x, z, halfWidth)) { diff --git a/core/src/main/java/art/arcane/iris/generation/hydrology/raster/RiffleProfile.java b/core/src/main/java/art/arcane/iris/generation/hydrology/raster/RiffleProfile.java index f32a219a3..9936ec362 100644 --- a/core/src/main/java/art/arcane/iris/generation/hydrology/raster/RiffleProfile.java +++ b/core/src/main/java/art/arcane/iris/generation/hydrology/raster/RiffleProfile.java @@ -53,13 +53,13 @@ final class RiffleProfile { } DistanceField distances = new DistanceField(heads); for (Map.Entry crest : crests.entrySet()) { - int[] output = distances.measure(crest.getValue(), DistanceField.ANY_LEVEL); + int[] output = distances.measure(crest.getValue(), DistanceField.ANY_LEVEL, LIMIT); if (output != null) { fields.add(new Field(crest.getKey(), output)); } } for (Map.Entry fall : feet.entrySet()) { - int[] output = distances.measure(fall.getValue(), fall.getKey().foot()); + int[] output = distances.measure(fall.getValue(), fall.getKey().foot(), fall.getKey().reach()); if (output != null) { plunges.add(new Plunge(fall.getKey(), output)); } @@ -191,6 +191,10 @@ final class RiffleProfile { return Math.clamp(PLUNGE_RADIUS_RATIO * drop(), PLUNGE_MIN_RADIUS, PLUNGE_MAX_RADIUS); } + int reach() { + return (int) Math.ceil(10D * radius()); + } + @Override public int compareTo(Fall other) { return foot != other.foot ? Integer.compare(foot, other.foot) : Integer.compare(top, other.top); @@ -224,13 +228,15 @@ final class RiffleProfile { private final int[] previous = new int[GRID * GRID]; private final int[] first = new int[LIMIT]; private int level; + private int limit; private DistanceField(int[] heads) { this.heads = heads; } - private int[] measure(Seeds seeds, int passable) { + private int[] measure(Seeds seeds, int passable, int reach) { level = passable; + limit = reach; Arrays.fill(distances, LIMIT); Arrays.fill(next, -1); Arrays.fill(previous, -1); @@ -247,7 +253,7 @@ final class RiffleProfile { } private void offer(int cell, int distance) { - if (distance + REMAINING[cell] >= LIMIT) { + if (distance + REMAINING[cell] >= limit) { return; } if (distances[cell] < LIMIT) { @@ -276,7 +282,7 @@ final class RiffleProfile { } private void spread() { - for (int distance = 0; distance < LIMIT; distance++) { + for (int distance = 0; distance < limit; distance++) { while (first[distance] >= 0) { int cell = first[distance]; remove(cell); diff --git a/core/src/test/java/art/arcane/iris/generation/hydrology/raster/ChunkWaterRasterTest.java b/core/src/test/java/art/arcane/iris/generation/hydrology/raster/ChunkWaterRasterTest.java index 2130b4e49..41ff70c4e 100644 --- a/core/src/test/java/art/arcane/iris/generation/hydrology/raster/ChunkWaterRasterTest.java +++ b/core/src/test/java/art/arcane/iris/generation/hydrology/raster/ChunkWaterRasterTest.java @@ -19,6 +19,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 art.arcane.iris.generation.hydrology.water.ShapedNetwork; import art.arcane.iris.generation.terrain.IrisMaterialPalette; @@ -911,6 +912,30 @@ public class ChunkWaterRasterTest { assertWindowOrderFree(scene, 27, 37, 12); } + @Test + public void crossWindowSettlingKeepsAStepAtTheEndOfAnOutletZone() { + HydrologyTier narrow = tier("river", 2f, 0.5f, 4, IrisBankStyle.SMOOTH); + HydrologyTier wide = tier("river", 3f, 0.5f, 4, IrisBankStyle.SMOOTH); + Reach low = line(332L, wide, 0L, 504f, 200f, 600f, 200f, (x, z) -> 62); + Reach drawn = line(331L, narrow, low.id(), 492f, 200f, 504f, 200f, (x, z) -> x < 500f ? 66 : 65); + boolean[] zone = new boolean[drawn.xs().length]; + for (int point = 0; point < zone.length; point++) { + zone[point] = drawn.xs()[point] - drawn.xs()[0] <= 8f; + } + ReachStyle[] style = ReachShaper.styles(drawn.grade(), new boolean[zone.length], zone, narrow.waterfallMinimumDrop(), SEA_LEVEL); + assertEquals("the last outlet zone point steps down one block, shown as two", ReachStyle.CASCADE, style[4]); + assertTrue("the step lies at the end of the outlet zone", zone[4] && !zone[5]); + Reach outlet = new Reach(drawn.id(), narrow, drawn.downstreamId(), drawn.xs(), drawn.zs(), drawn.grade(), drawn.halfWidth(), drawn.depth(), + style, drawn.catchment()); + Scene scene = new Scene(settings(new IrisHydrology()), (x, z) -> 75).reach(outlet).reach(low); + for (int x = 492; x <= 498; x++) { + assertEquals("outlet zone water at x=" + x, 66, scene.head(x, 200)); + } + assertEquals("the outlet zone keeps the step at its last point", 64, scene.head(500, 200)); + assertEquals(62, scene.head(502, 200)); + assertWindowOrderFree(scene, 30, 32, 12); + } + @Test public void crossWindowSettlingKeepsAnOutletsHeldLipAtThePondLevel() { HydrologyTier narrow = tier("river", 2f, 0.5f, 4, IrisBankStyle.SMOOTH);