mirror of
https://github.com/VolmitSoftware/Iris.git
synced 2026-11-27 00:04:42 +00:00
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
This commit is contained in:
1 parent
6aafec196b
commit
90205dc5fe
3 files changed
+41
-6
No files matched your search
@@ -82,11 +82,15 @@ public final class LinkBlend {
|
|||||||
fixed[0] = held || heldStart || style[0] == ReachStyle.POND_OUTLET;
|
fixed[0] = held || heldStart || style[0] == ReachStyle.POND_OUTLET;
|
||||||
for (int point = 1; point < style.length; point++) {
|
for (int point = 1; point < style.length; point++) {
|
||||||
held = held && nearLip(lips, feeder.xs()[point], feeder.zs()[point], feeder.halfWidth()[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;
|
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<PondMask> lips, float x, float z, float halfWidth) {
|
private static boolean nearLip(List<PondMask> lips, float x, float z, float halfWidth) {
|
||||||
for (PondMask lip : lips) {
|
for (PondMask lip : lips) {
|
||||||
if (ReachShaper.nearLip(lip, x, z, halfWidth)) {
|
if (ReachShaper.nearLip(lip, x, z, halfWidth)) {
|
||||||
|
|||||||
@@ -53,13 +53,13 @@ final class RiffleProfile {
|
|||||||
}
|
}
|
||||||
DistanceField distances = new DistanceField(heads);
|
DistanceField distances = new DistanceField(heads);
|
||||||
for (Map.Entry<Crest, Seeds> crest : crests.entrySet()) {
|
for (Map.Entry<Crest, Seeds> 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) {
|
if (output != null) {
|
||||||
fields.add(new Field(crest.getKey(), output));
|
fields.add(new Field(crest.getKey(), output));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for (Map.Entry<Fall, Seeds> fall : feet.entrySet()) {
|
for (Map.Entry<Fall, Seeds> 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) {
|
if (output != null) {
|
||||||
plunges.add(new Plunge(fall.getKey(), output));
|
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);
|
return Math.clamp(PLUNGE_RADIUS_RATIO * drop(), PLUNGE_MIN_RADIUS, PLUNGE_MAX_RADIUS);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int reach() {
|
||||||
|
return (int) Math.ceil(10D * radius());
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int compareTo(Fall other) {
|
public int compareTo(Fall other) {
|
||||||
return foot != other.foot ? Integer.compare(foot, other.foot) : Integer.compare(top, other.top);
|
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[] previous = new int[GRID * GRID];
|
||||||
private final int[] first = new int[LIMIT];
|
private final int[] first = new int[LIMIT];
|
||||||
private int level;
|
private int level;
|
||||||
|
private int limit;
|
||||||
|
|
||||||
private DistanceField(int[] heads) {
|
private DistanceField(int[] heads) {
|
||||||
this.heads = heads;
|
this.heads = heads;
|
||||||
}
|
}
|
||||||
|
|
||||||
private int[] measure(Seeds seeds, int passable) {
|
private int[] measure(Seeds seeds, int passable, int reach) {
|
||||||
level = passable;
|
level = passable;
|
||||||
|
limit = reach;
|
||||||
Arrays.fill(distances, LIMIT);
|
Arrays.fill(distances, LIMIT);
|
||||||
Arrays.fill(next, -1);
|
Arrays.fill(next, -1);
|
||||||
Arrays.fill(previous, -1);
|
Arrays.fill(previous, -1);
|
||||||
@@ -247,7 +253,7 @@ final class RiffleProfile {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void offer(int cell, int distance) {
|
private void offer(int cell, int distance) {
|
||||||
if (distance + REMAINING[cell] >= LIMIT) {
|
if (distance + REMAINING[cell] >= limit) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (distances[cell] < LIMIT) {
|
if (distances[cell] < LIMIT) {
|
||||||
@@ -276,7 +282,7 @@ final class RiffleProfile {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void spread() {
|
private void spread() {
|
||||||
for (int distance = 0; distance < LIMIT; distance++) {
|
for (int distance = 0; distance < limit; distance++) {
|
||||||
while (first[distance] >= 0) {
|
while (first[distance] >= 0) {
|
||||||
int cell = first[distance];
|
int cell = first[distance];
|
||||||
remove(cell);
|
remove(cell);
|
||||||
|
|||||||
+25
@@ -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.PondKind;
|
||||||
import art.arcane.iris.generation.hydrology.water.PondMask;
|
import art.arcane.iris.generation.hydrology.water.PondMask;
|
||||||
import art.arcane.iris.generation.hydrology.water.Reach;
|
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.ReachStyle;
|
||||||
import art.arcane.iris.generation.hydrology.water.ShapedNetwork;
|
import art.arcane.iris.generation.hydrology.water.ShapedNetwork;
|
||||||
import art.arcane.iris.generation.terrain.IrisMaterialPalette;
|
import art.arcane.iris.generation.terrain.IrisMaterialPalette;
|
||||||
@@ -911,6 +912,30 @@ public class ChunkWaterRasterTest {
|
|||||||
assertWindowOrderFree(scene, 27, 37, 12);
|
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
|
@Test
|
||||||
public void crossWindowSettlingKeepsAnOutletsHeldLipAtThePondLevel() {
|
public void crossWindowSettlingKeepsAnOutletsHeldLipAtThePondLevel() {
|
||||||
HydrologyTier narrow = tier("river", 2f, 0.5f, 4, IrisBankStyle.SMOOTH);
|
HydrologyTier narrow = tier("river", 2f, 0.5f, 4, IrisBankStyle.SMOOTH);
|
||||||
|
|||||||
Reference in new issue
Block a user