mirror of
https://github.com/VolmitSoftware/Iris.git
synced 2026-11-28 08:44:50 +00:00
Confluence review fixes
- Spread the junction step of feeders on tiers without cascades through the grader's spread rule, never moving outlet zone or held points - Extract ReachGrader.spreadPoint from the spread pass and clamp it so it only lowers - Throw when a downstream reach starts above its feeder's end, naming both reach ids and the junction - Restore the per-reach waterfall check in gradeNeverRisesDownstream, excluding drops that land at or below the stepped twin's junction level - Add ConfluenceGraderTest for spread junction steps, the fixed-point exception and the fail-closed junction - Describe junction spreading in the cascades setting and recapture the schema digest
This commit is contained in:
1 parent
4cf141b97b
commit
52761e1784
6 files changed
+169
-24
No files matched your search
+1
-1
@@ -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; drops that cannot be spread stay as small cascades below the waterfall minimum.")
|
||||
@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.")
|
||||
private boolean cascades = true;
|
||||
|
||||
@MinNumber(2)
|
||||
|
||||
+33
-5
@@ -36,12 +36,19 @@ public final class ConfluenceGrader {
|
||||
ReachDraft downstream = drafts.get(upstreamFirst[position]);
|
||||
for (int feeder : downstream.incoming) {
|
||||
ReachDraft draft = drafts.get(feeder);
|
||||
int[] settled = settle(footprint(draft), draft.grade, fixed(draft), receiving(drafts, downstream, feeder), downstream.grade[0],
|
||||
draft.tier.waterfallMinimumDrop());
|
||||
if (settled != draft.grade) {
|
||||
draft.grade = settled;
|
||||
touched[feeder] = true;
|
||||
requireJunction(draft, downstream);
|
||||
boolean[] fixed = fixed(draft);
|
||||
int waterfallMinimumDrop = draft.tier.waterfallMinimumDrop();
|
||||
int[] settled = settle(footprint(draft), draft.grade, fixed, receiving(drafts, downstream, feeder), downstream.grade[0],
|
||||
waterfallMinimumDrop);
|
||||
if (settled == draft.grade) {
|
||||
continue;
|
||||
}
|
||||
if (!draft.tier.cascades()) {
|
||||
spreadJunction(settled, draft.grade, fixed, waterfallMinimumDrop, ReachGrader.startLimit(drafts, draft));
|
||||
}
|
||||
draft.grade = settled;
|
||||
touched[feeder] = true;
|
||||
}
|
||||
}
|
||||
return touched;
|
||||
@@ -67,6 +74,27 @@ public final class ConfluenceGrader {
|
||||
return nearest;
|
||||
}
|
||||
|
||||
private static void requireJunction(ReachDraft feeder, ReachDraft downstream) {
|
||||
if (downstream.grade[0] <= feeder.last()) {
|
||||
return;
|
||||
}
|
||||
int end = feeder.xs.length - 1;
|
||||
throw new IllegalStateException("Reach " + downstream.id + " starts at " + downstream.grade[0] + ", above the end " + feeder.last()
|
||||
+ " of its feeder reach " + feeder.id + " at junction " + feeder.xs[end] + "," + feeder.zs[end]);
|
||||
}
|
||||
|
||||
private static void spreadJunction(int[] settled, int[] grade, boolean[] fixed, int waterfallMinimumDrop, int startLimit) {
|
||||
int lowered = 0;
|
||||
while (settled[lowered] == grade[lowered]) {
|
||||
lowered++;
|
||||
}
|
||||
for (int point = settled.length - 2; point >= 0; point--) {
|
||||
if (!ReachGrader.spreadPoint(settled, point, waterfallMinimumDrop, startLimit, fixed) && point < lowered) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static boolean pooled(Footprint feeder, boolean[] fixed, List<Footprint> receiving, double[] arc, int point) {
|
||||
if (arc[point] > POOL_CAP || fixed[point]) {
|
||||
return false;
|
||||
|
||||
@@ -136,7 +136,7 @@ final class ReachGrader {
|
||||
levels[pond] = level;
|
||||
}
|
||||
|
||||
private static int startLimit(List<ReachDraft> drafts, ReachDraft draft) {
|
||||
static int startLimit(List<ReachDraft> drafts, ReachDraft draft) {
|
||||
int limit = Integer.MIN_VALUE;
|
||||
for (int upstream : draft.incoming) {
|
||||
ReachDraft feeder = drafts.get(upstream);
|
||||
@@ -194,14 +194,22 @@ final class ReachGrader {
|
||||
|
||||
private static void spread(int[] grade, int waterfallMinimumDrop, int startLimit, boolean[] held) {
|
||||
for (int point = grade.length - 2; point >= 0; point--) {
|
||||
int drop = grade[point] - grade[point + 1];
|
||||
if (drop >= 2 && drop < waterfallMinimumDrop && (held == null || !held[point])) {
|
||||
int limit = point == 0 ? startLimit : carryLimit(grade, point, waterfallMinimumDrop);
|
||||
grade[point] = Math.max(grade[point + 1] + 1, limit);
|
||||
}
|
||||
spreadPoint(grade, point, waterfallMinimumDrop, startLimit, held);
|
||||
}
|
||||
}
|
||||
|
||||
static boolean spreadPoint(int[] grade, int point, int waterfallMinimumDrop, int startLimit, boolean[] held) {
|
||||
int drop = grade[point] - grade[point + 1];
|
||||
if (drop < 2 || drop >= waterfallMinimumDrop || held != null && held[point]) {
|
||||
return false;
|
||||
}
|
||||
int limit = point == 0 ? startLimit : carryLimit(grade, point, waterfallMinimumDrop);
|
||||
int spread = Math.min(grade[point], Math.max(grade[point + 1] + 1, limit));
|
||||
boolean lowered = spread < grade[point];
|
||||
grade[point] = spread;
|
||||
return lowered;
|
||||
}
|
||||
|
||||
private static void lowerIncomingEnds(List<ReachDraft> drafts, ReachDraft draft) {
|
||||
for (int upstream : draft.incoming) {
|
||||
int[] grade = drafts.get(upstream).grade;
|
||||
|
||||
Reference in new issue
Block a user