code wiki / _hdl_build / nx_skullsdf.nx

nx_skullsdf.nx

buildroot/runtime/_hdl_build/nx_skullsdf.nx

146229 B2774 linesdepth 5pulls 12 transitivereach 0 importersview sourcekind tooltopic skullsdf
docsdependenciesstructsconstsfunctions

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 5 imports · 0 importers

nx_isosurf.nx nx_itoa_lib.nx nx_memfloor.nx nx_sdfprim_lib.nx nx_fieldfit_lib.nx nx_skullsdf.nx

imports: nx_isosurf.nxnx_itoa_lib.nxnx_memfloor.nxnx_sdfprim_lib.nxnx_fieldfit_lib.nx

imported by: nobody (leaf or entry point)

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

main ss_puts ss_streq ss_atoi ss_tune ff_ctx_new sys_mmap nxa_die sys_write sys_exit nxa_lock_take nxa_lock_addr sys_write ↻ nxa_lock_give nxa_lock_addr ↻ nxa_report_overrun sys_write ↻ nxa_dump_printable sys_write ↻ nxa_dump_sizes sys_write ↻ ss_lm_load ss_load_ref ss_rd32 ss_r_f32 ss_ref_map ss_r_f32 ↻ ss_rd32 ↻ ss_puts ↻ ff_bin ff_cell ff_regions ss_defaults ss_load_fit ff_load_prefix sys_mmap ↻ sys_read_file sys_openat_rd sys_lseek sys_mmap ↻

structs

none

consts

23const SS_MAGIC_2026: i64 = 2026
24const SS_MAGIC_1024: i64 = 1024
25const SS_MAGIC_8388608: i64 = 8388608
26const SS_MAGIC_8388607: i64 = 8388607
27const SS_MAGIC_40000: i64 = 40000
29const SS_G: i64 = 160 // grid cells per axis
30const SS_EXT: i64 = 120 // world half-extent in MILLIMETRES. A male skull is ~185mm long and
44const SS_SCALE: i64 = 1000
45const SS_REF_W: i64 = 151 // reference bounding box, mm, measured off BodyParts3D: x lateral
46const SS_REF_H: i64 = 215 // HEIGHT = the file's z extent (BodyParts3D is a floor-origin z-UP body frame)
47const SS_REF_D: i64 = 209 // DEPTH = the file's y extent (antero-posterior, face at -y). Until 2026-09-18 the two
49const SS_TOL: i64 = 25 // mm each dimension may differ before the build is called wrong
50const SS_Q: i64 = SP_Q // fixed point for the distance functions
51const SS_NQ: i64 = 4096 // the scale surface_nets emits gradient normals in (nx_isosurf.nx:68)
52const SS_ISO: i64 = 0
53const SS_BONE: i64 = 0xe8e0d8
66const SS_RDQ: i64 = 256 // fixed-point units per millimetre in the redistanced field
67const SS_RD_INF: i64 = 76800 // 300mm x SS_RDQ -- farther than any point in the sampled box
77const SS_FQ: i64 = SP_FQ
78const SS_RD_NEAR: i64 = 3 // near-band half-width, cells, for the printed |grad| A/B
79const SS_RD_LO: i64 = 800 // |grad| per-mille below this counts under (same bar as ss_grad)
80const SS_RD_HI: i64 = 1200 // |grad| per-mille above this counts over (same bar as ss_grad)
95const SS_K: i64 = 3
147const SS_BHASKARA_NUM_PERMILLE: i64 = 4000
148const SS_BHASKARA_DEN: i64 = 40500
150const SS_LERP_ONE: i64 = 1024
155const SS_PERMILLE: i64 = 1000
158const SS_EXTENT_SENTINEL: i64 = 999999
162const SS_GRAD_BAND_LO: i64 = 800
163const SS_GRAD_BAND_HI: i64 = 1200
165const SS_MARCH_CELLS_DEFAULT: i64 = 2000
166const SS_MARCH_CELLS_MIN: i64 = 1000
176const SP_N: i64 = 87
177const SS_FIT_MIN: i64 = 58 // the v1 vector length: a fit file carrying at least this many ints
181const P_VW: i64 = 0 // vault half-width
182const P_VH: i64 = 1 // vault half-height
183const P_VD: i64 = 2 // vault half-depth
184const P_VY: i64 = 3 // vault centre y
185const P_VZ: i64 = 4 // vault centre z
186const P_FY: i64 = 5 // frontal centre y
187const P_FZ: i64 = 6 // frontal centre z
188const P_FH: i64 = 7 // frontal half-height
189const P_FD: i64 = 8 // frontal half-depth
190const P_MY: i64 = 9 // maxilla centre y
191const P_MZ: i64 = 10 // maxilla centre z
192const P_MW: i64 = 11 // maxilla half-width
193const P_MH: i64 = 12 // maxilla half-height
194const P_MD: i64 = 13 // maxilla half-depth
195const P_JY: i64 = 14 // mandible chin y
196const P_JZ: i64 = 15 // mandible chin z
197const P_RX: i64 = 16 // ramus x offset
198const P_RY: i64 = 17 // ramus centre y
199const P_OR: i64 = 18 // orbit radius
200const P_OX: i64 = 19 // orbit centre x
206const P_BX: i64 = 20 // brow bar half-span
207const P_BY: i64 = 21 // brow bar y
208const P_BZ: i64 = 22 // brow bar z
209const P_ZAX: i64 = 23 // zygomatic arch face-end x
210const P_ZAY: i64 = 24 // zygomatic arch face-end y
211const P_ZAZ: i64 = 25 // zygomatic arch face-end z
212const P_ZBX: i64 = 26 // zygomatic arch ear-end x
213const P_ZBY: i64 = 27 // zygomatic arch ear-end y
214const P_ZBZ: i64 = 28 // zygomatic arch ear-end z
215const P_ZR: i64 = 29 // zygomatic arch radius
216const P_NY: i64 = 30 // nasal bones centre y
217const P_NZ: i64 = 31 // nasal bones centre z
218const P_NRX: i64 = 32 // nasal radius x
219const P_NRY: i64 = 33 // nasal radius y
220const P_NRZ: i64 = 34 // nasal radius z
221const P_JAX: i64 = 35 // jaw body chin-end x
222const P_JAZ: i64 = 36 // jaw body chin-end z offset from P_JZ
223const P_JBX: i64 = 37 // jaw body angle-end x
224const P_JBY: i64 = 38 // jaw body angle-end y offset from P_JY
225const P_JBZ: i64 = 39 // jaw body angle-end z
226const P_JR: i64 = 40 // jaw body radius
227const P_RZ: i64 = 41 // ramus centre z
228const P_RRX: i64 = 42 // ramus radius x
229const P_RRY: i64 = 43 // ramus radius y
230const P_RRZ: i64 = 44 // ramus radius z
231const P_OAY: i64 = 45 // orbit opening y
232const P_OAZ: i64 = 46 // orbit opening z
233const P_OBX: i64 = 47 // orbit apex x
234const P_OBY: i64 = 48 // orbit apex y
235const P_OBZ: i64 = 49 // orbit apex z
236const P_PAY: i64 = 50 // nasal aperture opening y
237const P_PAZ: i64 = 51 // nasal aperture opening z
238const P_PBY: i64 = 52 // nasal aperture back y
239const P_PBZ: i64 = 53 // nasal aperture back z
240const P_PR: i64 = 54 // nasal aperture radius
241const P_CRX: i64 = 55 // chin ellipsoid radius x
242const P_CRY: i64 = 56 // chin ellipsoid radius y
243const P_CRZ: i64 = 57 // chin ellipsoid radius z
248const P_UY: i64 = 58 // upper arch: occlusal centre y
249const P_UZ: i64 = 59 // upper arch: arc centre z
250const P_UAX: i64 = 60 // upper arch: lateral semi-axis
251const P_UAZ: i64 = 61 // upper arch: anterior semi-axis
252const P_UTH: i64 = 62 // upper arch: half arc span, degrees
253const P_UN: i64 = 63 // upper arch: tooth count
254const P_UTW: i64 = 64 // upper arch: tooth width
255const P_UTHT: i64 = 65 // upper arch: tooth height
256const P_UPR: i64 = 66 // upper arch: molar widening, permil at the arc ends
257const P_LY: i64 = 67 // lower arch: occlusal centre y
258const P_LZ: i64 = 68 // lower arch: arc centre z
259const P_LAX: i64 = 69 // lower arch: lateral semi-axis
260const P_LAZ: i64 = 70 // lower arch: anterior semi-axis
261const P_LTH: i64 = 71 // lower arch: half arc span, degrees
262const P_LN: i64 = 72 // lower arch: tooth count
263const P_LTW: i64 = 73 // lower arch: tooth width
264const P_LTHT: i64 = 74 // lower arch: tooth height
265const P_LPR: i64 = 75 // lower arch: molar widening, permil at the arc ends
271const P_OSW: i64 = 76 // orbit socket semi-width x (the rim's lateral half-span)
272const P_OSH: i64 = 77 // orbit socket semi-height y
273const P_OSD: i64 = 78 // orbit socket semi-depth z (the back wall sits at P_OCZ - P_OSD, inside the bone)
274const P_OCZ: i64 = 79 // orbit socket centre z; the front pokes through the face at P_OCZ + P_OSD
275const P_PAW: i64 = 80 // piriform aperture width (rim to rim)
276const P_PAH: i64 = 81 // piriform aperture height (rhinion to nasospinale)
277const P_PAD: i64 = 82 // piriform aperture depth: the nasal floor wall sits P_PAD behind the rim at P_PAZ
278const P_NTILT: i64 = 83 // nasal plate pitch, degrees: the rhinion end forward of the nasion end
279const P_NTH: i64 = 84 // nasal plate half-thickness
280const P_AAR: i64 = 85 // alveolar process radius: the U-arch of bone the upper teeth stand in
281const P_FPR: i64 = 86 // maxillary frontal process radius (the bone either side of the aperture, up to the orbits)
497const SS_LAT_MID: i64 = 25 // |x| under this is the midline column
498const SS_LAT_FAR: i64 = 55 // |x| over this is the far-lateral column (temple / zygomatic arch / gonion)
523const SS_TD_N: i64 = 9
801const SG_DIM: i64 = 24 // spatial hash grid, cells per axis
802const SG_EXT: i64 = 140 // half-extent covered, mm
803const SS_TUNE_LAT: i64 = 6 // reverse-term lattice spacing, mm (the objective's sampling of OUR surface)
804const SS_GR_N: i64 = 7 // the named regions of ss_gap_region (vault, base, brow-orbits, nasal, zygomatic, mandible, maxilla)
814const SS_LMQ_N: i64 = 18 // the ruler's quantity count, in skc_qname order (15 + the three of 2026-09-19)
815const SS_LMQ_PRED: i64 = 16 // the quantities this field can place from its stations
816const SS_LMQ_BYTES: i64 = 4096
817const SS_LMQ_NONE: i64 = 0 - 999999999 // "this quantity is not predicted from the stations" -- a value no landmark can reach
1127const SS_RES_MAGIC: i64 = 0x4e585253 // 'NXRS'
1128const SS_RES_MAXN: i64 = 256 // lattice nodes per axis, upper bound (256^3 x 8 = 134MB;

functions

105func ss_k() -> i64 { if SS_KSET == 1 { return SS_KVAL } return SS_K }
107func 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 }
112func ss_pn(v: i64) -> i64 { nxi_out(v); return 0 }
113func ss_atoi(s: *u8) -> i64
called by 1: main
119func ss_streq(a: *u8, b: *u8) -> i64
called by 1: main
124func ss_isqrt(v: i64) -> i64 { return sp_isqrt(v) }
125func ss_abs(v: i64) -> i64 { if v<0 { return 0-v } return v }
called by 1: main
126func ss_min(a: i64, b: i64) -> i64 { if a<b { return a } return b }
127func ss_max(a: i64, b: i64) -> i64 { if a>b { return a } return b }
285func ss_param_live(k: i64) -> i64
307func ss_defaults(P: *i64) -> i64
called by 2: ss_pdefss_tune
341func ss_field_p(px: i64, py: i64, pz: i64, sexf: i64, robust: i64, P: *i64) -> i64
called by 1: ss_field calls 1: ss_field_p_q
346func ss_field_p_q(px: i64, py: i64, pz: i64, sexf: i64, robust: i64, P: *i64) -> i64
428func ss_load_fit(P: *i64) -> i64
called by 2: ss_pdefss_tune calls 1: ff_load_prefix
434func ss_pdef() -> *i64
442func ss_field(px: i64, py: i64, pz: i64, sexf: i64, robust: i64) -> i64
450func ss_field_world(px: i64, py: i64, pz: i64, sexf: i64, robust: i64) -> i64
called by 1: ss_gapmap calls 1: ss_field
455func ss_field_world_q(px: i64, py: i64, pz: i64, sexf: i64, robust: i64) -> i64
called by 1: main calls 2: ss_field_p_qss_pdef
499func ss_tdepth2(y: i64, ax: i64) -> i64
called by 1: ss_tdepth
516func ss_tdepth(y: i64) -> i64 { return ss_tdepth2(y, 0) }
called by 1: main calls 1: ss_tdepth2
526func ss_td_tab() -> i64
called by 1: ss_tdepth_q
546func ss_tdepth_q(y: i64) -> i64
called by 1: main calls 1: ss_td_tab
563func ss_f32(v: i64, scale: i64) -> i64
581func ss_wr32(b: *u8, o: i64, v: i64) -> i64
597func ss_bandix(y: i64) -> i64
called by 1: ss_thick
608func ss_band_req(ix: i64) -> i64
called by 1: ss_thick
619func ss_rd32(b: *u8, o: i64) -> i64
622func ss_r_f32(bits: i64, scale: i64) -> i64
655func ss_ref_map(buf: *u8, o: i64, cx: i64, cy: i64, cz: i64, scale: i64, out3: *i64) -> i64
called by 2: ss_fitss_load_ref calls 2: ss_r_f32ss_rd32
661func ss_ref_map_normal(buf: *u8, o: i64, scale: i64, out3: *i64) -> i64
calls 2: ss_r_f32ss_rd32
667func ss_fit(path: *u8, sexf: i64, robust: i64, stride: i64) -> i64
736func ss_load_ref(path: *u8, RX: *i64, RY: *i64, RZ: *i64, cap: i64, stride: i64) -> i64
called by 1: ss_tune calls 3: ss_rd32ss_r_f32ss_ref_map
821func ss_lm_load() -> i64
called by 1: ss_tune
857func ss_lm_predict(P: *i64, Q: *i64) -> i64
901func ss_lm_term(P: *i64) -> i64
called by 1: ss_tune calls 1: ss_lm_predict
925func ss_tune(path: *u8, sexf: i64, robust: i64, stride: i64, passes: i64, step0: i64, save: *u8) -> i64
988func ss_thick(path: *u8, sexf: i64, robust: i64, stride: i64) -> i64
1061func ss_grad(sexf: i64, robust: i64, step: i64, near: i64) -> i64
1138func ss_res_load(path: *u8) -> i64
called by 1: main
1155func ss_res_at(x: i64, y: i64, z: i64) -> i64
called by 1: main
1206func ss_vb_count(rbuf: *u8, rhdr: i64, rnt: i64, cy: i64, cz: i64, ocy: i64, ocz: i64,
called by 1: ss_voxref calls 2: ss_r_f32ss_rd32
1246func ss_vb_build(rbuf: *u8, rhdr: i64, rnt: i64, cx: i64, cy: i64, cz: i64, ocx: i64, ocy: i64, ocz: i64,
called by 1: ss_voxref calls 2: ss_r_f32ss_rd32
1294func ss_gap_region(x: i64, y: i64, z: i64) -> i64
called by 1: ss_gapmap calls 2: ss_pdefsp_icos
1320func ss_gap_regname(i: i64) -> i64
called by 1: ss_gapmap calls 1: ss_puts
1331func ss_gap_wrcol(b: *u8, o: i64, gq: i64) -> i64
called by 1: ss_gapmap calls 2: ss_wr32ss_f32
1352func ss_gap_node(w: i64, org: i64, cell: i64, n1: i64) -> i64
called by 1: ss_gapmap
1359func ss_gap_wrhdr(buf: *u8, nt: i64) -> i64
called by 2: ss_gapmapss_voxref calls 1: ss_wr32
1375func ss_gapmap(ref: *u8, oursout: *u8, oraout: *u8, sexf: i64, robust: i64, cum: i64, resout: *u8, latmm: i64) -> i64
1912func ss_voxref(ref: *u8, outp: *u8, cum: i64) -> i64
2135func ss_rd_try(f: i64, g: i64, cell: i64, best: i64) -> i64
called by 2: ss_gapmapmain
2154func ss_rd_solve(a0: i64, b0: i64, c0: i64, h: i64) -> i64
called by 1: ss_rd_sweep calls 1: ss_isqrt
2177func ss_rd_sweep(dist: *i64, n1: i64, h: i64, di: i64, dj: i64, dk: i64) -> i64
called by 2: ss_gapmapmain calls 1: ss_rd_solve
2230func ss_rd_gradstat(F: *i64, n1: i64, cell: i64, q: i64, tag: *u8) -> i64
called by 1: main calls 3: ss_isqrtss_putsss_pn
2279func main(argc: i64, argv: *i64) -> i64