mirror of
https://github.com/VolmitSoftware/Iris.git
synced 2026-10-27 06:20:02 +00:00
Prefer longer routes when ranking river sources
routing.lengthPreference adds route length to the source score so outlets take their longest legal course.
This commit is contained in:
1 parent
6945cbfd9b
commit
4b497a7d20
13 files changed
+28
-17
No files matched your search
@@ -278,6 +278,7 @@ final class PackHydrologyValidator {
|
||||
PackJsonFieldChecks.validateOptionalDoubleRange(path, routing, "uphillPenalty", 0D, 128D, errors);
|
||||
PackJsonFieldChecks.validateOptionalDoubleRange(path, routing, "slopePenalty", 0D, 16D, errors);
|
||||
PackJsonFieldChecks.validateOptionalDoubleRange(path, routing, "confluenceAttraction", 0D, 1D, errors);
|
||||
PackJsonFieldChecks.validateOptionalDoubleRange(path, routing, "lengthPreference", 0D, 8D, errors);
|
||||
|
||||
int tileSize = integerValue(routing, "tileSize", 2048);
|
||||
int sampleSpacing = integerValue(routing, "sampleSpacing", 64);
|
||||
|
||||
@@ -2113,9 +2113,10 @@ public final class HydrologyPlanner {
|
||||
addSourceDiagnostic(node, surface, stable, HydrologyCandidateRejection.COURSE_TOO_SHORT, diagnostics);
|
||||
continue;
|
||||
}
|
||||
// Elevation and route length share the same scale: 1000 route blocks count as 100 blocks of height.
|
||||
double score = (required ? 1.0E15D : 0D)
|
||||
+ weight * 1.0E9D
|
||||
+ terrain.naturalHeight() * 1.0E5D
|
||||
+ (terrain.naturalHeight() + routeLength * 0.1D * settings.routing().lengthPreference()) * 1.0E5D
|
||||
+ routing.potential()[node.index()]
|
||||
+ HydrologyHash.unit(stable);
|
||||
candidates.add(new SourceCandidate(node.index(), stable, score, required));
|
||||
|
||||
@@ -35,7 +35,7 @@ public record HydrologyPlannerSettings(
|
||||
Source undergroundSources = new Source(true, 0.25D, Integer.MIN_VALUE, 0, 1, 512);
|
||||
return new HydrologyPlannerSettings(
|
||||
63,
|
||||
new Routing(2048, 64, 8192, 8192, 384, 192, 1.5D, 24D, 2D, 0.2D),
|
||||
new Routing(2048, 64, 8192, 8192, 384, 192, 1.5D, 24D, 2D, 0.2D, 1D),
|
||||
new Surface(true, surfaceSources, 4, 8, 2, 4, 10, 1.5D, Banks.defaults()),
|
||||
new Hydraulics(8),
|
||||
new Underground(true, undergroundSources, -48, 72, 3, 8, 1, 3, 6, 14, true),
|
||||
@@ -151,7 +151,8 @@ public record HydrologyPlannerSettings(
|
||||
double valleyPreference,
|
||||
double uphillPenalty,
|
||||
double slopePenalty,
|
||||
double confluenceAttraction
|
||||
double confluenceAttraction,
|
||||
double lengthPreference
|
||||
) {
|
||||
public Routing {
|
||||
if (tileSize < 32 || sampleSpacing < 4 || tileSize % sampleSpacing != 0) {
|
||||
@@ -177,6 +178,7 @@ public record HydrologyPlannerSettings(
|
||||
requireFiniteNonNegative(uphillPenalty, "uphillPenalty");
|
||||
requireFiniteNonNegative(slopePenalty, "slopePenalty");
|
||||
requireFiniteNonNegative(confluenceAttraction, "confluenceAttraction");
|
||||
requireFiniteNonNegative(lengthPreference, "lengthPreference");
|
||||
}
|
||||
|
||||
// Route refinement is derived from the lattice, never authored.
|
||||
|
||||
+2
-1
@@ -671,7 +671,8 @@ public final class IrisHydrologyRuntime implements AutoCloseable {
|
||||
routing.getValleyPreference(),
|
||||
routing.getUphillPenalty(),
|
||||
routing.getSlopePenalty(),
|
||||
routing.getConfluenceAttraction()
|
||||
routing.getConfluenceAttraction(),
|
||||
routing.getLengthPreference()
|
||||
);
|
||||
HydrologyPlannerSettings.Source plannerSurfaceSources = new HydrologyPlannerSettings.Source(
|
||||
surfaceEnabled,
|
||||
|
||||
@@ -70,4 +70,9 @@ public class IrisRiverRoutingConfig {
|
||||
@MaxNumber(1)
|
||||
@Desc("How strongly routes are drawn toward existing drainage.")
|
||||
private double confluenceAttraction = 0.2D;
|
||||
|
||||
@MinNumber(0)
|
||||
@MaxNumber(8)
|
||||
@Desc("How strongly longer source-to-outlet routes are preferred when choosing river sources; 0 ranks by elevation alone.")
|
||||
private double lengthPreference = 1D;
|
||||
}
|
||||
Reference in new issue
Block a user