show the generated region maps in the viewer

Tiles are single maps of single regions, generated on worker threads
that each own a worldgen, since the layers keep RNG state. Only the
visible tiles are queued, nearest first, so the viewer never computes
more than the window shows and sleeps once it has drawn it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-10-08 18:24:59 +03:00
parent 63fd30a189
commit 5ad62524f1
10 changed files with 939 additions and 116 deletions

View File

@@ -13,6 +13,7 @@
(import save)
(import dump)
(import worldgen)
(import settings)
(import verify)
(var worldgen-assets [(* const char) 6]
@@ -73,22 +74,18 @@
(cJSON-Delete j))
(return bad))
;;; Generates every region the save stored, with the save's own world
;;; settings, and diffs the maps.
;;; Generates every region the save stored, with the save's own world
;;; settings, and diffs the maps.
(fn verify ((save-path (* const char)) (assets-dir (* const char)) (out (* const char))) int
(var s (* save) (save/open save-path))
(if (! s)
(var source world-source)
(if (! (world-source/load save-path (& source)))
(return 1))
(var settings world-settings (world-settings/defaults))
(= (. settings seed) (. s seed))
(= (. settings size-x) (. s size-x))
(= (. settings size-y) (. s size-y))
(= (. settings size-z) (. s size-z))
(for (var i int 0) (< i (. s config-count)) (++ i)
(.set (& settings) [(. s config-keys) i] [(. s config-values) i]))
(var g (* worldgen) (worldgen/make settings assets-dir))
(var g (* worldgen) (worldgen/make (. source settings) assets-dir))
(if (! g)
(return 1))
(var s (* save) (save/open save-path))
(var failed int (+ (verify-stories s g) (verify-regions s g out)))
(save/close s)
(return failed))