code wiki / (root) / nx_garment_boundary_t138.nx

nx_garment_boundary_t138.nx

buildroot/runtime/nx_garment_boundary_t138.nx

71905 B1539 linesdepth 3pulls 5 transitivereach 1 importersview sourcekind librarytopic garment
docsdependenciesstructsconstsfunctions

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

nx_syscalls.nx nx_nxa.nx nx_nxa_garment_bind_lib.nx nx_garment_boundary_t138.nx nx_garment_strap_gate_t138.nx

imports: nx_syscalls.nxnx_nxa.nxnx_nxa_garment_bind_lib.nx

imported by: nx_garment_strap_gate_t138.nx

structs

none

consts

31const GMG_Q: i64 = 4096
32const GMG_DM: i64 = 10000
33const GMG_UNITS_178: i64 = 171530
34const GMG_MM_178: i64 = 1780
35const GMG_UM_PER_MM: i64 = 1000
36const GMG_TWO_PI_MILLI: i64 = 6283
37const GMG_KINDS: i64 = 9
38const GMG_VSTRIDE: i64 = 5
39const GMG_TSTRIDE: i64 = 3
40const GMG_DIRSTRIDE: i64 = 8
41const GMG_HDR: i64 = 8
42const GMG_GARM_VER: i64 = 20260830
43const GMG_NBR_CAP: i64 = 32
44const GMG_BADJ_CAP: i64 = 4
45const GMG_OV_CAP: i64 = 16384
46const GMG_OT_CAP: i64 = 32768
47const GMG_SEC_CAP: i64 = 262144
48const GMG_STAT_N: i64 = 32
49const GMG_PUSH_PASSES: i64 = 8
50const GMG_SKEL_STRIDE: i64 = 8
51const GMG_SKIN_STRIDE: i64 = 8
52const GMG_DYN_FIELDS: i64 = 8
53const GMG_STRAP_K: i64 = 9
54const GMG_STRAP_CAP: i64 = 24
55const GMG_BIG: i64 = 4611686018427387903
56const GMG_ISQRT_HI: i64 = 3037000499
57const GMG_CROSS_SHIFT: i64 = 64
58const GMG_NRM_CAP: i64 = 1000000
61const GMG_F_SHELL: i64 = 0
62const GMG_F_HEM: i64 = 1
63const GMG_F_STRAP: i64 = 2
65const GMG_M_SWIM: i64 = 1
66const GMG_M_WOVEN: i64 = 2
67const GMG_M_JERSEY: i64 = 3
68const GMG_M_SATIN: i64 = 4
70const GMG_ERR_BADNXA: i64 = 0 - 5
71const GMG_ERR_REFUSED_THICK: i64 = 0 - 4
72const GMG_ERR_EMPTY: i64 = 0 - 6
73const GMG_ERR_CAP: i64 = 0 - 7
76const GMG_TORSO_HALFW: i64 = 15000 // the page shader's own torso gate (|bind x| < 15000)
77const GMG_ARM_BIND_X: i64 = 12000 // a dominant joint this far off the midline is an arm joint
78const GMG_HEAD_DM: i64 = 8600 // above the chin line (.885 H) a dominant joint is a head joint
79const GMG_FRONT_Y: i64 = 0 - 1200 // the page's bust-side convention: front is y < -1200
80const GMG_YBLEND: i64 = 1200 // front/back blend half-width (units) for the leg/neck lines
81const GMG_HIP_DM: i64 = 5450 // hip band top (.545 H), the incumbent paint band's own edge
82const GMG_CROTCH_DM: i64 = 4750 // crotch .475 H (Drillis-Contini 1966)
83const GMG_KNEE_DM: i64 = 2850 // knee .285 H (Drillis-Contini 1966, the page's own gdJn(.285))
84const GMG_HIPJ_DM: i64 = 5200 // hip joint .52 H (Drillis-Contini) -- the anchor the page maps NIP through
85const GMG_EYE_DM: i64 = 9300 // eye line .93 H, the second anchor
86const GMG_NIP_RATIO_DM: i64 = 7200 // published nipple ratio .72 H before the per-mesh anchor mapping
87const GMG_HEADJ_PROBE_DM: i64 = 9500
88const GMG_BUST_HALF_DM: i64 = 550 // the nipple detail's own half-width (.055 H)
89const GMG_EASE_FADE_LO: i64 = 7400 // ease fades to zero over the bust->shoulder band so necklines hug
90const GMG_EASE_FADE_HI: i64 = 8000
91const GMG_MIDTHIGH_DM: i64 = 4025 // (hip .52 + knee .285) / 2 -- Drillis-Contini mid-thigh, the shorts hem
92const GMG_SHORTS_TOP_DM: i64 = 5600
93const GMG_TEE_NECK_DM: i64 = 8350 // crew neck front: .835 H (acromion .818 + a finger)
94const GMG_TEE_NECK_RISE: i64 = 300
95const GMG_SLEEVE_TOP_DM: i64 = 7400
96const GMG_SLEEVE_HALFW: i64 = 19000 // short-sleeve cap reach off the midline (units)
97const GMG_SLEEVE_BAND_LO: i64 = 7800
98const GMG_SLEEVE_BAND_HI: i64 = 8700
99const GMG_SLEEVE_X_LO: i64 = 12000
100const GMG_ONEPIECE_NECK_F: i64 = 7700 // one-piece scoop front .77 H
101const GMG_ONEPIECE_NECK_B: i64 = 7000 // one-piece back .70 H
102const GMG_STRAP_SHOULDER_DM: i64 = 8580
103const GMG_STRAP_BAND_TOL_DM: i64 = 120 // bikini back band half-height
104const GMG_SARONG_X: i64 = 13500 // the knot sits on the hip side
105const GMG_SARONG_DM: i64 = 6150
106const GMG_SARONG_R: i64 = 5000
107const GMG_WAIST_BAND_DM: i64 = 150 // skirt waistband half-height around the skirt's own top ring
108const GMG_SKIRT_TOP_TOL_DM: i64 = 300
109const GMG_STRAP_SEARCH_DM: i64 = 700
110const GMG_STRAP_AX_MAX: i64 = 14500
111const GMG_STRAP_AX_FRONT: i64 = 9000
112const GMG_STRAP_Y_FRONT: i64 = 0 - 9000
113const GMG_STRAP_AX_SHOULDER: i64 = 11400
114const GMG_STRAP_Y_SHOULDER: i64 = 2000
115const GMG_STRAP_AX_BACK: i64 = 8000
116const GMG_STRAP_Y_BACK: i64 = 9000
117const GMG_STRAP_HALFW_BIKINI_UM: i64 = 6000 // 12 mm bikini strap
118const GMG_STRAP_HALFW_DRESS_UM: i64 = 10000 // 20 mm dress / one-piece strap
119const GMG_SWIM_INNER_UM: i64 = 200 // a swim hem's inner edge is pressed to the skin (0.2 mm)
120const GMG_PUSH_MARGIN: i64 = 2
121const GMG_CLEAR_PERMIL: i64 = 900 // the clearance tooth's bar: 0.9 t (vertex-to-vertex is an
123const GMG_CLEAR_REPORT_MULT: i64 = 4
133const GMG_T_SWIM_UM: i64 = 550
134const GMG_T_JERSEY_UM: i64 = 700
135const GMG_T_WOVEN_UM: i64 = 350
136const GMG_T_SARONG_UM: i64 = 300
137const GMG_T_SATIN_UM: i64 = 250
138const GMG_ELASTIC_UM: i64 = 1000
139const GMG_EASE_TEE_UM: i64 = 75000
140const GMG_EASE_SHORTS_UM: i64 = 76200
141const GMG_EASE_DRESS_UM: i64 = 75000
142const GMG_EASE_EVENING_UM: i64 = 63500
143const GMG_EASE_KNOT_RADIAL_UM: i64 = 30000
146const GMG_C_B: i64 = 0
147const GMG_C_FLEN: i64 = 1
148const GMG_C_POS: i64 = 2
149const GMG_C_NV: i64 = 3
150const GMG_C_IDX: i64 = 4
151const GMG_C_NT: i64 = 5
152const GMG_C_NRM: i64 = 6
153const GMG_C_ZMN: i64 = 7
154const GMG_C_H: i64 = 8
155const GMG_C_HH: i64 = 9
156const GMG_C_AX: i64 = 10
157const GMG_C_VF: i64 = 11
158const GMG_C_NIP: i64 = 12
159const GMG_C_DYN: i64 = 13
160const GMG_C_ND: i64 = 14
161const GMG_C_GTH: i64 = 15
162const GMG_C_GAP: i64 = 16
163const GMG_C_YMID: i64 = 17
164const GMG_C_BIND: i64 = 18
165const GMG_C_NJ: i64 = 19
166const GMG_C_VMAP: i64 = 20
167const GMG_C_INNER: i64 = 21
168const GMG_C_SEL: i64 = 22
169const GMG_C_NBR: i64 = 23
170const GMG_C_NBC: i64 = 24
171const GMG_C_DEG: i64 = 25
172const GMG_C_OV: i64 = 26
173const GMG_C_ONV: i64 = 27
174const GMG_C_OT: i64 = 28
175const GMG_C_ONT: i64 = 29
176const GMG_C_CAND: i64 = 30
177const GMG_C_NCAND: i64 = 31
178const GMG_C_TRIS: i64 = 32
179const GMG_C_NTRIS: i64 = 33
180const GMG_C_THICK_PERMIL: i64 = 34
181const GMG_C_UPMK: i64 = 35
182const GMG_C_BSET: i64 = 36
183const GMG_C_RING: i64 = 37
184const GMG_C_BADJ: i64 = 38
185const GMG_C_BDEG: i64 = 39
186const GMG_C_STACK: i64 = 40
187const GMG_C_SEEN: i64 = 41
188const GMG_C_NOPUSH: i64 = 42
189const GMG_C_NBROVER: i64 = 43
190const GMG_C_AJ: i64 = 44
191const GMG_C_AW: i64 = 45
192const GMG_C_DST: i64 = 46 // the asset's own DYNA row stride (ref9d ships 12 words, not the 8 the
194const GMG_C_DIL: i64 = 47 // per-vertex pinch-dilation flags (see gmg_build steps 1-3)
195const GMG_C_SLOTS: i64 = 48
196const GMG_PINCH_PASSES: i64 = 4
198const GMG_VF_TOR: i64 = 1
199const GMG_VF_ARM: i64 = 2
200const GMG_VF_HEAD: i64 = 4
202const GMG_S_NV: i64 = 0
203const GMG_S_NT: i64 = 1
204const GMG_S_SHELL: i64 = 2
205const GMG_S_HEM: i64 = 3
206const GMG_S_BEDGES: i64 = 4
207const GMG_S_PUSHED: i64 = 5
208const GMG_S_STRAPS: i64 = 6
209const GMG_S_MINCLEAR: i64 = 7
210const GMG_S_LOOPS: i64 = 8
211const GMG_S_OPEN: i64 = 9
212const GMG_S_SEL: i64 = 10
213const GMG_S_T: i64 = 11
214const GMG_S_TH: i64 = 12
215const GMG_S_EASE: i64 = 13
216const GMG_S_CLASS: i64 = 14
217const GMG_S_WITHIN: i64 = 15
218const GMG_S_SLF: i64 = 16
219const GMG_S_SLB: i64 = 17
220const GMG_S_SRF: i64 = 18
221const GMG_S_SRB: i64 = 19
222const GMG_S_NBROVER: i64 = 20
223const GMG_S_VOFF: i64 = 21
224const GMG_S_TOFF: i64 = 22
225const GMG_S_ID: i64 = 23
226const GMG_S_PINCHPASS: i64 = 24 // selection passes taken by the pinch dilation (1 = no pinch found)
1355const GMG_CLIP_RECORD_WORDS:i64=4
1356const GMG_CLIP_CAP_WORDS:i64=16
1357const GMG_CLIP_DISTANCE_MAX:i64=2147483647
1358const GMG_CLIP_E_INPUT:i64=0-30
1359const GMG_CLIP_E_CAP:i64=0-31
1393const GMG_CLIP_E_RANGE:i64=0-32
1394const GMG_CLIP_I64_MAX:i64=9223372036854775807
1451const GMG_ATTACH_HDR:i64=12
1452const GMG_ATTACH_REC:i64=8
1453const GMG_ATTACH_COORD_MAX:i64=16777216
1454const GMG_ATTACH_E_SOURCE:i64=-40
1455const GMG_ATTACH_E_SHAPE:i64=-41
1456const GMG_ATTACH_E_GEOMETRY:i64=-42

functions

228func 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 }
229func gmg_pn(v: i64) -> i64
243func gmg_abs(v: i64) -> i64 { if v < 0 { return 0 - v } return v }
244func gmg_min(a: i64, b: i64) -> i64 { if a < b { return a } return b }
245func gmg_max(a: i64, b: i64) -> i64 { if a > b { return a } return b }
called by 1: gmg_load
247func gmg_isqrt(v: i64) -> i64
266func gmg_sst(a: i64, b: i64, x: i64) -> i64
274func gmg_um2u(um: i64) -> i64 { return um * GMG_UNITS_178 / (GMG_MM_178 * GMG_UM_PER_MM) }
275func gmg_circ2radial_um(circ_um: i64) -> i64 { return circ_um * 1000 / GMG_TWO_PI_MILLI }
called by 1: gmg_mat
280func gmg_mat(G: *i64, kind: i64, out: *i64) -> i64
305func gmg_pos(G: *i64) -> *i64 { return G[GMG_C_POS] as *i64 }
306func gmg_nrm(G: *i64) -> *i64 { return G[GMG_C_NRM] as *i64 }
307func gmg_hh(G: *i64) -> *i64 { return G[GMG_C_HH] as *i64 }
308func gmg_ax(G: *i64) -> *i64 { return G[GMG_C_AX] as *i64 }
309func gmg_vf(G: *i64) -> *u8 { return G[GMG_C_VF] as *u8 }
310func gmg_has(G: *i64, v: i64, bit: i64) -> i64
317func gmg_near_joint(G: *i64, fdm: i64) -> i64
called by 1: gmg_load calls 1: gmg_abs
334func gmg_load(b: *u8, flen: i64) -> *i64
548func gmg_near_body(G: *i64, x: i64, y: i64, z: i64, hlo: i64, hhi: i64, axmax: i64) -> i64
called by 1: gmg_strap calls 4: gmg_posgmg_hhgmg_axgmg_vf
577func gmg_hleg(G: *i64, v: i64) -> i64
588func gmg_hneck(G: *i64, v: i64) -> i64
599func gmg_hneck_tee(G: *i64, v: i64) -> i64
called by 1: gmg_region calls 1: gmg_ax
606func gmg_dyn_side(G: *i64, side: i64) -> i64
called by 1: gmg_region
619func gmg_in_dyn(G: *i64, v: i64, d: i64) -> i64
called by 1: gmg_region calls 1: gmg_pos
633func gmg_region(G: *i64, kind: i64, v: i64) -> i64
683func gmg_ease_at(G: *i64, kind: i64, mat: *i64, v: i64) -> i64
called by 1: gmg_build calls 2: gmg_hhgmg_sst
693func gmg_addv(G: *i64, src: i64, d: i64, flag: i64) -> i64
called by 1: gmg_build calls 2: gmg_posgmg_nrm
708func gmg_addv_at(G: *i64, x: i64, y: i64, z: i64, src: i64, flag: i64) -> i64
called by 2: gmg_strapgmg_build
717func gmg_addt(G: *i64, a: i64, b: i64, c: i64) -> i64
called by 2: gmg_strapgmg_build
727func gmg_nbr_add(G: *i64, u0: i64, v0: i64) -> i64
called by 1: gmg_build
745func gmg_nbr_count(G: *i64, u0: i64, v0: i64) -> i64
called by 1: gmg_build
765func gmg_strap_frame_v1(ring:*i64,nrm:*i64,n:i64,i:i64,halfw:i64,previous:*i64,out:*i64)->i64
called by 1: gmg_strap calls 1: gmg_isqrt
781func gmg_strap(G: *i64, mat: *i64, sx: i64, hF: i64, hB: i64, halfw: i64, ends: *i64) -> i64
857func gmg_build(G: *i64, kind: i64, stat: *i64) -> i64
1229func gmg_gen_all(G: *i64, sec: *i64, stats: *i64) -> i64
1275func gmg_print_stat(st: *i64) -> i64
calls 2: gmg_putsgmg_pn
1301func gmg_write_nxa(b: *u8, flen: i64, sec: *i64, nwords: i64, outpath: *u8) -> i64
1360func gmg_clip_distance(a:i64,b:i64,c:i64,k:i64)->i64
1363func gmg_clip_vertex(out:*i64,n:i64,k:i64)->i64
1366func gmg_clip_crossing(out:*i64,n:i64,s:i64,e:i64,ds:i64,de:i64)->i64
called by 1: gmg_clip_triangle_bary_v1 calls 1: gmg_abs
1371func gmg_clip_triangle_bary_v1(distance:*i64,out:*i64,cap_words:i64)->i64
1395func gmg_clip_product(a:i64,b:i64)->i64
1398func 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}
1399func gmg_clip_scalar(d:*i64,r:*i64,result:*i64)->i64
1412func gmg_clip_polygon_bary_v1(d:*i64,input:*i64,n:i64,out:*i64,scratch:*i64,cap_words:i64)->i64
1444func gmg_clip_area_ratio_v1(poly:*i64,n:i64,result:*i64)->i64{return ngb_clip_area_ratio_v1(poly,n,result)}
1458func gmg_attach_source_v1(b:*u8,n:i64)->i64{return ngb_attach_source_v1(b,n)}
1459func gmg_attach_face_v1(pos:*i64,idx:*i64,face:i64)->i64{return ngb_attach_face_v1(pos,idx,face)}
1462func 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)}
1467func gmg_attach_onepiece_into_v1(G:*i64,out:*i64,cap:i64,scratch:*i64,sw:i64)->i64
1499func gmg_attach_compose_into_v1(b:*u8,n:i64,s:*i64,nw:i64,out:*u8,cap:i64,work:*i64,ww:i64)->i64
1519func 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}
called by 1: gmg_write_nxa_checked_v1 calls 1: sys_write
1520func gmg_write_nxa_checked_v1(b:*u8,flen:i64,sec:*i64,nwords:i64,outpath:*u8)->i64