l = te-ts;
t = (replay->cursor-ts)/l;
+ /*
+ * Adjust t, so that its derivative matches at the endpoints.
+ * Since t needs to go from 0 to 1, it will naturally change at
+ * different rates between keyframes. So this smooths it out.
+ *
+ * Newton method, going through standard direct quadratic eq has
+ * precision / other problems. Also we only care about 0>t>1.
+ */
+ f32 b = (kf[1].time-ts)/l,
+ x0 = 1.0-t;
+ for( u32 i=0; i<4; i ++ )
+ {
+ f32 ix0 = 1.0f-x0,
+ fx_x0 = 2.0f*b*x0*ix0 + ix0*ix0 - t,
+ fxd_x0 = 2.0f*(-2.0f*b*x0 + b + x0 - 1.0f);
+ x0 = x0 - (fx_x0/fxd_x0);
+ }
+ t = 1.0-x0;
+
f32 t0 = t*m_start+(1.0f-m_start),
t1 = t*m_end;