public static void HandleSteppedCurve(ref Vector3KeyFrame lhs, ref Vector3KeyFrame rhs, ref Vector3 value) { for (int i = 0; i < 3; i++) { if (lhs.outSlope[i] == Mathf.Infinity || rhs.inSlope[i] == Mathf.Infinity) { value[i] = lhs.value[i]; } } }
public override bool Equals(object obj) { if (obj.GetType() != typeof(Vector3KeyFrame)) { return(false); } Vector3KeyFrame rhs = (Vector3KeyFrame)obj; return(Mathf.Approximately(rhs.time, this.time) && rhs == this); }
public Vector3 Evaluate(float curveT) { if (_keyCount == 0) { return(Vector3.zero); } if (_keyCount == 1) { return(_curveData.keys[0].value); } curveT = WrapTime(curveT); int lhsIndex = 0, rhsIndex = 0; FindIndexForSampling(curveT, ref lhsIndex, ref rhsIndex); Vector3KeyFrame lhsKey = _curveData.keys[lhsIndex]; Vector3KeyFrame rhsKey = _curveData.keys[rhsIndex]; float dx = rhsKey.time - lhsKey.time; Vector3 m1, m2; float t; if (dx != 0f) { t = (curveT - lhsKey.time) / dx; m1 = lhsKey.outSlope * dx; m2 = rhsKey.inSlope * dx; } else { t = 0f; m1 = Vector3.zero; m2 = Vector3.zero; } Vector3 ret = CurveUtils.HermiteInterpolate(t, lhsKey.value, m1, m2, rhsKey.value); CurveUtils.HandleSteppedCurve(ref lhsKey, ref rhsKey, ref ret); return(ret); }