mirror of
https://github.com/VolmitSoftware/Iris.git
synced 2026-11-30 01:34:04 +00:00
Step-pool grouping
- Add StepPools to group drops into level pools on cascading tiers - Pass the seed through ReachGrader and record each point's floor - Stop a waterfall absorbing the run-out at one waterfall's depth, so falls never merge - Hold non-estuary points above sea level so no pool pulls the sea upstream of the estuary - Protect pond outlet starts and every held point from grouping - Test step pools, plunge reaches, tall-fall rollover and pond outlet zones - Check the short-pit lock on ungrouped grades and bound grouped grades by one pool length - Count visible drops in the gradeNeverRisesDownstream ratio - Check the delta branch water on ungrouped grades and within one pool length when grouped
This commit is contained in:
6 files changed
+319
-22
No files matched your search
@@ -17,7 +17,7 @@ final class ReachGrader {
|
||||
}
|
||||
}
|
||||
|
||||
static int[] grade(List<ReachDraft> drafts, int[] upstreamFirst, int seaLevel, int maxFill, PondChain ponds) {
|
||||
static int[] grade(List<ReachDraft> drafts, int[] upstreamFirst, int seaLevel, int maxFill, PondChain ponds, long seed) {
|
||||
boolean[] lakeFloor = new boolean[drafts.size()];
|
||||
for (int position = upstreamFirst.length - 1; position >= 0; position--) {
|
||||
int index = upstreamFirst[position];
|
||||
@@ -54,17 +54,23 @@ final class ReachGrader {
|
||||
estuary(draft, seaLevel + maxFill);
|
||||
}
|
||||
int[] grade = profile(drafts, draft);
|
||||
int[] floors = new int[grade.length];
|
||||
for (int point = 0; point < grade.length; point++) {
|
||||
if (draft.held != null && draft.held[point] && !draft.ocean[point]) {
|
||||
grade[point] = level;
|
||||
floors[point] = level;
|
||||
continue;
|
||||
}
|
||||
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, seaLevel + 1);
|
||||
level = Math.min(level, Math.max(floor, Math.min(grade[point], cap)));
|
||||
grade[point] = level;
|
||||
}
|
||||
draft.grade = grade;
|
||||
if (draft.tier.cascades()) {
|
||||
StepPools.group(grade, floors, draft.xs, draft.zs, draft.catchments, draft.tier, protectedStart(draft), seed);
|
||||
}
|
||||
graded[index] = true;
|
||||
lowerIncomingEnds(drafts, draft);
|
||||
}
|
||||
@@ -81,6 +87,24 @@ final class ReachGrader {
|
||||
return levels;
|
||||
}
|
||||
|
||||
private static float protectedStart(ReachDraft draft) {
|
||||
if (!draft.outlet) {
|
||||
return 0f;
|
||||
}
|
||||
float start = Math.max(ReachShaper.OUTLET_LENGTH, 2f * (draft.tier.halfWidth(draft.catchments[0]) + 1f));
|
||||
if (draft.held == null) {
|
||||
return start;
|
||||
}
|
||||
float along = 0f;
|
||||
for (int point = 1; point < draft.xs.length; point++) {
|
||||
along += (float) Math.hypot(draft.xs[point] - draft.xs[point - 1], draft.zs[point] - draft.zs[point - 1]);
|
||||
if (draft.held[point]) {
|
||||
start = Math.max(start, along);
|
||||
}
|
||||
}
|
||||
return start;
|
||||
}
|
||||
|
||||
private static void estuary(ReachDraft draft, int highestBank) {
|
||||
int length = draft.tier.estuary().length();
|
||||
float along = 0f;
|
||||
|
||||
@@ -18,7 +18,7 @@ public final class ReachShaper {
|
||||
private static final int SMOOTHING_PASSES = 2;
|
||||
private static final float TAPER_LENGTH = 24f;
|
||||
private static final float WAIST = 0.5f;
|
||||
private static final float OUTLET_LENGTH = 8f;
|
||||
static final float OUTLET_LENGTH = 8f;
|
||||
private static final float LIP_MARGIN = 4f;
|
||||
private static final int LEAD_IN_REACH = 16;
|
||||
private static final float LIP_HALF_WIDTH = 1f;
|
||||
@@ -74,7 +74,7 @@ public final class ReachShaper {
|
||||
}
|
||||
ReachGrader.PondChain chain = pondChain(drafts, ponds, outletDrafts);
|
||||
int[] order = upstreamFirst(drafts, chain);
|
||||
int[] levels = ReachGrader.grade(drafts, order, settings.seaLevel(), settings.deformation().maxFill(), chain);
|
||||
int[] levels = ReachGrader.grade(drafts, order, settings.seaLevel(), settings.deformation().maxFill(), chain, seed);
|
||||
for (int index : order) {
|
||||
finish(drafts, drafts.get(index), settings.seaLevel());
|
||||
}
|
||||
|
||||
@@ -0,0 +1,89 @@
|
||||
package art.arcane.iris.generation.hydrology.water;
|
||||
|
||||
import art.arcane.iris.generation.hydrology.grid.CellHash;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
final class StepPools {
|
||||
static final float POOL_MIN_WIDTHS = 2.5f;
|
||||
static final float POOL_MAX_WIDTHS = 5f;
|
||||
static final float POOL_MIN = 6f;
|
||||
static final float POOL_MAX = 32f;
|
||||
static final float PLUNGE_PER_DROP = 0.75f;
|
||||
static final float PLUNGE_MIN = 6f;
|
||||
static final float PLUNGE_MAX = 16f;
|
||||
static final int ROLLOVER_DROP = 2;
|
||||
static final float ROLLOVER_WIDTHS = 1.5f;
|
||||
static final float ROLLOVER_MIN = 4f;
|
||||
static final float ROLLOVER_MAX = 12f;
|
||||
private static final int STEP_EXTRA = 2;
|
||||
private static final long SALT_POOL = 0x535445504f4f4cL;
|
||||
|
||||
private StepPools() {
|
||||
}
|
||||
|
||||
static int stepMaxDrop(HydrologyTier tier) {
|
||||
return tier.waterfallMinimumDrop() + STEP_EXTRA;
|
||||
}
|
||||
|
||||
static void group(int[] grade, int[] floors, float[] xs, float[] zs, float[] catchments, HydrologyTier tier, float protectedLength, long seed) {
|
||||
int count = grade.length;
|
||||
float[] along = along(xs, zs);
|
||||
int start = 1;
|
||||
while (start < count && along[start] <= protectedLength) {
|
||||
start++;
|
||||
}
|
||||
int point = start;
|
||||
while (point < count - 1) {
|
||||
if (grade[point] >= grade[point - 1]) {
|
||||
point++;
|
||||
continue;
|
||||
}
|
||||
int top = grade[point - 1];
|
||||
int first = top - grade[point];
|
||||
boolean cliff = first >= tier.waterfallMinimumDrop();
|
||||
float width = 2f * (tier.halfWidth(catchments[point]) + 1f);
|
||||
float span = cliff ? Math.clamp(first * PLUNGE_PER_DROP, PLUNGE_MIN, PLUNGE_MAX)
|
||||
: Math.clamp(width * poolWidths(seed, xs[point], zs[point]), POOL_MIN, POOL_MAX);
|
||||
int end = point;
|
||||
int highestFloor = Integer.MIN_VALUE;
|
||||
for (int next = point + 1; next < count - 1 && along[next] - along[point] < span; next++) {
|
||||
highestFloor = Math.max(highestFloor, floors[next - 1]);
|
||||
if (grade[next] >= grade[end]) {
|
||||
continue;
|
||||
}
|
||||
int limit = cliff ? grade[point] - tier.waterfallMinimumDrop() : top - stepMaxDrop(tier) - 1;
|
||||
if (grade[next] <= limit || highestFloor > grade[next]) {
|
||||
break;
|
||||
}
|
||||
end = next;
|
||||
}
|
||||
Arrays.fill(grade, point, end, grade[end]);
|
||||
if (cliff && first >= 2 * tier.waterfallMinimumDrop()) {
|
||||
rollover(grade, floors, along, point, width, start);
|
||||
}
|
||||
point = end + 1;
|
||||
}
|
||||
}
|
||||
|
||||
private static float poolWidths(long seed, float x, float z) {
|
||||
double share = CellHash.unit(CellHash.mix(seed, SALT_POOL, (int) Math.floor(x), (int) Math.floor(z)));
|
||||
return (float) (POOL_MIN_WIDTHS + (POOL_MAX_WIDTHS - POOL_MIN_WIDTHS) * share);
|
||||
}
|
||||
|
||||
private static void rollover(int[] grade, int[] floors, float[] along, int foot, float width, int start) {
|
||||
float length = Math.clamp(ROLLOVER_WIDTHS * width, ROLLOVER_MIN, ROLLOVER_MAX);
|
||||
int brink = foot - 1;
|
||||
for (int point = brink; point >= start && along[brink] - along[point] < length; point--) {
|
||||
grade[point] = Math.min(grade[point], Math.max(grade[point] - ROLLOVER_DROP, Math.max(floors[point], grade[point + 1])));
|
||||
}
|
||||
}
|
||||
|
||||
private static float[] along(float[] xs, float[] zs) {
|
||||
float[] along = new float[xs.length];
|
||||
for (int point = 1; point < xs.length; point++) {
|
||||
along[point] = along[point - 1] + (float) Math.hypot(xs[point] - xs[point - 1], zs[point] - zs[point - 1]);
|
||||
}
|
||||
return along;
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user