mirror of
https://github.com/VolmitSoftware/Iris.git
synced 2026-11-29 17:23:59 +00:00
Drawdown follows zone wetness
- Carry each column's bounded zone wetness and whether climate zones apply to it as wetness and climateZoned sample channels, copied by HeightLattice - Draw pond and lake surfaces down by climateDrawdown times one minus the bounded zone wetness at the floor inside climate zones, and by one minus rainfall where the zones are off or climateZones is false - Test the drawdown in wet, dry and transition zones and outside them, and that two windows give a pond the same level - Test that a policy wetness min keeps a dry-zone pond from drawing down, from the terrain source through the planner - Describe the rainfall policy as lowering ponds only where the climate zones do not apply - Recapture the schema digest
This commit is contained in:
1 parent
fa43b276f4
commit
720b9ac967
9 files changed
+210
-20
No files matched your search
+1
-1
@@ -26,7 +26,7 @@ public class IrisHydrologyPolicy {
|
||||
|
||||
@MinNumber(0)
|
||||
@MaxNumber(MAX_MULTIPLIER)
|
||||
@Description("Multiplier on the water that falls in this area. Higher values grow more and larger streams and keep ponds fuller. With no value set anywhere it is 1.")
|
||||
@Description("Multiplier on the water that falls in this area. Higher values grow more and larger streams. Where the wet and dry zones do not apply, values below 1 also lower pond and lake surfaces. With no value set anywhere it is 1.")
|
||||
private Double rainfall = null;
|
||||
|
||||
@MinNumber(0)
|
||||
|
||||
+4
-5
@@ -166,17 +166,16 @@ public final class IrisHydrologyTerrainSource implements HydrologyTerrainSource,
|
||||
Policy policy = policy(complex.baseBiomeLineage(x, z), regions.get(x, z));
|
||||
out.height()[index] = (float) height;
|
||||
out.ocean()[index] = StrictMath.round(height) < settings.seaLevel() && oceanIntent(x, z);
|
||||
float wet = policy.climateZones() ? wetness(x, z, policy) : 1f;
|
||||
boolean zoned = wetness != null && policy.climateZones();
|
||||
float wet = zoned ? (float) Math.clamp(climate.wetness(wetness.noise(x, z)), policy.minWetness(), policy.maxWetness()) : 1f;
|
||||
out.rainfall()[index] = policy.rainfall() * wet;
|
||||
out.pondDensity()[index] = policy.pondDensity() * wet;
|
||||
out.wetness()[index] = wet;
|
||||
out.climateZoned()[index] = zoned;
|
||||
out.permission()[index] = policy.permission();
|
||||
out.fluidProfile()[index] = policy.fluid();
|
||||
}
|
||||
|
||||
private float wetness(int x, int z, Policy policy) {
|
||||
return wetness == null ? 1f : (float) Math.clamp(climate.wetness(wetness.noise(x, z)), policy.minWetness(), policy.maxWetness());
|
||||
}
|
||||
|
||||
private boolean oceanIntent(int x, int z) {
|
||||
BiomeBuffetLayout.Cell cell = buffet == null ? null : buffet.terrain(x, z);
|
||||
IrisBiome focused = cell == null ? focus : cell.biome();
|
||||
|
||||
@@ -184,6 +184,8 @@ public final class HeightLattice {
|
||||
out.ocean()[index] = samples.ocean()[sample];
|
||||
out.rainfall()[index] = samples.rainfall()[sample];
|
||||
out.pondDensity()[index] = samples.pondDensity()[sample];
|
||||
out.wetness()[index] = samples.wetness()[sample];
|
||||
out.climateZoned()[index] = samples.climateZoned()[sample];
|
||||
out.permission()[index] = samples.permission()[sample];
|
||||
out.fluidProfile()[index] = samples.fluidProfile()[sample];
|
||||
}
|
||||
@@ -345,6 +347,8 @@ public final class HeightLattice {
|
||||
private final boolean[] ocean;
|
||||
private final float[] rainfall;
|
||||
private final float[] pondDensity;
|
||||
private final float[] wetness;
|
||||
private final boolean[] climateZoned;
|
||||
private final byte[] permission;
|
||||
private final String[] fluidProfile;
|
||||
private final AtomicReferenceArray<CompletableFuture<Void>> marks;
|
||||
@@ -356,6 +360,8 @@ public final class HeightLattice {
|
||||
this.ocean = new boolean[cells];
|
||||
this.rainfall = new float[cells];
|
||||
this.pondDensity = new float[cells];
|
||||
this.wetness = new float[cells];
|
||||
this.climateZoned = new boolean[cells];
|
||||
this.permission = new byte[cells];
|
||||
this.fluidProfile = new String[cells];
|
||||
this.marks = new AtomicReferenceArray<>(cells);
|
||||
@@ -366,6 +372,8 @@ public final class HeightLattice {
|
||||
ocean[local] = samples.ocean()[sample];
|
||||
rainfall[local] = samples.rainfall()[sample];
|
||||
pondDensity[local] = samples.pondDensity()[sample];
|
||||
wetness[local] = samples.wetness()[sample];
|
||||
climateZoned[local] = samples.climateZoned()[sample];
|
||||
permission[local] = samples.permission()[sample];
|
||||
fluidProfile[local] = samples.fluidProfile()[sample];
|
||||
}
|
||||
@@ -375,6 +383,8 @@ public final class HeightLattice {
|
||||
out.ocean()[index] = ocean[local];
|
||||
out.rainfall()[index] = rainfall[local];
|
||||
out.pondDensity()[index] = pondDensity[local];
|
||||
out.wetness()[index] = wetness[local];
|
||||
out.climateZoned()[index] = climateZoned[local];
|
||||
out.permission()[index] = permission[local];
|
||||
out.fluidProfile()[index] = fluidProfile[local];
|
||||
}
|
||||
|
||||
+12
@@ -8,6 +8,8 @@ public final class HydrologySampleBuffer {
|
||||
private final boolean[] ocean;
|
||||
private final float[] rainfall;
|
||||
private final float[] pondDensity;
|
||||
private final float[] wetness;
|
||||
private final boolean[] climateZoned;
|
||||
private final byte[] permission;
|
||||
private final String[] fluidProfile;
|
||||
|
||||
@@ -19,6 +21,8 @@ public final class HydrologySampleBuffer {
|
||||
this.ocean = new boolean[capacity];
|
||||
this.rainfall = new float[capacity];
|
||||
this.pondDensity = new float[capacity];
|
||||
this.wetness = new float[capacity];
|
||||
this.climateZoned = new boolean[capacity];
|
||||
this.permission = new byte[capacity];
|
||||
this.fluidProfile = new String[capacity];
|
||||
}
|
||||
@@ -39,6 +43,14 @@ public final class HydrologySampleBuffer {
|
||||
return pondDensity;
|
||||
}
|
||||
|
||||
public float[] wetness() {
|
||||
return wetness;
|
||||
}
|
||||
|
||||
public boolean[] climateZoned() {
|
||||
return climateZoned;
|
||||
}
|
||||
|
||||
public byte[] permission() {
|
||||
return permission;
|
||||
}
|
||||
|
||||
@@ -228,7 +228,7 @@ public final class PondPlanner {
|
||||
>= Math.clamp(settings.ponds().natural().keep() * floor.pondDensity()[0], 0f, 1f) * settings.density()) {
|
||||
return null;
|
||||
}
|
||||
return new Candidate(basin, kind, floorX, floorZ, floor.rainfall()[0], fluid(floor));
|
||||
return new Candidate(basin, kind, floorX, floorZ, dryness(floor), fluid(floor));
|
||||
}
|
||||
|
||||
private Pond lake(LakeCandidate candidate, HeightLattice fine) {
|
||||
@@ -239,13 +239,18 @@ public final class PondPlanner {
|
||||
if ((floor.permission()[0] & HydrologySampleBuffer.ALLOW_PONDS) == 0) {
|
||||
return null;
|
||||
}
|
||||
return measureLake(fine, new LakeSite(candidate, floor.rainfall()[0], fluid(floor)));
|
||||
return measureLake(fine, new LakeSite(candidate, dryness(floor), fluid(floor)));
|
||||
}
|
||||
|
||||
private String fluid(HydrologySampleBuffer floor) {
|
||||
return floor.fluidProfile()[0] == null ? settings.ponds().fluid() : floor.fluidProfile()[0];
|
||||
}
|
||||
|
||||
private static float dryness(HydrologySampleBuffer floor) {
|
||||
float wetness = floor.climateZoned()[0] ? floor.wetness()[0] : floor.rainfall()[0];
|
||||
return Math.clamp(1f - wetness, 0f, 1f);
|
||||
}
|
||||
|
||||
private boolean qualifies(DemGrid raw, Basin basin, PondKind kind) {
|
||||
long area = (long) basin.cells().length * raw.cell() * raw.cell();
|
||||
HydrologySettings.NaturalPonds natural = settings.ponds().natural();
|
||||
@@ -337,7 +342,7 @@ public final class PondPlanner {
|
||||
return null;
|
||||
}
|
||||
int lowest = Math.max(settings.minY() + 1, settings.seaLevel());
|
||||
int level = Math.min(Math.min(Math.max(lowest, (int) Math.floor(spill.height()) - freeboard(site) - drawdown(site.rainfall())),
|
||||
int level = Math.min(Math.min(Math.max(lowest, (int) Math.floor(spill.height()) - freeboard(site) - drawdown(site.dryness())),
|
||||
settings.maxY() - 1), levelCap);
|
||||
int failures = 0;
|
||||
for (int round = 0; round < LEVEL_ROUNDS && level >= lowest; round++) {
|
||||
@@ -763,8 +768,8 @@ public final class PondPlanner {
|
||||
CellHash.mix(settings.seed(), SALT_FREEBOARD, site.floorX(), site.floorZ()));
|
||||
}
|
||||
|
||||
private int drawdown(float rainfall) {
|
||||
return Math.round(settings.ponds().climateDrawdown() * Math.clamp(1f - rainfall, 0f, 1f));
|
||||
private int drawdown(float dryness) {
|
||||
return Math.round(settings.ponds().climateDrawdown() * dryness);
|
||||
}
|
||||
|
||||
private static int radius(DemGrid raw, Basin basin) {
|
||||
@@ -800,15 +805,15 @@ public final class PondPlanner {
|
||||
|
||||
int floorZ();
|
||||
|
||||
float rainfall();
|
||||
float dryness();
|
||||
|
||||
String fluid();
|
||||
}
|
||||
|
||||
private record Candidate(Basin basin, PondKind kind, int floorX, int floorZ, float rainfall, String fluid) implements Site {
|
||||
private record Candidate(Basin basin, PondKind kind, int floorX, int floorZ, float dryness, String fluid) implements Site {
|
||||
}
|
||||
|
||||
private record LakeSite(LakeCandidate lake, float rainfall, String fluid) implements Site {
|
||||
private record LakeSite(LakeCandidate lake, float dryness, String fluid) implements Site {
|
||||
@Override
|
||||
public PondKind kind() {
|
||||
return PondKind.LAKE;
|
||||
|
||||
Reference in new issue
Block a user