lay out rivers as the Rivers mod does

Every stored riverDistance column matches. Plates are built from 25
ocean samples per zone rather than a region map per zone, and the
ocean distance from a ring search that finds what the mod's BFS does,
so a plate costs 0.08 s; workers cache a few, as a wide view spans
several.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-10-08 18:40:53 +03:00
parent 5ad62524f1
commit 517d279c8d
10 changed files with 1257 additions and 38 deletions

View File

@@ -372,17 +372,41 @@ nothing here uses.
Deferred: the river config section moves to phase 4, where there is
something to configure.
** 4. Rivers layout
- Port =fastnoise= (OpenSimplex2 2D FBm) and =rivers=:
- zone ocean flags;
- distance to ocean;
- river tree, with the exact RNG call order;
- chunk segment sets;
- =SampleRiver=.
- =vsmv verify-rivers= compares per-column =riverDistance= against the
saved moddata in every stored map chunk.
- Viewer: river layer (segments plus the =riverDistance= field), computed
per plate in the background.
** 4. Rivers layout (done)
=src/rivers.sex= and =src/fastnoise.sex= port Rivers 5.0.3's layout
and its per-column sampler. =vsmv verify= now also recomputes
=riverDistance= for every stored map chunk:
- *6,558,720 / 6,558,720* columns match where Rivers stored the
moddata.
- *5,009 / 5,009* chunks without it rightly have no river within 300
blocks.
How the port works:
- *Ocean test.* The ocean test per zone is one blurred ocean pixel at
the zone centre's chunk: 25 raw samples instead of the mod's whole
region map per zone. =ocean-layer.blurred-at= computes it.
- *Ocean distance.* An expanding-ring search returns exactly what the
mod's pruned BFS finds, the Euclidean distance to the nearest ocean
zone.
- *Generation.* A FIFO queue and an LCG with the mod's call order.
=FindHighestZone='s stable sort is kept, ties to the first neighbour
in x-then-z order.
- *NaN directions.* .NET 10 converts NaN to int 0, saturating, and
=saturating-int= mirrors it. A NaN direction arises when the uphill
target is the start zone.
- *Speed.* A plate takes about 0.08 s.
- *Chunk lookups.* Segment lookups per chunk go through a 64 x 64 grid
over the plate.
Viewer:
- *Rivers layer.* Water, valley distance and Rivers' ocean zones. The
sample density follows the zoom: 64, 32 or 16 samples per region
side.
- *Plate cache.* Each worker keeps its last four plates. With one,
workers rebuilt plates constantly and the overview took 19 s; with
four, 0.7 s.
- *Hover info.* River distance and bank depth.
- *World panel.* A rivers config path; empty means the mod's defaults.
** 5. Terrain height
- Port =NewGenTerra='s per-column path: