mirror of
https://github.com/VolmitSoftware/Iris.git
synced 2026-11-30 09:44:24 +00:00
Per-area wetness clamp
- Add hydrologyPolicy wetness with min and max bounds, inherited like the other policy fields - Clamp the climate zone wetness to the area's bounds before it scales rainfall and pond density - Reject wetness bounds outside 0..1 or with min above max at sampling and in pack validation - Report non-neutral wetness bounds as a RIVER_CLIMATE export limit on the owning policy - Recapture the schema digest
This commit is contained in:
1 parent
f7ddd68d26
commit
0245a10c95
11 files changed
+181
-9
No files matched your search
+3
@@ -35,6 +35,9 @@ public class IrisHydrologyPolicy {
|
||||
@Description("Whether the dimension's wet and dry zones apply in this area. false keeps this area's full rainfall and pond density even inside a dry zone. With no value set anywhere they apply.")
|
||||
private Boolean climateZones = null;
|
||||
|
||||
@Description("Bounds on the wetness of the dimension's wet and dry zones in this area: min keeps a swamp wet inside a dry zone, max keeps a desert mostly dry inside a wet zone. It has no effect where the wet and dry zones are off or climateZones is false. With no value set anywhere the zone wetness applies unchanged.")
|
||||
private IrisHydrologyWetness wetness = null;
|
||||
|
||||
@Description("Whether streams and rivers may form in this area. With no value set anywhere they are allowed.")
|
||||
private IrisHydrologyPermission streams = null;
|
||||
|
||||
|
||||
+24
@@ -0,0 +1,24 @@
|
||||
package art.arcane.iris.generation.hydrology.config;
|
||||
|
||||
import art.arcane.iris.pack.schema.annotation.MaxNumber;
|
||||
import art.arcane.iris.pack.schema.annotation.MinNumber;
|
||||
import art.arcane.volmlib.util.documentation.Description;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
@Accessors(chain = true)
|
||||
@NoArgsConstructor
|
||||
@Description("Bounds on how wet the dimension's wet and dry zones make this area. The zone wetness runs from the climate's dryRainfall in dry zones to 1 in wet zones and is held between min and max here before it scales rainfall and pond density.")
|
||||
@Data
|
||||
public class IrisHydrologyWetness {
|
||||
@MinNumber(0)
|
||||
@MaxNumber(1)
|
||||
@Description("Lowest wetness this area falls to, even inside a dry zone. 0.7 keeps 70% of the rainfall and pond density in dry zones.")
|
||||
private double min = 0D;
|
||||
|
||||
@MinNumber(0)
|
||||
@MaxNumber(1)
|
||||
@Description("Highest wetness this area reaches, even inside a wet zone. 0.35 keeps at most 35% of the rainfall and pond density. Must not be below min.")
|
||||
private double max = 1D;
|
||||
}
|
||||
+19
-5
@@ -4,6 +4,7 @@ import art.arcane.iris.generation.bake.ChunkBakeCache;
|
||||
import art.arcane.iris.generation.biome.IrisBiome;
|
||||
import art.arcane.iris.generation.hydrology.config.IrisHydrologyPermission;
|
||||
import art.arcane.iris.generation.hydrology.config.IrisHydrologyPolicy;
|
||||
import art.arcane.iris.generation.hydrology.config.IrisHydrologyWetness;
|
||||
import art.arcane.iris.generation.hydrology.grid.HydrologySampleBuffer;
|
||||
import art.arcane.iris.generation.hydrology.grid.HydrologyTerrainSource;
|
||||
import art.arcane.iris.generation.hydrology.plan.HydrologySettings;
|
||||
@@ -165,15 +166,15 @@ 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) : 1f;
|
||||
float wet = policy.climateZones() ? wetness(x, z, policy) : 1f;
|
||||
out.rainfall()[index] = policy.rainfall() * wet;
|
||||
out.pondDensity()[index] = policy.pondDensity() * wet;
|
||||
out.permission()[index] = policy.permission();
|
||||
out.fluidProfile()[index] = policy.fluid();
|
||||
}
|
||||
|
||||
private float wetness(int x, int z) {
|
||||
return wetness == null ? 1f : (float) climate.wetness(wetness.noise(x, z));
|
||||
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) {
|
||||
@@ -204,12 +205,17 @@ public final class IrisHydrologyTerrainSource implements HydrologyTerrainSource,
|
||||
IrisHydrologyPermission ponds = inherited(biomes, region, IrisHydrologyPolicy::getPonds, IrisHydrologyPermission.ALLOW);
|
||||
String fluid = inherited(biomes, region, IrisHydrologyPolicy::getFluid, null);
|
||||
boolean climateZones = inherited(biomes, region, IrisHydrologyPolicy::getClimateZones, Boolean.TRUE);
|
||||
IrisHydrologyWetness wetness = inherited(biomes, region, IrisHydrologyPolicy::getWetness, null);
|
||||
requireMultiplier("rainfall", rainfall, biomes, region);
|
||||
requireMultiplier("pondDensity", pondDensity, biomes, region);
|
||||
if (fluid != null) {
|
||||
settings.requireFillingFluid(fluid, "the hydrology policy for " + where(biomes, region));
|
||||
}
|
||||
return new Policy((float) rainfall, (float) pondDensity, permission(streams, ponds), fluid, climateZones);
|
||||
double minWetness = wetness == null ? 0D : wetness.getMin();
|
||||
double maxWetness = wetness == null ? 1D : wetness.getMax();
|
||||
requireWetness(minWetness, maxWetness, biomes, region);
|
||||
return new Policy((float) rainfall, (float) pondDensity, permission(streams, ponds), fluid, climateZones, (float) minWetness,
|
||||
(float) maxWetness);
|
||||
}
|
||||
|
||||
private <T> T inherited(List<IrisBiome> biomes, IrisRegion region, Function<IrisHydrologyPolicy, T> field, T fallback) {
|
||||
@@ -230,6 +236,13 @@ public final class IrisHydrologyTerrainSource implements HydrologyTerrainSource,
|
||||
}
|
||||
}
|
||||
|
||||
private static void requireWetness(double min, double max, List<IrisBiome> biomes, IrisRegion region) {
|
||||
if (!(min >= 0D && min <= max && max <= 1D)) {
|
||||
throw new IllegalArgumentException("Hydrology policy wetness for " + where(biomes, region) + " must have 0 <= min <= max <= 1, got min "
|
||||
+ min + " and max " + max);
|
||||
}
|
||||
}
|
||||
|
||||
private static String where(List<IrisBiome> biomes, IrisRegion region) {
|
||||
StringBuilder where = new StringBuilder("biome ").append(biomes.isEmpty() ? "none" : biomes.getFirst().getLoadKey());
|
||||
for (int index = 1; index < biomes.size(); index++) {
|
||||
@@ -238,7 +251,8 @@ public final class IrisHydrologyTerrainSource implements HydrologyTerrainSource,
|
||||
return where.append(" in region ").append(region == null ? "none" : region.getLoadKey()).toString();
|
||||
}
|
||||
|
||||
private record Policy(float rainfall, float pondDensity, byte permission, String fluid, boolean climateZones) {
|
||||
private record Policy(float rainfall, float pondDensity, byte permission, String fluid, boolean climateZones, float minWetness,
|
||||
float maxWetness) {
|
||||
}
|
||||
|
||||
private record PolicyKey(List<IrisBiome> biomes, IrisRegion region) {
|
||||
|
||||
@@ -5,6 +5,7 @@ import art.arcane.iris.generation.decoration.HydrologyVegetation;
|
||||
import art.arcane.iris.generation.decoration.IrisDecorator;
|
||||
import art.arcane.iris.generation.hydrology.config.IrisHydrology;
|
||||
import art.arcane.iris.generation.hydrology.config.IrisHydrologyPolicy;
|
||||
import art.arcane.iris.generation.hydrology.config.IrisHydrologyWetness;
|
||||
import art.arcane.iris.generation.hydrology.plan.HydrologySettings;
|
||||
import art.arcane.iris.generation.terrain.IrisDimension;
|
||||
import art.arcane.iris.generation.terrain.IrisRegion;
|
||||
@@ -259,6 +260,10 @@ final class PackHydrologyValidator {
|
||||
if (policy.getDecorators() != null) {
|
||||
validateDecorators(field + ".decorators", policy.getDecorators(), data, errors);
|
||||
}
|
||||
IrisHydrologyWetness wetness = policy.getWetness();
|
||||
if (wetness != null && !(wetness.getMin() >= 0D && wetness.getMin() <= wetness.getMax() && wetness.getMax() <= 1D)) {
|
||||
errors.add(field + ".wetness must have 0 <= min <= max <= 1, got min " + wetness.getMin() + " and max " + wetness.getMax() + ".");
|
||||
}
|
||||
}
|
||||
|
||||
private static void close(File packFolder, IrisData data, List<String> errors) {
|
||||
|
||||
+11
-3
@@ -5,6 +5,7 @@ import art.arcane.iris.generation.block.IrisBlockData;
|
||||
import art.arcane.iris.generation.decoration.IrisDecorator;
|
||||
import art.arcane.iris.generation.hydrology.config.IrisHydrologyPermission;
|
||||
import art.arcane.iris.generation.hydrology.config.IrisHydrologyPolicy;
|
||||
import art.arcane.iris.generation.hydrology.config.IrisHydrologyWetness;
|
||||
import art.arcane.iris.generation.hydrology.plan.HydrologySettings;
|
||||
import art.arcane.iris.generation.hydrology.water.HydrologyTier;
|
||||
import art.arcane.iris.generation.terrain.IrisDimension;
|
||||
@@ -101,13 +102,20 @@ final class RiverLimits {
|
||||
|
||||
private void inspectClimate(RiverCompiler.Area area) {
|
||||
HydrologySettings.Climate climate = settings.climate();
|
||||
if (!climate.enabled() || climate.dryness() <= 0.0F || climate.dryRainfall() >= 1.0F) {
|
||||
Sourced<Boolean> zones = sourced(area, IrisHydrologyPolicy::getClimateZones);
|
||||
if (!climate.enabled() || zones != null && !zones.value()) {
|
||||
return;
|
||||
}
|
||||
Sourced<Boolean> zones = sourced(area, IrisHydrologyPolicy::getClimateZones);
|
||||
if (zones == null || zones.value()) {
|
||||
boolean zoned = climate.dryness() > 0.0F && climate.dryRainfall() < 1.0F;
|
||||
if (zoned) {
|
||||
add(ExportLimit.RIVER_CLIMATE, hydrology, "", "Wet and dry zones are not exported: rivers start in dry zones as they do in wet ones");
|
||||
}
|
||||
Sourced<IrisHydrologyWetness> wetness = sourced(area, IrisHydrologyPolicy::getWetness);
|
||||
double driest = zoned ? climate.dryRainfall() : 1.0;
|
||||
if (wetness != null && (wetness.value().getMin() > driest || wetness.value().getMax() < 1.0)) {
|
||||
add(ExportLimit.RIVER_CLIMATE, wetness.owner(), "wetness",
|
||||
"Hydrology policy wetness is not exported: rivers form at the dimension density here");
|
||||
}
|
||||
}
|
||||
|
||||
private void inspectShore(RiverCompiler.Area area) {
|
||||
|
||||
Reference in new issue
Block a user