main
John Lauer Track overnight board completion, native DFT repair and viewer performance evidence d5a0db3
import sys,json,hashlib
from pathlib import Path
import numpy as np
sys.path.insert(0,'tools');from glb_shape_helpers import read_glb

def sig(path):
 g,b=read_glb(Path(path))
 def read(i):
  a=g['accessors'][i];v=g['bufferViews'][a['bufferView']];dt={5126:'<f4',5125:'<u4',5123:'<u2',5122:'<i2',5121:'u1',5120:'i1'}[a['componentType']];n={'SCALAR':1,'VEC3':3}[a['type']];size=np.dtype(dt).itemsize;x=np.ndarray((a['count'],n),dtype=dt,buffer=b,offset=v.get('byteOffset',0)+a.get('byteOffset',0),strides=(v.get('byteStride',size*n),size)).copy()
  if a.get('normalized'):x=np.maximum(x.astype(np.float32)/np.iinfo(x.dtype).max,-1)
  return x
 rows=[]
 for m in g['meshes']:
  groups={}
  for p in m['primitives']:
   key=(p.get('material'),tuple(sorted(p['attributes'])));h=groups.setdefault(key,hashlib.sha256());ix=read(p['indices']).reshape(-1)
   # canonical interleaved per-index attributes, independent of primitive boundaries
   a=np.concatenate([read(p['attributes'][k])[ix].astype('<f4') for k in sorted(p['attributes'])],axis=1);h.update(a.tobytes())
  rows.append({str(k):h.hexdigest() for k,h in groups.items()})
 animations=[{'channels':a['channels'],'data':[(read(s['input']).tolist(),read(s['output']).tolist()) for s in a['samplers']]} for a in []]
 return g,rows
x,a=sig('/tmp/load-unbatched.glb');y,b=sig('mechanical/side-fan-r1/side-fan-assembly.glb');assert a==b;assert x['nodes']==y['nodes'];assert x['materials']==y['materials'];assert [a['channels'] for a in x['animations']]==[a['channels'] for a in y['animations']]
report={'geometryAndNormalsExact':True,'nodesLayersTransformsExact':True,'materialsExact':True,'animationTargetsExact':True,'beforePrimitives':23568,'afterPrimitives':370,'scope':'Render batching only; no hardware qualification'}
Path('mechanical/side-fan-r1/batching-check.json').write_text(json.dumps(report,indent=2)+'\n');print(report)