Add setter methods for spline points

This commit is contained in:
Wojtek Figat
2021-01-27 12:12:40 +01:00
parent 53601d8a85
commit d0c0259ee2
2 changed files with 66 additions and 2 deletions

View File

@@ -231,9 +231,41 @@ void Spline::ClearSpline()
UpdateSpline();
}
void Spline::SetSplinePoint(int32 index, const Vector3& point, bool updateSpline)
{
CHECK(index >= 0 && index < GetSplinePointsCount());
Curve[index].Value.Translation = _transform.WorldToLocal(point);
if (updateSpline)
UpdateSpline();
}
void Spline::SetSplineLocalPoint(int32 index, const Vector3& point, bool updateSpline)
{
CHECK(index >= 0 && index < GetSplinePointsCount());
Curve[index].Value.Translation = point;
if (updateSpline)
UpdateSpline();
}
void Spline::SetSplineTransform(int32 index, const Transform& point, bool updateSpline)
{
CHECK(index >= 0 && index < GetSplinePointsCount());
Curve[index].Value = _transform.WorldToLocal(point);
if (updateSpline)
UpdateSpline();
}
void Spline::SetSplineLocalTransform(int32 index, const Transform& point, bool updateSpline)
{
CHECK(index >= 0 && index < GetSplinePointsCount());
Curve[index].Value = point;
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(point));
const Keyframe k(Curve.IsEmpty() ? 0.0f : Curve.GetKeyframes().Last().Time + 1.0f, Transform(_transform.WorldToLocal(point)));
Curve.GetKeyframes().Add(k);
if (updateSpline)
UpdateSpline();
@@ -241,7 +273,7 @@ void Spline::AddSplinePoint(const Vector3& point, bool updateSpline)
void Spline::AddSplineLocalPoint(const Vector3& point, bool updateSpline)
{
const Keyframe k(Curve.IsEmpty() ? 0.0f : Curve.GetKeyframes().Last().Time + 1.0f, Transform(_transform.WorldToLocal(point)));
const Keyframe k(Curve.IsEmpty() ? 0.0f : Curve.GetKeyframes().Last().Time + 1.0f, Transform(point));
Curve.GetKeyframes().Add(k);
if (updateSpline)
UpdateSpline();

View File

@@ -198,6 +198,38 @@ public:
/// </summary>
API_FUNCTION() void ClearSpline();
/// <summary>
/// Sets the spline curve at the given index (world-space).
/// </summary>
/// <param name="index">The curve keyframe index. Zero-based, smaller than GetSplinePointsCount().</param>
/// <param name="point">The location of the point to set (world-space).</param>
/// <param name="updateSpline">True if update spline after adding the point, otherwise false.</param>
API_FUNCTION() void SetSplinePoint(int32 index, const Vector3& point, bool updateSpline = true);
/// <summary>
/// Sets the spline curve at the given index (local-space).
/// </summary>
/// <param name="index">The curve keyframe index. Zero-based, smaller than GetSplinePointsCount().</param>
/// <param name="point">The location of the point to set (local-space).</param>
/// <param name="updateSpline">True if update spline after adding the point, otherwise false.</param>
API_FUNCTION() void SetSplineLocalPoint(int32 index, const Vector3& point, bool updateSpline = true);
/// <summary>
/// Sets the spline curve at the given index (world-space).
/// </summary>
/// <param name="index">The curve keyframe index. Zero-based, smaller than GetSplinePointsCount().</param>
/// <param name="point">The location of the point to set (world-space).</param>
/// <param name="updateSpline">True if update spline after adding the point, otherwise false.</param>
API_FUNCTION() void SetSplineTransform(int32 index, const Transform& point, bool updateSpline = true);
/// <summary>
/// Sets the spline curve at the given index (local-space).
/// </summary>
/// <param name="index">The curve keyframe index. Zero-based, smaller than GetSplinePointsCount().</param>
/// <param name="point">The location of the point to set (local-space).</param>
/// <param name="updateSpline">True if update spline after adding the point, otherwise false.</param>
API_FUNCTION() void SetSplineLocalTransform(int32 index, const Transform& point, bool updateSpline = true);
/// <summary>
/// Adds the point to the spline curve (at the end).
/// </summary>