code wiki / (root) / nx_mountain_chain.nx

nx_mountain_chain.nx

buildroot/runtime/nx_mountain_chain.nx

17367 B420 linesdepth 4pulls 4 transitivereach 0 importersview sourcekind tool
docsdependenciesstructsconstsfunctions

about

nx_mountain_chain.nx -- specialized mountain-chain generator. Eleventh kind-specific generator per feedback-kind-specific-generators-not-broad-noise. A mountain chain is NOT FBM noise -- it has a primary RIDGE polyline, height envelope along the ridge, perpendicular falloff to neighbouring valleys, and tributary ridges branching off the main spine. Generator architecture: - Main ridge polyline: hash-deterministic meandering line with mild perturbation, similar to nx_river_carve but no downhill bias (mountains follow tectonic stress, not drainage). - Per-segment height: bell curve along the ridge length; peak at mid-ridge, taper toward both ends. - Perpendicular falloff: smoothstep over ridge_width on either side. - Tributary ridges: N branches at hash-determined indices along the main spine, each at a hash-determined angle off-perpendicular. Record layout (variable-length; first 8 i64 are header): rec[0] = n_main_points number of main-ridge polyline points rec[1] = n_tributaries count of branch ridges rec[2] = peak_height_q14_m max height of main spine rec[3] = ridge_width_q14_m perpendicular falloff distance rec[4] = peak_at_index which main point has the global max rec[5] = seed Park-Miller LCG seed rec[6] = reserved rec[7] = reserved rec[8..] = main_points 2 i64 per point (x, z) rec[...] = tributary records 4 i64 per tributary: start_idx, n_tributary_pts, height_factor_q14, reserved rec[...] = tributary points 2 i64 per tributary point (x, z) genealogy_id: anderson_2003_tectonic_geomorphology + himalaya_orogeny_canon + ridge_field_canon lineage_id: nx_mountain_chain_polyline_tributary_v1 nx_safety_envelope: intended_use: "Polyline mountain-chain generator with

dependencies 3 imports · 0 importers

nx_syscalls.nx nx_tier.nx nx_camera_q14.nx nx_mountain_chain.nx

imports: nx_syscalls.nxnx_tier.nxnx_camera_q14.nx

imported by: nobody (leaf or entry point)

call flow from main pre-order; caps 40 nodes / depth 6 declared; ↻ = already shown

main sys_mmap nx_mountain_chain_generate _mc_isqrt _mc_hash nx_camera_cos_q14_centideg nx_camera_sin_q14_centideg _normalise_centideg nx_camera_sin_q14_centideg ↻ nx_mountain_chain_elevatio _mc_dist_sq_to_segment

structs

none

consts

56const NX_MAGIC_2654435761: i64 = 2654435761
57const NX_MAGIC_1597334677: i64 = 1597334677
58const NX_MAGIC_4500: i64 = 4500
59const NX_MAGIC_18000: i64 = 18000
60const NX_MAGIC_9000: i64 = 9000
61const NX_MAGIC_2000: i64 = 2000
63const NX_MC_Q: nx_int = 16384
66const NX_MC_LCG_A: nx_int = 48271
67const NX_MC_LCG_M: nx_int = 2147483647
70const NX_MC_OFF_N_MAIN: nx_int = 0
71const NX_MC_OFF_N_TRIBUTARIES: nx_int = 1
72const NX_MC_OFF_PEAK_HEIGHT: nx_int = 2
73const NX_MC_OFF_RIDGE_WIDTH: nx_int = 3
74const NX_MC_OFF_PEAK_AT_INDEX: nx_int = 4
75const NX_MC_OFF_SEED: nx_int = 5
76const NX_MC_HEADER_STRIDE: nx_int = 8
78const NX_MC_POINT_STRIDE: nx_int = 2
79const NX_MC_TRIBUTARY_STRIDE: nx_int = 4
80const NX_MC_TRIB_OFF_START_IDX: nx_int = 0
81const NX_MC_TRIB_OFF_N_PTS: nx_int = 1
82const NX_MC_TRIB_OFF_HEIGHT_F: nx_int = 2

functions

85func _mc_hash(seed: nx_int, a: nx_int, b: nx_int) -> nx_int
95func _mc_isqrt(n: nx_int) -> nx_int
107func _mc_dist_sq_to_segment(
150func nx_mountain_chain_generate(
292func nx_mountain_chain_elevation_at(
called by 1: main calls 1: _mc_dist_sq_to_segment
377func main() -> i64