nx_worldpipe_core_relief_t140.nx
buildroot/runtime/nx_worldpipe_core_relief_t140.nx
about
nx_worldpipe_core.nx -- THE PURE STAGED-TERRAIN CORE. Extracted from nx_worldpipe.nx on
2026-08-28 for gameengine rung GE14a, so the SHIPPING WASM ENGINE and the NAS-side pipeline
cannot disagree about the ground they respectively walk on and bake.
WHY THE SPLIT EXISTS, MEASURED (the rung's original wording said "the engine imports
nx_worldpipe" and that is NOT IMPLEMENTABLE): nx_wasm_craft carries ZERO sys_mmap /
sys_read_file / sys_write -- it is allocator-free and syscall-free BY CONSTRUCTION, which is
exactly why it compiles to wasm ("wasm has no mmap; every buffer is an arena offset" is written
in its own arena map) -- while nx_worldpipe.wp_hydro_bake allocates 819,200 B and pulls
nx_trimesh and nx_terrain_erode_lib into the closure. So the pipeline splits along the line the
TARGET draws: everything here is PURE ARITHMETIC over (x,z) with no allocation and no syscall,
and every allocating stage (hydrology bake, erosion bake, features, lighting) stays in
nx_worldpipe. That is the boundary, and it is a property of the code, not a preference.
ONE RULER, TWO CONSUMERS: the function bodies below are the SAME BYTES nx_worldpipe carried,
moved not copied -- nx_worldpipe now imports this lib and keeps its call sites unchanged, so a
copy cannot drift into a second answer for the same ground. The single source change is that the
moved code calls rlf_noise3 DIRECTLY instead of through nx_trimesh's one-line delegate
(tm_noise3 is literally `return rlf_noise3(...)`), because nx_relief_lib is 7,310 B of pure
arithmetic while nx_trimesh is a 45 KB mesh library the wasm target must not carry.
That change makes byte-identity of the rebuilt ELF unavailable as the neutrality proof, so the
proof is an EXTERNAL CONSTANT instead: nx_worldpipe_core_gate asserts a KAT of heights and
parameters harvested from the PRE-EXTRACTION organ.
STAGE 1 params: 0 continentalness, 1 temperature, 2 humidity, 3 erosion, 4 weirdness, 5 river.
license_tier: ORIGINAL No hw writes (Rule 26).
dependencies 4 imports · 3 importers
imports: nx_syscalls.nxnx_relief_lib.nxnx_itrig.nxnx_genp_allow_lib.nx
imported by: nx_wasm_craft_relief_save_t143.nxnx_wasm_craft_relief_t143.nxnx_worldpipe_relief_gate_t140.nx
structs
| none |
consts
| 32 | const WP_MAGIC_1400: i64 = 1400 |
| 33 | const WP_MAGIC_3400: i64 = 3400 |
| 34 | const WP_MAGIC_2600: i64 = 2600 |
| 35 | const WP_MAGIC_2100: i64 = 2100 |
| 36 | const WP_MAGIC_1700: i64 = 1700 |
| 37 | const WP_MAGIC_1300: i64 = 1300 |
| 38 | const WP_MAGIC_2400: i64 = 2400 |
| 39 | const WP_MAGIC_9973: i64 = 9973 |
| 40 | const WP_MAGIC_524287: i64 = 524287 |
| 41 | const WP_MAGIC_1024: i64 = 1024 |
| 115 | const WP_HEIGHT_Q: i64 = 256 |
functions
| 50 | func wp_iabs(v: i64) -> i64 { if v < 0 { return 0-v } return v } |
| 51 | func wp_clamp(v: i64, lo: i64, hi: i64) -> i64 { if v<lo {return lo} if v>hi {return hi} return v } |
| 55 | func wp_param(x: i64, z: i64, k: i64) -> i64 |
| 70 | func wp_spline(c: i64) -> i64 |
| 82 | func wp_height_core(cont: i64, ero: i64, weird: i64, x: i64, z: i64) -> i64 |
| 92 | func wp_height_params(cont: i64, ero: i64, weird: i64, x: i64, z: i64) -> i64 |
| 97 | func wp_flow_h(x: i64, z: i64) -> i64 |
| 104 | func wp_height_raw(x: i64, z: i64) -> i64 |
| 116 | func wp_dune_wave_q(packed: i64, x: i64, z: i64, phase_seed: i64) -> i64 |
| 132 | func wp_dune_coast_q(relief: i64, inland: i64, wavelength: i64) -> i64 |
| 142 | func wp_dune_raw_delta(legacy: i64, base_q: i64, raised_q: i64) -> i64 |