"""Decode FBX animation curve values and compare two clips frame by frame. Range or amplitude comparisons pair up motions that merely span the same extents; matching the actual key values settles it. """ import os, struct, sys, zlib SCALAR={"Y":2,"C":1,"I":4,"F":4,"D":8,"L":8}; ELEM={"f":4,"d":8,"l":8,"i":4,"b":1} FMT={"f":"f","d":"d","l":"q","i":"i","b":"b"} def curves(path): d=open(path,'rb').read(); u64=struct.unpack("=7500 N=25 if u64 else 13; out=[] def rp(p,want): t=chr(d[p]); s=p; p+=1 if t in SCALAR: p+=SCALAR[t]; return p,None if t in ELEM: n,enc,cl=struct.unpack("1e-6]; mb=[c for c in cb if max(c)-min(c)>1e-6] if len(ma)!=len(mb): return False,"moving curves %d vs %d"%(len(ma),len(mb)) ka=sorted(ma,key=lambda c:(len(c),c[0])); kb=sorted(mb,key=lambda c:(len(c),c[0])) matched=0 for x,y in zip(ka,kb): n=min(len(x),len(y)) if n and all(abs(x[i]-y[i])