code wiki / _hdl_build / nx_gltf_static_descriptor_gate_t338.nx

nx_gltf_static_descriptor_gate_t338.nx source

↩ module page · 39 lines · 2548 B

1import "nx_gltf_static_descriptor_candidate_t338.nx" 2func main()->i64{ 3 let ln:*i64=sys_mmap(16) as *i64;let src:*u8=sys_read_file("knowledge/gates/connected-body-sdf-domain-t337.glb",ln) 4 let cx:*i64=sys_mmap(GLD_CONTEXT_WORDS*8) as *i64 5 if gltf_view_open(src,ln[0],cx)!=0{return 1} 6 let w:*i64=sys_mmap(32) as *i64 7 if gltf_render_static_descriptor(cx,0,w)!=0{return 2};let n:i64=w[2] 8 let buf:*u8=sys_mmap_try(n);if (buf as i64)==0{return 3};w[0]=buf as i64;w[1]=n;w[2]=0;w[3]=0 9 if gltf_render_static_descriptor(cx,0,w)!=0||w[2]!=n{return 4} 10 let fd:i64=sys_openat_wr("knowledge/gates/connected-body-static-descriptor-t338.json",MODE_0644);if fd<0{return 5} 11 let wr:i64=sys_write(fd,buf,n);sys_close(fd);if wr!=n{return 6} 12 sys_write(1,"STATIC_DESCRIPTOR_EXACT_WRITE_PASS\n",35) 13 w[0]=0;w[1]=0;w[2]=0;w[3]=0 14 if gltf_render_static_descriptor(cx,1,w)==0{return 7} 15 sys_write(1,"STATIC_INVALID_NODE_REFUSED\n",28) 16 w[0]=buf as i64;w[1]=n-1;w[2]=0;w[3]=0 17 if gltf_render_static_descriptor(cx,0,w)!=-3{return 8} 18 sys_write(1,"STATIC_SHORT_OUTPUT_REFUSED\n",28) 19 let scaleAt:i64=gls_find(src,ln[0],0,"0.0009765625") 20 if scaleAt<0{return 9};let saved:u8=src[scaleAt+5];src[scaleAt+5]=56 as u8 21 w[0]=0;w[1]=0;w[2]=0;w[3]=0 22 if gltf_render_static_descriptor(cx,0,w)!=-2{return 10};src[scaleAt+5]=saved 23 sys_write(1,"STATIC_NONUNIFORM_SCALE_REFUSED\n",32) 24 let noff:i64=cx[8]-cx[6]+35880;let nsave:i64=gll_ru32(src,noff);glp_u32(src,noff,2139095040) 25 w[0]=0;w[1]=0;w[2]=0;w[3]=0 26 if gltf_render_static_descriptor(cx,0,w)!=-2{return 11};glp_u32(src,noff,nsave) 27 sys_write(1,"STATIC_NONFINITE_NORMAL_REFUSED\n",32) 28 let extra:*u8=",\"materials\":[{\"pbrMetallicRoughness\":{\"baseColorTexture\":{\"index\":0}}}]" 29 var end:i64=20+gll_ru32(src,12);while src[end-1]==(32 as u8){end=end-1};if src[end-1]!=(125 as u8){return 12} 30 let en:i64=gll_slen(extra);let jn:i64=gll_align4(end-20+en);let oldBin:i64=20+gll_ru32(src,12);let bytes:i64=20+jn+ln[0]-oldBin 31 let altered:*u8=sys_mmap(bytes);var bi:i64=0;while bi<end-1{altered[bi]=src[bi];bi=bi+1} 32 var ei:i64=0;while ei<en{altered[bi]=extra[ei];bi=bi+1;ei=ei+1};altered[bi]=125 as u8;bi=bi+1 33 while bi<20+jn{altered[bi]=32 as u8;bi=bi+1};ei=oldBin;while ei<ln[0]{altered[bi]=src[ei];bi=bi+1;ei=ei+1} 34 glp_u32(altered,8,bytes);glp_u32(altered,12,jn) 35 let tx:*i64=sys_mmap(GLD_CONTEXT_WORDS*8) as *i64;if gltf_view_open(altered,bytes,tx)!=0{return 13} 36 if gpd_static_material_admit(tx,0)!=-2{return 14} 37 sys_write(1,"STATIC_TEXTURE_WITHOUT_UV_REFUSED\n",34) 38 gltf_view_close(tx);gltf_view_close(cx);return 0 39}