code wiki / _hdl_build / nx_bodybench.nx
nx_bodybench.nx
buildroot/runtime/_hdl_build/nx_bodybench.nx
about
nx_bodybench.nx -- ★SOVEREIGN BODY JUDGE, registerable as an MCP tool. Moves the shape ruler OFF the dev
laptop (it was PowerShell + System.Drawing) INTO a NishiLang organ that runs on the NAS: any agent, plan or
workflow can now measure a generated body against the BodyParts3D oracle with ONE call and get a permil
verdict back as JSON -- no image round-trip, no third-party runtime, no human in the loop. That is what
"it needs to scale" means: the measurement is a service, not a person at a keyboard.
OOP, tagged-dispatch (NOT struct fn-pointer fields -- seq715: obj.fn(args) compiles and does NOT call):
* MeshView -- an object that renders ONE mesh at ONE yaw into coverage + per-pixel normal buffers
(a minimal measurement rasterizer: projection + edge-function fill + z-buffer + normal;
no shading/shadow/floor/texture -- those are display concerns, not measurement).
* Judge -- a small hierarchy dispatched by KIND: J_SILH (silhouette IoU) and J_NORMAL (normal-field
angular agreement). judge_eval(kind, ...) is the polymorphic entry; add a kind to extend.
* BodyBench -- orchestrates: renders ours+oracle at yaw 0 and 90, runs each judge, emits per-judge permil
and the HONEST HEADLINE = MIN over judges (hold several judges, publish the minimum).
nx_bodybench <ours.nxmesh> <oracle.nxmesh> [W] [H]
-> {"front_iou":..,"side_iou":..,"shape":..,"headline":..,"self_iou":1000,"self_shape":1000, ...}
The self_* fields are a built-in NON-VACUITY proof: ours-vs-ours must score 1000/1000 or the ruler is broken.
license_tier: ORIGINAL expect_exit: 0
dependencies 2 imports · 0 importers
imports: nx_syscalls.nxnx_itoa_lib.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
| 23 | const BB_Q14: i64 = 16384 |
| 24 | const BB_ZFAR: i64 = 2000000000 |
| 25 | const BB_BIG: i64 = 2000000000 |
| 26 | const BB_M8388607: i64 = 8388607 |
| 27 | const BB_M8388608: i64 = 8388608 |
| 28 | const BB_POSQ0: i64 = 4096 |
| 29 | const BB_TARGET: i64 = 200000 |
| 30 | const BB_MAGIC_40500: i64 = 40500 |
| 31 | const BB_ACOSN: i64 = 8192 // acos LUT resolution over cos in [-Q14,+Q14] |
| 32 | const BB_DETR: i64 = 2 // detail-judge window radius -> a (2R+1)^2 = 5x5 neighbourhood; big |
| 223 | const J_SILH: i64 = 1 |
| 224 | const J_NORMAL: i64 = 2 |
functions
| 36 | func bb_streq(a: *u8, b: *u8) -> i64 |
| 42 | func bb_satoi(s: *u8) -> i64 called by 1: main |
| 48 | func bb_hw(s: *u8) -> i64 { var n: i64 = 0; while s[n] != (0 as u8) { n = n+1 } sys_write(1, s, n); return 0 } |
| 53 | func bb_pn(v: i64) -> i64 { nxi_out(v); return 0 } |
| 54 | func bb_rdbits(b: *u8, o: i64) -> i64 |
| 57 | func bb_f32mul(b: *u8, o: i64, mul: i64) -> i64 |
| 70 | func bb_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 } called by 1: mv_render |
| 71 | func bb_wrap(d: i64) -> i64 { var x: i64 = d % 360; if x < 0 { x = x + 360 } return x } |
| 72 | func bb_min(a: i64, b: i64) -> i64 { if a < b { return a } return b } |
| 73 | func bb_max(a: i64, b: i64) -> i64 { if a > b { return a } return b } called by 1: mv_render |
| 75 | func bb_sin_fill(t: *i64) -> i64 called by 1: main |
| 82 | func bb_acos_fill(acosT: *i64, sinT: *i64) -> i64 |
| 100 | func bb_acos_deg(acosT: *i64, dotq: i64) -> i64 called by 1: judge_eval |
| 116 | func mv_render(mb: *u8, ntris: i64, triBase: i64, lidBase: i64, W: i64, H: i64, yaw: i64, sinT: *i64, |
| 226 | func judge_eval(kind: i64, npx: i64, covA: *i64, covB: *i64, |
| 264 | func bb_detail_fill(W: i64, H: i64, cov: *i64, nx: *i64, ny: *i64, nz: *i64, out: *i64) -> i64 called by 1: main |
| 310 | func bb_detail_score(npx: i64, covA: *i64, covB: *i64, dA: *i64, dB: *i64) -> i64 called by 1: main |
| 333 | func bb_detail_head(W: i64, H: i64, covA: *i64, covB: *i64, dA: *i64, dB: *i64, frac: i64) -> i64 called by 1: main |
| 368 | func bb_emit_kv(name: *u8, v: i64, last: i64) -> i64 |
| 374 | func main(argc: i64, argv: *i64) -> i64 |