nx_gltf_inventory_candidate_t180.nx
buildroot/runtime/nx_gltf_inventory_candidate_t180.nx
about
nx_gltf2mesh.nx -- GLB/VRM -> NXMSH2 mesh-oracle extractor (debt 1785902685, the D2 POSITION slice).
The whole bench suite (nx_bodybench / nx_twinbench / nx_curvebench / nx_facemark) judges .nxmesh
oracles, but NO organ could turn a donor .glb/.vrm into one -- donor FORM was invisible to every
instrument we own (operator 2026-08-05: the T2 being is still a clay blob because the ruler only
reads skeletons). This organ reads ONLY what a form oracle needs: every TRIANGLES primitive's
POSITION + indices (u16 AND u32, tight or strided bufferViews), multi-mesh multi-primitive concat.
FAIL-CLOSED at every offset (D1): a file this cannot parse REFUSES with a named reason and a
nonzero exit -- never a segfault, never a silent empty mesh (zero accepted tris = REFUSAL).
Morph-target POSITIONs are excluded by scoping the attribute scan to the primitive's attributes{}.
Skinned bind-pose positions are model-space per the glTF spec (node transforms ignored for skinned
meshes); VRM avatars are skinned throughout -- reported in the status line, never silent.
nx_gltf2mesh <in.glb|.vrm> <out.nxmesh> | nx_gltf2mesh selftest
nx_gltf2mesh <in.glb|.vrm> <out.nxa> -- R22 RIG-CARRYING INGEST (charsim.plan, contract
symbol g2_skin_weights): when the OUTPUT name ends in .nxa the donor's skin is carried into
the estate's rig container NXANIM01 -- VERT (shared vertex table, mm) / TRIS (index triples)
/ SKEL (one record per skins[].joints entry: parent, bind position from inverseBindMatrices,
identity quat) / SKIN (per vertex four joint indices + four Q12 weights summing to EXACTLY
4096). That layout is the one nx_nxa_skin WRITES, nx_nxa_check ENFORCES and nx_nxa_rig_emit
DIVIDES BY -- read from those three, never invented here. NXMSH2 structurally cannot carry a
rig (84-byte triangle soup, no joint section, 17 consumers hardcode that arithmetic), which
is why the round trip measured 2026-08-22 lost every named part of every rigged donor.
An unskinned donor asked for .nxa is REFUSED by name; the .nxmesh path is byte-identical.
license_tier: ORIGINAL expect_exit: 0
dependencies 5 imports · 0 importers
imports: nx_syscalls.nxnx_nxa.nxnx_vecmath.nxnx_gltf_load_inventory_t180.nxnx_bundle_ingest.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
| 27 | const G2_MAGIC_2000000000: i64 = 2000000000 |
| 28 | const G2_MAGIC_4096: i64 = 4096 |
| 33 | const G2_SCALE_STEP: i64 = 1000 |
| 34 | const G2_MAX_SCALE_TRIES: i64 = 4 |
| 35 | const G2_DEF_SLIVER_FLOOR_MM: i64 = 100 |
| 36 | const G2_ASCII_EQ: i64 = 61 |
| 37 | const G2_ASCII_NL: i64 = 10 |
| 38 | const G2_ASCII_ZERO: i64 = 48 |
| 39 | const G2_ASCII_NINE: i64 = 57 |
| 40 | const G2_CONFBUF: i64 = 16 |
| 41 | const G2_UNITS_CONF: *u8 = "knowledge/gltf2mesh_units.conf" |
| 42 | const G2_UCONF_PFXLEN: i64 = 11 // len("units_conf=") |
| 44 | const G2_CAP: i64 = 33554432 |
| 45 | const G2_MAXEL: i64 = 1024 |
| 46 | const G2_MAXTRI: i64 = 400000 |
| 47 | const G2_Q14: i64 = 16384 |
| 48 | const G2_M8388607: i64 = 8388607 |
| 49 | const G2_M8388608: i64 = 8388608 |
| 50 | const G2_GREY: i64 = 780 |
| 51 | const G2_CT_F32: i64 = 5126 |
| 52 | const G2_CT_U16: i64 = 5123 |
| 53 | const G2_CT_U32: i64 = 5125 |
| 54 | const G2_MODE_TRIS: i64 = 4 |
| 55 | const G2_HDR: i64 = 16 |
| 56 | const G2_LAYROW: i64 = 24 |
| 57 | const G2_TRIREC: i64 = 84 |
| 60 | const G2_CT_U8: i64 = 5121 // glTF UNSIGNED_BYTE: JOINTS_0, normalized WEIGHTS_0 |
| 61 | const G2_Q12: i64 = 4096 // SKIN weight unit AND SKEL quat unit (nx_nxa_check: sum == 4096) |
| 62 | const G2_VEC4_SLOTS: i64 = 4 // JOINTS_0/WEIGHTS_0 are VEC4: four influences per vertex |
| 63 | const G2_U8_MAX: i64 = 255 // normalized u8 denominator (glTF: v/255) |
| 64 | const G2_U16_MAX: i64 = 65535 // normalized u16 denominator (glTF: v/65535) |
| 65 | const G2_F32_MANT_DENOM: i64 = 16777216 // 2^24: a float32 weight in [0,1] is exact to below 1/2^24 |
| 66 | const G2_F32_BYTES: i64 = 4 |
| 67 | const G2_U16_BYTES: i64 = 2 |
| 68 | const G2_U32_BYTES: i64 = 4 |
| 69 | const G2_VEC3_F32_BYTES: i64 = 12 |
| 70 | const G2_MAT4_BYTES: i64 = 64 |
| 71 | const G2_MAT4_COL: i64 = 4 // column-major: element (row r, col c) sits at c*4 + r |
| 72 | const G2_IBM_T_COL: i64 = 3 // the translation column of a MAT4 |
| 73 | const G2_IBM_W_ROW: i64 = 3 // the affine row: must decode to 0 0 0 1 |
| 74 | const G2_Q12_IDENT_TOL: i64 = 1 // f32 1.0 / 0.0 decode EXACTLY to 4096 / 0 and the decode truncates below one unit, so any rotation or scale in a bind matrix shows as a deviation above ONE unit |
| 75 | const G2_NXA_HDR_BYTES: i64 = 32 // magic, version, section count, TOC check |
| 76 | const G2_NXA_TOC_BYTES: i64 = 32 // tag, byte offset, wordlen, payload check |
| 77 | const G2_NXA_TOC_WORDS: i64 = 4 |
| 78 | const G2_NXA_SECS: i64 = 4 // VERT TRIS SKEL SKIN |
| 79 | const G2_SKEL_WORDS: i64 = 8 // parent, tx, ty, tz, qx, qy, qz, qw |
| 80 | const G2_SKIN_WORDS: i64 = 8 // j0 j1 j2 j3 w0 w1 w2 w3 |
| 81 | const G2_VERT_WORDS: i64 = 3 |
| 82 | const G2_TRI_WORDS: i64 = 3 |
| 83 | const G2_NXA_EXT_LEN: i64 = 4 // ".nxa" |
| 84 | const G2_IBM_DEFAULT_IDENTITY: i64 = 1 // glTF: absent inverseBindMatrices == identity == every joint binds at the origin |
| 85 | const G2_CX_WORDS: i64 = 32 // the emitter's context record |
| 87 | const G2_SW_OK: i64 = 0 |
| 88 | const G2_SW_SHAPE: i64 = 1 |
| 89 | const G2_SW_JOINT_RANGE: i64 = 2 |
| 90 | const G2_SW_SUM_TOL: i64 = 3 |
| 91 | const G2_SW_ZERO_WEIGHT: i64 = 4 |
| 92 | const G2_SW_NEGATIVE: i64 = 5 |
| 93 | const G2_IB_NONIDENT: i64 = 2 |
| 94 | const G2_IB_SHEAR: i64 = 3 |
| 95 | const G2_MAT3_DIM: i64 = 3 |
| 100 | const G2_SHEAR_TOL_Q12: i64 = 7 |
| 102 | const G2_IBM_CONFLICT_TOL_MM: i64 = 1 |
| 1566 | const GPN_CTX_WORDS:i64=18 |
| 1568 | const GPN_GLB_LENGTH_MAX:i64=4294967295 |
| 1569 | const GPN_NORMALIZATION_HEADROOM:i64=64 |
functions
| 104 | 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 } |
| 105 | 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 } |
| 110 | func g2_u16(b: *u8, o: i64) -> i64 |
| 115 | func g2_u32(b: *u8, o: i64) -> i64 |
| 124 | func g2_f32s(w: i64, scale: i64) -> i64 |
| 139 | func g2_f32mm(w: i64) -> i64 { return g2_f32s(w, 1000) } |
| 140 | func g2_ceil_div(a: i64, d: i64) -> i64 { return (a + d - 1) / d } called by 1: g2_skin_weights |
| 144 | func g2_conf_i64(path: *u8, key: *u8, miss: i64) -> i64 |
| 206 | func g2_pick_scale(hgt: i64, floor_mm: i64) -> i64 called by 1: g2_convert |
| 219 | func g2_enc(v: i64, scale: i64) -> i64 |
| 234 | func g2_wr32(b: *u8, o: i64, v: i64) -> i64 |
| 240 | func g2_isqrt(x: i64) -> i64 { return vm_isqrt(x) } |
| 243 | func g2_lit_at(b: *u8, o: i64, e: i64, lit: *u8) -> i64 |
| 252 | func g2_topkey(b: *u8, s: i64, e: i64, lit: *u8) -> i64 |
| 279 | func g2_elems(b: *u8, arr: i64, e: i64, starts: *i64, ends: *i64, maxn: i64) -> i64 called by 1: g2_convert |
| 318 | func g2_key(b: *u8, s: i64, e: i64, lit: *u8) -> i64 |
| 337 | func g2_ifield(b: *u8, s: i64, e: i64, lit: *u8, def: i64) -> i64 |
| 358 | func g2_objend(b: *u8, off: i64, e: i64) -> i64 called by 1: g2_convert |
| 384 | func g2_hasstr(b: *u8, s: i64, e: i64, lit: *u8) -> i64 |
| 390 | func g2_refuse(reason: *u8) -> i64 |
| 398 | func g2_name_has(b: *u8, s: i64, e: i64, skip: *u8) -> i64 |
| 424 | func g2_filter(f: *u8) -> i64 |
| 450 | func g2_intarray(b: *u8, arr: i64, e: i64, out: *i64, maxn: i64) -> i64 called by 1: g2_convert |
| 481 | func g2_nodename(b: *u8, s: i64, e: i64, out: *i64) -> i64 |
| 501 | func g2_ends_nxa(path: *u8) -> i64 called by 1: g2_convert |
| 536 | func g2_skin_weights(cx: *i64, joi: i64, wei: i64, nvp: i64, vbase: i64, nj: i64, skin: *i64, st: *i64) -> i64 |
| 620 | func g2_ibm_one(cx: *i64, ibi: i64, kloc: i64, dv: i64, out3: *i64, st: *i64) -> i64 |
| 702 | func g2_toc(toc: *i64, ti: i64, tag: *u8, off: i64, wl: i64, words: *i64) -> i64 |
| 717 | func g2_emit_nxa(cx: *i64) -> i64 |
| 1019 | func g2_convert(inp: *u8, outp: *u8, skip: *u8) -> i64 |
| 1497 | func st_wr(path: *u8, buf: *u8, n: i64) -> i64 |
| 1504 | func st_mkglb(buf: *u8, breakmode: i64) -> i64 |
| 1535 | func g2_selftest() -> i64 |
| 1570 | func gpn_reason(code:i64)->*u8 called by 1: gpn_convert |
| 1587 | func gpn_deps(cx:*i64,w:*JsonWriter)->i64 called by 2: gpn_receiptgpn_convert calls 11: sys_mmapglp_resetglp_membernx_json_nextjson_begin_objectbix_num+5 |
| 1639 | func gpn_receipt(cx:*i64)->i64 called by 2: gpn_convertgpn_main calls 13: sys_clock_gettime_realbic_lensys_mmapsys_munmapjson_begin_objectbix_key+7 |
| 1682 | func gpn_convert(cx:*i64,src:*u8,out:*u8,sha:*u8,digest:*u8)->i64 |
| 1702 | func gpn_main(argc:i64,argv:*i64)->i64 |
| 1739 | func gli_report(src:*u8,n:i64,stats:*i64,input:*u8,receipt:*u8,sha:*u8)->i64 |
| 1764 | func gli_main(argc:i64,argv:*i64)->i64 |
| 1796 | func main(argc: i64, argv: *i64) -> i64 |