mirror of
https://github.com/VolmitSoftware/Iris.git
synced 2026-11-27 00:04:42 +00:00
Plunge pool tailout
- The plunge bowl ends at the next step's brink when that brink is nearer than the pool radius, so the pool rises back to the crest and the brink keeps 1-block water (R78). - A brink distance field over the foot level, seeded at cells with a 4-neighbour at least 2 lower, sets each cell's span to the smaller of the radius and its foot-plus-brink distance; without a brink in reach the span is the radius, as before. - The depth under the fall foot is unchanged; with no cell between the foot and the brink only the brink keeps its sill, and a foot that is itself a brink keeps the sill. - Removes the 4 tick conversion cells at 146..148,329,-2826..-2828 and 489,329,-2182 where corner falls sat beside deep brink water.
This commit is contained in:
1 parent
f4bd105157
commit
6f3b96cfb3
2 files changed
+48
-7
No files matched your search
@@ -43,9 +43,10 @@ final class RiffleProfile {
|
||||
}
|
||||
TreeMap<Crest, Seeds> crests = new TreeMap<>();
|
||||
TreeMap<Fall, Seeds> feet = new TreeMap<>();
|
||||
TreeMap<Integer, Seeds> brinks = new TreeMap<>();
|
||||
for (int z = 1; z < GRID - 1; z++) {
|
||||
for (int x = 1; x < GRID - 1; x++) {
|
||||
collect(z * GRID + x, crests, feet);
|
||||
collect(z * GRID + x, crests, feet, brinks);
|
||||
}
|
||||
}
|
||||
if (crests.isEmpty() && feet.isEmpty()) {
|
||||
@@ -59,9 +60,11 @@ final class RiffleProfile {
|
||||
}
|
||||
}
|
||||
for (Map.Entry<Fall, Seeds> fall : feet.entrySet()) {
|
||||
int[] output = distances.measure(fall.getValue(), fall.getKey().foot(), fall.getKey().reach());
|
||||
Fall key = fall.getKey();
|
||||
int[] output = distances.measure(fall.getValue(), key.foot(), key.reach());
|
||||
if (output != null) {
|
||||
plunges.add(new Plunge(fall.getKey(), output));
|
||||
Seeds tail = brinks.get(key.foot());
|
||||
plunges.add(new Plunge(key, output, tail == null ? null : distances.measure(tail, key.foot(), key.reach())));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -94,7 +97,7 @@ final class RiffleProfile {
|
||||
return flowing[grid] ? plunge(cell, riffled, head, variation) : riffled;
|
||||
}
|
||||
|
||||
private void collect(int cell, TreeMap<Crest, Seeds> crests, TreeMap<Fall, Seeds> feet) {
|
||||
private void collect(int cell, TreeMap<Crest, Seeds> crests, TreeMap<Fall, Seeds> feet, TreeMap<Integer, Seeds> brinks) {
|
||||
int head = heads[cell];
|
||||
if (head == DRY) {
|
||||
return;
|
||||
@@ -112,6 +115,7 @@ final class RiffleProfile {
|
||||
}
|
||||
if (crest) {
|
||||
crests.computeIfAbsent(new Crest(head - 1, features[cell], flowing[cell]), ignored -> new Seeds()).add(cell);
|
||||
brinks.computeIfAbsent(head, ignored -> new Seeds()).add(cell);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -127,11 +131,12 @@ final class RiffleProfile {
|
||||
for (Plunge plunge : plunges) {
|
||||
Fall fall = plunge.fall();
|
||||
int distance = plunge.distances()[cell];
|
||||
if (fall.foot() != head || distance >= 10D * fall.radius()) {
|
||||
double span = plunge.span(cell);
|
||||
if (fall.foot() != head || distance >= span) {
|
||||
continue;
|
||||
}
|
||||
long depth = Math.clamp(Math.round(PLUNGE_RATIO * fall.drop() * (0.85D + 0.15D * variation)), PLUNGE_MIN_DEPTH, PLUNGE_MAX_DEPTH);
|
||||
double u = distance / (10D * fall.radius());
|
||||
double u = distance / span;
|
||||
double bowl = 1D - u * u * (3D - 2D * u);
|
||||
carved = (int) Math.min(carved, head - 1L - Math.round((depth - 1L) * bowl));
|
||||
}
|
||||
@@ -216,7 +221,11 @@ final class RiffleProfile {
|
||||
}
|
||||
}
|
||||
|
||||
private record Plunge(Fall fall, int[] distances) {
|
||||
private record Plunge(Fall fall, int[] distances, int[] brinks) {
|
||||
double span(int cell) {
|
||||
double radius = 10D * fall.radius();
|
||||
return brinks == null ? radius : Math.min(radius, distances[cell] + (double) brinks[cell]);
|
||||
}
|
||||
}
|
||||
|
||||
private static final class DistanceField {
|
||||
|
||||
@@ -87,6 +87,38 @@ public class RiffleProfileTest {
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void plungePoolsTailOutBeforeTheNextStep() {
|
||||
Surface pool = new Surface((x, z) -> x < 0 ? 110 : 98);
|
||||
for (int brink : new int[]{5, 2, 1}) {
|
||||
int next = brink + 1;
|
||||
Surface stepped = new Surface((x, z) -> x < 0 ? 110 : x < next ? 98 : 96);
|
||||
for (int z = -8; z <= 8; z++) {
|
||||
for (int original : new int[]{92, 96}) {
|
||||
String bed = original + " bed at z " + z + " with the next step's brink at x " + brink;
|
||||
assertEquals("lip sill for the " + bed, 109, stepped.bed(-1, z, original));
|
||||
if (original == 96) {
|
||||
assertEquals("plunge floor under the fall for the " + bed, pool.bed(0, z, original), stepped.bed(0, z, original));
|
||||
}
|
||||
assertTrue("plunge pool at the foot for the " + bed, stepped.bed(0, z, original) <= 95);
|
||||
assertEquals("1-block water over the brink for the " + bed, 97, stepped.bed(brink, z, original));
|
||||
for (int x = 0; x < brink; x++) {
|
||||
int here = stepped.bed(x, z, original);
|
||||
assertTrue("deepest at the foot, at " + x + " for the " + bed, stepped.bed(0, z, original) <= here);
|
||||
assertTrue("tailout rises toward the brink at " + x + " for the " + bed, here <= stepped.bed(x + 1, z, original));
|
||||
if (brink >= 5) {
|
||||
assertTrue("tailout face at " + x + " for the " + bed, stepped.bed(x + 1, z, original) - here <= 2);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Surface wedged = new Surface((x, z) -> x < 0 ? 110 : x < 1 ? 98 : 96);
|
||||
for (int z = -8; z <= 8; z++) {
|
||||
assertEquals("a foot that is also the next step's brink keeps the sill at z " + z, 97, wedged.bed(0, z, 92));
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void plungeFieldsMatchAcrossChunkBorders() {
|
||||
IntBinaryOperator heads = (x, z) -> x + z < -7 ? 110 : 98;
|
||||
|
||||
Reference in new issue
Block a user