mirror of
https://github.com/VolmitSoftware/Iris.git
synced 2026-11-28 16:54:04 +00:00
Polish surface rivers: estuaries, ponds, erosion, sea caves
Surface rivers gain a drowned inlet at the mouth, a spring pond and an inland terminal pond, a configurable erosion profile (thalweg fraction, blend curve, bed noise, smoothing) and a per-area shore biome width; banks lose freeboard and inset for a single sink. Underground courses accept tributaries, coastal grottos can be admitted as standalone sea caves, and a region or biome can confine the rivers born in it. Tile planning forks its ring work through HydrologyForkJoin. Pack validation, the schema, the probes and the tests follow.
This commit is contained in:
64 files changed
+5619
-622
No files matched your search
@@ -1705,7 +1705,7 @@ public final class HydrologyPackProbe {
|
||||
List<ChannelIncision> incisions = channelIncisions(
|
||||
tile.footprint(),
|
||||
scopedCourseIds,
|
||||
settings.surface().banks().inset(),
|
||||
settings.surface().banks().sink(),
|
||||
settings.surface().maximumIncision()
|
||||
);
|
||||
for (ChannelIncision incision : incisions) {
|
||||
@@ -2698,7 +2698,9 @@ public final class HydrologyPackProbe {
|
||||
int deepCourses,
|
||||
int features,
|
||||
int coveragePairs,
|
||||
long engineReadyNanos
|
||||
long engineReadyNanos,
|
||||
int surfaceJunctions,
|
||||
int undergroundJunctions
|
||||
) {
|
||||
}
|
||||
|
||||
@@ -2896,7 +2898,7 @@ public final class HydrologyPackProbe {
|
||||
Locale.ROOT,
|
||||
"IRIS_HYDROLOGY_PACK_SEED seed=%d hydrology_seed=%d tiles=%d courses=%d "
|
||||
+ "surface_courses=%d underground_courses=%d deep_courses=%d features=%d "
|
||||
+ "pairs=%d engine_ready_ms=%.3f%n",
|
||||
+ "pairs=%d engine_ready_ms=%.3f surface_junctions=%d underground_junctions=%d%n",
|
||||
summary.seed(),
|
||||
summary.hydrologySeed(),
|
||||
summary.tiles(),
|
||||
@@ -2906,7 +2908,9 @@ public final class HydrologyPackProbe {
|
||||
summary.deepCourses(),
|
||||
summary.features(),
|
||||
summary.coveragePairs(),
|
||||
summary.engineReadyNanos() / 1_000_000D
|
||||
summary.engineReadyNanos() / 1_000_000D,
|
||||
summary.surfaceJunctions(),
|
||||
summary.undergroundJunctions()
|
||||
);
|
||||
}
|
||||
shapeMetrics.requireOrganicSurfaceNetwork();
|
||||
@@ -2976,6 +2980,8 @@ public final class HydrologyPackProbe {
|
||||
int undergroundCourses = 0;
|
||||
int deepCourses = 0;
|
||||
int features = 0;
|
||||
int surfaceJunctions = 0;
|
||||
int undergroundJunctions = 0;
|
||||
long hydrologySeed;
|
||||
long engineReadyNanos;
|
||||
Set<CoverageKey> seedCoverage = new HashSet<>();
|
||||
@@ -3008,10 +3014,57 @@ public final class HydrologyPackProbe {
|
||||
shapeMetrics.observe(tile, runtime.settings());
|
||||
List<HydrologyColumnSample> orderedColumns = null;
|
||||
courses += tile.courses().size();
|
||||
List<Junction> tileJunctions = junctions(tile);
|
||||
int tileSurfaceCourses = 0;
|
||||
int tileUndergroundCourses = 0;
|
||||
for (RiverCourse course : tile.courses()) {
|
||||
if (course.type() == RiverCourseType.SURFACE) {
|
||||
tileSurfaceCourses++;
|
||||
} else if (course.type() == RiverCourseType.UNDERGROUND) {
|
||||
tileUndergroundCourses++;
|
||||
}
|
||||
}
|
||||
System.out.printf(
|
||||
Locale.ROOT,
|
||||
"IRIS_HYDROLOGY_PACK_TILE seed=%d tile_x=%d tile_z=%d courses=%d surface_courses=%d "
|
||||
+ "underground_courses=%d junctions=%d%n",
|
||||
seed,
|
||||
tileKey.tileX(),
|
||||
tileKey.tileZ(),
|
||||
tile.courses().size(),
|
||||
tileSurfaceCourses,
|
||||
tileUndergroundCourses,
|
||||
tileJunctions.size()
|
||||
);
|
||||
for (Junction junction : tileJunctions) {
|
||||
if (junction.type() == RiverCourseType.SURFACE) {
|
||||
surfaceJunctions++;
|
||||
} else {
|
||||
undergroundJunctions++;
|
||||
}
|
||||
System.out.printf(
|
||||
Locale.ROOT,
|
||||
"IRIS_HYDROLOGY_PACK_JUNCTION seed=%d tile_x=%d tile_z=%d type=%s x=%d y=%d z=%d "
|
||||
+ "tributary=%016x stem=%016x tributary_stations=%d%n",
|
||||
seed,
|
||||
tileKey.tileX(),
|
||||
tileKey.tileZ(),
|
||||
junction.type().name(),
|
||||
junction.point().x(),
|
||||
junction.point().y(),
|
||||
junction.point().z(),
|
||||
junction.tributaryId(),
|
||||
junction.stemId(),
|
||||
junction.tributaryStations()
|
||||
);
|
||||
}
|
||||
HashMap<Long, String> profilesByCourse = new HashMap<>(tile.courses().size());
|
||||
for (RiverCourse course : tile.courses()) {
|
||||
profilesByCourse.put(course.id(), course.profileKey());
|
||||
observedConfiguredCoverage.add(courseCoverage(course));
|
||||
ConfiguredCoverage courseCoverage = courseCoverage(course);
|
||||
if (courseCoverage != null) {
|
||||
observedConfiguredCoverage.add(courseCoverage);
|
||||
}
|
||||
if (course.type() == RiverCourseType.SURFACE) {
|
||||
surfaceCourses++;
|
||||
} else if (course.type() == RiverCourseType.UNDERGROUND) {
|
||||
@@ -3140,10 +3193,61 @@ public final class HydrologyPackProbe {
|
||||
deepCourses,
|
||||
features,
|
||||
seedCoverage.size(),
|
||||
engineReadyNanos
|
||||
engineReadyNanos,
|
||||
surfaceJunctions,
|
||||
undergroundJunctions
|
||||
));
|
||||
}
|
||||
|
||||
record Junction(
|
||||
RiverCourseType type,
|
||||
HydrologyPoint point,
|
||||
long tributaryId,
|
||||
long stemId,
|
||||
int tributaryStations
|
||||
) {
|
||||
}
|
||||
|
||||
/**
|
||||
* A junction is a course whose last centerline point lies on, or within a channel width of, a
|
||||
* station of another course of the same type: the tributary ends on its stem.
|
||||
*/
|
||||
static List<Junction> junctions(HydrologyTile tile) {
|
||||
ArrayList<Junction> junctions = new ArrayList<>();
|
||||
for (RiverCourse course : tile.courses()) {
|
||||
if (course.segments().isEmpty()) {
|
||||
continue;
|
||||
}
|
||||
HydrologyPoint end = course.segments().getLast().end();
|
||||
int stations = 0;
|
||||
for (HydraulicSegment segment : course.segments()) {
|
||||
stations += segment.centerline().size();
|
||||
}
|
||||
Long stemId = null;
|
||||
double stemDistance = Double.POSITIVE_INFINITY;
|
||||
for (RiverCourse stem : tile.courses()) {
|
||||
if (stem.id() == course.id() || stem.type() != course.type()) {
|
||||
continue;
|
||||
}
|
||||
for (HydraulicSegment segment : stem.segments()) {
|
||||
double reach = segment.width() / 2D + 1D;
|
||||
for (HydrologyPoint point : segment.centerline()) {
|
||||
double distance = point.distanceSquared2D(end);
|
||||
if (distance <= reach * reach && distance < stemDistance) {
|
||||
stemId = stem.id();
|
||||
stemDistance = distance;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (stemId != null) {
|
||||
junctions.add(new Junction(course.type(), end, course.id(), stemId, stations));
|
||||
}
|
||||
}
|
||||
junctions.sort(Comparator.comparingLong(Junction::tributaryId));
|
||||
return List.copyOf(junctions);
|
||||
}
|
||||
|
||||
// No public production equivalent: HydrologyPlanner.routeTurnDegrees is private.
|
||||
static double turnDegrees(HydrologyPoint previous, HydrologyPoint point, HydrologyPoint next) {
|
||||
double incomingX = point.x() - previous.x();
|
||||
@@ -4082,8 +4186,10 @@ public final class HydrologyPackProbe {
|
||||
case UNDERGROUND -> CoverageFamily.UNDERGROUND;
|
||||
case DEEP_FLUID -> CoverageFamily.DEEP;
|
||||
case SURFACE_POOL -> CoverageFamily.POOL;
|
||||
// A sea cave is not a source-budgeted course family; its coverage is the coastal grotto feature.
|
||||
case SEA_CAVE -> null;
|
||||
};
|
||||
return new ConfiguredCoverage(family, course.profileKey());
|
||||
return family == null ? null : new ConfiguredCoverage(family, course.profileKey());
|
||||
}
|
||||
|
||||
private static void validateTileBlockBounds(
|
||||
|
||||
@@ -228,8 +228,10 @@ public final class HydrologyPlannerProbe {
|
||||
0.5D,
|
||||
12D,
|
||||
0.5D,
|
||||
0.1D
|
||||
, 1D, 0),
|
||||
0.1D,
|
||||
1D,
|
||||
0
|
||||
),
|
||||
new HydrologyPlannerSettings.Surface(
|
||||
true,
|
||||
surfaceSources,
|
||||
@@ -253,7 +255,8 @@ public final class HydrologyPlannerProbe {
|
||||
4,
|
||||
5,
|
||||
9,
|
||||
true
|
||||
true,
|
||||
0
|
||||
),
|
||||
new HydrologyPlannerSettings.Outlets(
|
||||
false,
|
||||
@@ -263,10 +266,13 @@ public final class HydrologyPlannerProbe {
|
||||
12,
|
||||
32,
|
||||
2,
|
||||
4,
|
||||
4
|
||||
),
|
||||
HydrologyPlannerSettings.Geometry.defaults(),
|
||||
List.of(), List.of()
|
||||
List.of(), List.of(),
|
||||
0D,
|
||||
HydrologyPlannerSettings.SeaCaves.disabled()
|
||||
);
|
||||
}
|
||||
|
||||
@@ -306,7 +312,9 @@ public final class HydrologyPlannerProbe {
|
||||
"dry",
|
||||
"flooded",
|
||||
List.of("water"), List.of()
|
||||
);
|
||||
,
|
||||
Double.NaN,
|
||||
null);
|
||||
};
|
||||
}
|
||||
|
||||
@@ -357,7 +365,9 @@ public final class HydrologyPlannerProbe {
|
||||
"bank",
|
||||
"flooded",
|
||||
List.of("water"), List.of()
|
||||
);
|
||||
,
|
||||
Double.NaN,
|
||||
null);
|
||||
};
|
||||
}
|
||||
|
||||
@@ -439,8 +449,10 @@ public final class HydrologyPlannerProbe {
|
||||
0.5D,
|
||||
12D,
|
||||
0.5D,
|
||||
0.2D
|
||||
, 1D, 0),
|
||||
0.2D,
|
||||
1D,
|
||||
0
|
||||
),
|
||||
new HydrologyPlannerSettings.Surface(
|
||||
true,
|
||||
surfaceSources,
|
||||
@@ -464,7 +476,8 @@ public final class HydrologyPlannerProbe {
|
||||
5,
|
||||
6,
|
||||
12,
|
||||
true
|
||||
true,
|
||||
0
|
||||
),
|
||||
new HydrologyPlannerSettings.Outlets(
|
||||
true,
|
||||
@@ -474,10 +487,13 @@ public final class HydrologyPlannerProbe {
|
||||
12,
|
||||
48,
|
||||
2,
|
||||
8,
|
||||
8
|
||||
),
|
||||
HydrologyPlannerSettings.Geometry.defaults(),
|
||||
List.of(deepFluid), List.of()
|
||||
List.of(deepFluid), List.of(),
|
||||
0D,
|
||||
HydrologyPlannerSettings.SeaCaves.disabled()
|
||||
);
|
||||
}
|
||||
|
||||
@@ -522,7 +538,9 @@ public final class HydrologyPlannerProbe {
|
||||
"shore",
|
||||
"dry",
|
||||
"flooded",
|
||||
List.of("water"), List.of()
|
||||
List.of("water"), List.of(),
|
||||
Double.NaN,
|
||||
null
|
||||
);
|
||||
};
|
||||
}
|
||||
@@ -556,7 +574,9 @@ public final class HydrologyPlannerProbe {
|
||||
"dry",
|
||||
"flooded",
|
||||
List.of("water"), List.of()
|
||||
);
|
||||
,
|
||||
Double.NaN,
|
||||
null);
|
||||
}
|
||||
|
||||
private static long[] parseSeeds(String[] arguments) {
|
||||
|
||||
@@ -28,6 +28,7 @@ import java.nio.file.Files;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Comparator;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
@@ -179,6 +180,18 @@ public final class RiverTransectProbe {
|
||||
System.out.println(String.format(Locale.ROOT,
|
||||
"%s tile=%d,%d seed=%d courses=%d planMs=%.1f",
|
||||
PREFIX, key.tileX(), key.tileZ(), configuration.seed(), tile.courses().size(), planMillis));
|
||||
for (RiverCourse course : tile.courses()) {
|
||||
if (course.type() != RiverCourseType.SEA_CAVE) {
|
||||
continue;
|
||||
}
|
||||
HydraulicSegment chamber = course.segments().getFirst();
|
||||
System.out.println(String.format(Locale.ROOT,
|
||||
"%s seaCave id=%016x inner=%d,%d,%d mouth=%d,%d,%d cavePlan=%s",
|
||||
PREFIX, course.id(),
|
||||
chamber.start().x(), chamber.start().y(), chamber.start().z(),
|
||||
chamber.end().x(), chamber.end().y(), chamber.end().z(),
|
||||
tile.cavePlan(course.id()).map((plan) -> plan.accepted() ? "accepted" : "rejected").orElse("none")));
|
||||
}
|
||||
|
||||
for (String line : rejectionLines(tile)) {
|
||||
System.out.println(PREFIX + " " + line);
|
||||
@@ -457,8 +470,28 @@ public final class RiverTransectProbe {
|
||||
line(image, (from.naturalPoint().x() - minimumX) / scale, (from.naturalPoint().z() - minimumZ) / scale,
|
||||
(to.naturalPoint().x() - minimumX) / scale, (to.naturalPoint().z() - minimumZ) / scale, 0x20C020);
|
||||
}
|
||||
// Sea-cave chambers: every column the chamber owns in dark blue, so the cave shows on the coast with
|
||||
// its open side to the sea; the centerline on top in white like a surface course.
|
||||
HashSet<Long> seaCaveIds = new HashSet<>();
|
||||
for (RiverCourse course : tile.courses()) {
|
||||
int rgb = course.type() == RiverCourseType.SURFACE ? 0xFFFFFF : 0xFF00FF;
|
||||
if (course.type() == RiverCourseType.SEA_CAVE) {
|
||||
seaCaveIds.add(course.id());
|
||||
}
|
||||
}
|
||||
if (!seaCaveIds.isEmpty()) {
|
||||
for (HydrologyColumnSample column : tile.footprint().columns().values()) {
|
||||
for (HydrologyColumnLayer layer : column.layers()) {
|
||||
if (seaCaveIds.contains(layer.feature().courseId()) && layer.terrainOwned() && layer.channel()) {
|
||||
plot(image, (column.x() - minimumX) / scale, (column.z() - minimumZ) / scale, 0x000080, 0);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
for (RiverCourse course : tile.courses()) {
|
||||
int rgb = course.type() == RiverCourseType.SURFACE || course.type() == RiverCourseType.SEA_CAVE
|
||||
? 0xFFFFFF
|
||||
: 0xFF00FF;
|
||||
for (HydraulicSegment segment : course.segments()) {
|
||||
for (HydrologyPoint point : segment.centerline()) {
|
||||
plot(image, (point.x() - minimumX) / scale, (point.z() - minimumZ) / scale, rgb, 1);
|
||||
|
||||
Reference in new issue
Block a user