mirror of
https://github.com/VolmitSoftware/Iris.git
synced 2026-11-28 00:34:19 +00:00
Step height knob
- Add tier stepHeight 1..2, default 2, in the settings fingerprint - Snap channel heads by tier and keep ponds, lakes and inlets at 2 - Key riffle crests on any lower neighbour, falls unchanged - Start one-block outlets at their pond's surface - Reject tiers with a larger step than the next larger tier - Recapture the fingerprint and schema digest
This commit is contained in:
28 files changed
+206
-75
No files matched your search
@@ -52,6 +52,11 @@ public class IrisHydrologyTier {
|
||||
@Description("Smallest drop in blocks that becomes a waterfall.")
|
||||
private int waterfallMinimumDrop = 6;
|
||||
|
||||
@MinNumber(1)
|
||||
@MaxNumber(2)
|
||||
@Description("Smallest step in blocks between this tier's water surfaces. 2 keeps channel surfaces on every second height above the sea. 1 lets a channel fall one block at a time, and works best with cascades false, which spreads drops into a gentle slope. Falls and plunge pools are unchanged. Ponds and lakes always use 2. A tier cannot use a larger step than the next larger tier.")
|
||||
private int stepHeight = 2;
|
||||
|
||||
@MinNumber(0)
|
||||
@MaxNumber(64)
|
||||
@Description("Width in blocks of the band beside the water where the ground is reshaped into banks. 0 leaves the ground beside the channel as it is.")
|
||||
|
||||
+16
-2
@@ -23,6 +23,7 @@ import art.arcane.iris.generation.hydrology.config.IrisPondShore;
|
||||
import art.arcane.iris.generation.hydrology.config.IrisSeaInlets;
|
||||
import art.arcane.iris.generation.hydrology.underground.SeaInletPlanner;
|
||||
import art.arcane.iris.generation.hydrology.underground.SeaInletRasterizer;
|
||||
import art.arcane.iris.generation.hydrology.raster.WaterHeads;
|
||||
import art.arcane.iris.generation.hydrology.water.HydrologyTier;
|
||||
import art.arcane.iris.generation.hydrology.water.LakeCandidate;
|
||||
import art.arcane.iris.generation.noise.IrisGeneratorStyle;
|
||||
@@ -232,6 +233,7 @@ public final class HydrologySettings {
|
||||
}
|
||||
compiled.sort(Comparator.comparingDouble(HydrologyTier::minCatchment));
|
||||
requireDistinctCatchments(compiled);
|
||||
requireNoStepUpstream(compiled);
|
||||
return List.copyOf(compiled);
|
||||
}
|
||||
|
||||
@@ -246,6 +248,17 @@ public final class HydrologySettings {
|
||||
}
|
||||
}
|
||||
|
||||
private static void requireNoStepUpstream(List<HydrologyTier> sorted) {
|
||||
for (int index = 1; index < sorted.size(); index++) {
|
||||
HydrologyTier lower = sorted.get(index - 1);
|
||||
HydrologyTier upper = sorted.get(index);
|
||||
if (lower.stepHeight() > upper.stepHeight()) {
|
||||
throw new IllegalArgumentException("Hydrology tier '" + lower.name() + "' has stepHeight " + lower.stepHeight() + " above the larger tier '"
|
||||
+ upper.name() + "' with " + upper.stepHeight() + "; the water it feeds would stand above its own");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static HydrologyTier tier(IrisHydrologyTier config, String field) {
|
||||
FloatRange halfWidth = floatRange(config.getHalfWidth(), field + ".halfWidth", RangeFloor.POSITIVE);
|
||||
if (halfWidth.max() > MAX_HALF_WIDTH) {
|
||||
@@ -258,7 +271,7 @@ public final class HydrologySettings {
|
||||
}
|
||||
return new HydrologyTier(config.getName(), (float) config.getMinCatchment(), halfWidth.min(), halfWidth.max(),
|
||||
(float) config.getWidthFactor(), (float) config.getDepthRatio(), config.getInset(), config.isCascades(),
|
||||
config.getWaterfallMinimumDrop(), config.getBankBand(), config.getBankStyle(),
|
||||
config.getWaterfallMinimumDrop(), config.getStepHeight(), config.getBankBand(), config.getBankStyle(),
|
||||
estuary(config.getEstuary(), field + ".estuary"), delta(config, halfWidth.max(), field + ".delta"),
|
||||
materials(config.getMaterials(), field + ".materials"), config.getFluid(), decorators(config.getDecorators(), field + ".decorators"));
|
||||
}
|
||||
@@ -583,6 +596,7 @@ public final class HydrologySettings {
|
||||
requireNonNegative(config.getWidthFactor(), field + ".widthFactor");
|
||||
requireNonNegative(config.getDepthRatio(), field + ".depthRatio");
|
||||
requireAtLeast(config.getWaterfallMinimumDrop(), MIN_WATERFALL_DROP, field + ".waterfallMinimumDrop");
|
||||
requireWithin(config.getStepHeight(), 1, WaterHeads.STANDING_STEP, field + ".stepHeight");
|
||||
requireShoreDepth(config.getMaterials(), field + ".materials");
|
||||
}
|
||||
|
||||
@@ -687,7 +701,7 @@ public final class HydrologySettings {
|
||||
for (HydrologyTier tier : tiers) {
|
||||
hash.add(tier.name()).add(tier.minCatchment()).add(tier.minHalfWidth()).add(tier.maxHalfWidth())
|
||||
.add(tier.widthFactor()).add(tier.depthRatio()).add(tier.inset()).add(tier.cascades())
|
||||
.add(tier.waterfallMinimumDrop()).add(tier.bankBand()).add(tier.bankStyle())
|
||||
.add(tier.waterfallMinimumDrop()).add(tier.stepHeight()).add(tier.bankBand()).add(tier.bankStyle())
|
||||
.add(tier.estuary().length()).add(tier.estuary().flare())
|
||||
.add(tier.delta().channels()).add(tier.delta().spreadDegrees()).add(tier.delta().length())
|
||||
.add(tier.materials()).add(tier.fluid());
|
||||
|
||||
@@ -114,17 +114,17 @@ final class ChunkFeatures {
|
||||
|
||||
boolean hasOnlyLevel(int head, int seaLevel) {
|
||||
for (Pond pond : ponds) {
|
||||
if (WaterHeads.snap(pond.level(), seaLevel) != head) {
|
||||
if (WaterHeads.standing(pond.level(), seaLevel) != head) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
for (Pond lake : lakes) {
|
||||
if (WaterHeads.snap(lake.level(), seaLevel) != head) {
|
||||
if (WaterHeads.standing(lake.level(), seaLevel) != head) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
for (SeaInlet inlet : inlets) {
|
||||
if (WaterHeads.snap(inlet.waterLevel(), seaLevel) != head) {
|
||||
if (WaterHeads.standing(inlet.waterLevel(), seaLevel) != head) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -101,19 +101,19 @@ public final class LinkBlend {
|
||||
}
|
||||
|
||||
private static Reach regraded(Reach reach, int[] grade, float[] halfWidth, float[] depth, int seaLevel) {
|
||||
ReachStyle[] style = grade == reach.grade() ? reach.style() : restyled(reach.style(), grade, reach.tier().waterfallMinimumDrop(), seaLevel);
|
||||
ReachStyle[] style = grade == reach.grade() ? reach.style() : restyled(reach.style(), grade, reach.tier().waterfallMinimumDrop(), seaLevel, reach.tier().stepHeight());
|
||||
return new Reach(reach.id(), reach.tier(), reach.downstreamId(), reach.xs(), reach.zs(), grade, halfWidth, depth, style,
|
||||
reach.catchment());
|
||||
}
|
||||
|
||||
private static ReachStyle[] restyled(ReachStyle[] style, int[] grade, int waterfallMinimumDrop, int seaLevel) {
|
||||
private static ReachStyle[] restyled(ReachStyle[] style, int[] grade, int waterfallMinimumDrop, int seaLevel, int stepHeight) {
|
||||
boolean[] mouth = new boolean[style.length];
|
||||
boolean[] outlet = new boolean[style.length];
|
||||
for (int point = 0; point < style.length; point++) {
|
||||
mouth[point] = style[point] == ReachStyle.MOUTH;
|
||||
outlet[point] = style[point] == ReachStyle.POND_OUTLET;
|
||||
}
|
||||
return ReachShaper.styles(grade, mouth, outlet, waterfallMinimumDrop, seaLevel);
|
||||
return ReachShaper.styles(grade, mouth, outlet, waterfallMinimumDrop, seaLevel, stepHeight);
|
||||
}
|
||||
|
||||
private static int lowestEnd(List<Reach> feeders) {
|
||||
|
||||
+2
-2
@@ -77,7 +77,7 @@ public final class PondChannelSettlement {
|
||||
BitSet visited = new BitSet(width * (bounds.maxZ() - bounds.minZ() + 1));
|
||||
for (Reach reach : reaches) {
|
||||
for (int segment = 0; segment + 1 < reach.xs().length; segment++) {
|
||||
if (WaterHeads.snap(brinks.lowestGrade(reach, segment), seaLevel) >= WaterHeads.snap(level, seaLevel)) {
|
||||
if (WaterHeads.snap(brinks.lowestGrade(reach, segment), seaLevel, reach.tier().stepHeight()) >= WaterHeads.standing(level, seaLevel)) {
|
||||
continue;
|
||||
}
|
||||
float radius = Math.max(reach.halfWidth()[segment], reach.halfWidth()[segment + 1]) + 1f;
|
||||
@@ -114,7 +114,7 @@ public final class PondChannelSettlement {
|
||||
return level;
|
||||
}
|
||||
int head = brinks.head(channel);
|
||||
return head < WaterHeads.snap(level, seaLevel) ? head : level;
|
||||
return head < WaterHeads.standing(level, seaLevel) ? head : level;
|
||||
}
|
||||
|
||||
private record Bounds(int minX, int minZ, int maxX, int maxZ) {
|
||||
|
||||
+11
-11
@@ -91,7 +91,7 @@ final class RasterComposer {
|
||||
int ground = natural[cell];
|
||||
SeaInlet inlet = features.openInletAt(x, z, inletColumn);
|
||||
if (inlet != null) {
|
||||
head[cell] = WaterHeads.snap(inlet.waterLevel(), settings.seaLevel());
|
||||
head[cell] = WaterHeads.standing(inlet.waterLevel(), settings.seaLevel());
|
||||
terrain[cell] = Math.min(Math.min(ground, inletColumn[0]), head[cell] - 1);
|
||||
role[cell] = WaterRole.INLET;
|
||||
feature[cell] = inlet.id();
|
||||
@@ -105,15 +105,15 @@ final class RasterComposer {
|
||||
double variation = BedProfile.variation(settings.seed(), x, z);
|
||||
if (lake >= 0) {
|
||||
Pond water = features.lake(lake);
|
||||
standing(cell, water, trench(ground, WaterHeads.snap(water.level(), settings.seaLevel()), ground, variation, BedProfile.detail(settings.seed(), x, z)));
|
||||
standing(cell, water, trench(ground, WaterHeads.standing(water.level(), settings.seaLevel()), ground, variation, BedProfile.detail(settings.seed(), x, z)));
|
||||
return;
|
||||
}
|
||||
if (pondIndex >= 0) {
|
||||
Pond water = features.pond(pondIndex);
|
||||
pond[cell] = pondIndex;
|
||||
double detail = BedProfile.detail(settings.seed(), x, z);
|
||||
int floor = interior(cell) ? pondFloor(pondIndex, WaterHeads.snap(water.level(), settings.seaLevel()), x, z, ground, variation, detail) : ground;
|
||||
standing(cell, water, trench(floor, WaterHeads.snap(water.level(), settings.seaLevel()), ground, variation, detail));
|
||||
int floor = interior(cell) ? pondFloor(pondIndex, WaterHeads.standing(water.level(), settings.seaLevel()), x, z, ground, variation, detail) : ground;
|
||||
standing(cell, water, trench(floor, WaterHeads.standing(water.level(), settings.seaLevel()), ground, variation, detail));
|
||||
return;
|
||||
}
|
||||
if (cursor.channel.reach != null) {
|
||||
@@ -124,7 +124,7 @@ final class RasterComposer {
|
||||
}
|
||||
|
||||
private void standing(int cell, Pond water, int floor) {
|
||||
head[cell] = WaterHeads.snap(water.level(), settings.seaLevel());
|
||||
head[cell] = WaterHeads.standing(water.level(), settings.seaLevel());
|
||||
terrain[cell] = Math.min(floor, head[cell] - 1);
|
||||
role[cell] = WaterRole.POND;
|
||||
feature[cell] = water.id();
|
||||
@@ -206,8 +206,8 @@ final class RasterComposer {
|
||||
}
|
||||
int taper = settings.ponds().shore().taper();
|
||||
boolean tapered = nearPond >= 0 && pondEdge <= taper;
|
||||
if (tapered && ground > WaterHeads.snap(features.pond(nearPond).level(), settings.seaLevel())) {
|
||||
cut = Math.min(cut, taperCut(WaterHeads.snap(features.pond(nearPond).level(), settings.seaLevel()), ground, BedProfile.position(pondEdge / taper, -variation)));
|
||||
if (tapered && ground > WaterHeads.standing(features.pond(nearPond).level(), settings.seaLevel())) {
|
||||
cut = Math.min(cut, taperCut(WaterHeads.standing(features.pond(nearPond).level(), settings.seaLevel()), ground, BedProfile.position(pondEdge / taper, -variation)));
|
||||
}
|
||||
terrain[cell] = raise == Integer.MIN_VALUE ? cut : Math.max(cut, raise);
|
||||
if (bank.reach != null && (!tapered || bankEdge <= pondEdge)) {
|
||||
@@ -336,17 +336,17 @@ final class RasterComposer {
|
||||
}
|
||||
SeaInlet inlet = features.openInletAt(x, z, inletColumn);
|
||||
if (inlet != null) {
|
||||
sample.set(WaterHeads.snap(inlet.waterLevel(), settings.seaLevel()), inlet.id(), WaterRole.INLET);
|
||||
sample.set(WaterHeads.standing(inlet.waterLevel(), settings.seaLevel()), inlet.id(), WaterRole.INLET);
|
||||
return;
|
||||
}
|
||||
int lake = features.lakeCovers(x, z) ? features.lakeAt(x, z, naturalAt(x, z)) : -1;
|
||||
if (lake >= 0) {
|
||||
sample.set(WaterHeads.snap(features.lake(lake).level(), settings.seaLevel()), features.lake(lake).id(), WaterRole.POND);
|
||||
sample.set(WaterHeads.standing(features.lake(lake).level(), settings.seaLevel()), features.lake(lake).id(), WaterRole.POND);
|
||||
return;
|
||||
}
|
||||
int pond = features.pondAt(x, z);
|
||||
if (pond >= 0) {
|
||||
sample.set(WaterHeads.snap(features.pond(pond).level(), settings.seaLevel()), features.pond(pond).id(), WaterRole.POND);
|
||||
sample.set(WaterHeads.standing(features.pond(pond).level(), settings.seaLevel()), features.pond(pond).id(), WaterRole.POND);
|
||||
return;
|
||||
}
|
||||
features.segments().nearest(x, z, ReachSegments.Scope.CHANNEL, cursor);
|
||||
@@ -377,7 +377,7 @@ final class RasterComposer {
|
||||
continue;
|
||||
}
|
||||
Pond held = features.pond(index);
|
||||
int level = WaterHeads.snap(held.level(), settings.seaLevel());
|
||||
int level = WaterHeads.standing(held.level(), settings.seaLevel());
|
||||
if (held.damRaise() > 0 && terrain[cell] < level && level + 1 > crest) {
|
||||
crest = level + 1;
|
||||
dam = held.id();
|
||||
|
||||
@@ -35,11 +35,12 @@ final class ReachGeometry {
|
||||
|
||||
static ReachGeometry of(Reach reach, Reach linked, long seed, int seaLevel) {
|
||||
int[] grade = reach.grade();
|
||||
int stepHeight = reach.tier().stepHeight();
|
||||
int[] steps = new int[grade.length - 1];
|
||||
int count = 0;
|
||||
boolean falls = false;
|
||||
for (int segment = 0; segment + 1 < grade.length; segment++) {
|
||||
if (WaterHeads.snap(grade[segment], seaLevel) != WaterHeads.snap(grade[segment + 1], seaLevel)) {
|
||||
if (WaterHeads.snap(grade[segment], seaLevel, stepHeight) != WaterHeads.snap(grade[segment + 1], seaLevel, stepHeight)) {
|
||||
steps[count++] = segment;
|
||||
falls |= grade[segment] - grade[segment + 1] >= BRINK_MIN_DROP;
|
||||
}
|
||||
@@ -56,15 +57,15 @@ final class ReachGeometry {
|
||||
double[] shifts = new double[count];
|
||||
double[] starts = new double[count];
|
||||
int curves = 0;
|
||||
int start = WaterHeads.snap(grade[0], seaLevel);
|
||||
int start = WaterHeads.snap(grade[0], seaLevel, stepHeight);
|
||||
boolean outlet = reach.style()[0] == ReachStyle.POND_OUTLET;
|
||||
boolean feeder = reach.downstreamId() != 0L;
|
||||
int landing = WaterHeads.snap(grade[grade.length - 1], seaLevel);
|
||||
int landing = WaterHeads.snap(grade[grade.length - 1], seaLevel, stepHeight);
|
||||
for (int step = 0; step < count; step++) {
|
||||
int segment = steps[step];
|
||||
double middle = middle(along, segment);
|
||||
int upper = WaterHeads.snap(grade[segment], seaLevel);
|
||||
int lower = WaterHeads.snap(grade[segment + 1], seaLevel);
|
||||
int upper = WaterHeads.snap(grade[segment], seaLevel, stepHeight);
|
||||
int lower = WaterHeads.snap(grade[segment + 1], seaLevel, stepHeight);
|
||||
if (grade[segment] - grade[segment + 1] < BRINK_MIN_DROP || linked.grade()[segment] - linked.grade()[segment + 1] < BRINK_MIN_DROP || middle <= held || outlet && upper == start || feeder && lower == landing
|
||||
|| reach.style()[segment] == ReachStyle.MOUTH || reach.style()[segment + 1] == ReachStyle.MOUTH) {
|
||||
continue;
|
||||
|
||||
@@ -57,9 +57,10 @@ final class ReachSegments {
|
||||
boolean hasOnlyLevel(int head, int seaLevel) {
|
||||
for (int index = 0; index < size; index++) {
|
||||
int[] grade = reaches[index].grade();
|
||||
int stepHeight = reaches[index].tier().stepHeight();
|
||||
int start = grade[segments[index]];
|
||||
int end = grade[segments[index] + 1];
|
||||
if (WaterHeads.snap(start, seaLevel) != head || WaterHeads.snap(end, seaLevel) != head) {
|
||||
if (WaterHeads.snap(start, seaLevel, stepHeight) != head || WaterHeads.snap(end, seaLevel, stepHeight) != head) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -108,7 +108,7 @@ final class RiffleProfile {
|
||||
if (neighbour == DRY) {
|
||||
continue;
|
||||
}
|
||||
crest |= neighbour <= head - 2;
|
||||
crest |= neighbour < head;
|
||||
if (flowing[cell] && neighbour - head >= PLUNGE_MIN_DROP) {
|
||||
feet.computeIfAbsent(new Fall(head, neighbour), ignored -> new Seeds()).add(cell);
|
||||
}
|
||||
|
||||
@@ -31,7 +31,7 @@ public final class TongueGuard {
|
||||
int[] stopped = new int[tongues.length];
|
||||
int count = 0;
|
||||
for (int fall : tongues) {
|
||||
int lowestGround = WaterHeads.snap(reach.grade()[fall], seaLevel) - 1 - maxFill;
|
||||
int lowestGround = WaterHeads.snap(reach.grade()[fall], seaLevel, reach.tier().stepHeight()) - 1 - maxFill;
|
||||
if (passesTheGround(reach, geometry, segments, cursor, fall, natural, lowestGround)) {
|
||||
stopped[count++] = fall;
|
||||
}
|
||||
|
||||
@@ -1,20 +1,24 @@
|
||||
package art.arcane.iris.generation.hydrology.raster;
|
||||
|
||||
public final class WaterHeads {
|
||||
private static final int STEP = 2;
|
||||
public static final int STANDING_STEP = 2;
|
||||
|
||||
private WaterHeads() {
|
||||
}
|
||||
|
||||
public static int snap(int planned, int seaLevel) {
|
||||
return planned - Math.floorMod(planned - seaLevel, STEP);
|
||||
public static int snap(int planned, int seaLevel, int stepHeight) {
|
||||
return planned - Math.floorMod(planned - seaLevel, stepHeight);
|
||||
}
|
||||
|
||||
public static int standing(int planned, int seaLevel) {
|
||||
return snap(planned, seaLevel, STANDING_STEP);
|
||||
}
|
||||
|
||||
static int channelHead(ReachCursor.Choice choice, ReachGeometry geometry, int seaLevel) {
|
||||
return snap(choice.reach.grade()[geometry.point(choice)], seaLevel);
|
||||
return snap(choice.reach.grade()[geometry.point(choice)], seaLevel, choice.reach.tier().stepHeight());
|
||||
}
|
||||
|
||||
public static int lowestAboveSea(int seaLevel) {
|
||||
return seaLevel + STEP;
|
||||
public static int lowestAboveSea(int seaLevel, int stepHeight) {
|
||||
return seaLevel + stepHeight;
|
||||
}
|
||||
}
|
||||
@@ -16,6 +16,7 @@ public record HydrologyTier(
|
||||
int inset,
|
||||
boolean cascades,
|
||||
int waterfallMinimumDrop,
|
||||
int stepHeight,
|
||||
int bankBand,
|
||||
IrisBankStyle bankStyle,
|
||||
Estuary estuary,
|
||||
|
||||
@@ -42,7 +42,8 @@ final class ReachGrader {
|
||||
int source = outletPond[index];
|
||||
if (source >= 0) {
|
||||
settle(drafts, ponds, inflows[source], levels, fed, graded, settled, lakeFloor, source, seaLevel);
|
||||
draft.carry = Math.min(draft.carry, levels[source]);
|
||||
int pondHead = draft.tier.stepHeight() < WaterHeads.STANDING_STEP ? WaterHeads.standing(levels[source], seaLevel) : levels[source];
|
||||
draft.carry = Math.min(draft.carry, pondHead);
|
||||
fed[index] = levels[source];
|
||||
}
|
||||
for (int upstream : draft.incoming) {
|
||||
@@ -65,7 +66,7 @@ final class ReachGrader {
|
||||
}
|
||||
int cap = draft.ocean[point] ? seaLevel : draft.target[point] + MAX_POOL;
|
||||
int floor = lakeFloor[index] ? draft.floor : Math.max(seaLevel, Math.min(draft.floor, (int) Math.floor(draft.bank[point]) + maxFill));
|
||||
floors[point] = draft.ocean[point] ? floor : Math.max(floor, WaterHeads.lowestAboveSea(seaLevel));
|
||||
floors[point] = draft.ocean[point] ? floor : Math.max(floor, WaterHeads.lowestAboveSea(seaLevel, draft.tier.stepHeight()));
|
||||
level = Math.min(level, Math.max(floor, Math.min(grade[point], cap)));
|
||||
grade[point] = level;
|
||||
}
|
||||
|
||||
@@ -386,7 +386,7 @@ public final class ReachShaper {
|
||||
}
|
||||
|
||||
private static void restyle(ReachDraft draft, int seaLevel) {
|
||||
draft.style = styles(draft.grade, draft.ocean, draft.fixed(), draft.tier.waterfallMinimumDrop(), seaLevel);
|
||||
draft.style = styles(draft.grade, draft.ocean, draft.fixed(), draft.tier.waterfallMinimumDrop(), seaLevel, draft.tier.stepHeight());
|
||||
}
|
||||
|
||||
private static void chaikin(ReachDraft draft) {
|
||||
@@ -570,13 +570,13 @@ public final class ReachShaper {
|
||||
return Math.clamp(1f - remaining / length, 0f, 1f);
|
||||
}
|
||||
|
||||
public static ReachStyle[] styles(int[] grade, boolean[] ocean, boolean[] outletZone, int waterfallMinimumDrop, int seaLevel) {
|
||||
public static ReachStyle[] styles(int[] grade, boolean[] ocean, boolean[] outletZone, int waterfallMinimumDrop, int seaLevel, int stepHeight) {
|
||||
ReachStyle[] styles = new ReachStyle[grade.length];
|
||||
for (int point = 0; point < grade.length; point++) {
|
||||
int drop = point == 0 ? 0 : grade[point - 1] - grade[point];
|
||||
styles[point] = style(drop, waterfallMinimumDrop, ocean[point], outletZone[point]);
|
||||
if (drop == 1 && !ocean[point] && outletZone[point - 1]
|
||||
&& WaterHeads.snap(grade[point - 1], seaLevel) - WaterHeads.snap(grade[point], seaLevel) >= 2) {
|
||||
&& WaterHeads.snap(grade[point - 1], seaLevel, stepHeight) - WaterHeads.snap(grade[point], seaLevel, stepHeight) >= 2) {
|
||||
styles[point] = ReachStyle.CASCADE;
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -142,7 +142,7 @@ public class HydrologyPlanCodecTest {
|
||||
HydrologyPlanCodec.decodeWindow(settings, damaged);
|
||||
}
|
||||
|
||||
HydrologyTier foreign = new HydrologyTier("foreign", 0f, 1f, 2f, 1f, 0.4f, 1, true, 6, 0, IrisBankStyle.SMOOTH,
|
||||
HydrologyTier foreign = new HydrologyTier("foreign", 0f, 1f, 2f, 1f, 0.4f, 1, true, 6, 2, 0, IrisBankStyle.SMOOTH,
|
||||
new HydrologyTier.Estuary(48, 2.5f), new HydrologyTier.Delta(0, 35f, 64), new IrisHydrologyMaterials(), "water", List.of());
|
||||
Reach stray = new Reach(6L, foreign, -1L, new float[]{1f, 2f}, new float[]{1f, 2f}, new int[]{1, 1}, new float[]{1f, 1f},
|
||||
new float[]{1f, 1f}, new ReachStyle[]{ReachStyle.RUN, ReachStyle.RUN}, 1f);
|
||||
|
||||
+33
-1
@@ -5,6 +5,7 @@ import art.arcane.iris.generation.decoration.IrisDecorationPart;
|
||||
import art.arcane.iris.generation.decoration.IrisDecorator;
|
||||
import art.arcane.iris.generation.hydrology.config.IrisFluidProfile;
|
||||
import art.arcane.iris.generation.hydrology.config.IrisHydrology;
|
||||
import art.arcane.iris.generation.hydrology.config.IrisHydrologyTier;
|
||||
import art.arcane.iris.generation.hydrology.config.IrisHydrologyMaterials;
|
||||
import art.arcane.iris.generation.hydrology.water.HydrologyTier;
|
||||
import art.arcane.iris.generation.terrain.IrisMaterialPalette;
|
||||
@@ -25,6 +26,7 @@ import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertNotSame;
|
||||
import static org.junit.Assert.assertNull;
|
||||
import static org.junit.Assert.assertNotEquals;
|
||||
import static org.junit.Assert.assertThrows;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
@@ -33,7 +35,7 @@ public class HydrologySettingsTest {
|
||||
private static final int SEA_LEVEL = 62;
|
||||
private static final int MIN_Y = -64;
|
||||
private static final int MAX_Y = 320;
|
||||
private static final long DEFAULT_FINGERPRINT = 7576271788988330967L;
|
||||
private static final long DEFAULT_FINGERPRINT = -2376958294785826560L;
|
||||
|
||||
@Test
|
||||
public void densityIsBoundedAndChangesThePlanIdentity() {
|
||||
@@ -266,6 +268,36 @@ public class HydrologySettingsTest {
|
||||
assertEquals("fingerprint must be identical in every JVM run", DEFAULT_FINGERPRINT, first);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void stepHeightIsBoundedAndChangesThePlanIdentity() {
|
||||
HydrologySettings defaults = compile(new IrisHydrology());
|
||||
defaults.tiers().forEach(tier -> assertEquals(tier.name(), 2, tier.stepHeight()));
|
||||
IrisHydrology fine = new IrisHydrology();
|
||||
fine.getTiers().forEach(tier -> tier.setStepHeight(1));
|
||||
HydrologySettings compiled = compile(fine);
|
||||
compiled.tiers().forEach(tier -> assertEquals(tier.name(), 1, tier.stepHeight()));
|
||||
assertNotEquals(defaults.fingerprint(), compiled.fingerprint());
|
||||
for (int outside : new int[]{0, 3}) {
|
||||
IrisHydrology config = new IrisHydrology();
|
||||
config.getTiers().get(0).setStepHeight(outside);
|
||||
IllegalArgumentException failure = assertThrows(IllegalArgumentException.class, () -> compile(config));
|
||||
assertTrue(failure.getMessage(), failure.getMessage().contains("stepHeight"));
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void aLargerTierCannotTakeASmallerStepThanItsFeeders() {
|
||||
IrisHydrology streamsOnly = new IrisHydrology();
|
||||
streamsOnly.setTiers(new KList<>(new IrisHydrologyTier().setName("stream").setStepHeight(1),
|
||||
new IrisHydrologyTier().setName("river").setMinCatchment(20000D).setHalfWidth(new KList<>(2D, 8D)).setStepHeight(2)));
|
||||
assertEquals(1, compile(streamsOnly).tiers().get(0).stepHeight());
|
||||
IrisHydrology upsideDown = new IrisHydrology();
|
||||
upsideDown.setTiers(new KList<>(new IrisHydrologyTier().setName("stream").setStepHeight(2),
|
||||
new IrisHydrologyTier().setName("river").setMinCatchment(20000D).setHalfWidth(new KList<>(2D, 8D)).setStepHeight(1)));
|
||||
IllegalArgumentException failure = assertThrows(IllegalArgumentException.class, () -> compile(upsideDown));
|
||||
assertTrue(failure.getMessage(), failure.getMessage().contains("stepHeight"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void schedulingKnobsDoNotChangeTheFingerprint() {
|
||||
HydrologySettings eager = compile(new IrisHydrology().setPrefetchRings(4));
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
package art.arcane.iris.generation.hydrology.plan;
|
||||
|
||||
import art.arcane.iris.generation.hydrology.config.IrisHydrology;
|
||||
import art.arcane.iris.generation.hydrology.raster.WaterHeads;
|
||||
import art.arcane.iris.generation.hydrology.water.ConfluenceGrader;
|
||||
import art.arcane.iris.generation.hydrology.water.HydrologyTier;
|
||||
import art.arcane.iris.generation.hydrology.water.Pond;
|
||||
@@ -41,6 +43,35 @@ public class PlannedSceneTest {
|
||||
WaterInvariants.detachedOutlets(openFractal()));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void oneBlockTiersKeepOutletsAndConfluencesConnected() {
|
||||
IrisHydrology config = PlannedScene.packConfig();
|
||||
config.getTiers().forEach(tier -> tier.setStepHeight(1).setCascades(false));
|
||||
HydrologySettings settings = HydrologySettings.compile(config, SEED, SEA_LEVEL, SyntheticTerrain.MIN_Y, SyntheticTerrain.MAX_Y);
|
||||
PlannedScene scene = PlannedScene.plan(SyntheticTerrain.openFractal(1L).withRainfall((x, z) -> RAINFALL), settings, 2, 2);
|
||||
assertEquals("detached outlets", List.of(), WaterInvariants.detachedOutlets(scene));
|
||||
assertEquals("confluence tongues", List.of(), WaterInvariants.confluenceTongues(scene));
|
||||
Map<Long, Reach> byId = new HashMap<>();
|
||||
int oneBlockDrops = 0;
|
||||
for (Reach reach : scene.reaches()) {
|
||||
byId.put(reach.id(), reach);
|
||||
for (int point = 1; point < reach.grade().length; point++) {
|
||||
oneBlockDrops += reach.grade()[point - 1] - reach.grade()[point] == 1 ? 1 : 0;
|
||||
}
|
||||
}
|
||||
assertTrue("one-block drops in the plan " + oneBlockDrops, oneBlockDrops > 100);
|
||||
int outlets = 0;
|
||||
for (Pond pond : scene.ponds()) {
|
||||
Reach outlet = byId.get(pond.outletReachId());
|
||||
if (outlet != null) {
|
||||
outlets++;
|
||||
assertTrue("outlet " + outlet.id() + " starts at " + outlet.grade()[0] + " above its pond's surface " + WaterHeads.standing(pond.level(), SEA_LEVEL),
|
||||
outlet.grade()[0] <= WaterHeads.standing(pond.level(), SEA_LEVEL));
|
||||
}
|
||||
}
|
||||
assertTrue("outlets checked " + outlets, outlets > 0);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void confluencesHaveNoTongues() {
|
||||
assertEquals("confluence tongues on openFractal(1) with rainfall " + RAINFALL + " over 2x2 windows", List.of(),
|
||||
@@ -308,7 +339,7 @@ public class PlannedSceneTest {
|
||||
}
|
||||
zone[point] = along <= OUTLET_LENGTH;
|
||||
}
|
||||
ReachStyle[] style = ReachShaper.styles(reach.grade(), new boolean[zone.length], zone, reach.tier().waterfallMinimumDrop(), seaLevel);
|
||||
ReachStyle[] style = ReachShaper.styles(reach.grade(), new boolean[zone.length], zone, reach.tier().waterfallMinimumDrop(), seaLevel, reach.tier().stepHeight());
|
||||
return new Reach(reach.id(), reach.tier(), reach.downstreamId(), reach.xs(), reach.zs(), reach.grade(), reach.halfWidth(), reach.depth(),
|
||||
style, reach.catchment());
|
||||
}
|
||||
|
||||
@@ -33,7 +33,7 @@ final class WaterInvariants {
|
||||
List<Long> detached = new ArrayList<>();
|
||||
for (Pond pond : checkedPonds(scene)) {
|
||||
Reach outlet = reaches.get(pond.outletReachId());
|
||||
if (!floodsIntoOutlet(scene, pond, outlet, WaterHeads.snap(pond.level(), seaLevel))) {
|
||||
if (!floodsIntoOutlet(scene, pond, outlet, WaterHeads.standing(pond.level(), seaLevel))) {
|
||||
detached.add(outlet.id());
|
||||
}
|
||||
}
|
||||
@@ -151,7 +151,7 @@ final class WaterInvariants {
|
||||
if (box != null) {
|
||||
boolean heldStart = feeders.containsKey(feeder.id()) && feeder.grade()[0] - level > ConfluenceGrader.MAX_START_LOWERING;
|
||||
boolean[] held = held(feeder, lips.getOrDefault(feeder.id(), List.of()), heldStart);
|
||||
junctions.add(new Junction(feeder, WaterHeads.snap(level, seaLevel), pool, held, box));
|
||||
junctions.add(new Junction(feeder, WaterHeads.snap(level, seaLevel, feeder.tier().stepHeight()), pool, held, box));
|
||||
}
|
||||
}
|
||||
return junctions;
|
||||
@@ -159,7 +159,7 @@ final class WaterInvariants {
|
||||
|
||||
private static boolean perched(PlannedScene scene, Junction junction, int seaLevel) {
|
||||
Reach feeder = junction.feeder();
|
||||
boolean endsAtTheJunction = WaterHeads.snap(feeder.grade()[feeder.grade().length - 1], seaLevel) <= junction.head();
|
||||
boolean endsAtTheJunction = WaterHeads.snap(feeder.grade()[feeder.grade().length - 1], seaLevel, feeder.tier().stepHeight()) <= junction.head();
|
||||
int[] box = junction.box();
|
||||
for (int z = box[1]; z <= box[3]; z++) {
|
||||
for (int x = box[0]; x <= box[2]; x++) {
|
||||
@@ -231,7 +231,7 @@ final class WaterInvariants {
|
||||
|
||||
private static boolean fallsToTheJunction(Reach feeder, int point, int seaLevel) {
|
||||
for (int next = point + 1; next < feeder.grade().length; next++) {
|
||||
boolean step = WaterHeads.snap(feeder.grade()[next], seaLevel) < WaterHeads.snap(feeder.grade()[next - 1], seaLevel);
|
||||
boolean step = WaterHeads.snap(feeder.grade()[next], seaLevel, feeder.tier().stepHeight()) < WaterHeads.snap(feeder.grade()[next - 1], seaLevel, feeder.tier().stepHeight());
|
||||
ReachStyle style = feeder.style()[next];
|
||||
if (step && style != ReachStyle.CASCADE && style != ReachStyle.WATERFALL) {
|
||||
return false;
|
||||
|
||||
@@ -692,7 +692,7 @@ public class WindowPlannerTest {
|
||||
leading++;
|
||||
}
|
||||
assertTrue(pond + " outlet " + outlet.id() + " starts off its shore at " + outlet.xs()[0] + "," + outlet.zs()[0], leading > 0);
|
||||
int head = WaterHeads.snap(pond.level(), SEA_LEVEL);
|
||||
int head = WaterHeads.standing(pond.level(), SEA_LEVEL);
|
||||
for (int segment = 0; segment < leading; segment++) {
|
||||
int[] box = segmentBox(outlet, segment);
|
||||
for (int z = box[1]; z <= box[3]; z++) {
|
||||
@@ -700,7 +700,7 @@ public class WindowPlannerTest {
|
||||
int[] covering = nearestCovering(outlet, x, z);
|
||||
if (covering[0] == segment && onShore(mask, x, z)) {
|
||||
assertEquals(pond + " outlet " + outlet.id() + " water at " + x + "," + z, head,
|
||||
WaterHeads.snap(outlet.grade()[covering[1]], SEA_LEVEL));
|
||||
WaterHeads.snap(outlet.grade()[covering[1]], SEA_LEVEL, outlet.tier().stepHeight()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+47
-6
@@ -925,7 +925,7 @@ public class ChunkWaterRasterTest {
|
||||
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);
|
||||
ReachStyle[] style = ReachShaper.styles(drawn.grade(), new boolean[zone.length], zone, narrow.waterfallMinimumDrop(), SEA_LEVEL, narrow.stepHeight());
|
||||
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(),
|
||||
@@ -1027,7 +1027,7 @@ public class ChunkWaterRasterTest {
|
||||
|
||||
@Test
|
||||
public void crossWindowJunctionDropsSpreadOnTiersWithoutCascades() {
|
||||
HydrologyTier gentle = new HydrologyTier("stream", 0f, 2f, 2f, 0f, 0.5f, 1, false, 6, 4, IrisBankStyle.SMOOTH,
|
||||
HydrologyTier gentle = new HydrologyTier("stream", 0f, 2f, 2f, 0f, 0.5f, 1, false, 6, 2, 4, IrisBankStyle.SMOOTH,
|
||||
new HydrologyTier.Estuary(48, 2.5f), new HydrologyTier.Delta(0, 35f, 64), new IrisHydrologyMaterials(), "water", List.of());
|
||||
HydrologyTier wide = tier("river", 3f, 0.5f, 4, IrisBankStyle.SMOOTH);
|
||||
Reach low = line(262L, wide, 0L, 504f, 200f, 600f, 200f, (x, z) -> 62);
|
||||
@@ -2004,7 +2004,7 @@ public class ChunkWaterRasterTest {
|
||||
|
||||
private int straightHead(double x, double z) {
|
||||
segments.nearest(x, z, ReachSegments.Scope.CHANNEL, straight);
|
||||
return straight.channel.reach == null ? Integer.MIN_VALUE : WaterHeads.snap(straight.channel.grade(), SEA_LEVEL);
|
||||
return straight.channel.reach == null ? Integer.MIN_VALUE : WaterHeads.snap(straight.channel.grade(), SEA_LEVEL, straight.channel.reach.tier().stepHeight());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2133,7 +2133,7 @@ public class ChunkWaterRasterTest {
|
||||
private static float firstSeaLevelHead(HydrologySettings settings) {
|
||||
Reach river = DeltaCoast.river(DeltaCoast.shape(settings, 0, 0, List.of(), DeltaCoast.NO_NEIGHBOUR, DeltaCoast.SEED, DeltaCoast::cliffBacked), DeltaCoast.ROW);
|
||||
int point = 0;
|
||||
while (WaterHeads.snap(river.grade()[point], SEA_LEVEL) > SEA_LEVEL) {
|
||||
while (WaterHeads.snap(river.grade()[point], SEA_LEVEL, river.tier().stepHeight()) > SEA_LEVEL) {
|
||||
point++;
|
||||
}
|
||||
return river.xs()[point];
|
||||
@@ -2286,7 +2286,7 @@ public class ChunkWaterRasterTest {
|
||||
}
|
||||
|
||||
private static HydrologyTier lavaTier() {
|
||||
return new HydrologyTier("lava", 0f, 1.5f, 1.5f, 0f, 0.5f, 1, true, 6, 8, IrisBankStyle.SMOOTH,
|
||||
return new HydrologyTier("lava", 0f, 1.5f, 1.5f, 0f, 0.5f, 1, true, 6, 2, 8, IrisBankStyle.SMOOTH,
|
||||
new HydrologyTier.Estuary(48, 2.5f), new HydrologyTier.Delta(0, 35f, 64), new IrisHydrologyMaterials(), "lava", List.of());
|
||||
}
|
||||
|
||||
@@ -2385,8 +2385,49 @@ public class ChunkWaterRasterTest {
|
||||
return HydrologySettings.compile(config, SEED, SEA_LEVEL, MIN_Y, MAX_Y);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void oneBlockStepsReachTheWorld() {
|
||||
Reach fine = stepped(301L, steppedTier(1));
|
||||
Reach coarse = stepped(301L, steppedTier(2));
|
||||
for (long seed = 1L; seed <= 24L; seed++) {
|
||||
String label = "seed " + seed + ": ";
|
||||
Scene scene = new Scene(seededSettings(seed), (x, z) -> 110).reach(fine);
|
||||
Scene even = new Scene(seededSettings(seed), (x, z) -> 110).reach(coarse);
|
||||
int oneBlockSteps = 0;
|
||||
for (int x = -39; x < 32; x++) {
|
||||
int planned = 100 - Math.floorDiv(x + 40, 8);
|
||||
if (Math.floorMod(x + 40, 8) >= 2 && Math.floorMod(x + 40, 8) <= 5) {
|
||||
assertEquals(label + "planned level at " + x, planned, scene.head(x, 8));
|
||||
assertEquals(label + "the 2-block tier snaps at " + x, planned - Math.floorMod(planned - SEA_LEVEL, 2), even.head(x, 8));
|
||||
}
|
||||
oneBlockSteps += scene.head(x - 1, 8) - scene.head(x, 8) == 1 ? 1 : 0;
|
||||
}
|
||||
assertTrue(label + "one-block steps " + oneBlockSteps, oneBlockSteps >= 9);
|
||||
assertEquals(label + "the upper side of a riffle sits one block deep", scene.head(-1, 8) - 1, scene.terrain(-1, 8));
|
||||
int fallCells = 0;
|
||||
for (int x = 34; x <= 48; x++) {
|
||||
for (int z = 3; z <= 13; z++) {
|
||||
fallCells += scene.role(x, z) == WaterRole.WATERFALL ? 1 : 0;
|
||||
}
|
||||
}
|
||||
assertTrue(label + "the fall keeps its role", fallCells > 0);
|
||||
assertEquals(label + "the fall lands on its level", 83, scene.head(44, 12));
|
||||
assertTrue(label + "the fall still has a plunge pool: bed " + scene.terrain(44, 8), scene.terrain(44, 8) <= 83 - 3);
|
||||
assertEquals(label + "leaks", 0, scene.leaks(-50, -10, 130, 30));
|
||||
}
|
||||
}
|
||||
|
||||
private static HydrologyTier steppedTier(int stepHeight) {
|
||||
return new HydrologyTier("stream", 0f, 5f, 5f, 0f, 0.8f, 1, false, 6, stepHeight, 4, IrisBankStyle.SMOOTH,
|
||||
new HydrologyTier.Estuary(48, 2.5f), new HydrologyTier.Delta(0, 35f, 64), new IrisHydrologyMaterials(), "water", List.of());
|
||||
}
|
||||
|
||||
private static Reach stepped(long id, HydrologyTier tier) {
|
||||
return line(id, tier, 0L, -48f, 8f, 120f, 8f, (x, z) -> x < 40f ? 100 - Math.floorDiv((int) Math.floor(x) + 40, 8) : 83);
|
||||
}
|
||||
|
||||
private static HydrologyTier tier(String name, float halfWidth, float depthRatio, int bankBand, IrisBankStyle style) {
|
||||
return new HydrologyTier(name, 0f, halfWidth, halfWidth, 0f, depthRatio, 1, true, 6, bankBand, style,
|
||||
return new HydrologyTier(name, 0f, halfWidth, halfWidth, 0f, depthRatio, 1, true, 6, 2, bankBand, style,
|
||||
new HydrologyTier.Estuary(48, 2.5f), new HydrologyTier.Delta(0, 35f, 64), new IrisHydrologyMaterials(), "water", List.of());
|
||||
}
|
||||
|
||||
|
||||
+2
-2
@@ -197,7 +197,7 @@ public class PondChannelSettlementTest {
|
||||
depth[point] = 2f;
|
||||
styles[point] = ReachStyle.RUN;
|
||||
}
|
||||
HydrologyTier tier = new HydrologyTier("river", 0f, 40f, 40f, 0f, 0.5f, 2, true, 6, 0, IrisBankStyle.SMOOTH,
|
||||
HydrologyTier tier = new HydrologyTier("river", 0f, 40f, 40f, 0f, 0.5f, 2, true, 6, 2, 0, IrisBankStyle.SMOOTH,
|
||||
new HydrologyTier.Estuary(48, 2.5f), new HydrologyTier.Delta(0, 35f, 64), null, "water", List.of());
|
||||
return new Reach(id, tier, 0L, xs, zs, grade, widths, depth, styles, 1000f);
|
||||
}
|
||||
@@ -252,7 +252,7 @@ public class PondChannelSettlementTest {
|
||||
}
|
||||
|
||||
private static Reach line(long id, int x0, int z0, int x1, int z1, float width, int first, int last) {
|
||||
HydrologyTier tier = new HydrologyTier("river", 0f, width, width, 0f, 0.5f, 2, true, 6, 0, IrisBankStyle.SMOOTH,
|
||||
HydrologyTier tier = new HydrologyTier("river", 0f, width, width, 0f, 0.5f, 2, true, 6, 2, 0, IrisBankStyle.SMOOTH,
|
||||
new HydrologyTier.Estuary(48, 2.5f), new HydrologyTier.Delta(0, 35f, 64), null, "water", List.of());
|
||||
float[] widths = new float[]{width, width};
|
||||
float[] depth = new float[]{2f, 2f};
|
||||
|
||||
@@ -25,7 +25,7 @@ import static org.junit.Assert.assertTrue;
|
||||
public class ReachIndexTest {
|
||||
private static final WindowKey WINDOW = new WindowKey(0, 0);
|
||||
private static final int BANK_BAND = 4;
|
||||
private static final HydrologyTier TIER = new HydrologyTier("test", 0f, 1f, 4f, 1f, 0.4f, 1, true, 6, BANK_BAND, IrisBankStyle.SMOOTH,
|
||||
private static final HydrologyTier TIER = new HydrologyTier("test", 0f, 1f, 4f, 1f, 0.4f, 1, true, 6, 2, BANK_BAND, IrisBankStyle.SMOOTH,
|
||||
new HydrologyTier.Estuary(48, 2.5f), new HydrologyTier.Delta(0, 35f, 64), new IrisHydrologyMaterials(), "water", List.of());
|
||||
|
||||
@Test
|
||||
@@ -186,7 +186,7 @@ public class ReachIndexTest {
|
||||
}
|
||||
|
||||
private static HydrologyTier tier(String name, int bankBand) {
|
||||
return new HydrologyTier(name, 0f, 0.5f, 4f, 1f, 0.4f, 1, true, 6, bankBand, IrisBankStyle.SMOOTH,
|
||||
return new HydrologyTier(name, 0f, 0.5f, 4f, 1f, 0.4f, 1, true, 6, 2, bankBand, IrisBankStyle.SMOOTH,
|
||||
new HydrologyTier.Estuary(48, 2.5f), new HydrologyTier.Delta(0, 35f, 64), new IrisHydrologyMaterials(),
|
||||
"water", List.of());
|
||||
}
|
||||
|
||||
+1
-1
@@ -17,7 +17,7 @@ import static org.junit.Assert.assertSame;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
public class ReachSegmentsTest {
|
||||
private static final HydrologyTier TIER = new HydrologyTier("test", 0f, 1f, 4f, 1f, 0.4f, 1, true, 6, 4, IrisBankStyle.SMOOTH,
|
||||
private static final HydrologyTier TIER = new HydrologyTier("test", 0f, 1f, 4f, 1f, 0.4f, 1, true, 6, 2, 4, IrisBankStyle.SMOOTH,
|
||||
new HydrologyTier.Estuary(48, 2.5f), new HydrologyTier.Delta(0, 35f, 64), new IrisHydrologyMaterials(), "water", List.of());
|
||||
|
||||
@Test
|
||||
|
||||
+11
-11
@@ -624,7 +624,7 @@ public class ReachShaperTest {
|
||||
boolean[] noZone = new boolean[count];
|
||||
Arrays.fill(grade, 0, 3, 90);
|
||||
Arrays.fill(grade, 3, count, 78);
|
||||
ReachStyle[] style = ReachShaper.styles(grade, noOcean, noZone, 6, SEA_LEVEL);
|
||||
ReachStyle[] style = ReachShaper.styles(grade, noOcean, noZone, 6, SEA_LEVEL, 2);
|
||||
float[] flare = ReachShaper.plungeFlare(grade, style, noOcean, distance, 0f, 6);
|
||||
assertEquals(ReachShaper.PLUNGE_FLARE, flare[3], 0f);
|
||||
assertEquals("nothing above the foot", 0f, flare[2], 0f);
|
||||
@@ -637,14 +637,14 @@ public class ReachShaperTest {
|
||||
int[] atFirst = new int[count];
|
||||
Arrays.fill(atFirst, 1, count, -12);
|
||||
atFirst[0] = 0;
|
||||
assertEquals("index 0 never flares", 0f, ReachShaper.plungeFlare(atFirst, ReachShaper.styles(atFirst, noOcean, noZone, 6, -40), noOcean, distance, 0f, 6)[0], 0f);
|
||||
assertEquals("index 0 never flares", 0f, ReachShaper.plungeFlare(atFirst, ReachShaper.styles(atFirst, noOcean, noZone, 6, -40, 2), noOcean, distance, 0f, 6)[0], 0f);
|
||||
int[] atLast = new int[count];
|
||||
atLast[count - 1] = -12;
|
||||
assertEquals("the last index never flares", 0f, ReachShaper.plungeFlare(atLast, ReachShaper.styles(atLast, noOcean, noZone, 6, -40), noOcean, distance, 0f, 6)[count - 1], 0f);
|
||||
assertEquals("the last index never flares", 0f, ReachShaper.plungeFlare(atLast, ReachShaper.styles(atLast, noOcean, noZone, 6, -40, 2), noOcean, distance, 0f, 6)[count - 1], 0f);
|
||||
|
||||
boolean[] ocean = new boolean[count];
|
||||
Arrays.fill(ocean, 3, count, true);
|
||||
ReachStyle[] mouth = ReachShaper.styles(grade, ocean, noZone, 6, SEA_LEVEL);
|
||||
ReachStyle[] mouth = ReachShaper.styles(grade, ocean, noZone, 6, SEA_LEVEL, 2);
|
||||
float[] atSea = ReachShaper.plungeFlare(grade, mouth, ocean, distance, 0f, 6);
|
||||
for (int point = 0; point < count; point++) {
|
||||
assertEquals("a fall into the sea flares nothing at " + point, 0f, atSea[point], 0f);
|
||||
@@ -2120,7 +2120,7 @@ public class ReachShaperTest {
|
||||
|
||||
int[] grade = {62, 62, 62, 40, 40};
|
||||
boolean[] ocean = {false, false, false, true, true};
|
||||
ReachStyle[] styles = ReachShaper.styles(grade, ocean, new boolean[grade.length], 6, SEA_LEVEL);
|
||||
ReachStyle[] styles = ReachShaper.styles(grade, ocean, new boolean[grade.length], 6, SEA_LEVEL, 2);
|
||||
assertEquals(List.of(ReachStyle.RUN, ReachStyle.RUN, ReachStyle.WATERFALL, ReachStyle.MOUTH, ReachStyle.MOUTH), List.of(styles));
|
||||
}
|
||||
|
||||
@@ -2131,17 +2131,17 @@ public class ReachShaperTest {
|
||||
boolean[] held = {true, true, true, false, false};
|
||||
assertEquals("a one-block step off a held lip that the even head snap shows as two blocks",
|
||||
List.of(ReachStyle.POND_OUTLET, ReachStyle.POND_OUTLET, ReachStyle.POND_OUTLET, ReachStyle.CASCADE, ReachStyle.RUN),
|
||||
List.of(ReachShaper.styles(grade, ocean, held, 6, SEA_LEVEL)));
|
||||
assertEquals("the same step hidden by the head snap", ReachStyle.RIFFLE, ReachShaper.styles(grade, ocean, held, 6, SEA_LEVEL + 1)[3]);
|
||||
List.of(ReachShaper.styles(grade, ocean, held, 6, SEA_LEVEL, 2)));
|
||||
assertEquals("the same step hidden by the head snap", ReachStyle.RIFFLE, ReachShaper.styles(grade, ocean, held, 6, SEA_LEVEL + 1, 2)[3]);
|
||||
assertEquals("a one-block step that leaves no held lip", ReachStyle.RIFFLE,
|
||||
ReachShaper.styles(grade, ocean, new boolean[grade.length], 6, SEA_LEVEL)[3]);
|
||||
ReachShaper.styles(grade, ocean, new boolean[grade.length], 6, SEA_LEVEL, 2)[3]);
|
||||
int[] zoned = {78, 78, 77, 77, 77};
|
||||
boolean[] zone = {true, true, true, true, false};
|
||||
assertEquals("a one-block step inside an outlet zone that the head snap shows as two blocks",
|
||||
List.of(ReachStyle.POND_OUTLET, ReachStyle.POND_OUTLET, ReachStyle.CASCADE, ReachStyle.POND_OUTLET, ReachStyle.RUN),
|
||||
List.of(ReachShaper.styles(zoned, ocean, zone, 6, SEA_LEVEL)));
|
||||
List.of(ReachShaper.styles(zoned, ocean, zone, 6, SEA_LEVEL, 2)));
|
||||
assertEquals("the same step inside the zone hidden by the head snap", ReachStyle.POND_OUTLET,
|
||||
ReachShaper.styles(zoned, ocean, zone, 6, SEA_LEVEL + 1)[2]);
|
||||
ReachShaper.styles(zoned, ocean, zone, 6, SEA_LEVEL + 1, 2)[2]);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -2899,7 +2899,7 @@ public class ReachShaperTest {
|
||||
|
||||
private static HydrologyTier withSteps(HydrologyTier tier, boolean cascades, int waterfallMinimumDrop) {
|
||||
return new HydrologyTier(tier.name(), tier.minCatchment(), tier.minHalfWidth(), tier.maxHalfWidth(), tier.widthFactor(), tier.depthRatio(),
|
||||
tier.inset(), cascades, waterfallMinimumDrop, tier.bankBand(), tier.bankStyle(), tier.estuary(), tier.delta(), tier.materials(),
|
||||
tier.inset(), cascades, waterfallMinimumDrop, 2, tier.bankBand(), tier.bankStyle(), tier.estuary(), tier.delta(), tier.materials(),
|
||||
tier.fluid(), tier.decorators());
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -351,7 +351,7 @@ public class IrisComplexHeightStreamTest {
|
||||
IrisHydrologyMaterials ponds = RASTER_SETTINGS.ponds().materials();
|
||||
ChunkWaterRaster raster = mock(ChunkWaterRaster.class);
|
||||
IrisHydrologyMaterials tierMaterials = new IrisHydrologyMaterials();
|
||||
HydrologyTier tier = new HydrologyTier("river", 0f, 1f, 2f, 1f, 0.4f, 1, true, 6, 0, IrisBankStyle.SMOOTH,
|
||||
HydrologyTier tier = new HydrologyTier("river", 0f, 1f, 2f, 1f, 0.4f, 1, true, 6, 2, 0, IrisBankStyle.SMOOTH,
|
||||
new HydrologyTier.Estuary(48, 2.5f), new HydrologyTier.Delta(0, 35f, 64), tierMaterials, "water", List.of());
|
||||
when(raster.waterHead(anyInt(), anyInt())).thenReturn(Integer.MIN_VALUE);
|
||||
when(raster.tier(5, 9)).thenReturn(tier);
|
||||
|
||||
@@ -84,7 +84,7 @@ public class SchemaBuilderIdentityTest {
|
||||
@ClassRule
|
||||
public static final PlatformLeakGuard PLATFORM_GUARD = PlatformLeakGuard.clean();
|
||||
|
||||
private static final String EXPECTED_SCHEMA_DIGEST = "c87139f807de29aa444923b6b0a1f85dc8de882ea8cf13ea3818fbdaeb352ae6";
|
||||
private static final String EXPECTED_SCHEMA_DIGEST = "addfddb3462b79563ecc3ba52a3000d36d2fc02e63966ae2e1bdf42de90130b5";
|
||||
|
||||
private static final List<Class<?>> SCHEMA_ROOTS = List.of(
|
||||
IrisDimension.class,
|
||||
|
||||
@@ -81,7 +81,7 @@ public final class WaterScene {
|
||||
}
|
||||
|
||||
public static HydrologyTier tier(String name, float halfWidth, float depthRatio) {
|
||||
return new HydrologyTier(name, 0f, halfWidth, halfWidth, 0f, depthRatio, 1, true, 6, 0, IrisBankStyle.SMOOTH,
|
||||
return new HydrologyTier(name, 0f, halfWidth, halfWidth, 0f, depthRatio, 1, true, 6, 2, 0, IrisBankStyle.SMOOTH,
|
||||
new HydrologyTier.Estuary(48, 2.5f), new HydrologyTier.Delta(0, 35f, 64), new IrisHydrologyMaterials(), "water", List.of());
|
||||
}
|
||||
|
||||
|
||||
@@ -149,7 +149,7 @@ final class HydrologyRasterMetrics {
|
||||
}
|
||||
|
||||
private int head(Pond pond) {
|
||||
return WaterHeads.snap(pond.level(), settings.seaLevel());
|
||||
return WaterHeads.standing(pond.level(), settings.seaLevel());
|
||||
}
|
||||
|
||||
WaterRole role(int x, int z) {
|
||||
|
||||
Reference in new issue
Block a user