nx_mountain_chain.nx
buildroot/runtime/nx_mountain_chain.nx
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
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
structs
| none |
consts
| 56 | const NX_MAGIC_2654435761: i64 = 2654435761 |
| 57 | const NX_MAGIC_1597334677: i64 = 1597334677 |
| 58 | const NX_MAGIC_4500: i64 = 4500 |
| 59 | const NX_MAGIC_18000: i64 = 18000 |
| 60 | const NX_MAGIC_9000: i64 = 9000 |
| 61 | const NX_MAGIC_2000: i64 = 2000 |
| 63 | const NX_MC_Q: nx_int = 16384 |
| 66 | const NX_MC_LCG_A: nx_int = 48271 |
| 67 | const NX_MC_LCG_M: nx_int = 2147483647 |
| 70 | const NX_MC_OFF_N_MAIN: nx_int = 0 |
| 71 | const NX_MC_OFF_N_TRIBUTARIES: nx_int = 1 |
| 72 | const NX_MC_OFF_PEAK_HEIGHT: nx_int = 2 |
| 73 | const NX_MC_OFF_RIDGE_WIDTH: nx_int = 3 |
| 74 | const NX_MC_OFF_PEAK_AT_INDEX: nx_int = 4 |
| 75 | const NX_MC_OFF_SEED: nx_int = 5 |
| 76 | const NX_MC_HEADER_STRIDE: nx_int = 8 |
| 78 | const NX_MC_POINT_STRIDE: nx_int = 2 |
| 79 | const NX_MC_TRIBUTARY_STRIDE: nx_int = 4 |
| 80 | const NX_MC_TRIB_OFF_START_IDX: nx_int = 0 |
| 81 | const NX_MC_TRIB_OFF_N_PTS: nx_int = 1 |
| 82 | const NX_MC_TRIB_OFF_HEIGHT_F: nx_int = 2 |
functions
| 85 | func _mc_hash(seed: nx_int, a: nx_int, b: nx_int) -> nx_int called by 1: nx_mountain_chain_generate |
| 95 | func _mc_isqrt(n: nx_int) -> nx_int called by 1: nx_mountain_chain_generate |
| 107 | func _mc_dist_sq_to_segment( called by 1: nx_mountain_chain_elevation_at |
| 150 | func nx_mountain_chain_generate( |
| 292 | func nx_mountain_chain_elevation_at( |
| 377 | func main() -> i64 |