code wiki / (root) / nx_anchor_feature.nx

nx_anchor_feature.nx

buildroot/runtime/nx_anchor_feature.nx

18861 B428 linesdepth 2pulls 2 transitivereach 1 importersview sourcekind tool
docsdependenciesstructsconstsfunctions

about

nx_anchor_feature.nx -- singular landmark-feature contributions. Solves the "generic FBM noise" problem for procgen worlds. Pure fractional Brownian motion gives terrain that LOOKS LIKE A WORLD in the abstract but has no signature features. Real worlds have landmarks that POP: Olympus Mons (22 km shield volcano, single massive cone), Hellas Basin (7 km deep impact crater 2300 km across), Valles Marineris (4000 km canyon system), Mt Everest, Mariana Trench, Caloris Basin on Mercury. This primitive ships the SHAPE FUNCTIONS for those features. Caller queries a feature's contribution at a (px, py) world coord; composer adds the contribution to the base FBM height. Body- specific anchor lists (Olympus Mons at 18 N 226 E, etc.) ship in nishi-engine/nx as the per-body data layer that composes this primitive into the surface generator. V1 kinds shipped (3): VOLCANIC_DOME -- Olympus Mons style: single radial peak with parabolic falloff (smooth shield-volcano profile) IMPACT_BASIN -- Hellas style: large circular depression with optional raised rim (negative magnitude) RIDGE -- mountain-range linear feature, 4-cardinal orientations (N-S or E-W in v1; arbitrary angle in v2 via nx_camera_q14 sin/cos import) V2 kinds queued (2): CANYON -- Valles Marineris style: linear depression with optional inner ridge / chasma structure PLATEAU -- Tharsis Bulge style: smooth flat-topped uplift Per cardinal `feedback-procgen-causal-growth-not-direct-sampling`: anchor features ARE the causal layer that makes one world feel distinct from another. Without them you get noise; with them you get geography. Loss audit: Q14 integer arithmetic throughout. Parabolic falloff is exact in Q14. Linear-feature distance is exact for the 2 cardinal orientations supported in v1.

dependencies 2 imports · 1 importers

nx_syscalls.nx nx_tier.nx nx_anchor_feature.nx nx_body_anchors.nx

imports: nx_syscalls.nxnx_tier.nx

imported by: nx_body_anchors.nx

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

main nx_anchor_kind_is_valid nx_anchor_orient_is_valid nx_anchor_volcanic_dome nx_anchor_impact_basin nx_anchor_ridge nx_anchor_orient_is_valid ↻ nx_anchor_feature_contribu nx_anchor_volcanic_dome ↻ nx_anchor_impact_basin ↻ nx_anchor_ridge ↻ nx_anchor_canyon nx_anchor_orient_is_valid ↻ nx_anchor_plateau nx_anchor_canyon ↻ nx_anchor_plateau ↻

structs

none

consts

53const NX_MAGIC_22000: i64 = 22000
54const NX_MAGIC_7000: i64 = 7000
55const NX_MAGIC_8000: i64 = 8000
56const NX_MAGIC_6395: i64 = 6395
57const NX_MAGIC_6405: i64 = 6405
58const NX_MAGIC_5000: i64 = 5000
59const NX_MAGIC_3000: i64 = 3000
62const NX_ANCHOR_Q: nx_int = 16384
66const NX_ANCHOR_VOLCANIC_DOME: nx_int = 0
67const NX_ANCHOR_IMPACT_BASIN: nx_int = 1
68const NX_ANCHOR_RIDGE: nx_int = 2
69const NX_ANCHOR_CANYON: nx_int = 3 // queued v2
70const NX_ANCHOR_PLATEAU: nx_int = 4 // queued v2
72const NX_ANCHOR_KIND_COUNT: nx_int = 5
75const NX_ANCHOR_ORIENT_NS: nx_int = 0 // N-S running; varies in Y
76const NX_ANCHOR_ORIENT_EW: nx_int = 1 // E-W running; varies in X

functions

79func nx_anchor_kind_is_valid(k: nx_int) -> nx_int
called by 1: main
88func nx_anchor_orient_is_valid(o: nx_int) -> nx_int
101func nx_anchor_volcanic_dome(
124func nx_anchor_impact_basin(
148func nx_anchor_ridge(
200func nx_anchor_canyon(
247func nx_anchor_plateau(
283func nx_anchor_feature_contribution(
312func main() -> i64