diff --git a/Source/Engine/Level/Actors/Spline.cpp b/Source/Engine/Level/Actors/Spline.cpp
index aaccd13fe..a3757253f 100644
--- a/Source/Engine/Level/Actors/Spline.cpp
+++ b/Source/Engine/Level/Actors/Spline.cpp
@@ -106,16 +106,29 @@ Vector3 Spline::GetSplineLocalPoint(int32 index) const
Transform Spline::GetSplineTransform(int32 index) const
{
- CHECK_RETURN(index >= 0 && index < GetSplinePointsCount(), Vector3::Zero)
+ CHECK_RETURN(index >= 0 && index < GetSplinePointsCount(), Transform::Identity)
return _transform.LocalToWorld(Curve[index].Value);
}
Transform Spline::GetSplineLocalTransform(int32 index) const
{
- CHECK_RETURN(index >= 0 && index < GetSplinePointsCount(), Vector3::Zero)
+ CHECK_RETURN(index >= 0 && index < GetSplinePointsCount(), Transform::Identity)
return Curve[index].Value;
}
+Transform Spline::GetSplineTangent(int32 index, bool isIn)
+{
+ return _transform.LocalToWorld(GetSplineLocalTangent(index, isIn));
+}
+
+Transform Spline::GetSplineLocalTangent(int32 index, bool isIn)
+{
+ CHECK_RETURN(index >= 0 && index < GetSplinePointsCount(), Transform::Identity)
+ const auto& k = Curve[index];
+ const auto& tangent = isIn ? k.TangentIn : k.TangentOut;
+ return tangent + k.Value;
+}
+
int32 Spline::GetSplinePointsCount() const
{
return Curve.GetKeyframes().Count();
@@ -263,6 +276,29 @@ void Spline::SetSplineLocalTransform(int32 index, const Transform& point, bool u
UpdateSpline();
}
+void Spline::SetSplineTangent(int32 index, const Transform& point, bool isIn, bool updateSpline)
+{
+ SetSplineLocalTangent(index, _transform.WorldToLocal(point), isIn, updateSpline);
+}
+
+void Spline::SetSplineLocalTangent(int32 index, const Transform& point, bool isIn, bool updateSpline)
+{
+ CHECK(index >= 0 && index < GetSplinePointsCount());
+ auto& k = Curve[index];
+ auto& tangent = isIn ? k.TangentIn : k.TangentOut;
+ tangent = point - k.Value;
+ if (updateSpline)
+ UpdateSpline();
+}
+
+void Spline::SetSplinePointTime(int32 index, float time, bool updateSpline)
+{
+ CHECK(index >= 0 && index < GetSplinePointsCount());
+ Curve[index].Time = time;
+ if (updateSpline)
+ UpdateSpline();
+}
+
void Spline::AddSplinePoint(const Vector3& point, bool updateSpline)
{
const Keyframe k(Curve.IsEmpty() ? 0.0f : Curve.GetKeyframes().Last().Time + 1.0f, Transform(_transform.WorldToLocal(point)));
diff --git a/Source/Engine/Level/Actors/Spline.h b/Source/Engine/Level/Actors/Spline.h
index 76f1eddab..772aac821 100644
--- a/Source/Engine/Level/Actors/Spline.h
+++ b/Source/Engine/Level/Actors/Spline.h
@@ -138,6 +138,24 @@ public:
/// The curve point transformation (local-space).
API_FUNCTION() Transform GetSplineLocalTransform(int32 index) const;
+ ///
+ /// Gets the spline curve point tangent at the given index (world-space).
+ ///
+ /// Tangents are stored relative to the curve point but this methods converts them to be in world-space.
+ /// The curve keyframe index. Zero-based, smaller than GetSplinePointsCount().
+ /// True if get arrive tangent, otherwise gets leave tangent (in or out).
+ /// The transformation of the tangent to set (world-space).
+ API_FUNCTION() Transform GetSplineTangent(int32 index, bool isIn);
+
+ ///
+ /// Gets the spline curve point tangent at the given index (local-space).
+ ///
+ /// Tangents are stored relative to the curve point but this methods converts them to be in local-space of the actor.
+ /// The curve keyframe index. Zero-based, smaller than GetSplinePointsCount().
+ /// True if get arrive tangent, otherwise gets leave tangent (in or out).
+ /// The transformation of the tangent to set (world-space).
+ API_FUNCTION() Transform GetSplineLocalTangent(int32 index, bool isIn);
+
///
/// Gets the amount of points in the spline.
///
@@ -218,7 +236,7 @@ public:
/// Sets the spline curve at the given index (world-space).
///
/// The curve keyframe index. Zero-based, smaller than GetSplinePointsCount().
- /// The location of the point to set (world-space).
+ /// The transformation of the point to set (world-space).
/// True if update spline after adding the point, otherwise false.
API_FUNCTION() void SetSplineTransform(int32 index, const Transform& point, bool updateSpline = true);
@@ -226,10 +244,38 @@ public:
/// Sets the spline curve at the given index (local-space).
///
/// The curve keyframe index. Zero-based, smaller than GetSplinePointsCount().
- /// The location of the point to set (local-space).
+ /// The transformation of the point to set (local-space).
/// True if update spline after adding the point, otherwise false.
API_FUNCTION() void SetSplineLocalTransform(int32 index, const Transform& point, bool updateSpline = true);
+ ///
+ /// Sets the spline curve point tangent at the given index (world-space).
+ ///
+ /// Tangents are stored relative to the curve point but this methods converts them to be in world-space.
+ /// The curve keyframe index. Zero-based, smaller than GetSplinePointsCount().
+ /// The transformation of the tangent to set (world-space).
+ /// True if set arrive tangent, otherwise sets leave tangent (in or out).
+ /// True if update spline after adding the point, otherwise false.
+ API_FUNCTION() void SetSplineTangent(int32 index, const Transform& point, bool isIn, bool updateSpline = true);
+
+ ///
+ /// Sets the spline curve point tangent at the given index (local-space).
+ ///
+ /// Tangents are stored relative to the curve point but this methods converts them to be in local-space of the actor.
+ /// The curve keyframe index. Zero-based, smaller than GetSplinePointsCount().
+ /// The transformation of the tangent to set (local-space).
+ /// True if set arrive tangent, otherwise sets leave tangent (in or out).
+ /// True if update spline after adding the point, otherwise false.
+ API_FUNCTION() void SetSplineLocalTangent(int32 index, const Transform& point, bool isIn, bool updateSpline = true);
+
+ ///
+ /// Sets the spline curve point time at the given index (world-space).
+ ///
+ /// The curve keyframe index. Zero-based, smaller than GetSplinePointsCount().
+ /// The time to set.
+ /// True if update spline after adding the point, otherwise false.
+ API_FUNCTION() void SetSplinePointTime(int32 index, float time, bool updateSpline = true);
+
///
/// Adds the point to the spline curve (at the end).
///