/* Returns the VR Center Eye Transform information interpolated to the given leap timestamp. If the desired * timestamp is outside of the recorded range, interpolation will fail and the returned transform will not * have the desired time. */ private TransformData transformAtTime(long time) { if (_history.Count == 0) { return(new TransformData() { leapTime = 0, localPosition = Vector3.zero, localRotation = Quaternion.identity }); } if (_history[0].leapTime >= time) { // Expect this when using LOW LATENCY image retrieval, which can yield negative latency estimates due to incorrect clock synchronization return(_history[0]); } int t = 1; while (t < _history.Count && _history[t].leapTime <= time) { t++; } if (!(t < _history.Count)) { // Expect this for initial frames which will have a very low frame rate return(_history[_history.Count - 1]); } return(TransformData.Lerp(_history[t - 1], _history[t], time)); }
/// <summary> /// Estimates the transform of this gameObject at the specified time /// </summary> /// <returns> /// A transform with leapTime == time only if interpolation was possible /// </returns> protected TransformData TransformAtTime(long time) { if (history.Count < 1) { //Debug.LogWarning ("NO HISTORY!"); return(new TransformData() { leapTime = 0, position = Vector3.zero, rotation = Quaternion.identity }); } if (history [0].leapTime >= time) { // Expect this when using LOW LATENCY image retrieval, which can yield negative latency estimates due to incorrect clock synchronization //if (history [0].leapTime > time) Debug.LogWarning("NO INTERPOLATION: Using earliest time = " + history[0].leapTime + " > time = " + time); return(history[0]); } int t = 1; while (t < history.Count && history[t].leapTime <= time) { t++; } if (!(t < history.Count)) { // Expect this for initial frames which will have a very low frame rate if (history[history.Count - 1].leapTime < time) { Debug.LogWarning("NO INTERPOLATION: Using most recent time = " + history[history.Count - 1].leapTime + " < time = " + time); } return(history[history.Count - 1]); } return(TransformData.Lerp(history[t - 1], history[t], time)); }