mirror of
https://github.com/VolmitSoftware/Iris.git
synced 2026-11-30 09:44:24 +00:00
Junction errors name window
- Reach indexes take their window key and name it when a reach id appears twice in one plan - Window planning passes its key through reach shaping, pond-channel settlement and confluence grading - A downstream reach starting above its feeder's end fails closed naming the window - Index, grader and plan-cache tests check that each failure names its window
This commit is contained in:
1 parent
41e38debad
commit
358f7218f8
17 files changed
+101
-64
No files matched your search
+1
-1
@@ -434,7 +434,7 @@ public final class HydrologyPlanCache {
|
||||
}
|
||||
|
||||
private static IndexedWindow indexed(WindowPlan plan) {
|
||||
return new IndexedWindow(plan, ReachIndex.build(plan.reaches(), plan.ponds()));
|
||||
return new IndexedWindow(plan, ReachIndex.build(plan.key(), plan.reaches(), plan.ponds()));
|
||||
}
|
||||
|
||||
private void persist(Consumer<HydrologyPlanStore> write, Object key) {
|
||||
|
||||
@@ -106,16 +106,16 @@ public final class WindowPlanner {
|
||||
}
|
||||
List<Pond> water = new ArrayList<>(ponds.ponds(raw, drainage.filled(), drainage.basins(), lakes, fine, cups));
|
||||
water.addAll(lakes);
|
||||
ShapedNetwork network = PondChannelSettlement.settle(shaper.shape(drainage.surface(), drainage.receivers(), drainage.accumulation(),
|
||||
drainage.channels(), water, fine, settings.seed()), settings.seaLevel());
|
||||
ShapedNetwork network = PondChannelSettlement.settle(key, shaper.shape(key, drainage.surface(), drainage.receivers(),
|
||||
drainage.accumulation(), drainage.channels(), water, fine, settings.seed()), settings.seaLevel());
|
||||
long passes = settlementPasses(water);
|
||||
for (long pass = 1; lowered(water, network.ponds()); pass++) {
|
||||
if (pass >= passes) {
|
||||
throw new IllegalStateException("Window " + key + " ponds did not settle within " + passes + " shaping passes");
|
||||
}
|
||||
water = replanned(settled(raw, cups, water, network.ponds()));
|
||||
network = PondChannelSettlement.settle(shaper.shape(drainage.surface(), drainage.receivers(), drainage.accumulation(),
|
||||
drainage.channels(), water, fine, settings.seed()), settings.seaLevel());
|
||||
network = PondChannelSettlement.settle(key, shaper.shape(key, drainage.surface(), drainage.receivers(),
|
||||
drainage.accumulation(), drainage.channels(), water, fine, settings.seed()), settings.seaLevel());
|
||||
}
|
||||
List<Reach> reaches = network.reaches();
|
||||
List<Pond> windowPonds = windowPonds(network.ponds());
|
||||
|
||||
+5
-4
@@ -1,5 +1,6 @@
|
||||
package art.arcane.iris.generation.hydrology.raster;
|
||||
|
||||
import art.arcane.iris.generation.hydrology.plan.WindowKey;
|
||||
import art.arcane.iris.generation.hydrology.water.Pond;
|
||||
import art.arcane.iris.generation.hydrology.water.PondKind;
|
||||
import art.arcane.iris.generation.hydrology.water.PondMask;
|
||||
@@ -16,12 +17,12 @@ public final class PondChannelSettlement {
|
||||
private PondChannelSettlement() {
|
||||
}
|
||||
|
||||
public static ShapedNetwork settle(ShapedNetwork network, int seaLevel) {
|
||||
public static ShapedNetwork settle(WindowKey window, ShapedNetwork network, int seaLevel) {
|
||||
int[] initial = new int[network.ponds().size()];
|
||||
for (int index = 0; index < initial.length; index++) {
|
||||
initial[index] = network.ponds().get(index).level();
|
||||
}
|
||||
int[] levels = levels(network.reaches(), network.ponds(), initial, seaLevel);
|
||||
int[] levels = levels(window, network.reaches(), network.ponds(), initial, seaLevel);
|
||||
List<Pond> water = new ArrayList<>(initial.length);
|
||||
for (int index = 0; index < initial.length; index++) {
|
||||
Pond pond = network.ponds().get(index);
|
||||
@@ -31,7 +32,7 @@ public final class PondChannelSettlement {
|
||||
return new ShapedNetwork(network.reaches(), water);
|
||||
}
|
||||
|
||||
static int[] levels(List<Reach> reaches, List<Pond> ponds, int[] initial, int seaLevel) {
|
||||
static int[] levels(WindowKey window, List<Reach> reaches, List<Pond> ponds, int[] initial, int seaLevel) {
|
||||
int[] levels = initial.clone();
|
||||
if (reaches.isEmpty() || ponds.isEmpty()) {
|
||||
return levels;
|
||||
@@ -43,7 +44,7 @@ public final class PondChannelSettlement {
|
||||
if (!eligible) {
|
||||
return levels;
|
||||
}
|
||||
ReachIndex index = ReachIndex.build(reaches, List.of());
|
||||
ReachIndex index = ReachIndex.build(window, reaches, List.of());
|
||||
List<Reach> nearby = new ArrayList<>();
|
||||
List<Pond> unused = new ArrayList<>();
|
||||
for (int pond = 0; pond < ponds.size(); pond++) {
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package art.arcane.iris.generation.hydrology.raster;
|
||||
|
||||
import art.arcane.iris.generation.hydrology.plan.WindowKey;
|
||||
import art.arcane.iris.generation.hydrology.water.Pond;
|
||||
import art.arcane.iris.generation.hydrology.water.PondMask;
|
||||
import art.arcane.iris.generation.hydrology.water.Reach;
|
||||
@@ -10,6 +11,7 @@ import java.util.BitSet;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
|
||||
public final class ReachIndex {
|
||||
private static final int BUCKET = 16;
|
||||
@@ -29,7 +31,7 @@ public final class ReachIndex {
|
||||
private final Map<Long, Reach> byId;
|
||||
private final Map<Long, List<Pond>> outlets;
|
||||
|
||||
private ReachIndex(List<Reach> reaches, List<Pond> ponds) {
|
||||
private ReachIndex(WindowKey window, List<Reach> reaches, List<Pond> ponds) {
|
||||
this.reaches = List.copyOf(reaches);
|
||||
this.ponds = List.copyOf(ponds);
|
||||
this.corridors = new float[this.reaches.size()][];
|
||||
@@ -55,12 +57,12 @@ public final class ReachIndex {
|
||||
this.reachBuckets = buckets(corridors.length, this::visitReach);
|
||||
this.pondBuckets = buckets(footprints.length, this::visitPond);
|
||||
this.feeders = feeders(this.reaches);
|
||||
this.byId = byId(this.reaches);
|
||||
this.byId = byId(window, this.reaches);
|
||||
this.outlets = outlets(this.ponds);
|
||||
}
|
||||
|
||||
public static ReachIndex build(List<Reach> reaches, List<Pond> ponds) {
|
||||
return new ReachIndex(reaches, ponds);
|
||||
public static ReachIndex build(WindowKey window, List<Reach> reaches, List<Pond> ponds) {
|
||||
return new ReachIndex(Objects.requireNonNull(window, "window"), reaches, ponds);
|
||||
}
|
||||
|
||||
public void candidates(int chunkX, int chunkZ, int halo, List<Reach> outReaches, List<Pond> outPonds) {
|
||||
@@ -128,11 +130,11 @@ public final class ReachIndex {
|
||||
return Map.copyOf(frozen);
|
||||
}
|
||||
|
||||
private static Map<Long, Reach> byId(List<Reach> reaches) {
|
||||
private static Map<Long, Reach> byId(WindowKey window, List<Reach> reaches) {
|
||||
Map<Long, Reach> byId = new HashMap<>();
|
||||
for (Reach reach : reaches) {
|
||||
if (byId.putIfAbsent(reach.id(), reach) != null) {
|
||||
throw new IllegalStateException("Reach id " + reach.id() + " appears twice in one plan");
|
||||
throw new IllegalStateException("Reach id " + reach.id() + " appears twice in the plan of window " + window);
|
||||
}
|
||||
}
|
||||
return Map.copyOf(byId);
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
package art.arcane.iris.generation.hydrology.water;
|
||||
|
||||
import art.arcane.iris.generation.hydrology.plan.WindowKey;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@@ -42,13 +44,13 @@ public final class ConfluenceGrader {
|
||||
}
|
||||
}
|
||||
|
||||
static boolean[] level(List<ReachDraft> drafts, int[] upstreamFirst) {
|
||||
static boolean[] level(WindowKey window, List<ReachDraft> drafts, int[] upstreamFirst) {
|
||||
boolean[] touched = new boolean[drafts.size()];
|
||||
for (int position = upstreamFirst.length - 1; position >= 0; position--) {
|
||||
ReachDraft downstream = drafts.get(upstreamFirst[position]);
|
||||
for (int feeder : downstream.incoming) {
|
||||
ReachDraft draft = drafts.get(feeder);
|
||||
requireJunction(draft, downstream);
|
||||
requireJunction(window, 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],
|
||||
@@ -86,13 +88,13 @@ public final class ConfluenceGrader {
|
||||
return nearest;
|
||||
}
|
||||
|
||||
private static void requireJunction(ReachDraft feeder, ReachDraft downstream) {
|
||||
private static void requireJunction(WindowKey window, 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]);
|
||||
throw new IllegalStateException("Window " + window + " 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 boolean pooled(Footprint feeder, boolean[] fixed, List<Footprint> receiving, double[] arc, int point) {
|
||||
|
||||
@@ -4,6 +4,7 @@ import art.arcane.iris.generation.hydrology.grid.CellHash;
|
||||
import art.arcane.iris.generation.hydrology.grid.DemGrid;
|
||||
import art.arcane.iris.generation.hydrology.grid.HeightLattice;
|
||||
import art.arcane.iris.generation.hydrology.plan.HydrologySettings;
|
||||
import art.arcane.iris.generation.hydrology.plan.WindowKey;
|
||||
import art.arcane.iris.generation.hydrology.raster.LinkBlend;
|
||||
|
||||
import java.util.ArrayList;
|
||||
@@ -32,7 +33,7 @@ public final class ReachShaper {
|
||||
this.settings = Objects.requireNonNull(settings, "settings");
|
||||
}
|
||||
|
||||
public ShapedNetwork shape(DemGrid filled, int[] receivers, float[] accumulation, BitSet channels, List<Pond> ponds,
|
||||
public ShapedNetwork shape(WindowKey window, DemGrid filled, int[] receivers, float[] accumulation, BitSet channels, List<Pond> ponds,
|
||||
HeightLattice fine, long seed) {
|
||||
requireNetwork(filled, receivers, accumulation, channels);
|
||||
PondLookup lookup = new PondLookup(ponds);
|
||||
@@ -74,7 +75,7 @@ public final class ReachShaper {
|
||||
for (int index : order) {
|
||||
finish(drafts, drafts.get(index));
|
||||
}
|
||||
boolean[] touched = ConfluenceGrader.level(drafts, order);
|
||||
boolean[] touched = ConfluenceGrader.level(window, drafts, order);
|
||||
for (int index = 0; index < touched.length; index++) {
|
||||
if (touched[index]) {
|
||||
restyle(drafts.get(index));
|
||||
|
||||
Reference in new issue
Block a user