nx_procgen_preset.nx
buildroot/runtime/nx_procgen_preset.nx
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
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
| 90 | struct Landscape |
consts
| 48 | const NX_MAGIC_1024: i64 = 1024 |
| 57 | const NX_PROCGEN_PRESET_FOREST: nx_int = 0 |
| 58 | const NX_PROCGEN_PRESET_DESERT: nx_int = 1 |
| 59 | const NX_PROCGEN_PRESET_MEADOW: nx_int = 2 |
| 60 | const NX_PROCGEN_PRESET_COAST: nx_int = 3 |
| 61 | const NX_PROCGEN_PRESET_MOUNTAIN: nx_int = 4 |
| 62 | const NX_PROCGEN_N_PRESETS: nx_int = 5 |
| 75 | const NX_PROCGEN_DEFAULT_WIDTH: nx_int = 64 |
| 76 | const NX_PROCGEN_DEFAULT_HEIGHT: nx_int = 64 |
| 77 | const NX_PROCGEN_DEFAULT_DENSITY_Q10: nx_int = 1024 // 1.0 = preset's natural density |
| 81 | const NX_PROCGEN_CELL_STEP_Q10: nx_int = 102 |
| 83 | const NX_PROCGEN_MAX_FEATURES: nx_int = 2048 |
functions
| 64 | func nx_procgen_preset_is_valid(p: nx_int) -> nx_int |
| 109 | func _preset_octaves(p: nx_int) -> nx_int |
| 118 | func _preset_persistence_q10(p: nx_int) -> nx_int |
| 127 | func _preset_base_radius(p: nx_int) -> nx_int |
| 139 | func _apply_density(base_radius: nx_int, density_q10: nx_int) -> nx_int |
| 147 | func _fill_heightmap(state: *PerlinState, w: nx_int, h: nx_int, |
| 172 | func nx_procgen_landscape(seed: nx_int, preset: nx_int, |
| 226 | func nx_procgen_landscape_cfg(seed: nx_int, preset: nx_int, |
| 275 | func nx_procgen_landscape_default(seed: nx_int) -> *Landscape |
| 288 | func nx_landscape_height_at(land: *Landscape, x: nx_int, y: nx_int) -> nx_int |
| 296 | func nx_landscape_height_band_at(land: *Landscape, x: nx_int, y: nx_int) -> nx_int |