lay rock strata and show them as an overlay
The surface rock matches the save's TopRockIdMap in all but 14 of 11.7 million columns. Rock tiles keep rock indices and take their colours from a palette on upload, so highlighting one rock, to find where it lies, recolours what is drawn instead of regenerating it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -370,14 +370,15 @@
|
||||
(+= value (thresholding (* v (. e amplitude)) (. e threshold) (. e smoothing))))
|
||||
(return value))
|
||||
|
||||
;;; LerpedWeightedIndex2DMap over a region's landform map: each pixel's
|
||||
;;; landforms box-blurred over a radius of 3, as (index, weight) lists.
|
||||
;;; LerpedWeightedIndex2DMap: each pixel's indices (landforms, or
|
||||
;;; geologic provinces) box-blurred over a radius, as (index, weight)
|
||||
;;; lists. Radius 3 at most, so a pixel has at most 49 entries.
|
||||
(define LANDFORM-BLUR 3)
|
||||
|
||||
(pub record landform-weights
|
||||
((size int) (pad int) (counts (* u8)) (indices (* u8)) (weights (* float))))
|
||||
|
||||
(fn landform-weights/make ((m (* const int-map))) landform-weights
|
||||
(pub fn landform-weights/make ((m (* const int-map)) (radius int)) landform-weights
|
||||
(var w landform-weights)
|
||||
(var n int (. m size))
|
||||
(= (. w size) n)
|
||||
@@ -387,10 +388,10 @@
|
||||
(= (. w weights) (malloc (* n n 49 (sizeof float))))
|
||||
(for (var x int 0) (< x n) (++ x)
|
||||
(for (var z int 0) (< z n) (++ z)
|
||||
(var min-x int (if (< (- x LANDFORM-BLUR) 0) 0 (- x LANDFORM-BLUR)))
|
||||
(var min-z int (if (< (- z LANDFORM-BLUR) 0) 0 (- z LANDFORM-BLUR)))
|
||||
(var max-x int (if (> (+ x LANDFORM-BLUR) (- n 1)) (- n 1) (+ x LANDFORM-BLUR)))
|
||||
(var max-z int (if (> (+ z LANDFORM-BLUR) (- n 1)) (- n 1) (+ z LANDFORM-BLUR)))
|
||||
(var min-x int (if (< (- x radius) 0) 0 (- x radius)))
|
||||
(var min-z int (if (< (- z radius) 0) 0 (- z radius)))
|
||||
(var max-x int (if (> (+ x radius) (- n 1)) (- n 1) (+ x radius)))
|
||||
(var max-z int (if (> (+ z radius) (- n 1)) (- n 1) (+ z radius)))
|
||||
(var frac float (/ (cast 1 float) (cast (* (+ (- max-x min-x) 1) (+ (- max-z min-z) 1)) float)))
|
||||
(var cell int (+ (* z n) x))
|
||||
(var base int (* cell 49))
|
||||
@@ -410,7 +411,7 @@
|
||||
(= [(. w counts) cell] (cast count u8))))
|
||||
(return w))
|
||||
|
||||
(fn landform-weights/release ((w (* landform-weights))) void
|
||||
(pub fn landform-weights/release ((w (* landform-weights))) void
|
||||
(free (. w counts))
|
||||
(free (. w indices))
|
||||
(free (. w weights)))
|
||||
@@ -426,7 +427,7 @@
|
||||
|
||||
;;; WeightsAt: the landform weights at landform-map position (x, z)
|
||||
;;; (inner pixels), into OUT of LENGTH entries.
|
||||
(fn landform-weights/at ((w (* const landform-weights)) (x float) (z float) (out (* float))
|
||||
(pub fn landform-weights/at ((w (* const landform-weights)) (x float) (z float) (out (* float))
|
||||
(length int)) void
|
||||
(for (var i int 0) (< i length) (++ i)
|
||||
(= [out i] 0))
|
||||
@@ -562,7 +563,7 @@
|
||||
(worldgen/map (. t g) MAP-LANDFORM 0 rx rz (& (. t landform-map)))
|
||||
(worldgen/map (. t g) MAP-OCEAN 0 rx rz (& (. t ocean-map)))
|
||||
(worldgen/map (. t g) MAP-UPHEAVAL 0 rx rz (& (. t upheaval-map)))
|
||||
(= (. t weights) (landform-weights/make (& (. t landform-map))))
|
||||
(= (. t weights) (landform-weights/make (& (. t landform-map)) LANDFORM-BLUR))
|
||||
(= (. t rx) rx)
|
||||
(= (. t rz) rz)
|
||||
(= (. t has-region) true))
|
||||
|
||||
Reference in New Issue
Block a user