nx_treegen.nx
buildroot/runtime/nx_treegen.nx
about
nx_treegen.nx -- ★SOVEREIGN INFINIGEN: procedural VEGETATION (trees). A seed grows a UNIQUE tree by recursive
branching (an L-system-style growth stack): trunk -> branches -> sub-branches -> leaf clusters, with
phototropism (upward bias) + seeded angle/length/count variation. Branches = tapering CAPSULES, leaves = green
spheres. Self-contained SDF + integer ray-march with a bounding-sphere early-reject (so hundreds of parts stay
fast). No ML, no assets. Different seed -> different tree. license_tier: ORIGINAL
dependencies 2 imports · 6 importers
imports: nx_syscalls.nxnx_itrig.nx
imported by: nx_diversity_gate.nxnx_diversity_veg_gate.nxnx_gt_annotations_gate.nxnx_livingworld_gate.nxnx_treegen_gate.nxnx_worldpop_gate.nx
structs
| none |
consts
| 8 | const TG_MAGIC_6364136223846793005: i64 = 6364136223846793005 |
| 9 | const TG_MAGIC_1442695040888963407: i64 = 1442695040888963407 |
| 10 | const TG_MAGIC_2147483647: i64 = 2147483647 |
| 11 | const TG_MAGIC_1024: i64 = 1024 |
| 12 | const TG_MAGIC_1048576: i64 = 1048576 |
| 13 | const TG_MAGIC_65536: i64 = 65536 |
| 14 | const TG_MAGIC_2654435761: i64 = 2654435761 |
| 15 | const TG_MAGIC_1013904223: i64 = 1013904223 |
| 16 | const TG_MAGIC_7919: i64 = 7919 |
| 17 | const TG_MAGIC_1700: i64 = 1700 |
| 18 | const TG_MAGIC_2900: i64 = 2900 |
| 19 | const TG_MAGIC_1400: i64 = 1400 |
| 20 | const TG_MAGIC_2400: i64 = 2400 |
| 21 | const TG_MAGIC_2100: i64 = 2100 |
| 22 | const TG_MAGIC_3400: i64 = 3400 |
| 23 | const TG_MAGIC_4096: i64 = 4096 |
| 24 | const TG_MAGIC_25736: i64 = 25736 |
| 25 | const TG_MAGIC_2600: i64 = 2600 |
| 26 | const TG_MAGIC_1500: i64 = 1500 |
| 27 | const TG_MAGIC_25735: i64 = 25735 |
| 28 | const TG_MAGIC_4090: i64 = 4090 |
| 29 | const TG_MAGIC_1000000: i64 = 1000000 |
| 30 | const TG_MAGIC_1100: i64 = 1100 |
| 31 | const TG_MAGIC_1103515245: i64 = 1103515245 |
| 32 | const TG_MAGIC_12345: i64 = 12345 |
| 34 | const TG_CAP: i64 = 700 // max parts |
| 35 | const TG_STR: i64 = 14 // per-part: type,kind, cx,cy,cz, bound, p1(3), r, p2(3) |
| 36 | const TG_CAPS: i64 = 0 |
| 37 | const TG_SPH: i64 = 1 |
| 38 | const TG_WOOD: i64 = 0 |
| 39 | const TG_LEAF: i64 = 1 |
| 40 | const TG_W: i64 = 448 |
| 41 | const TG_H: i64 = 512 |
| 42 | const TG_FOCAL: i64 = 620 |
functions
| 44 | func tg_isqrt(v: i64) -> i64 { if v<=0 {return 0} var x: i64=v; var y: i64=(x+1)/2; while y<x {x=y; y=(x+v/x)/2} return x } |
| 45 | func tg_abs(v: i64) -> i64 { if v<0 {return 0-v} return v } |
| 46 | func tg_min(a: i64, b: i64) -> i64 { if a<b {return a} return b } |
| 47 | func tg_max(a: i64, b: i64) -> i64 { if a>b {return a} return b } |
| 48 | func tg_clamp(v: i64, lo: i64, hi: i64) -> i64 { if v<lo {return lo} if v>hi {return hi} return v } |
| 49 | func tg_next(st: *i64) -> i64 { var h: i64=st[0]; h=h*TG_MAGIC_6364136223846793005+TG_MAGIC_1442695040888963407; st[0]=h; return (h>>33)&TG_MAGIC_2147483647 } |
| 50 | func tg_range(st: *i64, lo: i64, hi: i64) -> i64 { return lo + tg_next(st) % (hi-lo+1) } |
| 52 | func tg_addcaps(P: *i64, n: i64, ax: i64, ay: i64, az: i64, bx: i64, by: i64, bz: i64, r: i64, kind: i64) -> i64 |
| 59 | func tg_addsph(P: *i64, n: i64, cx: i64, cy: i64, cz: i64, r: i64, kind: i64) -> i64 called by 1: treegen_build_sp |
| 66 | func tg_tilt(dx: i64, dy: i64, dz: i64, ang: i64, phi: i64, out: *i64) -> i64 |
| 97 | func tg_species_palette(species: i64) -> i64 called by 1: treegen_build_sp |
| 108 | func treegen_build_sp(P: *i64, seed: i64, species: i64) -> i64 called by 4: mainmainmaintreegen_build calls 9: tg_species_palettesys_mmaptg_nexttg_rangetg_addcapsit_cos4096+3 |
| 218 | func treegen_build(P: *i64, seed: i64) -> i64 { return treegen_build_sp(P, seed, 0) } |
| 220 | func tg_part_sdf(P: *i64, k: i64, x: i64, y: i64, z: i64) -> i64 |
| 235 | func tg_sdf(P: *i64, np: i64, x: i64, y: i64, z: i64, kindout: *i64) -> i64 |
| 257 | func treegen_render(P: *i64, np: i64, yaw: i64, camz: i64, bgr: i64, bgg: i64, bgb: i64, fb: *i64) -> i64 |
| 323 | func tg_w() -> i64 { return TG_W } |
| 324 | func tg_h() -> i64 { return TG_H } |