diff --git a/Makefile b/Makefile index 2818ada..33b05c8 100644 --- a/Makefile +++ b/Makefile @@ -32,12 +32,12 @@ $(B)/cJSON.o: cJSON/cJSON.c cJSON/cJSON.h | $(B) $(B)/stb.o: src/stb.c third_party/stb/stb_image_write.h | $(B) $(CC) $(CFLAGS) $(CPPFLAGS) -c $< -o $@ -VSMV_OBJ = vsmv cs pb json maps save img dump lcg noise shape worldgen fastnoise rivers terra settings verify cJSON stb +VSMV_OBJ = vsmv cs pb json maps save img dump lcg noise shape worldgen fastnoise rivers terra strata settings verify cJSON stb $(B)/vsmv: $(VSMV_OBJ:%=$(B)/%.o) $(CC) $^ -o $@ -lsqlite3 -VIEWER_OBJ = viewer tiles settings worldgen fastnoise rivers terra shape noise lcg maps save pb json cs nk cJSON stb +VIEWER_OBJ = viewer tiles settings worldgen fastnoise rivers terra strata shape noise lcg maps save pb json cs nk cJSON stb $(B)/vs-map-viewer: $(VIEWER_OBJ:%=$(B)/%.o) $(CC) $^ -o $@ $(SDL_LIBS) -lsqlite3 diff --git a/Plan.org b/Plan.org index 1b5e4a4..fe0b2be 100644 --- a/Plan.org +++ b/Plan.org @@ -446,19 +446,44 @@ Viewer: about 11 us. - *Hover info.* Shows the height. -** 6. Rock strata + overlay -- Port =GenRockStrataNew.genBlockColumn=: - - province weights (lerped, radius 2) → per-group thickness budget; - - distortion noises; - - BottomUp/TopDown fill and the sedimentary thinning. -- Queries: rock at the surface, at depth /d/, at absolute Y, and the full - column. -- Validation: surface rock against =TopRockIdMap= (if stored). Decode - =chunk= blobs for full columns only if that isn't enough. -- Viewer: - - rock overlay with a mode switch (surface / depth / Y) and a slider; - - legend with per-rock highlight; - - click probe that shows the strata stack (rock, Y range, thickness). +** 6. Rock strata + overlay (done) +=src/strata.sex= ports =GenRockStrataNew.genBlockColumn=: +- *Budget.* Rock-group thickness budgets come from the geologic + provinces, blended by =LerpedWeightedIndex2DMap= with radius 2. +- *Distortion.* A thickness distortion seeded from the sea level. +- *Fill.* Strata are laid in =rockstrata.json= order, from the bottom + or the top, against their thickness maps. Sedimentary strata thin + above sea level; granite only consumes budget. +- *Missing groups.* A province that leaves out a group has a maximum + of 0 for it, not the class default of 99. + +Validation: +- *Surface rock.* =vsmv verify= compares our rock at the top solid + block with the save's =TopRockIdMap=. That block is + =min(stored, computed)= height, since caves lower the stored top. +- *Result.* 11,675,804 / 11,675,818 columns match, 99.9999%. The 14 + others likely carry structures placed later. A further 12,118 + columns have no rock on top. +- *Deeper layers* go through the same code but aren't checked against + chunk blocks. Decoding those blobs is the remaining step, if it is + ever needed. + +Viewer: +- *Rock layer.* Modes: surface, depth below the surface, or absolute + Y (water or air above the surface). +- *Legend.* Click a rock to grey out all others. That's the "find a + stratum" view: chalk at 20 blocks down across the whole world length + takes one click. +- *Palette tiles.* Rock tiles keep per-sample rock indices and are + coloured on upload, so changing the highlight re-uploads drawn tiles + without recomputing them. +- *Probe.* A click (without dragging) opens a Probe window with the + column's strata, top down, with Y ranges and thicknesses. +- *Hover info.* Shows the surface rock. +- *Command line.* =--rock-depth=, =--rock-y=, =--highlight= and + =--probe= set it all up for screenshots. +- *Tile keys.* Now injective bit fields. The old =map * 64 + stratum= + packing could alias once resolutions passed 64. ** 7. Performance + polish - Level of detail: diff --git a/src/strata.sex b/src/strata.sex new file mode 100644 index 0000000..566f2d1 --- /dev/null +++ b/src/strata.sex @@ -0,0 +1,241 @@ +;;; Rock strata of a column, as GenRockStrataNew lays them: given the +;;; column's surface height, which rock each block from y = 1 up to the +;;; surface is. Everything starts as granite; strata are laid bottom-up +;;; or top-down in rockstrata.json order, each as thick as its map +;;; allows and its rock group's budget in the local geologic provinces +;;; leaves. +;;; +;;; The result does not know where the column is air or water below the +;;; surface (overhangs, riverbeds): it is what the block there would be +;;; if it were rock, as the game's prospecting assumes too. + +(include stdio.h stdlib.h string.h math.h) +(import maps) +(import lcg) +(import noise) +(import shape) +(import json) +(import worldgen) +(import fastnoise) +(import rivers) +(import terra) + +(pub define MAX-ROCKS 32) +;;; A column entry below any rock: the mantle at y = 0. +(pub define ROCK-MANTLE 255) +(define PROVINCE-BLUR 2) + +(pub record strata + ((variant-count int) (variant-rock [int 32]) (variant-group [int 32]) + (variant-top-down [bool 32]) + ;; distinct rock codes; `granite' is the default rock's index + (rock-codes [* char 32]) (rock-count int) (granite int) + (province-count int) (province-max [float 128]) + (distort-x (* simplex-sum)) (distort-z (* simplex-sum)) (sea-level int) + (g (* worldgen)) + ;; the region last asked for + (rx int) (rz int) (has-region bool) (province-map int-map) (provinces landform-weights) + (maps [int-map 32]))) + +(var group-names [(* const char) 4] #("Sedimentary" "Metamorphic" "Igneous" "Volcanic")) + +(fn rock-index ((s (* strata)) (code (* const char))) int + (for (var i int 0) (< i (. s rock-count)) (++ i) + (if (== (strcmp [(. s rock-codes) i] code) 0) + (return i))) + (= [(. s rock-codes) (. s rock-count)] (strdup code)) + (++ (. s rock-count)) + (return (- (. s rock-count) 1))) + +(pub fn strata/make ((g (* worldgen)) (assets-dir (* const char))) (* strata) + (var path [char 1024]) + (snprintf path (sizeof path) "%s/survival/worldgen/rockstrata.json" assets-dir) + (var rockstrata (* cJSON) (json-load path)) + (snprintf path (sizeof path) "%s/survival/worldgen/geologicprovinces.json" assets-dir) + (var provinces (* cJSON) (json-load path)) + (snprintf path (sizeof path) "%s/survival/worldgen/global.json" assets-dir) + (var global (* cJSON) (json-load path)) + (if (|| (! rockstrata) (! provinces)) + (return NULL)) + (var s (* strata) (calloc 1 (sizeof strata))) + (= (. s g) g) + (var default-rock (* const char) "rock-granite") + (if (&& global (cJSON-GetStringValue (cJSON-GetObjectItem global "defaultRockCode"))) + (= default-rock (cJSON-GetStringValue (cJSON-GetObjectItem global "defaultRockCode")))) + (= (. s granite) (rock-index s default-rock)) + + (var variants (* cJSON) (cJSON-GetObjectItem rockstrata "variants")) + (for (var v (* cJSON) (. variants child)) (&& v (< (. s variant-count) MAX-STRATA)) (= v (. v next)) + (var i int (. s variant-count)) + (= [(. s variant-rock) i] + (rock-index s (cJSON-GetStringValue (cJSON-GetObjectItem v "blockcode")))) + (var group (* const char) (cJSON-GetStringValue (cJSON-GetObjectItem v "rockGroup"))) + (= [(. s variant-group) i] 0) + (for (var k int 0) (< k 4) (++ k) + (if (&& group (== (strcasecmp group [group-names k]) 0)) + (= [(. s variant-group) i] k))) + (var dir (* const char) (cJSON-GetStringValue (cJSON-GetObjectItem v "genDir"))) + (= [(. s variant-top-down) i] (&& dir (== (strcasecmp dir "TopDown") 0))) + (++ (. s variant-count))) + + ;; GeologicProvinceVariant.init: a group the province leaves out has + ;; a scaled maximum of 0, not the class default's 99. + (var mul float (/ (cast (. g settings size-y) float) (cast 256 float))) + (var pv (* cJSON) (cJSON-GetObjectItem provinces "variants")) + (for (var v (* cJSON) (. pv child)) (&& v (< (. s province-count) 32)) (= v (. v next)) + (var groups (* cJSON) (cJSON-GetObjectItem v "rockstrata")) + (for (var k int 0) (< k 4) (++ k) + (var entry (* cJSON) (cJSON-GetObjectItemCaseSensitive groups [group-names k])) + (var scaled float 0) + (if entry + (do + (var mt (* cJSON) (cJSON-GetObjectItem entry "maxThickness")) + (var max float (if (cJSON-IsNumber mt) (cast (cJSON-GetNumberValue mt) float) 99)) + (= scaled (* mul max)))) + (= [(. s province-max) (+ (* (. s province-count) 4) k)] scaled)) + (++ (. s province-count))) + + (= (. s sea-level) (cast (* 0.4313725490196078 (. g settings size-y)) int)) + (var amps [double 4] #(14 9 6 3)) + (var freqs [double 4]) + (= [freqs 0] (/ 1 100.0)) + (= [freqs 1] (/ 1 50.0)) + (= [freqs 2] (/ 1 25.0)) + (= [freqs 3] (/ 1 12.5)) + ;; seeded from the sea level, not the world seed + (= (. s distort-x) (simplex-sum/make amps freqs 4 (+ (. s sea-level) 9876))) + (= (. s distort-z) (simplex-sum/make amps freqs 4 (+ (. s sea-level) 9877))) + (cJSON-Delete rockstrata) + (cJSON-Delete provinces) + (if global (cJSON-Delete global)) + (return s)) + +(fn release-region ((s (* strata))) void + (if (! (. s has-region)) + (return)) + (free (. s province-map data)) + (landform-weights/release (& (. s provinces))) + (for (var i int 0) (< i (. s variant-count)) (++ i) + (free (. [(. s maps) i] data))) + (= (. s has-region) false)) + +(pub fn strata/free ((s (* strata))) void + (release-region s) + (for (var i int 0) (< i (. s rock-count)) (++ i) + (free [(. s rock-codes) i])) + (free (. s distort-x)) + (free (. s distort-z)) + (free s)) + +(fn use-region ((s (* strata)) (rx int) (rz int)) void + (if (&& (. s has-region) (== (. s rx) rx) (== (. s rz) rz)) + (return)) + (release-region s) + (worldgen/map (. s g) MAP-PROVINCE 0 rx rz (& (. s province-map))) + (= (. s provinces) (landform-weights/make (& (. s province-map)) PROVINCE-BLUR)) + (for (var i int 0) (< i (. s variant-count)) (++ i) + (worldgen/map (. s g) MAP-STRATA i rx rz (& [(. s maps) i]))) + (= (. s rx) rx) + (= (. s rz) rz) + (= (. s has-region) true)) + +;;; IntDataMap2D.GetIntLerpedCorrectly. +(fn lerped-correctly ((m (* const int-map)) (x float) (z float)) float + (var half float 0.5) + (var xl int (cast (floor (cast (- x half) double)) int)) + (var zl int (cast (floor (cast (- z half) double)) int)) + (var fx float (- x (+ (cast xl float) half))) + (var fz float (- z (+ (cast zl float) half))) + (var i int (+ (* (+ zl (. m pad-tl)) (. m size)) xl (. m pad-tl))) + (var tl float (cast [(. m data) i] float)) + (var tr float (cast [(. m data) (+ i 1)] float)) + (var bl float (cast [(. m data) (+ i (. m size))] float)) + (var br float (cast [(. m data) (+ i (. m size) 1)] float)) + (var top float (+ tl (* (- tr tl) fx))) + (var bot float (+ bl (* (- br bl) fx))) + (return (+ top (* (- bot top) fz)))) + +;;; GenRockStrataNew.genBlockColumn for block column (cx * 32 + lx, +;;; cz * 32 + lz) with surface at SURFACE: OUT[y] is the rock index of +;;; y = 0..surface, ROCK-MANTLE at 0. +(pub fn strata/column ((s (* strata)) (cx int) (cz int) (lx int) (lz int) (surface int) + (out (* u8))) void + (use-region s (/ cx 16) (/ cz 16)) + (var rdx int (% cx 16)) + (var rdz int (% cz 16)) + (var inv float (/ (cast 1 float) (cast 64 float))) + (var in-region-x float (* (* (cast rdx float) inv) (cast 32 float))) + (var in-region-z float (* (* (cast rdz float) inv) (cast 32 float))) + + (var weights [float 32]) + (landform-weights/at (& (. s provinces)) (+ in-region-x (* (cast lx float) inv)) + (+ in-region-z (* (cast lz float) inv)) weights (. s province-count)) + (var max [float 4] #(0 0 0 0)) + (var current [int 4] #(0 0 0 0)) + (for (var i int 0) (< i (. s province-count)) (++ i) + (var w float [weights i]) + (if (== w 0) + (continue)) + (for (var k int 0) (< k 4) (++ k) + (+= [max k] (* [(. s province-max) (+ (* i 4) k)] w)))) + + (var wx int (+ (* cx 32) lx)) + (var wz int (+ (* cz 32) lz)) + (var dx float (cast (.noise-2d (. s distort-x) wx wz) float)) + (var dz float (cast (.noise-2d (. s distort-z) wx wz) float)) + (var distort float (/ (+ dx dz) (cast 30 float))) + (if (< distort (cast 0.9 float)) (= distort (cast 0.9 float))) + (if (> distort (cast 1.1 float)) (= distort (cast 1.1 float))) + + (= [out 0] ROCK-MANTLE) + (for (var y int 1) (<= y surface) (++ y) + (= [out y] (cast (. s granite) u8))) + + (var lower int 1) + (var upper int surface) + (var id int -1) + (var group int 0) + (var thickness float 0) + (var rock int (. s granite)) + (var top-down bool false) + (while (<= lower upper) + (-= thickness 1) + (if (<= thickness (cast 0 float)) + (do + (++ id) + (if (>= id (. s variant-count)) + (break)) + (var m (* int-map) (& [(. s maps) id])) + (var step float (/ (cast (- (. m size) (. m pad-tl) (. m pad-br)) float) (cast 16 float))) + (= group [(. s variant-group) id]) + (= rock [(. s variant-rock) id]) + (= top-down [(. s variant-top-down) id]) + (var allowed float (- (* [max group] distort) (cast [current group] float))) + (var nx float (+ (* (cast rdx float) step) + (/ (* step (cast (+ (cast lx float) dx) float)) (cast 32 float)))) + (var nz float (+ (* (cast rdz float) step) + (/ (* step (cast (+ (cast lz float) dz) float)) (cast 32 float)))) + (if (< nx (cast -1.499 float)) (= nx (cast -1.499 float))) + (if (< nz (cast -1.499 float)) (= nz (cast -1.499 float))) + (= thickness (fminf allowed (lerped-correctly m nx nz))) + (if (== group 0) + (do + (var above int (- upper (. s sea-level))) + (if (< above 0) (= above 0)) + (-= thickness (* (cast above float) (cast 0.5 float))))) + (if (< thickness (cast 2 float)) + (do (= thickness -1) (continue))) + (if (== rock (. s granite)) + (do + (var t int (cast thickness int)) + (+= [current group] t) + (if top-down (-= upper t) (+= lower t)) + (continue))))) + (++ [current group]) + (if top-down + (do + (if (== [out upper] (. s granite)) (= [out upper] (cast rock u8))) + (-- upper)) + (do + (if (== [out lower] (. s granite)) (= [out lower] (cast rock u8))) + (++ lower))))) diff --git a/src/terra.sex b/src/terra.sex index 4c2db71..93a5c7b 100644 --- a/src/terra.sex +++ b/src/terra.sex @@ -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)) diff --git a/src/tiles.sex b/src/tiles.sex index 2699258..7828f80 100644 --- a/src/tiles.sex +++ b/src/tiles.sex @@ -22,12 +22,20 @@ (import fastnoise) (import rivers) (import terra) +(import strata) (pub define MAX-TILES 16384) -;;; Not worldgen maps: Rivers' distance to the nearest river, and the -;;; terrain height. +;;; Not worldgen maps: Rivers' distance to the nearest river, the +;;; terrain height, and the rock at the surface, at a depth or at a Y. (pub define LAYER-RIVERS 6) (pub define LAYER-HEIGHT 7) +(pub define LAYER-ROCK 8) +(pub define ROCK-AT-SURFACE 0) +(pub define ROCK-AT-DEPTH 1) +(pub define ROCK-AT-Y 2) +;;; Rock tile values besides rock indices. +(pub define VALUE-WATER 253) +(pub define VALUE-AIR 254) ;;; River tiles are sampled at a resolution the viewer picks by zoom, ;;; in the key's `stratum': a column costs too much to sample them all ;;; for an overview. @@ -39,10 +47,14 @@ (define TILE-READY 3) (define TILE-DRAWN 4) -(pub record tile-key ((map int) (stratum int) (rx int) (rz int))) +;;; STRATUM is the stratum for MAP-STRATA, the samples per region side +;;; for the sampled layers; PARAM is the rock layer's mode * 1024 + value. +(pub record tile-key ((map int) (stratum int) (rx int) (rz int) (param int))) +;;; Rock tiles keep their VALUES, rock indices, and are coloured from +;;; the palette on upload, so a new palette only re-uploads them. (pub record tile - ((key tile-key) (state int) (generation int) (size int) (pixels (* u32)) + ((key tile-key) (state int) (generation int) (size int) (pixels (* u32)) (values (* u8)) (texture (* SDL-Texture)) (last-used u64))) (pub record tiles @@ -51,13 +63,17 @@ (queue [int MAX_TILES]) (queue-len int) (queue-pos int) (free-slots [int MAX_TILES]) (free-count int) (settings world-settings) (rivers river-config) (assets-dir [char 1024]) (generation int) - (workers [pthread-t 32]) (worker-count int) (quit bool) (frame u64) (waiting int))) + (workers [pthread-t 32]) (worker-count int) (quit bool) (frame u64) (waiting int) + (palette [u32 256]))) (fn key-hash ((k tile-key)) u64 - ;; region x and z fit 21 bits each; map and stratum the rest - (return (c-bit-or (cast (& (. k rx) 2097151) u64) - (<< (cast (& (. k rz) 2097151) u64) 21) - (<< (cast (+ (* (. k map) 64) (. k stratum)) u64) 42)))) + ;; one-to-one: region x and z 16 bits each, map 4, stratum or + ;; resolution 10, param 18 + (return (c-bit-or (cast (& (. k rx) 65535) u64) + (<< (cast (& (. k rz) 65535) u64) 16) + (<< (cast (& (. k map) 15) u64) 32) + (<< (cast (& (. k stratum) 1023) u64) 36) + (<< (cast (& (. k param) 262143) u64) 46)))) ;;; The tile index is a cell-map keyed by (x, z): the hash is split ;;; over the two halves. @@ -236,6 +252,43 @@ (= (* size) res) (return px)) +;;; The rock tile: per sample, the rock at the surface, at a depth +;;; below it, or at an absolute Y (water or air above the surface). +(fn render-rocks ((tr (* terra)) (rocks (* strata)) (k tile-key) (size (* int))) (* u8) + (var res int (. k stratum)) + (var step int (/ 512 res)) + (var mode int (/ (. k param) 1024)) + (var value int (% (. k param) 1024)) + (var out (* u8) (malloc (* res res))) + (var heights [u16 1024]) + (var column (* u8) (malloc (+ (. tr size-y) 1))) + (var per-chunk int (/ 32 step)) + (if (< per-chunk 1) (= per-chunk 1)) + (for (var cz int 0) (< cz 16) (++ cz) + (for (var cx int 0) (< cx 16) (++ cx) + (if (|| (!= (% (* cx 32) step) 0) (!= (% (* cz 32) step) 0)) + (continue)) + (var chunk-x int (+ (* (. k rx) 16) cx)) + (var chunk-z int (+ (* (. k rz) 16) cz)) + (terra/chunk-heights tr chunk-x chunk-z (if (> step 32) 32 step) heights) + (for (var dz int 0) (< dz per-chunk) (++ dz) + (for (var dx int 0) (< dx per-chunk) (++ dx) + (var lx int (* dx step)) + (var lz int (* dz step)) + (var h int [heights (+ (* lz 32) lx)]) + (strata/column rocks chunk-x chunk-z lx lz h column) + (var y int h) + (if (== mode ROCK-AT-DEPTH) (= y (- h value)) + (== mode ROCK-AT-Y) (= y value)) + (var v u8 VALUE-AIR) + (if (< y 0) (= v ROCK-MANTLE) + (<= y h) (= v [column y]) + (< y (. tr sea-level)) (= v VALUE-WATER)) + (= [out (+ (* (+ (/ (* cz 32) step) dz) res) (/ (* cx 32) step) dx)] v))))) + (free column) + (= (* size) res) + (return out)) + ;;; Workers ------------------------------------------------------- (fn worker-main ((arg (* void))) (* void) @@ -245,6 +298,7 @@ (var cache river-cache) (memset (& cache) 0 (sizeof cache)) (var tr (* terra) NULL) + (var rocks (* strata) NULL) (pthread-mutex-lock (& (. t lock))) (while (! (. t quit)) (if (>= (. t queue-pos) (. t queue-len)) @@ -267,32 +321,41 @@ (do (if tr (terra/free tr)) (= tr NULL) + (if rocks (strata/free rocks)) + (= rocks NULL) (if g (worldgen/free g)) (release-river-cache (& cache)) (= g (worldgen/make settings (. t assets-dir))) (if g (= tr (terra/make g rivers))) + (if g (= rocks (strata/make g (. t assets-dir)))) (= (. cache sampler) (river-sampler/make (& rivers) (. settings size-y))) (= g-generation generation))) (var size int 0) (var px (* u32) NULL) + (var values (* u8) NULL) (if (&& g (== (. key map) LAYER-RIVERS)) (= px (render-rivers g (& cache) (& rivers) key (& size))) (&& tr (== (. key map) LAYER-HEIGHT)) (= px (render-heights tr key (& size))) + (&& tr rocks (== (. key map) LAYER-ROCK)) + (= values (render-rocks tr rocks key (& size))) g (= px (render g key (& size)))) (pthread-mutex-lock (& (. t lock))) - (if (&& px (== generation (. t generation)) (== (. tl state) TILE-WORKING)) + (if (&& (|| px values) (== generation (. t generation)) (== (. tl state) TILE-WORKING)) (do (= (. tl pixels) px) + (= (. tl values) values) (= (. tl size) size) (= (. tl state) TILE-READY)) (do (free px) + (free values) (if (&& (== generation (. t generation)) (== (. tl state) TILE-WORKING)) (= (. tl state) TILE-QUEUED))))) (pthread-mutex-unlock (& (. t lock))) + (if rocks (strata/free rocks)) (if tr (terra/free tr)) (if g (worldgen/free g)) (release-river-cache (& cache)) @@ -325,6 +388,7 @@ (if (. tl texture) (SDL-DestroyTexture (. tl texture))) (free (. tl pixels)) + (free (. tl values)) (memset tl 0 (sizeof tile))) (.release (& (. self index))) (= (. self index) (cell-map/make)) @@ -364,6 +428,7 @@ (if (. tl texture) (SDL-DestroyTexture (. tl texture))) (free (. tl pixels)) + (free (. tl values)) (memset tl 0 (sizeof tile)) (return best)) @@ -391,6 +456,12 @@ (= (. tl last-used) (. self frame)) (if (== (. tl state) TILE-READY) (do + (if (. tl values) + (do + (var n int (* (. tl size) (. tl size))) + (= (. tl pixels) (malloc (* n (sizeof u32)))) + (for (var i int 0) (< i n) (++ i) + (= [(. tl pixels) i] [(. self palette) [(. tl values) i]])))) (= (. tl texture) (SDL-CreateTexture renderer SDL-PIXELFORMAT-ARGB8888 SDL-TEXTUREACCESS-STATIC (. tl size) (. tl size))) (SDL-SetTextureScaleMode (. tl texture) SDL-SCALEMODE-NEAREST) @@ -407,6 +478,20 @@ (++ (. self queue-len)))) (return NULL)) + ;; A new palette for value tiles: drawn ones are coloured again from + ;; the values they kept. Main thread only. + (pub fn set-palette ((self (* tiles)) (palette (* const u32))) void + (pthread-mutex-lock (& (. self lock))) + (memcpy (. self palette) palette (sizeof (. self palette))) + (for (var i int 0) (< i MAX-TILES) (++ i) + (var tl (* tile) (& [(. self slots) i])) + (if (&& (. tl values) (== (. tl state) TILE-DRAWN)) + (do + (SDL-DestroyTexture (. tl texture)) + (= (. tl texture) NULL) + (= (. tl state) TILE-READY)))) + (pthread-mutex-unlock (& (. self lock)))) + ;; Hands this frame's queue to the workers. Returns how many tiles ;; requested this frame are not ready yet, queued or being made. (pub fn end-frame ((self (* tiles))) int diff --git a/src/verify.sex b/src/verify.sex index e4ae31e..b6a2c4d 100644 --- a/src/verify.sex +++ b/src/verify.sex @@ -13,6 +13,7 @@ (import fastnoise) (import rivers) (import terra) +(import strata) (import img) (define MAP-KINDS 6) @@ -179,7 +180,8 @@ ;;; with WorldGenTerrainHeightMap. Mismatches are counted by how far off ;;; they are, which tells a missing step (a raise of a few blocks) from ;;; noise that is wrong. -(pub fn verify-heights ((s (* save)) (g (* worldgen)) (config river-config) (dir (* const char))) int +(pub fn verify-heights ((s (* save)) (g (* worldgen)) (config river-config) (rocks (* strata)) + (dir (* const char))) int (var e extent (save/extent s "mapchunk")) (var w int (* (+ (- (. e x1) (. e x0)) 1) 32)) (var h int (* (+ (- (. e z1) (. e z0)) 1) 32)) @@ -194,6 +196,11 @@ (var by-class [i64 4]) (memset by-class 0 (sizeof by-class)) (var t0 clock-t (clock)) + (var rock-columns i64 0) + (var rock-matched i64 0) + (var no-rock i64 0) + (var rock-diff image (image/make w h)) + (var column [u8 1024]) (var m chunk-maps) (for (var cz int (. e z0)) (<= cz (. e z1)) (++ cz) (for (var cx int (. e x0)) (<= cx (. e x1)) (++ cx) @@ -219,7 +226,25 @@ (if (> d 0) (= colour 16719904)) (if (< d 0) (= colour 2105599)) (.set (& diff) (+ (* (- cx (. e x0)) 32) (% i 32)) (+ (* (- cz (. e z0)) 32) (/ i 32)) - colour)))) + colour) + + ;; The top rock the game recorded is at the top solid block after + ;; caves; the dry seabed raise only stacks more of it. + (var top (* const char) (save/block-code s [(. m top-rock) i])) + (if (|| (! (strncmp top "rock-" 5)) (! (strncmp top "rock" 4))) + (do + (strata/column rocks cx cz (% i 32) (/ i 32) got column) + (var y int (if (< want got) want got)) + (var ours int [column y]) + (var name (* const char) (if (== ours ROCK-MANTLE) "mantle" [(. rocks rock-codes) ours])) + (++ rock-columns) + (var same bool (== (strcmp name top) 0)) + (if same (++ rock-matched)) + (var rc u32 16719904) + (if same (= rc (palette (cast ours u32)))) + (.set (& rock-diff) (+ (* (- cx (. e x0)) 32) (% i 32)) (+ (* (- cz (. e z0)) 32) (/ i 32)) + rc)) + (++ no-rock))))) (printf "heights %lld/%lld columns match, %.1f s\n" matched columns (/ (cast (- (clock) t0) double) CLOCKS-PER-SEC)) (printf " stored - computed: <=-4 %lld, -3 %lld, -2 %lld, -1 %lld, +1 %lld, +2 %lld, +3 %lld, >=+4 %lld\n" @@ -227,7 +252,12 @@ [by-delta 8]) (printf " stored higher: %lld under water, %lld on land; stored lower: %lld under water, %lld on land\n" [by-class 0] [by-class 1] [by-class 2] [by-class 3]) + (printf "top rock %lld/%lld columns match (%.4f%%); %lld columns have no rock on top\n" + rock-matched rock-columns (/ (* 100.0 rock-matched) rock-columns) no-rock) (var path [char 1024]) + (snprintf path (sizeof path) "%s/diff-toprock.png" dir) + (.write (& rock-diff) path) + (.release (& rock-diff)) (snprintf path (sizeof path) "%s/diff-heights.png" dir) (.write (& diff) path) (.release (& diff)) @@ -238,4 +268,7 @@ (var unexplained i64 (+ [by-class 1] [by-class 2])) (printf " explained by the dry seabed raise and caves: all but %lld (%.3f%%)\n" unexplained (/ (* 100.0 unexplained) columns)) + ;; a handful of columns carry structures or boulders placed later + (if (> (* (- rock-columns rock-matched) 100000) rock-columns) + (return 1)) (return (if (< (* unexplained 1000) columns) 0 1))) diff --git a/src/viewer.sex b/src/viewer.sex index c30c802..109a41b 100644 --- a/src/viewer.sex +++ b/src/viewer.sex @@ -2,6 +2,7 @@ ;;; Nuklear for the panels drawn over the map, tiles for the map. ;;; ;;; vs-map-viewer [--assets DIR] [--zoom BLOCKS-PER-POINT] [--layer N] +;;; [--rock-depth N | --rock-y Y] [--highlight ROCK] [--probe X Z] ;;; [--screenshot FILE.png] [WORLD.vcdbs | serverconfig.json] ;;; ;;; --screenshot draws until no tile is pending, saves the window and @@ -18,6 +19,7 @@ (import fastnoise) (import rivers) (import terra) +(import strata) (import settings) (import tiles) @@ -30,13 +32,29 @@ (define MIN-ZOOM 0.0625) (define MAX-ZOOM 32.0) -(var layer-names [(* const char) 8] +(var layer-names [(* const char) 9] #("Landform" "Climate" "Geologic province" "Upheaval" "Ocean" "Rock strata thickness" - "Rivers" "Terrain height")) + "Rivers" "Terrain height" "Rock")) +(var rock-mode-names [(* const char) 3] #("Surface" "Depth below surface" "At Y")) + +;;; Rock colours, roughly as they look in game; others get a stable one. +(var rock-colour-codes [(* const char) 15] + #("rock-granite" "rock-andesite" "rock-basalt" "rock-peridotite" "rock-kimberlite" + "rock-claystone" "rock-sandstone" "rock-shale" "rock-conglomerate" "rock-limestone" + "rock-chert" "rock-chalk" "rock-bauxite" "rock-slate" "rock-phyllite")) +(var rock-colour-values [u32 15] + ;; Sex has no hex literals: B49A8C 6E6A66 3A3A3D 4F6B3A 5A6E7A C08A5A D8C38A + ;; 5E6470 9A7B5C C9C7B8 8A5A48 F0F0E8 B5532E 4A5568 7D8A7A + #(11836044 7236198 3815997 5204794 5926522 12618330 14205834 6186096 10124124 13223864 9067080 15790312 11883310 4871528 8227450)) (var climate-names [(* const char) 5] #("temperate" "hot" "warm" "cool" "icy")) ;;; What the region under the cursor holds, generated on the main ;;; thread when the cursor moves to another region. +;;; The strata of the column clicked last: top down, as (rock, top y, +;;; bottom y) runs. +(record probe ((valid bool) (x int) (z int) (height int) (count int) + (rocks [int 64]) (tops [int 64]) (bottoms [int 64]))) + (record hover ((valid bool) (rx int) (rz int) (maps region-maps) (plate (* river-plate)) (segments (* int)) (terra (* terra)) (cx int) (cz int) (has-chunk bool) (heights [u16 1024]))) @@ -47,7 +65,9 @@ (rivers river-config) (sampler river-sampler) (source world-source) (edit world-source) (g (* worldgen)) (tiles (* tiles)) (center-x double) (center-z double) (zoom double) (layer int) (stratum int) - (mouse-x float) (mouse-y float) (dragging bool) (ui-hovered bool) + (mouse-x float) (mouse-y float) (dragging bool) (dragged bool) (ui-hovered bool) + (rocks (* strata)) (rock-mode int) (rock-value int) (highlight int) (probe probe) + (column [u8 1100]) (highlight-code (* const char)) (probe-x int) (probe-z int) (hover hover) (pending int) (status [char 256]) (screenshot (* const char)))) (fn fail ((what (* const char))) int @@ -98,6 +118,37 @@ (= (. a hover terra) NULL) (= (. a hover has-chunk) false)) +;;; The colour of rock index I. +(fn rock-colour ((a (* app)) (i int)) u32 + (var code (* const char) [(. a rocks rock-codes) i]) + (for (var k int 0) (< k 15) (++ k) + (if (== (strcmp code [rock-colour-codes k]) 0) + (return [rock-colour-values k]))) + (var hash u32 (* (cast (+ i 41) u32) (cast 2654435761 u32))) + (return (& hash 16777215))) + +;;; The rock layer's palette: every rock in its colour, or only the +;;; highlighted one with the rest greyed out. +(fn update-palette ((a (* app))) void + (var p [u32 256]) + (for (var i int 0) (< i 256) (++ i) + (= [p i] 4280295456)) + (= [p VALUE-WATER] 4280171404) + (= [p VALUE-AIR] 4280295456) + (= [p ROCK-MANTLE] 4278190080) + (for (var i int 0) (< i (. a rocks rock-count)) (++ i) + (var c u32 (rock-colour a i)) + (if (&& (>= (. a highlight) 0) (!= i (. a highlight))) + (do + ;; grey, a third of the brightness + (var r u32 (& (>> c 16) 255)) + (var g u32 (& (>> c 8) 255)) + (var b u32 (& c 255)) + (var grey u32 (/ (+ r g b) 9)) + (= c (* grey 65793)))) + (= [p i] (c-bit-or 4278190080 c))) + (.set-palette (. a tiles) p)) + ;;; Makes SOURCE the world shown: a fresh generator for the panels, ;;; and every tile regenerated. (fn apply ((a (* app)) (source world-source)) bool @@ -107,6 +158,13 @@ (snprintf (. a status) (sizeof (. a status)) "cannot load worldgen assets from %s" (. a assets-dir)) (return false))) + (var rocks (* strata) (strata/make g (. a assets-dir))) + (if (. a rocks) + (strata/free (. a rocks))) + (= (. a rocks) rocks) + (if (>= (. a highlight) (. rocks rock-count)) + (= (. a highlight) -1)) + (= (. a probe valid) false) (if (. a g) (worldgen/free (. a g))) (= (. a g) g) @@ -117,6 +175,7 @@ (= (. a stratum) 0)) (= (. a sampler) (river-sampler/make (& (. a rivers)) (. source settings size-y))) (.set-settings (. a tiles) (. source settings) (. a rivers)) + (update-palette a) (snprintf (. a status) (sizeof (. a status)) "seed %d" (. source settings seed)) (return true)) @@ -197,6 +256,13 @@ (= (. k stratum) (. a stratum)) (if (== (. a layer) LAYER-RIVERS) (= (. k stratum) (river-resolution (. a zoom)))) (if (== (. a layer) LAYER-HEIGHT) (= (. k stratum) (height-resolution (. a zoom)))) + (= (. k param) 0) + (if (== (. a layer) LAYER-ROCK) + (do + (= (. k stratum) (height-resolution (. a zoom))) + (var value int (. a rock-value)) + (if (== (. a rock-mode) ROCK-AT-SURFACE) (= value 0)) + (= (. k param) (+ (* (. a rock-mode) 1024) value)))) (= (. k rx) (. [list i] rx)) (= (. k rz) (. [list i] rz)) (var tex (* SDL-Texture) (.request (. a tiles) (. a renderer) k)) @@ -310,18 +376,54 @@ (go-to-spawn a)))) (nk-end ctx)) +;;; The rock layer's mode, its depth or Y, and the legend: a rock clicked +;;; is highlighted, clicked again shows all. +(fn draw-rock-controls ((a (* app))) void + (var ctx (* struct nk-context) (. a ctx)) + (nk-layout-row-dynamic ctx 8 1) + (nk-spacing ctx 1) + (nk-layout-row-dynamic ctx 20 1) + (for (var i int 0) (< i 3) (++ i) + (if (nk-option-label ctx [rock-mode-names i] (== (. a rock-mode) i)) + (= (. a rock-mode) i))) + (if (== (. a rock-mode) ROCK-AT-DEPTH) + (nk-property-int ctx "Depth" 0 (& (. a rock-value)) 300 1 0.5) + (== (. a rock-mode) ROCK-AT-Y) + (nk-property-int ctx "Y" 1 (& (. a rock-value)) (- (. a source settings size-y) 1) 1 0.5)) + (nk-layout-row-dynamic ctx 8 1) + (nk-spacing ctx 1) + (var rocks (* strata) (. a rocks)) + (for (var i int 0) (< i (. rocks rock-count)) (++ i) + (nk-layout-row-template-begin ctx 18) + (nk-layout-row-template-push-static ctx 18) + (nk-layout-row-template-push-dynamic ctx) + (nk-layout-row-template-end ctx) + (var c u32 (rock-colour a i)) + (nk-button-color ctx (nk-rgb (cast (& (>> c 16) 255) int) (cast (& (>> c 8) 255) int) + (cast (& c 255) int))) + (var name (* const char) (+ [(. rocks rock-codes) i] 5)) + (var selected nk-bool (== (. a highlight) i)) + (if (nk-selectable-label ctx name NK-TEXT-LEFT (& selected)) + (do + (= (. a highlight) (if selected i -1)) + (update-palette a)))) + (nk-layout-row-dynamic ctx 18 1) + (nk-label ctx "Click a rock to show only it" NK-TEXT-LEFT)) + (fn draw-layers ((a (* app))) void (var ctx (* struct nk-context) (. a ctx)) (var w int) (var h int) (window-size a (& w) (& h)) - (if (nk-begin ctx "Layer" (nk-rect (- w 250) 10 240 260) + (if (nk-begin ctx "Layer" (nk-rect (- w 250) 10 240 (if (== (. a layer) LAYER-ROCK) 640 280)) (| NK-WINDOW-BORDER NK-WINDOW-MOVABLE NK-WINDOW-TITLE NK-WINDOW-MINIMIZABLE)) (do (nk-layout-row-dynamic ctx 20 1) - (for (var i int 0) (< i 8) (++ i) + (for (var i int 0) (< i 9) (++ i) (if (nk-option-label ctx [layer-names i] (== (. a layer) i)) (= (. a layer) i))) + (if (== (. a layer) LAYER-ROCK) + (draw-rock-controls a)) (if (== (. a layer) MAP-STRATA) (do (var g (* worldgen) (. a g)) @@ -352,6 +454,52 @@ (= (. a hover has-chunk) true))) (return [(. a hover heights) (+ (* (% z 32) 32) (% x 32))])) +;;; Probes the column at block (x, z): its height and strata. +(fn probe-at ((a (* app)) (x int) (z int)) void + (var h int (hover-height a x z)) + (strata/column (. a rocks) (/ x 32) (/ z 32) (% x 32) (% z 32) h (. a column)) + (var p (* probe) (& (. a probe))) + (= (. p valid) true) + (= (. p x) x) + (= (. p z) z) + (= (. p height) h) + (= (. p count) 0) + (for (var y int h) (>= y 1) (-- y) + (var r int [(. a column) y]) + (if (&& (> (. p count) 0) (== [(. p rocks) (- (. p count) 1)] r)) + (= [(. p bottoms) (- (. p count) 1)] y) + (< (. p count) 64) + (do + (= [(. p rocks) (. p count)] r) + (= [(. p tops) (. p count)] y) + (= [(. p bottoms) (. p count)] y) + (++ (. p count)))))) + +(fn draw-probe ((a (* app))) void + (var p (* probe) (& (. a probe))) + (if (! (. p valid)) + (return)) + (var ctx (* struct nk-context) (. a ctx)) + (var w int) + (var h int) + (window-size a (& w) (& h)) + (if (nk-begin ctx "Probe" (nk-rect (- w 330) (- h 330) 320 320) + (| NK-WINDOW-BORDER NK-WINDOW-MOVABLE NK-WINDOW-TITLE NK-WINDOW-SCALABLE + NK-WINDOW-CLOSABLE)) + (do + (nk-layout-row-dynamic ctx 18 1) + (var s (* world-settings) (& (. a source settings))) + (nk-labelf ctx NK-TEXT-LEFT "x %d z %d (from centre %d, %d)" (. p x) (. p z) + (- (. p x) (/ (. s size-x) 2)) (- (. p z) (/ (. s size-z) 2))) + (nk-labelf ctx NK-TEXT-LEFT "surface at y %d" (. p height)) + (for (var i int 0) (< i (. p count)) (++ i) + (var r int [(. p rocks) i]) + (var name (* const char) (if (== r ROCK-MANTLE) "mantle" (+ [(. a rocks rock-codes) r] 5))) + (var thick int (+ (- [(. p tops) i] [(. p bottoms) i]) 1)) + (nk-labelf ctx NK-TEXT-LEFT "%3d-%-3d %-14s %3d" [(. p tops) i] [(. p bottoms) i] name thick))) + (= (. p valid) false)) + (nk-end ctx)) + ;;; Rivers' sample at block (x, z), building the plate it needs. (fn hover-river ((a (* app)) (x int) (z int)) river-sample (var per-plate int (river-plate/chunks (& (. a rivers)))) @@ -411,8 +559,11 @@ (var r river-sample (hover-river a bx bz)) (nk-labelf ctx NK-TEXT-LEFT "river distance %.0f, bank depth %.3f" (. r distance) (. r bank)) - (nk-labelf ctx NK-TEXT-LEFT "terrain height %d (sea level %d)" - (hover-height a bx bz) (. a hover terra sea-level)))) + (var height int (hover-height a bx bz)) + (strata/column (. a rocks) (/ bx 32) (/ bz 32) (% bx 32) (% bz 32) height (. a column)) + (nk-labelf ctx NK-TEXT-LEFT "terrain height %d (sea level %d), %s" + height (. a hover terra sea-level) + (+ [(. a rocks rock-codes) [(. a column) height]] 5)))) (nk-labelf ctx NK-TEXT-LEFT "%d tiles pending" (. a pending)) (nk-label ctx (. a status) NK-TEXT-LEFT))) (nk-end ctx)) @@ -439,15 +590,29 @@ (do (if (. a dragging) (do + (if (> (+ (fabsf (. event motion xrel)) (fabsf (. event motion yrel))) 2) + (= (. a dragged) true)) (-= (. a center-x) (* (. event motion xrel) (. a zoom))) (-= (. a center-z) (* (. event motion yrel) (. a zoom))))) (= (. a mouse-x) (. event motion x)) (= (. a mouse-y) (. event motion y))) (&& (== type SDL-EVENT-MOUSE-BUTTON-DOWN) (! (. a ui-hovered)) (== (. event button button) SDL-BUTTON-LEFT)) - (= (. a dragging) true) + (do + (= (. a dragging) true) + (= (. a dragged) false)) (== type SDL-EVENT-MOUSE-BUTTON-UP) - (= (. a dragging) false) + (do + (if (&& (. a dragging) (! (. a dragged))) + (do + (var w int) + (var h int) + (window-size a (& w) (& h)) + (var bx int (cast (floor (to-world-x a (. event button x) w)) int)) + (var bz int (cast (floor (to-world-z a (. event button y) h)) int)) + (if (&& (>= bx 0) (>= bz 0) (< bx (. a source settings size-x)) (< bz (. a source settings size-z))) + (probe-at a bx bz)))) + (= (. a dragging) false)) (&& (== type SDL-EVENT-MOUSE-WHEEL) (! (. a ui-hovered))) (zoom-at a (pow 1.25 (- (. event wheel y))))) (nk-sdl-handle-event (. a ctx) event) @@ -470,6 +635,7 @@ (pub fn main ((argc int) (argv [* char])) int (var a (* app) (calloc 1 (sizeof app))) + (= (. a highlight) -1) (snprintf (. a assets-dir) (sizeof (. a assets-dir)) "assets") (snprintf (. a world-path) (sizeof (. a world-path)) "serverconfig.json") (for (var i int 1) (< i argc) (++ i) @@ -482,6 +648,17 @@ (do (++ i) (= (. a zoom) (atof [argv i]))) (&& (== (strcmp [argv i] "--layer") 0) more) (do (++ i) (= (. a layer) (atoi [argv i]))) + (&& (== (strcmp [argv i] "--rock-depth") 0) more) + (do (++ i) (= (. a rock-mode) ROCK-AT-DEPTH) (= (. a rock-value) (atoi [argv i]))) + (&& (== (strcmp [argv i] "--rock-y") 0) more) + (do (++ i) (= (. a rock-mode) ROCK-AT-Y) (= (. a rock-value) (atoi [argv i]))) + (&& (== (strcmp [argv i] "--probe") 0) (< (+ i 2) argc)) + (do + (= (. a probe-x) (atoi [argv (+ i 1)])) + (= (. a probe-z) (atoi [argv (+ i 2)])) + (+= i 2)) + (&& (== (strcmp [argv i] "--highlight") 0) more) + (do (++ i) (= (. a highlight-code) [argv i])) (&& (== (strcmp [argv i] "--screenshot") 0) more) (do (++ i) (= (. a screenshot) [argv i])) (snprintf (. a world-path) (sizeof (. a world-path)) "%s" [argv i]))) @@ -514,6 +691,14 @@ (fprintf stderr "%s\n" (. a status)) (return 1))) (go-to-spawn a) + (if (|| (. a probe-x) (. a probe-z)) + (probe-at a (. a probe-x) (. a probe-z))) + (if (. a highlight-code) + (do + (for (var i int 0) (< i (. a rocks rock-count)) (++ i) + (if (== (strcmp (+ [(. a rocks rock-codes) i] 5) (. a highlight-code)) 0) + (= (. a highlight) i))) + (update-palette a))) (var running bool true) (while running @@ -531,6 +716,7 @@ (draw-settings a) (draw-layers a) (draw-info a) + (draw-probe a) (= (. a ui-hovered) (|| (nk-window-is-any-hovered (. a ctx)) (nk-item-is-any-active (. a ctx)))) (SDL-SetRenderDrawColor (. a renderer) 24 32 40 255) @@ -547,6 +733,7 @@ (.stop (. a tiles)) (release-hover a) + (strata/free (. a rocks)) (worldgen/free (. a g)) (nk-sdl-shutdown (. a ctx)) (SDL-DestroyRenderer (. a renderer)) diff --git a/src/vsmv.sex b/src/vsmv.sex index af201d5..798e217 100644 --- a/src/vsmv.sex +++ b/src/vsmv.sex @@ -16,6 +16,7 @@ (import fastnoise) (import rivers) (import terra) +(import strata) (import settings) (import verify) @@ -91,7 +92,7 @@ (var s (* save) (save/open save-path)) (var failed int (+ (verify-stories s g) (verify-regions s g out) (verify-rivers s g (river-config/defaults) out) - (verify-heights s g (river-config/defaults) out))) + (verify-heights s g (river-config/defaults) (strata/make g assets-dir) out))) (save/close s) (return failed))