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

@@ -455,7 +455,24 @@
(if (&& (== v 255) forced-land (.has (& (. self require-land)) nx nz))
(= v 0))
(= [out (+ (* z size-x) x)] v)))
(box-blur out size-x size-z 5)))
(box-blur out size-x size-z 5))
;; One pixel of the blurred map, without forced land: what Rivers
;; samples per zone. Away from a window's edge every 5 x 5 box is
;; full, so this matches a pixel of `gen' for any window holding it.
(pub fn blurred-at ((self (* ocean-layer)) (px int) (pz int)) int
(var sum int 0)
(for (var dz int -2) (<= dz 2) (++ dz)
(var row int 0)
(for (var dx int -2) (<= dx 2) (++ dx)
(var nx int (+ px dx))
(var nz int (+ pz dz))
(var ox int (cast (* (. self wobble) (.noise-2d (. self wobble-x) nx nz)) int))
(var oz int (cast (* (. self wobble) (.noise-2d (. self wobble-z) nx nz)) int))
(+= row (.index-at self (+ nx ox) (+ nz oz))))
;; values are 0 or 255, only in the low byte
(+= sum (/ row 5)))
(return (/ sum 5))))
;;; GenMaps.ForceRandomLandArea: a natural blob of forced land covering
;;; RADIUS blocks around (x, z), in ocean map pixels.