code wiki / (root) / nx_treegen.nx

nx_treegen.nx

buildroot/runtime/nx_treegen.nx

17528 B324 linesdepth 2pulls 3 transitivereach 6 importersview sourcekind library
docsdependenciesstructsconstsfunctions

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

nx_syscalls.nx nx_itrig.nx nx_treegen.nx nx_diversity_gate.nx nx_diversity_veg_gate.nx nx_gt_annotations_gate.nx nx_livingworld_gate.nx nx_treegen_gate.nx nx_worldpop_gate.nx

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

8const TG_MAGIC_6364136223846793005: i64 = 6364136223846793005
9const TG_MAGIC_1442695040888963407: i64 = 1442695040888963407
10const TG_MAGIC_2147483647: i64 = 2147483647
11const TG_MAGIC_1024: i64 = 1024
12const TG_MAGIC_1048576: i64 = 1048576
13const TG_MAGIC_65536: i64 = 65536
14const TG_MAGIC_2654435761: i64 = 2654435761
15const TG_MAGIC_1013904223: i64 = 1013904223
16const TG_MAGIC_7919: i64 = 7919
17const TG_MAGIC_1700: i64 = 1700
18const TG_MAGIC_2900: i64 = 2900
19const TG_MAGIC_1400: i64 = 1400
20const TG_MAGIC_2400: i64 = 2400
21const TG_MAGIC_2100: i64 = 2100
22const TG_MAGIC_3400: i64 = 3400
23const TG_MAGIC_4096: i64 = 4096
24const TG_MAGIC_25736: i64 = 25736
25const TG_MAGIC_2600: i64 = 2600
26const TG_MAGIC_1500: i64 = 1500
27const TG_MAGIC_25735: i64 = 25735
28const TG_MAGIC_4090: i64 = 4090
29const TG_MAGIC_1000000: i64 = 1000000
30const TG_MAGIC_1100: i64 = 1100
31const TG_MAGIC_1103515245: i64 = 1103515245
32const TG_MAGIC_12345: i64 = 12345
34const TG_CAP: i64 = 700 // max parts
35const TG_STR: i64 = 14 // per-part: type,kind, cx,cy,cz, bound, p1(3), r, p2(3)
36const TG_CAPS: i64 = 0
37const TG_SPH: i64 = 1
38const TG_WOOD: i64 = 0
39const TG_LEAF: i64 = 1
40const TG_W: i64 = 448
41const TG_H: i64 = 512
42const TG_FOCAL: i64 = 620

functions

44func 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 }
45func tg_abs(v: i64) -> i64 { if v<0 {return 0-v} return v }
46func tg_min(a: i64, b: i64) -> i64 { if a<b {return a} return b }
47func tg_max(a: i64, b: i64) -> i64 { if a>b {return a} return b }
48func tg_clamp(v: i64, lo: i64, hi: i64) -> i64 { if v<lo {return lo} if v>hi {return hi} return v }
49func 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 }
50func tg_range(st: *i64, lo: i64, hi: i64) -> i64 { return lo + tg_next(st) % (hi-lo+1) }
called by 1: treegen_build_sp calls 1: tg_next
52func tg_addcaps(P: *i64, n: i64, ax: i64, ay: i64, az: i64, bx: i64, by: i64, bz: i64, r: i64, kind: i64) -> i64
called by 1: treegen_build_sp calls 1: tg_isqrt
59func tg_addsph(P: *i64, n: i64, cx: i64, cy: i64, cz: i64, r: i64, kind: i64) -> i64
called by 1: treegen_build_sp
66func tg_tilt(dx: i64, dy: i64, dz: i64, ang: i64, phi: i64, out: *i64) -> i64
97func tg_species_palette(species: i64) -> i64
called by 1: treegen_build_sp
108func treegen_build_sp(P: *i64, seed: i64, species: i64) -> i64
218func treegen_build(P: *i64, seed: i64) -> i64 { return treegen_build_sp(P, seed, 0) }
called by 3: mainmainmain calls 1: treegen_build_sp
220func tg_part_sdf(P: *i64, k: i64, x: i64, y: i64, z: i64) -> i64
called by 1: tg_sdf calls 2: tg_isqrttg_clamp
235func tg_sdf(P: *i64, np: i64, x: i64, y: i64, z: i64, kindout: *i64) -> i64
called by 1: treegen_render calls 1: tg_part_sdf
257func treegen_render(P: *i64, np: i64, yaw: i64, camz: i64, bgr: i64, bgg: i64, bgb: i64, fb: *i64) -> i64
323func tg_w() -> i64 { return TG_W }
324func tg_h() -> i64 { return TG_H }