code wiki / (root) / nx_procgen_preset.nx

nx_procgen_preset.nx

buildroot/runtime/nx_procgen_preset.nx

12254 B299 linesdepth 5pulls 6 transitivereach 14 importersview sourcekind librarytopic procgen
docsdependenciesstructsconstsfunctions

about

nx_procgen_preset.nx -- Tier-0 procgen landscape with bidirectional progressive disclosure, in pure NishiLang. The cardinal: every Tier-N entry point is a VISIBLE COMPOSITION of Tier-(N+1) primitives in this same file. No opaque internals, no cross-language escape hatch. A new user can call nx_procgen_landscape_default(42) and get a useful landscape; a power user can Read this file, copy the Tier-2 composition body, swap one call, and ship their own preset. Same toolchain, same parser, same compilation. === Tiers exposed by this module ===================================== Tier 0 (just-works) nx_procgen_landscape_default(seed) -> *Landscape Tier 1 (preset + knobs) nx_procgen_landscape(seed, preset, width, height, density_q10) -> *Landscape Tier 2 (compose primitives, no preset) The body of nx_procgen_landscape is a visible inline composition of nx_perlin_* + nx_poisson_disk_*. Copy and modify. Tier 3 (raw nx) import "nx_perlin.nx" import "nx_poisson_disk.nx" ... write your own pipeline. The primitives are in this same runtime/ directory and are .nx source you can read + edit. === The bidirectional invariant ====================================== Top-down: Tier 0 -> Tier 3 is "open the file, see the recipe." Bottom-up: Tier 3 -> Tier 0 is "save your composition as a named preset." See _preset_params() below -- that table IS the preset registry. A power user adds a row, gets a new preset, ships it.

dependencies 5 imports · 8 importers

nx_syscalls.nx nx_tier.nx nx_perlin.nx nx_poisson_disk.nx nx_procgen_signature.nx nx_procgen_preset.nx _ft_diag.nx nx_procgen_biome_test.nx nx_procgen_features_test.nx nx_procgen_preset_test.nx nx_procgen_water.nx nx_procgen_water_test.nx nx_scene_contract.nx nx_worldgen_tunelib.nx

imports: nx_syscalls.nxnx_tier.nxnx_perlin.nxnx_poisson_disk.nxnx_procgen_signature.nx

imported by: _ft_diag.nxnx_procgen_biome_test.nxnx_procgen_features_test.nxnx_procgen_preset_test.nxnx_procgen_water.nxnx_procgen_water_test.nxnx_scene_contract.nxnx_worldgen_tunelib.nx

structs

90struct Landscape

consts

48const NX_MAGIC_1024: i64 = 1024
57const NX_PROCGEN_PRESET_FOREST: nx_int = 0
58const NX_PROCGEN_PRESET_DESERT: nx_int = 1
59const NX_PROCGEN_PRESET_MEADOW: nx_int = 2
60const NX_PROCGEN_PRESET_COAST: nx_int = 3
61const NX_PROCGEN_PRESET_MOUNTAIN: nx_int = 4
62const NX_PROCGEN_N_PRESETS: nx_int = 5
75const NX_PROCGEN_DEFAULT_WIDTH: nx_int = 64
76const NX_PROCGEN_DEFAULT_HEIGHT: nx_int = 64
77const NX_PROCGEN_DEFAULT_DENSITY_Q10: nx_int = 1024 // 1.0 = preset's natural density
81const NX_PROCGEN_CELL_STEP_Q10: nx_int = 102
83const NX_PROCGEN_MAX_FEATURES: nx_int = 2048

functions

64func nx_procgen_preset_is_valid(p: nx_int) -> nx_int
109func _preset_octaves(p: nx_int) -> nx_int
118func _preset_persistence_q10(p: nx_int) -> nx_int
127func _preset_base_radius(p: nx_int) -> nx_int
139func _apply_density(base_radius: nx_int, density_q10: nx_int) -> nx_int
147func _fill_heightmap(state: *PerlinState, w: nx_int, h: nx_int,
172func nx_procgen_landscape(seed: nx_int, preset: nx_int,
226func nx_procgen_landscape_cfg(seed: nx_int, preset: nx_int,
275func nx_procgen_landscape_default(seed: nx_int) -> *Landscape
called by 1: main calls 1: nx_procgen_landscape
288func nx_landscape_height_at(land: *Landscape, x: nx_int, y: nx_int) -> nx_int
296func nx_landscape_height_band_at(land: *Landscape, x: nx_int, y: nx_int) -> nx_int