find one rock at any depth

A new rock mode looks for the one highlighted rock anywhere between the
surface and the mantle: the overlay shows the columns that hold it, the
cursor label how deep it starts, and Find nearest the nearest such
column. It can be chosen only while one rock is highlighted, and while
it is on, clicking a rock in the legend highlights that one instead.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-10-08 21:35:24 +03:00
parent df0b8d815a
commit 75d734c2d6
5 changed files with 94 additions and 24 deletions

View File

@@ -29,7 +29,9 @@
((valid bool) (query hover-query)
(height int) (sea-level int)
;; rock index at the query's surface, depth or Y; -1 when the block
;; there is water or air, -2 below the mantle
;; there is water or air, -2 below the mantle. At any depth (mode
;; 3, the value a rock index), that rock and the Y of its topmost
;; block, or -3 when the column has none of it.
(rock int) (rock-y int) (surface-rock int)
(landform int) (province int) (climate int) (ocean int) (upheaval int)
(river-distance double) (bank double)))
@@ -108,6 +110,17 @@
(= (. r sea-level) (. (. k tr) sea-level))
(strata/column (. k rocks) (/ x 32) (/ z 32) (% x 32) (% z 32) h (. k column))
(= (. r surface-rock) [(. k column) h])
(if (== (. q mode) 3)
(do
(= (. r rock) -3)
(for (var y int h) (>= y 1) (-- y)
(if (== [(. k column) y] (. q value))
(do
(= (. r rock) (. q value))
(= (. r rock-y) y)
(break))))
(= (. r valid) true)
(return)))
(var y int h)
(if (== (. q mode) 1) (= y (- h (. q value)))
(== (. q mode) 2) (= y (. q value)))