Add GetSplineDirection util to Spline
This commit is contained in:
@@ -77,6 +77,21 @@ Transform Spline::GetSplineLocalTransform(float time) const
|
||||
return t;
|
||||
}
|
||||
|
||||
Vector3 Spline::GetSplineDirection(float time) const
|
||||
{
|
||||
return _transform.LocalToWorldVector(GetSplineLocalDirection(time));
|
||||
}
|
||||
|
||||
Vector3 Spline::GetSplineLocalDirection(float time) const
|
||||
{
|
||||
if (Curve.GetKeyframes().Count() == 0)
|
||||
return Vector3::Forward;
|
||||
Transform t;
|
||||
Curve.EvaluateFirstDerivative(t, time, _loop);
|
||||
t.Translation.Normalize();
|
||||
return t.Translation;
|
||||
}
|
||||
|
||||
Vector3 Spline::GetSplinePoint(int32 index) const
|
||||
{
|
||||
CHECK_RETURN(index >= 0 && index < GetSplinePointsCount(), Vector3::Zero)
|
||||
|
||||
@@ -96,6 +96,20 @@ public:
|
||||
/// <returns>The calculated curve point transformation (local-space).</returns>
|
||||
API_FUNCTION() Transform GetSplineLocalTransform(float time) const;
|
||||
|
||||
/// <summary>
|
||||
/// Evaluates the spline curve direction (forward vector, aka position 1st derivative) at the given time in 3D (world-space).
|
||||
/// </summary>
|
||||
/// <param name="time">The time value. Can be negative or larger than curve length (curve will loop or clamp).</param>
|
||||
/// <returns>The calculated curve direction (world-space).</returns>
|
||||
API_FUNCTION() Vector3 GetSplineDirection(float time) const;
|
||||
|
||||
/// <summary>
|
||||
/// Evaluates the spline curve direction (forward vector, aka position 1st derivative) at the given time in 3D (local-space).
|
||||
/// </summary>
|
||||
/// <param name="time">The time value. Can be negative or larger than curve length (curve will loop or clamp).</param>
|
||||
/// <returns>The calculated curve direction (local-space).</returns>
|
||||
API_FUNCTION() Vector3 GetSplineLocalDirection(float time) const;
|
||||
|
||||
/// <summary>
|
||||
/// Evaluates the spline curve at the given index (world-space).
|
||||
/// </summary>
|
||||
|
||||
Reference in New Issue
Block a user