/// <summary> /// Calculate bounds of twovector intervals /// </summary> /// <param name="start">interp curve point at Start</param> /// <param name="end">interp curve point at End</param> /// <param name="currentMin">Input and Output could be updated if needs new interval minimum bound</param> /// <param name="currentMax">Input and Output could be updated if needs new interval maximmum bound</param> public static void CurveFindIntervalBounds( FInterpCurvePointTwoVectors start, FInterpCurvePointTwoVectors end, ref FTwoVectors currentMin, ref FTwoVectors currentMax) { bool isCurve = start.IsCurveKey(); float min, max; // Do the first curve FindBounds(out min, out max, start.OutVal.V1.X, start.LeaveTangent.V1.X, start.InVal, end.OutVal.V1.X, end.ArriveTangent.V1.X, end.InVal, isCurve); currentMin.V1.X = FMath.Min(currentMin.V1.X, min); currentMax.V1.X = FMath.Max(currentMax.V1.X, max); FindBounds(out min, out max, start.OutVal.V1.Y, start.LeaveTangent.V1.Y, start.InVal, end.OutVal.V1.Y, end.ArriveTangent.V1.Y, end.InVal, isCurve); currentMin.V1.Y = FMath.Min(currentMin.V1.Y, min); currentMax.V1.Y = FMath.Max(currentMax.V1.Y, max); FindBounds(out min, out max, start.OutVal.V1.Z, start.LeaveTangent.V1.Z, start.InVal, end.OutVal.V1.Z, end.ArriveTangent.V1.Z, end.InVal, isCurve); currentMin.V1.Z = FMath.Min(currentMin.V1.Z, min); currentMax.V1.Z = FMath.Max(currentMax.V1.Z, max); // Do the second curve FindBounds(out min, out max, start.OutVal.V2.X, start.LeaveTangent.V2.X, start.InVal, end.OutVal.V2.X, end.ArriveTangent.V2.X, end.InVal, isCurve); currentMin.V2.X = FMath.Min(currentMin.V2.X, min); currentMax.V2.X = FMath.Max(currentMax.V2.X, max); FindBounds(out min, out max, start.OutVal.V2.Y, start.LeaveTangent.V2.Y, start.InVal, end.OutVal.V2.Y, end.ArriveTangent.V2.Y, end.InVal, isCurve); currentMin.V2.Y = FMath.Min(currentMin.V2.Y, min); currentMax.V2.Y = FMath.Max(currentMax.V2.Y, max); FindBounds(out min, out max, start.OutVal.V2.Z, start.LeaveTangent.V2.Z, start.InVal, end.OutVal.V2.Z, end.ArriveTangent.V2.Z, end.InVal, isCurve); currentMin.V2.Z = FMath.Min(currentMin.V2.Z, min); currentMax.V2.Z = FMath.Max(currentMax.V2.Z, max); }
/// <summary> /// Constructor /// </summary> /// <param name="inVal">input value that corresponds to this key</param> /// <param name="outVal">Output value of templated type</param> public FInterpCurvePointTwoVectors(float inVal, FTwoVectors outVal) { InVal = inVal; OutVal = outVal; ArriveTangent = default(FTwoVectors); LeaveTangent = default(FTwoVectors); InterpMode = EInterpCurveMode.Linear; }
/// <summary> /// Constructor /// </summary> /// <param name="inVal">input value that corresponds to this key</param> /// <param name="outVal">Output value of templated type</param> /// <param name="arriveTangent">Tangent of curve arriving at this point. </param> /// <param name="leaveTangent">Tangent of curve leaving from this point.</param> /// <param name="interpMode">interpolation mode to use</param> public FInterpCurvePointTwoVectors(float inVal, FTwoVectors outVal, FTwoVectors arriveTangent, FTwoVectors leaveTangent, EInterpCurveMode interpMode) { InVal = inVal; OutVal = outVal; ArriveTangent = arriveTangent; LeaveTangent = leaveTangent; InterpMode = interpMode; }
/// <summary> /// Computes a tangent for the specified control point. Special case for FTwoVectors types; supports clamping. /// </summary> public static unsafe void ComputeCurveTangent( float prevTime, FTwoVectors prevPoint, float curTime, FTwoVectors curPoint, float nextTime, FTwoVectors nextPoint, float tension, bool wantClamping, out FTwoVectors outTangent) { if (wantClamping) { FTwoVectors result; ComputeClampableFloatVectorCurveTangentClamped( prevTime, (float *)&prevPoint, curTime, (float *)&curPoint, nextTime, (float *)&nextPoint, tension, sizeof(FTwoVectors), (float *)&result); outTangent = result; } else { AutoCalcTangent(prevPoint, curPoint, nextPoint, tension, out outTangent); float prevToNextTimeDiff = FMath.Max(FMath.KindaSmallNumber, nextTime - prevTime); outTangent /= prevToNextTimeDiff; } }
/// <summary> /// Computes Tangent for a curve segment /// </summary> public static void AutoCalcTangent(FTwoVectors prevP, FTwoVectors p, FTwoVectors nextP, float tension, out FTwoVectors outTan) { outTan = (1.0f - tension) * ((p - prevP) + (nextP - p)); }