code wiki / _hdl_build / nx_skullsdf.nx
nx_skullsdf.nx
buildroot/runtime/_hdl_build/nx_skullsdf.nx
about
nx_skullsdf.nx -- the skull as a FUSED SHELL WITH OPENINGS, built in the implicit path.
★WHY THIS EXISTS, from two render cycles of evidence rather than preference. nx_skullgen emits the
skull as seven LOFTED TUBES. Rendered, that is seven separate objects sharing a bounding box: the
nasal bones float clear of the face, the zygomatic arch is a rod passing through nothing, and the
braincase is a balloon with a jaw hanging near it. Moving the tubes closer helps a little and cannot
fix the class of problem, because A SKULL IS NOT A SET OF TUBES -- it is one continuous fused shell
with holes cut in it. Tubes cannot fuse and cannot have holes.
★THE IMPLICIT PATH DOES EXACTLY THOSE TWO THINGS AND WE ALREADY OWN IT: smooth-union joins bones into
one surface, subtraction cuts the orbits and the nasal aperture as real openings, and nx_isosurf's
surface_nets polygonizes the result into nx_trimesh. The plan reserved SDF for viscera on the grounds
that it cannot resolve an eyelash -- true, and irrelevant to bone, whose features are centimetres.
⚠So this does NOT replace the loft path for skin. It claims the skull only.
nx_skullsdf <out.nxmesh> [sex 0-1000] [robust 0-1000] [grid]
license_tier: ORIGINAL expect_exit: 0 No hw writes (Rule 26).
dependencies 3 imports · 0 importers
imports: nx_isosurf.nxnx_itoa_lib.nxnx_memfloor.nx
imported by: nobody (leaf or entry point)
call flow from main pre-order; caps 40 nodes / depth 6 declared; ↻ = already shown
structs
| none |
consts
| 21 | const SS_MAGIC_2026: i64 = 2026 |
| 22 | const SS_MAGIC_1024: i64 = 1024 |
| 23 | const SS_MAGIC_8388608: i64 = 8388608 |
| 24 | const SS_MAGIC_8388607: i64 = 8388607 |
| 25 | const SS_MAGIC_40000: i64 = 40000 |
| 27 | const SS_G: i64 = 160 // grid cells per axis |
| 28 | const SS_EXT: i64 = 120 // world half-extent in MILLIMETRES. A male skull is ~185mm long and |
| 42 | const SS_SCALE: i64 = 1000 |
| 43 | const SS_REF_W: i64 = 151 // reference bounding box, mm, measured off BodyParts3D |
| 44 | const SS_REF_H: i64 = 209 |
| 45 | const SS_REF_D: i64 = 215 |
| 46 | const SS_TOL: i64 = 25 // mm each dimension may differ before the build is called wrong |
| 47 | const SS_Q: i64 = 1024 // fixed point for the distance functions |
| 48 | const SS_NQ: i64 = 4096 // the scale surface_nets emits gradient normals in (nx_isosurf.nx:68) |
| 49 | const SS_ISO: i64 = 0 |
| 50 | const SS_BONE: i64 = 0xe8e0d8 |
| 62 | const SS_K: i64 = 6 |
| 216 | const SP_N: i64 = 20 |
| 217 | const P_VW: i64 = 0 // vault half-width |
| 218 | const P_VH: i64 = 1 // vault half-height |
| 219 | const P_VD: i64 = 2 // vault half-depth |
| 220 | const P_VY: i64 = 3 // vault centre y |
| 221 | const P_VZ: i64 = 4 // vault centre z |
| 222 | const P_FY: i64 = 5 // frontal centre y |
| 223 | const P_FZ: i64 = 6 // frontal centre z |
| 224 | const P_FH: i64 = 7 // frontal half-height |
| 225 | const P_FD: i64 = 8 // frontal half-depth |
| 226 | const P_MY: i64 = 9 // maxilla centre y |
| 227 | const P_MZ: i64 = 10 // maxilla centre z |
| 228 | const P_MW: i64 = 11 // maxilla half-width |
| 229 | const P_MH: i64 = 12 // maxilla half-height |
| 230 | const P_MD: i64 = 13 // maxilla half-depth |
| 231 | const P_JY: i64 = 14 // mandible chin y |
| 232 | const P_JZ: i64 = 15 // mandible chin z |
| 233 | const P_RX: i64 = 16 // ramus x offset |
| 234 | const P_RY: i64 = 17 // ramus centre y |
| 235 | const P_OR: i64 = 18 // orbit radius |
| 236 | const P_OX: i64 = 19 // orbit centre x |
| 351 | const SS_LAT_MID: i64 = 25 // |x| under this is the midline column |
| 352 | const SS_LAT_FAR: i64 = 55 // |x| over this is the far-lateral column (temple / zygomatic arch / gonion) |
| 575 | const SG_DIM: i64 = 24 // spatial hash grid, cells per axis |
| 576 | const SG_EXT: i64 = 140 // half-extent covered, mm |
functions
| 72 | func ss_k() -> i64 { if SS_KSET == 1 { return SS_KVAL } return SS_K } |
| 74 | func ss_puts(s: *u8) -> i64 { var n: i64=0; while s[n]!=(0 as u8){n=n+1} sys_write(1,s,n); return 0 } |
| 79 | func ss_pn(v: i64) -> i64 { nxi_out(v); return 0 } |
| 80 | func ss_atoi(s: *u8) -> i64 called by 1: main |
| 86 | func ss_streq(a: *u8, b: *u8) -> i64 called by 1: main |
| 91 | func ss_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 } |
| 92 | func ss_abs(v: i64) -> i64 { if v<0 { return 0-v } return v } |
| 93 | func ss_min(a: i64, b: i64) -> i64 { if a<b { return a } return b } |
| 94 | func ss_max(a: i64, b: i64) -> i64 { if a>b { return a } return b } called by 1: ss_sub |
| 107 | func ss_ellipsoid(px: i64, py: i64, pz: i64, cx: i64, cy: i64, cz: i64, rx: i64, ry: i64, rz: i64) -> i64 |
| 182 | func ss_capsule(px: i64, py: i64, pz: i64, ax: i64, ay: i64, az: i64, bx: i64, by: i64, bz: i64, r: i64) -> i64 |
| 198 | func ss_smin(a: i64, b: i64, k: i64) -> i64 |
| 205 | func ss_sub(a: i64, b: i64) -> i64 { return ss_max(a, 0-b) } |
| 241 | func ss_defaults(P: *i64) -> i64 |
| 250 | func ss_field_p(px: i64, py: i64, pz: i64, sexf: i64, robust: i64, P: *i64) -> i64 |
| 294 | func ss_pdef() -> *i64 |
| 301 | func ss_field(px: i64, py: i64, pz: i64, sexf: i64, robust: i64) -> i64 |
| 309 | func ss_field_world(px: i64, py: i64, pz: i64, sexf: i64, robust: i64) -> i64 |
| 353 | func ss_tdepth2(y: i64, ax: i64) -> i64 called by 1: ss_tdepth |
| 370 | func ss_tdepth(y: i64) -> i64 { return ss_tdepth2(y, 0) } |
| 371 | func ss_f32(v: i64, scale: i64) -> i64 called by 1: main |
| 389 | func ss_wr32(b: *u8, o: i64, v: i64) -> i64 called by 1: main |
| 405 | func ss_bandix(y: i64) -> i64 called by 1: ss_thick |
| 416 | func ss_band_req(ix: i64) -> i64 called by 1: ss_thick |
| 427 | func ss_rd32(b: *u8, o: i64) -> i64 |
| 430 | func ss_r_f32(bits: i64, scale: i64) -> i64 |
| 452 | func ss_fit(path: *u8, sexf: i64, robust: i64, stride: i64) -> i64 |
| 519 | func ss_load_ref(path: *u8, RX: *i64, RY: *i64, RZ: *i64, cap: i64, stride: i64) -> i64 |
| 578 | func sg_cell(x: i64, y: i64, z: i64) -> i64 called by 1: ss_bin_ref |
| 591 | func ss_bin_ref(RX: *i64, RY: *i64, RZ: *i64, n: i64, head: *i64, next: *i64) -> i64 |
| 604 | func ss_near_ref(x: i64, y: i64, z: i64, RX: *i64, RY: *i64, RZ: *i64, head: *i64, next: *i64) -> i64 |
| 643 | func ss_score_fwd(RX: *i64, RY: *i64, RZ: *i64, n: i64, sexf: i64, robust: i64, P: *i64) -> i64 |
| 657 | func ss_score_rev(RX: *i64, RY: *i64, RZ: *i64, n: i64, head: *i64, next: *i64, |
| 683 | func ss_score2(RX: *i64, RY: *i64, RZ: *i64, n: i64, head: *i64, next: *i64, |
| 692 | func ss_tune(path: *u8, sexf: i64, robust: i64, stride: i64, passes: i64) -> i64 |
| 749 | func ss_thick(path: *u8, sexf: i64, robust: i64, stride: i64) -> i64 |
| 822 | func ss_grad(sexf: i64, robust: i64, step: i64, near: i64) -> i64 |
| 868 | func main(argc: i64, argv: *i64) -> i64 |