code wiki / _hdl_build / nx_bodyparts.nx
nx_bodyparts.nx
buildroot/runtime/_hdl_build/nx_bodyparts.nx
about
nx_bodyparts.nx -- L0 TAXON + STRUCTURE CENSUS of the SEMANTIC TWIN LADDER (debt 1785954089;
operator 2026-08-05: "it is a human, female, has a head, then eyes... a clay blob is not the same
object as a girl"). Metric distance alone ranked an ARMLESS body first (nx_bodybench 278 vs 232) --
because no instrument could say WHAT the thing is. This organ answers the first question:
IS IT A HUMANOID, AND WHICH PARTS EXIST?
METHOD (structural, no rig required so it works on ANY mesh soup): slice the mesh into y-bands; in
each band build an x-histogram and count CLUSTERS (occupied runs separated by >=BP_GAP empty bins).
A standing humanoid has a signature no blob can fake: 3 clusters where the arms are clear of the
torso, 2 clusters where the legs separate, and a NECK (a width minimum) below a head mass. A pawn
silhouette is 1 cluster everywhere and is REFUSED as a humanoid -- semantically, not by score.
Bone-weight-driven NAMED segmentation (L2, VRM's 51 humanoid bones = free parts for rigged donors)
is the next rung and rides the same output rows.
nx_bodyparts <mesh.nxmesh> [bands] | selftest
Emits JSON: per-region cluster maxima, neck/head findings, part census, VERDICT=HUMANOID|NOT-HUMANOID
with the MISSING part named. license_tier: ORIGINAL expect_exit: 0
dependencies 1 imports · 0 importers
imports: nx_syscalls.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
| 19 | const BP_MAGIC_65536: i64 = 65536 |
| 20 | const BP_MAGIC_1600: i64 = 1600 |
| 21 | const BP_MAGIC_262144: i64 = 262144 |
| 22 | const BP_MAGIC_1350: i64 = 1350 |
| 23 | const BP_MAGIC_1300: i64 = 1300 |
| 24 | const BP_MAGIC_1430: i64 = 1430 |
| 26 | const BP_CAP: i64 = 33554432 |
| 27 | const BP_MAXTRI: i64 = 400000 |
| 28 | const BP_MAXBAND: i64 = 256 |
| 29 | const BP_XBINS: i64 = 128 |
| 30 | const BP_GAP: i64 = 2 |
| 31 | const BP_M8388607: i64 = 8388607 |
| 32 | const BP_M8388608: i64 = 8388608 |
| 33 | const BP_BIG: i64 = 4611686018427387903 |
| 35 | const BP_ARM_LO: i64 = 550 |
| 36 | const BP_ARM_HI: i64 = 800 |
| 37 | const BP_LEG_LO: i64 = 80 |
| 38 | const BP_LEG_HI: i64 = 420 |
| 39 | const BP_NECK_LO: i64 = 800 |
| 40 | const BP_NECK_HI: i64 = 920 |
| 42 | const BP_NECK_FRAC: i64 = 600 |
| 44 | const BP_HEAD_FRAC: i64 = 900 |
functions
| 46 | func hw(s: *u8) -> i64 { var n: i64=0; while s[n]!=(0 as u8){n=n+1} sys_write(1,s,n); return 0 } |
| 47 | func pn(v: i64) -> i64 { let b: *u8=sys_mmap(32) as *u8; var x: i64=v; var ng: i64=0; if x<0{ng=1;x=0-x} var i: i64=31; if x==0{b[i]=48 as u8;i=i-1} while x>0{b[i]=(48+x%10) as u8;x=x/10;i=i-1} if ng==1{b[i]=45 as u8;i=i-1} sys_write(1,(b as i64+i+1) as *u8,31-i); return 0 } |
| 48 | func bp_u32(b: *u8, o: i64) -> i64 { return (b[o] as i64) + ((b[o+1] as i64)<<8) + ((b[o+2] as i64)<<16) + ((b[o+3] as i64)<<24) } called by 1: bp_load |
| 50 | func bp_f32q(w: i64) -> i64 called by 1: bp_load |
| 64 | func bp_refuse(reason: *u8) -> i64 { hw("BODYPARTS REFUSED: " as *u8); hw(reason); hw("\n" as *u8); return 0 } |
| 67 | func bp_load(path: *u8, vx: *i64) -> i64 |
| 98 | func bp_clusters(occ: *i64) -> i64 called by 1: bp_run |
| 116 | func bp_width(occ: *i64) -> i64 called by 1: bp_run |
| 128 | func bp_run(path: *u8, nband: i64) -> i64 |
| 275 | func bp_encf(v: i64, scale: i64) -> i64 called by 1: bp_tri |
| 290 | func bp_w32(b: *u8, o: i64, v: i64) -> i64 |
| 295 | func bp_tri(b: *u8, off: i64, x0: i64, y0: i64, z0: i64, x1: i64, y1: i64, z1: i64, x2: i64, y2: i64, z2: i64) -> i64 |
| 304 | func bp_box(b: *u8, off: i64, xlo: i64, xhi: i64, ylo: i64, yhi: i64, zlo: i64, zhi: i64) -> i64 |
| 320 | func bp_hdr(b: *u8, ntri: i64) -> i64 |
| 330 | func bp_save(path: *u8, b: *u8, ntri: i64) -> i64 |
| 340 | func bp_fix_pawn(path: *u8) -> i64 |
| 347 | func bp_fix_human(path: *u8) -> i64 |
| 361 | func bp_selftest() -> i64 |
| 375 | func main(argc: i64, argv: *i64) -> i64 |