nx_body_skin_artifact_gate_t345.nx source
↩ module page · 39 lines · 4485 B
1import "nx_body_skin_cut.nx"
2import "nx_gate_verdict.nx"
3func bag_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)}
4func bag_equal(a:*u8,b:*u8,n:i64)->i64{var i:i64=0;while i<n{if a[i]!=b[i]{return 0};i=i+1};return 1}
5func bag_at(b:*u8,o:i64)->*u8{return ((b as i64)+o) as *u8}
6func bag_header(b:*u8,n:i64)->i64{
7 if (b as i64)<=0||n<88{return 0};if bag_equal(b,"NXMSH2" as *u8,6)!=1||bag_u32(b,8)!=3{return 0}
8 let nt:i64=bag_u32(b,12);if n!=88+nt*88{return 0}
9 var i:i64=0;var end:i64=0;while i<3{if bag_u32(b,32+i*24)!=end{return 0};end=end+bag_u32(b,36+i*24);if end>nt{return 0};i=i+1};if end!=nt{return 0};return 1
10}
11// Actual generator positions are integer-mm Float32 values. Refuse a nonintegral or nonfinite position.
12func bag_integer(bits:i64,out:*i64)->i64{
13 let e:i64=(bits>>23)&255;let m:i64=bits&8388607;if e==0&&m==0{out[0]=0;return 0};if e<127||e>157{return BJ_DOMAIN}
14 var v:i64=m+8388608;let shift:i64=e-150;if shift>=0{v=v<<shift}else{let mask:i64=(1<<(0-shift))-1;if (v&mask)!=0{return BJ_DOMAIN};v=v>>(0-shift)}
15 if ((bits>>31)&1)==1{v=0-v};if v<0-BJ_COORD_LIMIT||v>BJ_COORD_LIMIT{return BJ_DOMAIN};out[0]=v;return 0
16}
17func bag_vertex_equal(a:*u8,ai:i64,b:*u8,bi:i64)->i64{return bag_equal(bag_at(a,ai*12),bag_at(b,bi*12),12)}
18func main(argc:i64,argv:*i64)->i64{
19 let ctr:*i64=gv_ctr();gv_head("Actual generated NXMSH2 attachment artifact qualification" as *u8);if argc!=3{return 2}
20 let lens:*i64=sys_mmap(16) as *i64;let old:*u8=sys_read_file(argv[1] as *u8,lens);let fresh:*u8=sys_read_file(argv[2] as *u8,bjc_words(lens,1))
21 let good:i64=bag_header(old,lens[0])*bag_header(fresh,lens[1]);gv_check("both actual artifact headers and complete extents valid" as *u8,good,ctr);if good!=1{return gv_verdict("body_attachment_artifact" as *u8,ctr,"invalid source artifacts" as *u8)}
22 let before:i64=bag_u32(old,36);let after:i64=bag_u32(fresh,36);let added:i64=56;let removed:i64=616
23 gv_check("declared source cuts and positive bridge have exact triangle delta" as *u8,(before-after==removed-added&&after>added) as i64,ctr)
24 var layer:i64=1;while layer<3{let oo:i64=bag_u32(old,32+layer*24);let no:i64=bag_u32(fresh,32+layer*24);let count:i64=bag_u32(old,36+layer*24);gv_check("inner layer triangle count and all source bytes preserved" as *u8,(count==bag_u32(fresh,36+layer*24)&&bag_equal(bag_at(old,88+oo*84),bag_at(fresh,88+no*84),count*84)==1) as i64,ctr);layer=layer+1}
25 var source:i64=0;var kept:i64=0;var missing:i64=0;var i:i64=0
26 while i<after-added{let t:*u8=bag_at(fresh,88+i*84);while source<before&&bag_equal(bag_at(old,88+source*84),t,84)!=1{source=source+1;missing=missing+1};if source<before{kept=kept+1;source=source+1};i=i+1};missing=missing+before-source
27 gv_check("every retained skin triangle is exact ordered source geometry normal and material" as *u8,(kept==after-added&&missing==removed) as i64,ctr)
28 let pos:*i64=sys_mmap(9*8) as *i64;var nondegenerate:i64=0;var interior:i64=0;var boundary:i64=0;var badedge:i64=0
29 i=0;while i<added{let t:*u8=bag_at(fresh,88+(after-added+i)*84);var c:i64=0;var rc:i64=0;while c<9&&rc==0{rc=bag_integer(bag_u32(t,c*4),bjc_words(pos,c));c=c+1};if rc==0&&bj_triangle(pos,0,1,2)==0{nondegenerate=nondegenerate+1}
30 var edge:i64=0;while edge<3{var count:i64=0;var direction:i64=0;var owner:i64=-1;var q:i64=0
31 while q<after{if q!=after-added+i{let other:*u8=bag_at(fresh,88+q*84);var oe:i64=0;while oe<3{if bag_vertex_equal(t,edge,other,oe)==1&&bag_vertex_equal(t,(edge+1)%3,other,(oe+1)%3)==1{count=count+1;direction=direction+1;owner=q};if bag_vertex_equal(t,edge,other,(oe+1)%3)==1&&bag_vertex_equal(t,(edge+1)%3,other,oe)==1{count=count+1;direction=direction-1;owner=q};oe=oe+1}};q=q+1}
32 if count==1&&direction==-1{if owner<after-added{boundary=boundary+1}else{interior=interior+1}}else{badedge=badedge+1};edge=edge+1
33 };i=i+1
34 }
35 gv_check("all actual added strip triangles nondegenerate in checked integer domain" as *u8,(nondegenerate==added) as i64,ctr)
36 gv_check("all56 actual strip boundary edges have exactly one opposite retained owner" as *u8,(boundary==added) as i64,ctr)
37 gv_check("all56 interior edges paired oppositely and no extra owners" as *u8,(interior==added*2&&badedge==0) as i64,ctr)
38 return gv_verdict("body_attachment_artifact" as *u8,ctr,"specific declared neck port only; no whole-body manifold or intersections; legacy BG_MAXTRI and unchecked output allocator remain outside this gate; no anatomy acceptance" as *u8)
39}