"""Reimport the six review GLBs and compare their deformation to source audits.""" import json import sys from pathlib import Path sys.path.insert(0,str(Path(__file__).resolve().parent)) from bl_compare_mixamo_soma import audit folder=Path(sys.argv[sys.argv.index('--')+1]) source=json.loads((folder/'comparison.json').read_text())+json.loads((folder/'comparison_local.json').read_text()) results=[] for variant,prefix in [('raw','TokenRig41'),('local','TokenRigLocal')]: for label in ['Walking','Breathing Idle','Happy Idle']: path=folder/'animations'/variant/(label.replace(' ','_')+'.glb') item=audit('Export '+variant+' '+label,path,None,folder/'review') expected=next(x for x in source if x['label']==prefix+' '+label) actual=item['animation'] assert actual['range']==expected['animation']['range'],(path,actual['range']) errors={n:abs(actual['summary'][n]['max_edge_stretch']-expected['animation']['summary'][n]['max_edge_stretch']) for n in actual['summary']} assert max(errors.values())<.001,(path,errors) results.append({'file':str(path),'frames':actual['range'],'max_stretch_difference_from_source':errors,'bones':len(item['bones'])}) (folder/'export_verification.json').write_text(json.dumps(results,indent=2),encoding='utf-8') print('EXPORTS_VERIFIED',len(results))