Vixen
02b45cc4
csharp
public static class SplineOverlay

Drawing a spline in the viewport: the curve, its control points and its tangent handles.

Read the guide page for this →

Remarks

[docs/plan/31 § T8]'s owed overlay. SplineEdit is what a drag does to a curve and it has been testable since it was written; what was missing is the half a person aims at. Without it a spline is a set of numbers in a panel, which is the state every curve tool is unusable in.

⚠ Line vertices rather than draw calls, and the reason is the test. This produces the same LineVertex list SceneLines produces for everything else, so what it emits can be asserted without a viewport, a device or a window — and the failure it is most likely to have is arithmetic, not binding.

⚠ The curve is sampled by arc length, not by parameter. A Hermite segment's parameter runs at a different speed on every segment, so a fixed count per segment draws a tight corner with the same number of lines as a straight kilometre — the corner reads as faceted and the straight bit as wasteful. Sampling by distance spends the vertices where the curve bends.

⚠ A tangent handle is drawn at a third of its length, which is Bézier's convention and not an aesthetic one. A Hermite tangent and its Bézier control point differ by exactly that factor, and InsertOn converts between them — so a handle drawn at full length would sit somewhere the geometry never passes and a person dragging it would be aiming at the wrong place.

Fields and properties (6)

  • public const float SampleSpacing

    How far apart the curve is sampled, in metres.

  • public const int MaximumSamples

    The most samples one spline is drawn with, however long it is.

  • public static Color4 CurveColour

    What the curve itself is drawn in.

  • public static Color4 PointColour

    And a control point.

  • public static Color4 SelectedColour

    And a selected one.

  • public static Color4 TangentColour

    And a tangent handle.

Methods (3)

  • public static int Curve(in Spline spline, List<LineVertex> into)

    Emits the curve as a line strip.

  • public static int Point(in SplinePoint point, List<LineVertex> into, float size = 0.4, bool selected = false)

    Emits a control point's cross and its two tangent handles.

  • public static int Draw(SplineAsset asset, List<LineVertex> into, int selected = -1, float size = 0.4)

    Emits a whole spline: its curve, every point and every handle.

Used by (1)

  • SplineOverlayTestsVixen.Editor.SceneView.Tests