public sealed class SplineAssetThe authored form of a path: what a .vxspline holds and what an editor mutates.
Remarks
[docs/plan/31 § T8], and [docs/plan/26]'s largest owed item. One asset with two consumers — a road that deforms a terrain and a camera dolly that follows a track — which is why it is here rather than in either of them.
⚠ Two types, and the split is the point. Spline is immutable and precomputes an arc-length table; this is mutable and precomputes nothing. An editor moves a control point on every frame of a drag, and rebuilding a length table sixty times a second for a curve nobody is measuring is the cost that makes an editor feel heavy. Ask for Build when the answer is needed.
⚠ An asset with one point is legal and is not a curve. An author places the first point of a road before they place the second, and an asset that refused to exist until it had two would have to be built from a dialog rather than from the viewport. CanBuild is the question a consumer asks.
Fields and properties (6)
public string NameWhat it is called, which is what a scene names it by.
public bool IsClosedWhether the last point joins back to the first.
public IReadOnlyList<SplinePoint> PointsThe control points, in order.
public int CountHow many there are.
public bool CanBuildWhether there are enough points to evaluate a curve.
public SplinePoint this[int index]One control point.
Methods (18)
public SplineAsset()An empty asset.
public SplineAsset(string name, ReadOnlySpan<SplinePoint> controlPoints, bool closed = false)An asset over control points.
public static SplineAsset Through(string name, ReadOnlySpan<Vector3> positions, bool closed = false)A path through positions, with Catmull-Rom tangents.
public void Set(int index, SplinePoint point)Replaces a control point.
public void MoveTo(int index, Vector3 position)Moves a control point, carrying its tangents with it.
public int Add(SplinePoint point)Appends a control point at the end.
public void Insert(int index, SplinePoint point)Inserts a control point before an index.
public bool RemoveAt(int index)Removes a control point.
public void Clear()Empties it.
public void SetTangentOut(int index, Vector3 tangentOut, bool mirror = true)Sets a point's outgoing tangent, optionally mirroring the incoming one.
public void SetTangentIn(int index, Vector3 tangentIn, bool mirror = true)And the incoming one.
public void Smooth(float tension = 0)Recomputes every tangent from the positions, making the path smooth throughout.
public int InsertOn(float parameter)Inserts a control point on the curve without changing its shape.
public SplineAsset? Split(int index, string? name = null)Cuts the path at a control point, keeping the head and returning the tail.
public bool Join(SplineAsset other, bool reversed = false)Appends another path onto the end of this one.
public Spline Build()The curve this asset describes.
public SplineAsset Clone()An independent copy.
public string? Validate()Why this asset cannot be used, or if it can.
Used by (10)
- SplineAssetTestsVixen.Core.Mathematics.Tests
- TypeRegistrationVixen.Core.Mathematics
- Vixen_Core_Mathematics_SplineAssetSerializerVixen.Core.Mathematics
- SplineCommandVixen.Editor.SceneView
- SplineEditVixen.Editor.SceneView
- SplineEditTestsVixen.Editor.SceneView.Tests
- SplineOverlayVixen.Editor.SceneView
- SplineOverlayTestsVixen.Editor.SceneView.Tests
- TerrainAssetImporterVixen.Editor.Assets
- TerrainModuleVixen.Editor.Terrain