code wiki / (root) / nx_mmdev_lib.nx

nx_mmdev_lib.nx

buildroot/runtime/nx_mmdev_lib.nx

16161 B380 linesdepth 3pulls 5 transitivereach 13 importersview sourcekind library
docsdependenciesstructsconstsfunctions

about

nx_mmdev_lib.nx -- THE MILLIMETRE SURFACE-DEVIATION RULER (PG4, procgen.plan, 2026-08-24). WHY: every realism claim on the human lane is graded by nx_bodybench in PERMIL of silhouette and normal agreement. A cosmetic surgeon buys none of that. The clinical unit is millimetres of predicted-vs-actual surface deviation, and the published soft-tissue prediction bar sits near 1-2 mm mean error. Without a ruler in that unit every fidelity claim after this is aesthetic opinion wearing a number. WHAT IT MEASURES: for EVERY vertex of mesh A, the exact Euclidean distance to the nearest point on the SURFACE of mesh B (point-to-triangle, Ericson 5.1.5, all integer), then mean, p95 and max. Full population, never a sample: `verts` is printed and the gate binds every assertion to it. UNIT DERIVED, NOT PICKED: coordinates are held in tenths of a millimetre. The barycentric test forms products of two dot products; each dot is bounded by 3 * extent^2. For an extent of 2.5 m at 0.1 mm that is 3 * 25000^2 = 1.9e9 per dot and 3.5e18 per product, under the 9.2e18 i64 ceiling. A finer unit overflows a whole-body subject; a coarser one is too blunt for a 1 mm bar. The extent bound is CHECKED at load and the ruler REFUSES by name above it -- wrong in the direction of doing nothing. ACCELERATION WITHOUT SAMPLING: B's triangles go into a uniform grid whose resolution is derived from the triangle count (about four triangles per cell). A query walks expanding rings of cells and stops when the ring's inner face is provably farther than the best hit so far. Exact, never approximate. DECLARED IMPRECISIONS: (1) A's vertices are visited per triangle-vertex, so a vertex shared by k faces weighs k times -- the mean is valence-weighted, which favours dense regions; printed as `tri_verts`. (2) p95 is read from a histogram with 0.1 mm bins, so it is exact to the bin. (3) One-sided A->B; the gate runs both directions and reports both. license_tier: ORIGINAL

dependencies 3 imports · 9 importers

nx_syscalls.nx nx_vecmath.nx nx_nxmesh_lib.nx nx_mmdev_lib.nx nx_autorig_pose_gate.nx nx_devpaint_gate.nx nx_devpaint_lib.nx nx_mmdev.nx nx_mmdev_gate.nx nx_rigbench_lib.nx nx_rigbench_lib_t21.nx nx_xport_gate.nx nx_xport_lib.nx

imports: nx_syscalls.nxnx_vecmath.nxnx_nxmesh_lib.nx

imported by: nx_autorig_pose_gate.nxnx_devpaint_gate.nxnx_devpaint_lib.nxnx_mmdev.nxnx_mmdev_gate.nxnx_rigbench_lib.nxnx_rigbench_lib_t21.nxnx_xport_gate.nxnx_xport_lib.nx

structs

none

consts

32const MD_EXTENT_MAX: i64 = 25000
35const MD_HIST_BINS: i64 = 5000
36const MD_TARGET_TRIS_PER_CELL: i64 = 4
37const MD_P95_NUM: i64 = 95
38const MD_P95_DEN: i64 = 100
41const MD_R_VERTS: i64 = 0
42const MD_R_TRIS_B: i64 = 1
43const MD_R_SUM: i64 = 2
44const MD_R_MAX: i64 = 3
45const MD_R_P95: i64 = 4
46const MD_R_CELLS_AXIS: i64 = 5
47const MD_R_OVERFLOW_BIN: i64 = 6
48const MD_R_REFUSED: i64 = 7 // 0 ok, 1 extent bound, 2 unreadable, 3 empty
49const MD_R_N: i64 = 8
131const MD_G_MIN: i64 = 0
132const MD_G_CS: i64 = 3
133const MD_G_N: i64 = 4
134const MD_G_HEAD: i64 = 5
135const MD_G_NEXT: i64 = 6
136const MD_G_TRI: i64 = 7
137const MD_G_NTRI: i64 = 8
138const MD_G_ENTRIES: i64 = 9
149const MD_G_COORD: i64 = 10
150const MD_G_WORDS: i64 = 11

functions

51func md_res() -> *i64
called by 5: mainmainmainrb_runrb_run calls 1: sys_mmap
59func md_dist2_pt_tri(px: i64, py: i64, pz: i64,
called by 2: mainmd_query
152func md_cell_of(v: i64, mn: i64, cs: i64, n: i64) -> i64
160func md_grid_build(mb: *u8, gp: *i64) -> i64
269func md_query(mb: *u8, gp: *i64, px: i64, py: i64, pz: i64) -> i64
329func md_measure(ma: *u8, mb: *u8, res: *i64) -> i64
380func md_mean(res: *i64) -> i64 { if res[MD_R_VERTS] == 0 { return 0 } return res[MD_R_SUM] / res[MD_R_VERTS] }
called by 3: mm_dirmainmain