nx_garment_boundary_t138.nx
buildroot/runtime/nx_garment_boundary_t138.nx
about
nx_garment_gen_lib.nx -- CONFORMING GARMENT MESHES GENERATED FROM THE BODY SURFACE (2026-08-30,
gameengine gpe_garment_draw paint->mesh; operator: "the clothes are paint not objects").
WHAT IT BUILDS. For every garment id of the engine's table (1 bikini top . 2 bikini bottom . 3 one-piece
. 4 sarong knot . 5 sundress bodice . 6 tee . 7 shorts . 8 skirt waistband . 9 evening bodice) a SHELL:
the body triangles the garment covers, offset along the body's own smooth vertex normals by fabric
thickness + wearing ease, its open boundary CLOSED by a hem strip (the fabric's edge face, so the cloth
has a visible thickness), a raised binding band one ring inside every opening (the elastic / folded
hem), a PUSH-OUT pass that walks any vertex the offset dropped into a fold back out until no body vertex
sits inside the fabric, and RIBBON STRAPS between anatomical anchors for the strapped ids. Every garment
vertex records the BODY VERTEX it was grown from, so the page skins it with that vertex's own joint
weights and it rides pose, gait and the soft-tissue fields exactly as the skin under it does
(layering by construction: a layer that rides its underlayer's field cannot be pierced by it).
UNITS. Mesh units: 171530 per 1.78 m (the page's own pairing) => 96.37 units per mm. Heights are in
DECIMIL of the mesh's own measured stature ((z - zmin) * 10000 / H). Normals and blend weights are Q12.
Thickness and ease are DERIVED from micrometres in gmg_mat, with the source of each number beside it.
SECTION EMITTED: "GARM" (one tag, one checksum) =
header [ver=20260830, nkinds, vstride=5, tstride=3, units_per_mm_x1000, dirstride=8, total_words, 0]
dir nkinds x [id, nverts, ntris, voff(words from section start), toff, thickness_units, ease_units, class]
verts [x, y, z, src_body_vertex, flag] flag 0 shell . 1 hem . 2 strap
tris [a, b, c] local to the kind
Normals are NOT shipped: the page already accumulates area-weighted smooth normals for the skirt mesh
and does the same here (hem strips and straps carry their own copies of the shared vertices, so their
faces get their own normals). license_tier: ORIGINAL. No hw writes (Rule 26).
dependencies 3 imports · 1 importers
imports: nx_syscalls.nxnx_nxa.nxnx_nxa_garment_bind_lib.nx
imported by: nx_garment_strap_gate_t138.nx
structs
| none |
consts
| 31 | const GMG_Q: i64 = 4096 |
| 32 | const GMG_DM: i64 = 10000 |
| 33 | const GMG_UNITS_178: i64 = 171530 |
| 34 | const GMG_MM_178: i64 = 1780 |
| 35 | const GMG_UM_PER_MM: i64 = 1000 |
| 36 | const GMG_TWO_PI_MILLI: i64 = 6283 |
| 37 | const GMG_KINDS: i64 = 9 |
| 38 | const GMG_VSTRIDE: i64 = 5 |
| 39 | const GMG_TSTRIDE: i64 = 3 |
| 40 | const GMG_DIRSTRIDE: i64 = 8 |
| 41 | const GMG_HDR: i64 = 8 |
| 42 | const GMG_GARM_VER: i64 = 20260830 |
| 43 | const GMG_NBR_CAP: i64 = 32 |
| 44 | const GMG_BADJ_CAP: i64 = 4 |
| 45 | const GMG_OV_CAP: i64 = 16384 |
| 46 | const GMG_OT_CAP: i64 = 32768 |
| 47 | const GMG_SEC_CAP: i64 = 262144 |
| 48 | const GMG_STAT_N: i64 = 32 |
| 49 | const GMG_PUSH_PASSES: i64 = 8 |
| 50 | const GMG_SKEL_STRIDE: i64 = 8 |
| 51 | const GMG_SKIN_STRIDE: i64 = 8 |
| 52 | const GMG_DYN_FIELDS: i64 = 8 |
| 53 | const GMG_STRAP_K: i64 = 9 |
| 54 | const GMG_STRAP_CAP: i64 = 24 |
| 55 | const GMG_BIG: i64 = 4611686018427387903 |
| 56 | const GMG_ISQRT_HI: i64 = 3037000499 |
| 57 | const GMG_CROSS_SHIFT: i64 = 64 |
| 58 | const GMG_NRM_CAP: i64 = 1000000 |
| 61 | const GMG_F_SHELL: i64 = 0 |
| 62 | const GMG_F_HEM: i64 = 1 |
| 63 | const GMG_F_STRAP: i64 = 2 |
| 65 | const GMG_M_SWIM: i64 = 1 |
| 66 | const GMG_M_WOVEN: i64 = 2 |
| 67 | const GMG_M_JERSEY: i64 = 3 |
| 68 | const GMG_M_SATIN: i64 = 4 |
| 70 | const GMG_ERR_BADNXA: i64 = 0 - 5 |
| 71 | const GMG_ERR_REFUSED_THICK: i64 = 0 - 4 |
| 72 | const GMG_ERR_EMPTY: i64 = 0 - 6 |
| 73 | const GMG_ERR_CAP: i64 = 0 - 7 |
| 76 | const GMG_TORSO_HALFW: i64 = 15000 // the page shader's own torso gate (|bind x| < 15000) |
| 77 | const GMG_ARM_BIND_X: i64 = 12000 // a dominant joint this far off the midline is an arm joint |
| 78 | const GMG_HEAD_DM: i64 = 8600 // above the chin line (.885 H) a dominant joint is a head joint |
| 79 | const GMG_FRONT_Y: i64 = 0 - 1200 // the page's bust-side convention: front is y < -1200 |
| 80 | const GMG_YBLEND: i64 = 1200 // front/back blend half-width (units) for the leg/neck lines |
| 81 | const GMG_HIP_DM: i64 = 5450 // hip band top (.545 H), the incumbent paint band's own edge |
| 82 | const GMG_CROTCH_DM: i64 = 4750 // crotch .475 H (Drillis-Contini 1966) |
| 83 | const GMG_KNEE_DM: i64 = 2850 // knee .285 H (Drillis-Contini 1966, the page's own gdJn(.285)) |
| 84 | const GMG_HIPJ_DM: i64 = 5200 // hip joint .52 H (Drillis-Contini) -- the anchor the page maps NIP through |
| 85 | const GMG_EYE_DM: i64 = 9300 // eye line .93 H, the second anchor |
| 86 | const GMG_NIP_RATIO_DM: i64 = 7200 // published nipple ratio .72 H before the per-mesh anchor mapping |
| 87 | const GMG_HEADJ_PROBE_DM: i64 = 9500 |
| 88 | const GMG_BUST_HALF_DM: i64 = 550 // the nipple detail's own half-width (.055 H) |
| 89 | const GMG_EASE_FADE_LO: i64 = 7400 // ease fades to zero over the bust->shoulder band so necklines hug |
| 90 | const GMG_EASE_FADE_HI: i64 = 8000 |
| 91 | const GMG_MIDTHIGH_DM: i64 = 4025 // (hip .52 + knee .285) / 2 -- Drillis-Contini mid-thigh, the shorts hem |
| 92 | const GMG_SHORTS_TOP_DM: i64 = 5600 |
| 93 | const GMG_TEE_NECK_DM: i64 = 8350 // crew neck front: .835 H (acromion .818 + a finger) |
| 94 | const GMG_TEE_NECK_RISE: i64 = 300 |
| 95 | const GMG_SLEEVE_TOP_DM: i64 = 7400 |
| 96 | const GMG_SLEEVE_HALFW: i64 = 19000 // short-sleeve cap reach off the midline (units) |
| 97 | const GMG_SLEEVE_BAND_LO: i64 = 7800 |
| 98 | const GMG_SLEEVE_BAND_HI: i64 = 8700 |
| 99 | const GMG_SLEEVE_X_LO: i64 = 12000 |
| 100 | const GMG_ONEPIECE_NECK_F: i64 = 7700 // one-piece scoop front .77 H |
| 101 | const GMG_ONEPIECE_NECK_B: i64 = 7000 // one-piece back .70 H |
| 102 | const GMG_STRAP_SHOULDER_DM: i64 = 8580 |
| 103 | const GMG_STRAP_BAND_TOL_DM: i64 = 120 // bikini back band half-height |
| 104 | const GMG_SARONG_X: i64 = 13500 // the knot sits on the hip side |
| 105 | const GMG_SARONG_DM: i64 = 6150 |
| 106 | const GMG_SARONG_R: i64 = 5000 |
| 107 | const GMG_WAIST_BAND_DM: i64 = 150 // skirt waistband half-height around the skirt's own top ring |
| 108 | const GMG_SKIRT_TOP_TOL_DM: i64 = 300 |
| 109 | const GMG_STRAP_SEARCH_DM: i64 = 700 |
| 110 | const GMG_STRAP_AX_MAX: i64 = 14500 |
| 111 | const GMG_STRAP_AX_FRONT: i64 = 9000 |
| 112 | const GMG_STRAP_Y_FRONT: i64 = 0 - 9000 |
| 113 | const GMG_STRAP_AX_SHOULDER: i64 = 11400 |
| 114 | const GMG_STRAP_Y_SHOULDER: i64 = 2000 |
| 115 | const GMG_STRAP_AX_BACK: i64 = 8000 |
| 116 | const GMG_STRAP_Y_BACK: i64 = 9000 |
| 117 | const GMG_STRAP_HALFW_BIKINI_UM: i64 = 6000 // 12 mm bikini strap |
| 118 | const GMG_STRAP_HALFW_DRESS_UM: i64 = 10000 // 20 mm dress / one-piece strap |
| 119 | const GMG_SWIM_INNER_UM: i64 = 200 // a swim hem's inner edge is pressed to the skin (0.2 mm) |
| 120 | const GMG_PUSH_MARGIN: i64 = 2 |
| 121 | const GMG_CLEAR_PERMIL: i64 = 900 // the clearance tooth's bar: 0.9 t (vertex-to-vertex is an |
| 123 | const GMG_CLEAR_REPORT_MULT: i64 = 4 |
| 133 | const GMG_T_SWIM_UM: i64 = 550 |
| 134 | const GMG_T_JERSEY_UM: i64 = 700 |
| 135 | const GMG_T_WOVEN_UM: i64 = 350 |
| 136 | const GMG_T_SARONG_UM: i64 = 300 |
| 137 | const GMG_T_SATIN_UM: i64 = 250 |
| 138 | const GMG_ELASTIC_UM: i64 = 1000 |
| 139 | const GMG_EASE_TEE_UM: i64 = 75000 |
| 140 | const GMG_EASE_SHORTS_UM: i64 = 76200 |
| 141 | const GMG_EASE_DRESS_UM: i64 = 75000 |
| 142 | const GMG_EASE_EVENING_UM: i64 = 63500 |
| 143 | const GMG_EASE_KNOT_RADIAL_UM: i64 = 30000 |
| 146 | const GMG_C_B: i64 = 0 |
| 147 | const GMG_C_FLEN: i64 = 1 |
| 148 | const GMG_C_POS: i64 = 2 |
| 149 | const GMG_C_NV: i64 = 3 |
| 150 | const GMG_C_IDX: i64 = 4 |
| 151 | const GMG_C_NT: i64 = 5 |
| 152 | const GMG_C_NRM: i64 = 6 |
| 153 | const GMG_C_ZMN: i64 = 7 |
| 154 | const GMG_C_H: i64 = 8 |
| 155 | const GMG_C_HH: i64 = 9 |
| 156 | const GMG_C_AX: i64 = 10 |
| 157 | const GMG_C_VF: i64 = 11 |
| 158 | const GMG_C_NIP: i64 = 12 |
| 159 | const GMG_C_DYN: i64 = 13 |
| 160 | const GMG_C_ND: i64 = 14 |
| 161 | const GMG_C_GTH: i64 = 15 |
| 162 | const GMG_C_GAP: i64 = 16 |
| 163 | const GMG_C_YMID: i64 = 17 |
| 164 | const GMG_C_BIND: i64 = 18 |
| 165 | const GMG_C_NJ: i64 = 19 |
| 166 | const GMG_C_VMAP: i64 = 20 |
| 167 | const GMG_C_INNER: i64 = 21 |
| 168 | const GMG_C_SEL: i64 = 22 |
| 169 | const GMG_C_NBR: i64 = 23 |
| 170 | const GMG_C_NBC: i64 = 24 |
| 171 | const GMG_C_DEG: i64 = 25 |
| 172 | const GMG_C_OV: i64 = 26 |
| 173 | const GMG_C_ONV: i64 = 27 |
| 174 | const GMG_C_OT: i64 = 28 |
| 175 | const GMG_C_ONT: i64 = 29 |
| 176 | const GMG_C_CAND: i64 = 30 |
| 177 | const GMG_C_NCAND: i64 = 31 |
| 178 | const GMG_C_TRIS: i64 = 32 |
| 179 | const GMG_C_NTRIS: i64 = 33 |
| 180 | const GMG_C_THICK_PERMIL: i64 = 34 |
| 181 | const GMG_C_UPMK: i64 = 35 |
| 182 | const GMG_C_BSET: i64 = 36 |
| 183 | const GMG_C_RING: i64 = 37 |
| 184 | const GMG_C_BADJ: i64 = 38 |
| 185 | const GMG_C_BDEG: i64 = 39 |
| 186 | const GMG_C_STACK: i64 = 40 |
| 187 | const GMG_C_SEEN: i64 = 41 |
| 188 | const GMG_C_NOPUSH: i64 = 42 |
| 189 | const GMG_C_NBROVER: i64 = 43 |
| 190 | const GMG_C_AJ: i64 = 44 |
| 191 | const GMG_C_AW: i64 = 45 |
| 192 | const GMG_C_DST: i64 = 46 // the asset's own DYNA row stride (ref9d ships 12 words, not the 8 the |
| 194 | const GMG_C_DIL: i64 = 47 // per-vertex pinch-dilation flags (see gmg_build steps 1-3) |
| 195 | const GMG_C_SLOTS: i64 = 48 |
| 196 | const GMG_PINCH_PASSES: i64 = 4 |
| 198 | const GMG_VF_TOR: i64 = 1 |
| 199 | const GMG_VF_ARM: i64 = 2 |
| 200 | const GMG_VF_HEAD: i64 = 4 |
| 202 | const GMG_S_NV: i64 = 0 |
| 203 | const GMG_S_NT: i64 = 1 |
| 204 | const GMG_S_SHELL: i64 = 2 |
| 205 | const GMG_S_HEM: i64 = 3 |
| 206 | const GMG_S_BEDGES: i64 = 4 |
| 207 | const GMG_S_PUSHED: i64 = 5 |
| 208 | const GMG_S_STRAPS: i64 = 6 |
| 209 | const GMG_S_MINCLEAR: i64 = 7 |
| 210 | const GMG_S_LOOPS: i64 = 8 |
| 211 | const GMG_S_OPEN: i64 = 9 |
| 212 | const GMG_S_SEL: i64 = 10 |
| 213 | const GMG_S_T: i64 = 11 |
| 214 | const GMG_S_TH: i64 = 12 |
| 215 | const GMG_S_EASE: i64 = 13 |
| 216 | const GMG_S_CLASS: i64 = 14 |
| 217 | const GMG_S_WITHIN: i64 = 15 |
| 218 | const GMG_S_SLF: i64 = 16 |
| 219 | const GMG_S_SLB: i64 = 17 |
| 220 | const GMG_S_SRF: i64 = 18 |
| 221 | const GMG_S_SRB: i64 = 19 |
| 222 | const GMG_S_NBROVER: i64 = 20 |
| 223 | const GMG_S_VOFF: i64 = 21 |
| 224 | const GMG_S_TOFF: i64 = 22 |
| 225 | const GMG_S_ID: i64 = 23 |
| 226 | const GMG_S_PINCHPASS: i64 = 24 // selection passes taken by the pinch dilation (1 = no pinch found) |
| 1355 | const GMG_CLIP_RECORD_WORDS:i64=4 |
| 1356 | const GMG_CLIP_CAP_WORDS:i64=16 |
| 1357 | const GMG_CLIP_DISTANCE_MAX:i64=2147483647 |
| 1358 | const GMG_CLIP_E_INPUT:i64=0-30 |
| 1359 | const GMG_CLIP_E_CAP:i64=0-31 |
| 1393 | const GMG_CLIP_E_RANGE:i64=0-32 |
| 1394 | const GMG_CLIP_I64_MAX:i64=9223372036854775807 |
| 1451 | const GMG_ATTACH_HDR:i64=12 |
| 1452 | const GMG_ATTACH_REC:i64=8 |
| 1453 | const GMG_ATTACH_COORD_MAX:i64=16777216 |
| 1454 | const GMG_ATTACH_E_SOURCE:i64=-40 |
| 1455 | const GMG_ATTACH_E_SHAPE:i64=-41 |
| 1456 | const GMG_ATTACH_E_GEOMETRY:i64=-42 |
functions
| 228 | func gmg_puts(s: *u8) -> i64 { var n: i64 = 0; while s[n] != (0 as u8) { n = n + 1 } sys_write(1, s, n); return 0 } |
| 229 | func gmg_pn(v: i64) -> i64 |
| 243 | func gmg_abs(v: i64) -> i64 { if v < 0 { return 0 - v } return v } |
| 244 | func gmg_min(a: i64, b: i64) -> i64 { if a < b { return a } return b } |
| 245 | func gmg_max(a: i64, b: i64) -> i64 { if a > b { return a } return b } called by 1: gmg_load |
| 247 | func gmg_isqrt(v: i64) -> i64 |
| 266 | func gmg_sst(a: i64, b: i64, x: i64) -> i64 |
| 274 | func gmg_um2u(um: i64) -> i64 { return um * GMG_UNITS_178 / (GMG_MM_178 * GMG_UM_PER_MM) } |
| 275 | func gmg_circ2radial_um(circ_um: i64) -> i64 { return circ_um * 1000 / GMG_TWO_PI_MILLI } called by 1: gmg_mat |
| 280 | func gmg_mat(G: *i64, kind: i64, out: *i64) -> i64 |
| 305 | func gmg_pos(G: *i64) -> *i64 { return G[GMG_C_POS] as *i64 } |
| 306 | func gmg_nrm(G: *i64) -> *i64 { return G[GMG_C_NRM] as *i64 } |
| 307 | func gmg_hh(G: *i64) -> *i64 { return G[GMG_C_HH] as *i64 } |
| 308 | func gmg_ax(G: *i64) -> *i64 { return G[GMG_C_AX] as *i64 } |
| 309 | func gmg_vf(G: *i64) -> *u8 { return G[GMG_C_VF] as *u8 } |
| 310 | func gmg_has(G: *i64, v: i64, bit: i64) -> i64 |
| 317 | func gmg_near_joint(G: *i64, fdm: i64) -> i64 |
| 334 | func gmg_load(b: *u8, flen: i64) -> *i64 |
| 548 | func gmg_near_body(G: *i64, x: i64, y: i64, z: i64, hlo: i64, hhi: i64, axmax: i64) -> i64 |
| 577 | func gmg_hleg(G: *i64, v: i64) -> i64 |
| 588 | func gmg_hneck(G: *i64, v: i64) -> i64 |
| 599 | func gmg_hneck_tee(G: *i64, v: i64) -> i64 |
| 606 | func gmg_dyn_side(G: *i64, side: i64) -> i64 called by 1: gmg_region |
| 619 | func gmg_in_dyn(G: *i64, v: i64, d: i64) -> i64 |
| 633 | func gmg_region(G: *i64, kind: i64, v: i64) -> i64 |
| 683 | func gmg_ease_at(G: *i64, kind: i64, mat: *i64, v: i64) -> i64 |
| 693 | func gmg_addv(G: *i64, src: i64, d: i64, flag: i64) -> i64 |
| 708 | func gmg_addv_at(G: *i64, x: i64, y: i64, z: i64, src: i64, flag: i64) -> i64 |
| 717 | func gmg_addt(G: *i64, a: i64, b: i64, c: i64) -> i64 |
| 727 | func gmg_nbr_add(G: *i64, u0: i64, v0: i64) -> i64 called by 1: gmg_build |
| 745 | func gmg_nbr_count(G: *i64, u0: i64, v0: i64) -> i64 called by 1: gmg_build |
| 765 | func gmg_strap_frame_v1(ring:*i64,nrm:*i64,n:i64,i:i64,halfw:i64,previous:*i64,out:*i64)->i64 |
| 781 | func gmg_strap(G: *i64, mat: *i64, sx: i64, hF: i64, hB: i64, halfw: i64, ends: *i64) -> i64 |
| 857 | func gmg_build(G: *i64, kind: i64, stat: *i64) -> i64 |
| 1229 | func gmg_gen_all(G: *i64, sec: *i64, stats: *i64) -> i64 |
| 1275 | func gmg_print_stat(st: *i64) -> i64 |
| 1301 | func gmg_write_nxa(b: *u8, flen: i64, sec: *i64, nwords: i64, outpath: *u8) -> i64 |
| 1360 | func gmg_clip_distance(a:i64,b:i64,c:i64,k:i64)->i64 called by 1: gmg_clip_triangle_bary_v1 |
| 1363 | func gmg_clip_vertex(out:*i64,n:i64,k:i64)->i64 called by 1: gmg_clip_triangle_bary_v1 |
| 1366 | func gmg_clip_crossing(out:*i64,n:i64,s:i64,e:i64,ds:i64,de:i64)->i64 |
| 1371 | func gmg_clip_triangle_bary_v1(distance:*i64,out:*i64,cap_words:i64)->i64 |
| 1395 | func gmg_clip_product(a:i64,b:i64)->i64 |
| 1398 | func gmg_clip_gcd(a:i64,b:i64)->i64 {var x:i64=a;var y:i64=b;while y>0{let z:i64=x%y;x=y;y=z};return x} called by 1: gmg_clip_polygon_bary_v1 |
| 1399 | func gmg_clip_scalar(d:*i64,r:*i64,result:*i64)->i64 |
| 1412 | func gmg_clip_polygon_bary_v1(d:*i64,input:*i64,n:i64,out:*i64,scratch:*i64,cap_words:i64)->i64 called by 1: gmg_attach_onepiece_into_v1 calls 4: gmg_clip_scalargmg_absgmg_clip_productgmg_clip_gcd |
| 1444 | func gmg_clip_area_ratio_v1(poly:*i64,n:i64,result:*i64)->i64{return ngb_clip_area_ratio_v1(poly,n,result)} calls 1: ngb_clip_area_ratio_v1 |
| 1458 | func gmg_attach_source_v1(b:*u8,n:i64)->i64{return ngb_attach_source_v1(b,n)} |
| 1459 | func gmg_attach_face_v1(pos:*i64,idx:*i64,face:i64)->i64{return ngb_attach_face_v1(pos,idx,face)} |
| 1462 | func gmg_attach_validate_v1(b:*u8,n:i64,s:*i64,nw:i64,work:*i64,work_words:i64)->i64{return ngb_attach_validate_v1(b,n,s,nw,work,work_words)} |
| 1467 | func gmg_attach_onepiece_into_v1(G:*i64,out:*i64,cap:i64,scratch:*i64,sw:i64)->i64 |
| 1499 | func gmg_attach_compose_into_v1(b:*u8,n:i64,s:*i64,nw:i64,out:*u8,cap:i64,work:*i64,ww:i64)->i64 |
| 1519 | func gmg_write_all_v1(fd:i64,p:*u8,n:i64)->i64{var at:i64=0;while at<n{let wr:i64=sys_write(fd,((p as i64)+at) as *u8,n-at);if wr<=0||wr>n-at{return -9};at=at+wr};return 0} |
| 1520 | func gmg_write_nxa_checked_v1(b:*u8,flen:i64,sec:*i64,nwords:i64,outpath:*u8)->i64 called by 1: main calls 11: nxa_tag4nxa_section_entrysys_mmapnxa_check2nxa_magicsys_openat_exclusive+5 |