Outlets keep their width

- Pond outlets skip the junction width flare, so an outlet whose exit node takes a tributary leaves its pond at its own width
- Cross-window links into a pond outlet clamp its grade without rebasing its width or depth
- The cross-window width blend always measures from the downstream reach's first vertex
- Planner and cross-window tests cover narrow and wide tributaries at an outlet's exit node
This commit is contained in:
Brian Neumann-Fopiano committed 2026-11-01 20:43:39 -05:00
1 parent 1827ec1cc6
commit 41e38debad
5 files changed
+74 -24

No files matched your search

@@ -317,8 +317,8 @@ final class ChunkFeatures {
}
private Reach link(Reach reach, WindowKey owner) {
Reach linked = feederLink(reach, owner);
Integer pondLevel = outletLevel(reach, owner);
Reach linked = feederLink(reach, owner, pondLevel != null);
return settle(reach, pondLevel == null ? linked : LinkBlend.clamp(linked, pondLevel), owner);
}
@@ -359,7 +359,7 @@ final class ChunkFeatures {
return found;
}
private Reach feederLink(Reach downstream, WindowKey owner) {
private Reach feederLink(Reach downstream, WindowKey owner, boolean outlet) {
int junction = junction(downstream);
WindowKey link = windowAt(downstream, junction);
List<Reach> joining = feeders(link, downstream.id());
@@ -375,7 +375,7 @@ final class ChunkFeatures {
for (Reach reach : joining) {
feeders.add(cornerBlock(reach) == block ? resolve(reach, link) : reach);
}
return link.equals(owner) ? LinkBlend.clamp(downstream, feeders) : LinkBlend.blend(downstream, feeders, junction);
return link.equals(owner) || outlet ? LinkBlend.clamp(downstream, feeders) : LinkBlend.blend(downstream, feeders);
}
private List<Reach> feeders(WindowKey key, long downstreamId) {
@@ -22,7 +22,7 @@ public final class LinkBlend {
return from + (to - from) * share;
}
static Reach blend(Reach downstream, List<Reach> feeders, int junction) {
static Reach blend(Reach downstream, List<Reach> feeders) {
float width = 0f;
float depth = 0f;
for (Reach feeder : feeders) {
@@ -34,16 +34,15 @@ public final class LinkBlend {
float[] zs = downstream.zs();
float[] halfWidth = downstream.halfWidth().clone();
float[] depths = downstream.depth().clone();
float widthShift = width - halfWidth[junction];
float depthShift = depth - depths[junction];
float[] along = new float[xs.length];
for (int point = 1; point < xs.length; point++) {
along[point] = along[point - 1] + (float) Math.hypot(xs[point] - xs[point - 1], zs[point] - zs[point - 1]);
}
float widthShift = width - halfWidth[0];
float depthShift = depth - depths[0];
float along = 0f;
for (int point = 0; point < xs.length; point++) {
float fromJunction = along[point] - along[junction];
halfWidth[point] += blend(widthShift, 0f, fromJunction);
depths[point] += blend(depthShift, 0f, fromJunction);
if (point > 0) {
along += (float) Math.hypot(xs[point] - xs[point - 1], zs[point] - zs[point - 1]);
}
halfWidth[point] += blend(widthShift, 0f, along);
depths[point] += blend(depthShift, 0f, along);
}
return regraded(downstream, clamped(downstream.grade(), lowestEnd(feeders)), halfWidth, depths);
}
@@ -488,7 +488,7 @@ public final class ReachShaper {
private static void widths(ReachDraft draft, float upstream, float feederEnd) {
int count = draft.xs.length;
boolean flare = draft.incoming.length > 0;
boolean flare = draft.incoming.length > 0 && !draft.outlet;
boolean taper = !flare && !draft.outlet;
float[] distance = distances(draft.xs, draft.zs);
float running = upstream;