rework the viewer around base layers, overlays and side panels

One base layer is drawn opaque and any number of overlays over it, so
rocks can be looked for on top of the terrain rather than instead of
it. Settings and rock finding live in fixed panels beside the map, not
in windows over it. What is under the cursor is worked out on a thread
of its own, since computing it per frame stalled the window.

Find nearest searches regions outward from the view's centre and stops
once no nearer region is left; probes leave pins.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-10-08 20:39:29 +03:00
parent 4666188b21
commit e412274837
7 changed files with 1065 additions and 247 deletions

View File

@@ -647,10 +647,11 @@
(= [out 0] (* dx force))
(= [out 1] (* dz force)))
;;; Heights of the columns of chunk (cx, cz) whose local x and z are
;;; multiples of STEP, into HEIGHTS[lz * 32 + lx]; the rest are left
;;; alone. A height is the top solid block, 0 if there is none.
(pub fn terra/chunk-heights ((t (* terra)) (cx int) (cz int) (step int) (heights (* u16))) void
;;; A height is the top solid block, 0 if there is none.
;;; Heights of the columns of chunk (cx, cz) from local (lx0, lz0) to
;;; (lx1, lz1) inclusive, every STEP-th, into HEIGHTS[lz * 32 + lx].
(fn heights-in ((t (* terra)) (cx int) (cz int) (lx0 int) (lz0 int) (lx1 int) (lz1 int)
(step int) (heights (* u16))) void
(use-region t (/ cx 16) (/ cz 16))
(var per-plate int (river-plate/chunks (& (. t config))))
(var plate (* river-plate) (use-plate t (/ cx per-plate) (/ cz per-plate)))
@@ -686,8 +687,8 @@
(var ths [double 16])
(var c (* river-config) (& (. t config)))
(for (var lz int 0) (< lz 32) (+= lz step)
(for (var lx int 0) (< lx 32) (+= lx step)
(for (var lz int lz0) (<= lz lz1) (+= lz step)
(for (var lx int lx0) (<= lx lx1) (+= lx step)
(var wx int (+ (* cx 32) lx))
(var wz int (+ (* cz 32) lz))
(var sample river-sample (river-sampler/sample (& (. t sampler)) plate (. t segments)
@@ -785,3 +786,18 @@
(if solid (= height y)))
(= [heights (+ (* lz 32) lx)] (cast height u16))))
(free w))
;;; Heights of the columns of chunk (cx, cz) whose local x and z are
;;; multiples of STEP, into HEIGHTS[lz * 32 + lx]; the rest are left
;;; alone.
(pub fn terra/chunk-heights ((t (* terra)) (cx int) (cz int) (step int) (heights (* u16))) void
(heights-in t cx cz 0 0 31 31 step heights))
;;; The height of the one column at block (x, z): 1/1024th of a chunk's
;;; work, for a cursor or a probe.
(pub fn terra/column-height ((t (* terra)) (x int) (z int)) int
(var heights [u16 1024])
(var lx int (% x 32))
(var lz int (% z 32))
(heights-in t (/ x 32) (/ z 32) lx lz lx lz 1 heights)
(return [heights (+ (* lz 32) lx)]))