code wiki / (root) / nx_anatstack.nx

nx_anatstack.nx

buildroot/runtime/nx_anatstack.nx

26292 B410 linesdepth 2pulls 3 transitivereach 13 importersview sourcekind library
docsdependenciesstructsconstsfunctions

about

nx_anatstack.nx -- ★LAYERED ANATOMICAL MODEL (operator 2026-07-08: "stop building circles on circles -- you need the skeleton and muscles and all that so that as you get to the top layer it's anatomically PERFECT for the final layer brush through"). The RIGHT inside-out architecture: don't eyeball skin ellipsoids -- build the real stack and let the skin EMERGE from it: LAYER 0 SKELETON -- the skull's bony forms (cranium, temporals, zygomatics, maxilla, mandible, nasal, brow) LAYER 1 MUSCLE -- the facial muscles as CAPSULES (temporalis, masseter, zygomaticus, orbicularis, ...) LAYER 2 FAT/SOFT -- the fat pads (malar, buccal, periorbital, labial, submental) -> SKIN = the smooth-union ENVELOPE over all layers + a dermal offset = anatomically DERIVED, not sculpted. Self-contained (own SDF + integer ray-march) so it doesn't destabilize the sdf_render pipeline. Capsules are a real muscle shape (beyond ellipsoids). Every position is anatomically reasoned in the faceanat landmark frame (y up: chin -676, mouth -390, subnasale -150, eye +178, brow +322, crown +760; -z = front/toward camera). license_tier: ORIGINAL

dependencies 2 imports · 6 importers

nx_syscalls.nx nx_itrig.nx nx_anatstack.nx nx_anatstack_gate.nx nx_creaturegen.nx nx_face_expr_gate.nx nx_facesculpt_gate.nx nx_facs.nx nx_figuregen.nx

imports: nx_syscalls.nxnx_itrig.nx

imported by: nx_anatstack_gate.nxnx_creaturegen.nxnx_face_expr_gate.nxnx_facesculpt_gate.nxnx_facs.nxnx_figuregen.nx

structs

none

consts

15const AS_MAGIC_1024: i64 = 1024
16const AS_MAGIC_374761393: i64 = 374761393
17const AS_MAGIC_668265263: i64 = 668265263
18const AS_MAGIC_1274126177: i64 = 1274126177
19const AS_MAGIC_2654435761: i64 = 2654435761
20const AS_MAGIC_1013904223: i64 = 1013904223
21const AS_MAGIC_4096: i64 = 4096
22const AS_MAGIC_1048576: i64 = 1048576
23const AS_MAGIC_65536: i64 = 65536
24const AS_MAGIC_1000000: i64 = 1000000
25const AS_MAGIC_1000000000: i64 = 1000000000
26const AS_MAGIC_1400: i64 = 1400
27const AS_MAGIC_16777215: i64 = 16777215
29const AS_STRIDE: i64 = 12 // per-part: layer,type, p1(3), r(3), p2(3), _
30const AS_BONE: i64 = 0
31const AS_MUSCLE: i64 = 1
32const AS_FAT: i64 = 2
33const AS_ELLIP: i64 = 0
34const AS_CAPS: i64 = 1
35const AS_W: i64 = 512
36const AS_H: i64 = 512
37const AS_FOCAL: i64 = 640
38const AS_K: i64 = 46 // smooth-union blend radius (units)
63const AS_FEAT: i64 = 16777216
64const AS_FUZZ: i64 = 33554432
65const AS_FUZZAMP: i64 = 7 // displacement amplitude (units)
66const AS_FUZZCELL: i64 = 13 // noise lattice cell (units)
72const AS_GLOSS: i64 = 67108864
73const AS_MATTE: i64 = 134217728
74const AS_HAIRM: i64 = 201326592

functions

40func as_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 }
41func as_iabs(v: i64) -> i64 { if v < 0 { return 0-v } return v }
42func as_min(a: i64, b: i64) -> i64 { if a < b { return a } return b }
43func as_clamp(v: i64, lo: i64, hi: i64) -> i64 { if v<lo {return lo} if v>hi {return hi} return v }
called by 1: as_part_sdf
45func as_ellip(P: *i64, i: i64, cx: i64, cy: i64, cz: i64, rx: i64, ry: i64, rz: i64, layer: i64) -> i64
49func as_caps(P: *i64, i: i64, ax: i64, ay: i64, az: i64, bx: i64, by: i64, bz: i64, r: i64, layer: i64) -> i64
82func as_set_skintex(ptr: i64, w: i64, scale: i64) -> i64 { AS_SKINTEX = ptr; AS_SKINTEXW = w; AS_SKINTEXS = scale; return 0 }
called by 3: mainmainmain
83func as_color_last(P: *i64, i_after: i64, rgb: i64) -> i64 { P[i_after - AS_STRIDE + 11] = rgb; return i_after }
84func as_feature_last(P: *i64, i_after: i64, rgb: i64) -> i64 { P[i_after - AS_STRIDE + 11] = rgb + AS_FEAT; return i_after }
85func as_fuzz_last(P: *i64, i_after: i64) -> i64 { P[i_after - AS_STRIDE + 11] = P[i_after - AS_STRIDE + 11] + AS_FUZZ; return i_after }
92func anat_set_expr(e: i64, inten: i64) -> i64 { AS_EXPR = e; AS_EXPRI = inten; return 0 }
93func as_shifty(P: *i64, idx: i64, dy: i64) -> i64 { let b: i64 = idx*AS_STRIDE; P[b+3]=P[b+3]+dy; if P[b+1]==AS_CAPS { P[b+9]=P[b+9]+dy } return 0 }
94func as_shiftz(P: *i64, idx: i64, dz: i64) -> i64 { let b: i64 = idx*AS_STRIDE; P[b+4]=P[b+4]+dz; if P[b+1]==AS_CAPS { P[b+10]=P[b+10]+dz } return 0 }
95func as_growx(P: *i64, idx: i64, dx: i64) -> i64 { P[idx*AS_STRIDE+5]=P[idx*AS_STRIDE+5]+dx; return 0 }
96func as_growy(P: *i64, idx: i64, dy: i64) -> i64 { P[idx*AS_STRIDE+6]=P[idx*AS_STRIDE+6]+dy; return 0 }
99func as_apply_expr(P: *i64) -> i64
124func as_h3(ix: i64, iy: i64, iz: i64) -> i64
called by 1: as_noise3
130func as_noise3(x: i64, y: i64, z: i64) -> i64
called by 1: anatstack_sdf calls 1: as_h3
151func anatstack_build(P: *i64) -> i64
211func as_part_sdf(P: *i64, k: i64, x: i64, y: i64, z: i64) -> i64
232func as_smin(a: i64, b: i64, k: i64) -> i64
called by 1: anatstack_sdf calls 2: as_iabsas_min
241func anatstack_sdf(P: *i64, np: i64, x: i64, y: i64, z: i64, maxlayer: i64, inflate: i64) -> i64
263func anatstack_nearest_fl(P: *i64, np: i64, x: i64, y: i64, z: i64, maxlayer: i64, inflate: i64) -> i64
called by 2: anatstack_rendermain calls 1: as_part_sdf
281func anatstack_render(P: *i64, np: i64, yaw: i64, camz: i64, maxlayer: i64, inflate: i64, cr: i64, cg: i64, cb: i64, fb: *i64) -> i64
409func as_w() -> i64 { return AS_W }
called by 1: main
410func as_h() -> i64 { return AS_H }