Table of Contents

Class CurvySplineSegment

Class covering a Curvy Spline Segment / ControlPoint

[ExecuteAlways]
public class CurvySplineSegment : DTVersionedMonoBehaviour
Inheritance
Object
Component
Behaviour
MonoBehaviour
DTVersionedMonoBehaviour
CurvySplineSegment

Fields

GizmoTangentColor

The color used in Gizmos to draw a segment's tangents

public static readonly Color GizmoTangentColor

Field Value

Color

Properties

AutoBakeOrientation

If set, Control Point's rotation will be set to the calculated Up-Vector3

public bool AutoBakeOrientation { get; set; }

Property Value

bool

Remarks

This is particularly useful when connecting splines

AutoHandleDistance

public float AutoHandleDistance { get; set; }

Property Value

float

AutoHandles

Gets or Sets Auto Handles. When setting it the value of connected control points is also updated

public bool AutoHandles { get; set; }

Property Value

bool

Bounds

Gets this segment's bounds in world space

public Bounds Bounds { get; }

Property Value

Bounds

CacheSize

Gets the number of individual cache points of this segment

public int CacheSize { get; }

Property Value

int

Remarks

The actual approximations arrays' size is CacheSize + 1

Connection

Gets/Sets the connection handler this Control Point is using (if any)

[CanBeNull]
public CurvyConnection Connection { get; }

Property Value

CurvyConnection

Remarks

If set to null, FollowUp wil be set to null to

ConnectionSyncPosition

When part of a CurvyConnection, this defines whether the connection's position is applied to this Control Point The synchronization process is applied by CurvyConnection at each frame in its update methods. So if you modify the value of this property, and want the synchronization to happen right away, you will have to call the connection's SetSynchronisationPositionAndRotation(Vector3, Quaternion) with the connection's position and rotation as parameters

public bool ConnectionSyncPosition { get; set; }

Property Value

bool

ConnectionSyncRotation

When part of a CurvyConnection, this defines whether the connection's rotation is applied to this Control Point The synchronization process is applied by CurvyConnection at each frame in its update methods. So if you modify the value of this property, and want the synchronization to happen right away, you will have to call the connection's SetSynchronisationPositionAndRotation(Vector3, Quaternion) with the connection's position and rotation as parameters

public bool ConnectionSyncRotation { get; set; }

Property Value

bool

Distance

Gets the distance from spline start to the start of this segment (localF=0)

public float Distance { get; }

Property Value

float

DistancesApproximation

List of distances approximating the segments's length Approximations are a set of precomputed properties of points sampled along the spline. Approximations are computed and stored for fast access to an approximation of the spline. The fidelity of the approximation depends on the spline's CacheDensity and MaxPointsPerUnit properties. Approximations are computed when the spline is refreshed. Spline refreshing is done automatically when needed (see UpdateIn), but you can also force it by calling Refresh().

public SubArray<float> DistancesApproximation { get; }

Property Value

SubArray<float>
See Also

EffectiveTcbParameters

Returns the actual TcbParameters for this segment, considering global and local settings.

public TcbParameters EffectiveTcbParameters { get; }

Property Value

TcbParameters
See Also

EndBias

Local Bias at segment end. Is used only if OverrideGlobalBias is true

public float EndBias { get; set; }

Property Value

float

Remarks

This only applies to splines using TCB

EndContinuity

Local Continuity at segment end. Is used only if OverrideGlobalContinuity is true

public float EndContinuity { get; set; }

Property Value

float

Remarks

This only applies to splines using TCB

EndTension

Local Tension at segment end. Is used only if OverrideGlobalTension is true

public float EndTension { get; set; }

Property Value

float

Remarks

This only applies to splines using TCB

FollowUp

Gets the connected Control Point that is set as "Head To"

[CanBeNull]
public CurvySplineSegment FollowUp { get; }

Property Value

CurvySplineSegment

FollowUpHeading

Gets or sets the heading toward the "Head To" segment

public ConnectionHeadingEnum FollowUpHeading { get; set; }

Property Value

ConnectionHeadingEnum

HandleIn

Bézier spline left handle in spline's local coordinates

public Vector3 HandleIn { get; set; }

Property Value

Vector3

HandleInPosition

Bézier spline left handle in world coordinates

public Vector3 HandleInPosition { get; set; }

Property Value

Vector3

HandleOut

Bézier spline right handle in spline's local coordinates

public Vector3 HandleOut { get; set; }

Property Value

Vector3

HandleOutPosition

Bézier spline right handle in world coordinates

public Vector3 HandleOutPosition { get; set; }

Property Value

Vector3

HasUnprocessedLocalOrientation

Returns true if the local orientation is different than the last one used in the segment approximations cache computation

public bool HasUnprocessedLocalOrientation { get; }

Property Value

bool

HasUnprocessedLocalPosition

Returns true if the local position is different than the last one used in the segment approximations cache computation

public bool HasUnprocessedLocalPosition { get; }

Property Value

bool

IsFirstControlPoint

Gets whether this Control Point is the first IGNORING closed splines

public bool IsFirstControlPoint { get; }

Property Value

bool

IsLastControlPoint

Gets whether this Control Point is the last IGNORING closed splines

public bool IsLastControlPoint { get; }

Property Value

bool

Length

Gets the length of this spline segment

public float Length { get; }

Property Value

float

Metadata

The Metadata components added to this GameObject

public HashSet<CurvyMetadataBase> Metadata { get; }

Property Value

HashSet<CurvyMetadataBase>

OrientationInfluencesSpline

Returns wheter the orientation of this Control Point influences the orientation of its containing spline's approximation points. Returns false if control point is not part of a spline

public bool OrientationInfluencesSpline { get; }

Property Value

bool

OverrideGlobalBias

Whether local StartBias and EndBias should be used. Otherwise the global values are used. See Bias

public bool OverrideGlobalBias { get; set; }

Property Value

bool

Remarks

This only applies to splines using TCB

OverrideGlobalContinuity

Whether local StartContinuity and EndContinuity should be used. Otherwise the global values are used. See Continuity

public bool OverrideGlobalContinuity { get; set; }

Property Value

bool

Remarks

This only applies to splines using TCB

OverrideGlobalTension

Whether local StartTension and EndTension should be used. Otherwise the global values are used. See Tension

public bool OverrideGlobalTension { get; set; }

Property Value

bool

Remarks

This only applies to splines using TCB

PositionsApproximation

List of points approximating the segments's shape. Approximations are a set of precomputed properties of points sampled along the spline. Approximations are computed and stored for fast access to an approximation of the spline. The fidelity of the approximation depends on the spline's CacheDensity and MaxPointsPerUnit properties. Approximations are computed when the spline is refreshed. Spline refreshing is done automatically when needed (see UpdateIn), but you can also force it by calling Refresh().

public SubArray<Vector3> PositionsApproximation { get; }

Property Value

SubArray<Vector3>
See Also

SerializedOrientationAnchor

The serialized value of OrientationAnchor. This value is ignored in some cases (invisible control points, first and last visible control points). Use IsControlPointAnOrientationAnchor(CurvySplineSegment) to get the correct value.

public bool SerializedOrientationAnchor { get; set; }

Property Value

bool

Spline

Gets the parent spline

[CanBeNull]
public CurvySpline Spline { get; }

Property Value

CurvySpline

StartBias

Local Bias at segment start. Is used only if OverrideGlobalBias is true

public float StartBias { get; set; }

Property Value

float

Remarks

This only applies to splines using TCB

StartContinuity

Local Continuity at segment start. Is used only if OverrideGlobalContinuity is true

public float StartContinuity { get; set; }

Property Value

float

Remarks

This only applies to splines using TCB

StartTension

Local Tension at segment start. Is used only if OverrideGlobalTension is true

public float StartTension { get; set; }

Property Value

float

Remarks

This only applies to splines using TCB

Swirl

Swirling Mode

public CurvyOrientationSwirl Swirl { get; set; }

Property Value

CurvyOrientationSwirl

SwirlTurns

Turns to swirl

public float SwirlTurns { get; set; }

Property Value

float

SynchronizeTCB

Keep Start/End-TCB synchronized

public bool SynchronizeTCB { get; set; }

Property Value

bool

Remarks

Applies only to TCB Interpolation

TF

Gets the TF of this Control Point TF stands for Total Fragment. It's a value ranging from 0 to 1 inclusive. 0 means the spline's start and 1 means the spline's end. This is the "time" parameter used in the splines' formulas. A point's TF is not proportional to its distance from the spline's start. Depending on the spline, a value of 0.5 does not always mean the middle, distance wise, of the spline

public float TF { get; }

Property Value

float

Remarks

This yields the same result as LocalFToTF(0)

TangentsApproximation

List of tangents approximating the segments's shape Approximations are a set of precomputed properties of points sampled along the spline. Approximations are computed and stored for fast access to an approximation of the spline. The fidelity of the approximation depends on the spline's CacheDensity and MaxPointsPerUnit properties. Approximations are computed when the spline is refreshed. Spline refreshing is done automatically when needed (see UpdateIn), but you can also force it by calling Refresh().

public SubArray<Vector3> TangentsApproximation { get; }

Property Value

SubArray<Vector3>
See Also

UpsApproximation

List of directions approximating the segments's orientation Approximations are a set of precomputed properties of points sampled along the spline. Approximations are computed and stored for fast access to an approximation of the spline. The fidelity of the approximation depends on the spline's CacheDensity and MaxPointsPerUnit properties. Approximations are computed when the spline is refreshed. Spline refreshing is done automatically when needed (see UpdateIn), but you can also force it by calling Refresh().

public SubArray<Vector3> UpsApproximation { get; }

Property Value

SubArray<Vector3>
See Also

Methods

BSpline(ReadOnlyCollection<CurvySplineSegment>, float, bool, bool, int, Vector3[])

Gets the position of a point on the B-Spline

public static Vector3 BSpline(ReadOnlyCollection<CurvySplineSegment> controlPoints, float tf, bool isClamped, bool isClosed, int degree, Vector3[] p0Array)

Parameters

controlPoints ReadOnlyCollection<CurvySplineSegment>

The spline's control points.

tf float

A value between 0 and 1 defining where the point is on the spline

isClamped bool

IsBSplineClamped

isClosed bool

Closed

degree int

BSplineDegree

p0Array Vector3[]

An array used in internal computations. This is to avoid excessive allocations.The length of the array should be greater or equal to degree + 1. The content of the array does not matter, since it gets overwritten by the method

Returns

Vector3

BakeOrientationToTransform()

Modify the control point's local rotation to match the segment's orientation

public void BakeOrientationToTransform()

CanFollowUpHeadToEnd(CurvySplineSegment)

Returns true if followUp can be associated with a heading direction of Plus

public static bool CanFollowUpHeadToEnd(CurvySplineSegment followUp)

Parameters

followUp CurvySplineSegment

Returns

bool

CanFollowUpHeadToStart(CurvySplineSegment)

Returns true if followUp can be associated with a heading direction of Minus

public static bool CanFollowUpHeadToStart(CurvySplineSegment followUp)

Parameters

followUp CurvySplineSegment

Returns

bool

DeleteMetadata()

Removes all Metadata components of this Control Point

public void DeleteMetadata()

Disconnect()

Resets the connections related data (Connection, FollowUp, etc) while updating the Connection object and dirtying relevant splines.

public void Disconnect()

Disconnect(bool)

Resets the connections related data (Connection, FollowUp, etc) while updating the Connection object and dirtying relevant splines.

public void Disconnect(bool destroyEmptyConnection)

Parameters

destroyEmptyConnection bool

whether the related Connection should be destroyed if it becomes empty due to this Disconnect call

DistanceToLocalF(float)

Gets the local F of a point given its local distance Local F stands for Local Fragment. It's a value ranging from 0 to 1 inclusive. 0 means the segment's start and 1 means the segment's end. This is the "time" parameter used in the splines' formulas. A point's localF is not proportional to its distance from the segment's start. Depending on the spline, a value of 0.5 does not always mean the middle, distance wise, of the segment

public float DistanceToLocalF(float localDistance)

Parameters

localDistance float

The distance between the segment's start and the point you are interested in. Value should be in the range from 0 to Length inclusive

Returns

float

GetInterpolatedMetadata<T, U>(float)

Gets an interpolated Metadata value for a certain F

public U GetInterpolatedMetadata<T, U>(float f) where T : CurvyInterpolatableMetadataBase<U>

Parameters

f float

a local F in the range 0..1

Returns

U

The interpolated value. If no Metadata of specified type is present at the given tf, the default value of type U is returned

Type Parameters

T

Metadata type inheriting from CurvyInterpolatableMetadataBase

U

Metadata's Value type

GetMetadata<T>(bool)

Gets Metadata of this ControlPoint

public T GetMetadata<T>(bool autoCreate = false) where T : CurvyMetadataBase

Parameters

autoCreate bool

whether to create the Metadata component if it's not present

Returns

T

the Metadata component or null

Type Parameters

T

Metadata type

GetNearestPointF(Vector3, Space)

Gets the localF of the point on the segment that is the nearest to a given position localF stands for Local Fragment. It's a value ranging from 0 to 1 inclusive. 0 means the segment's start and 1 means the segment's end. This is the "time" parameter used in the splines' formulas. A point's localF is not proportional to its distance from the segment's start. Depending on the spline, a value of 0.5 does not always mean the middle, distance wise, of the segment

public float GetNearestPointF(Vector3 position, Space space = Space.Self)

Parameters

position Vector3

The point's position

space Space

The space (spline's local space or the world space) in which position is expressed

Returns

float

Remarks

This method's precision and speed depend on the CacheDensity

GetOrientationFast(float, bool, Space)

Gets the rotation of a point on the spline segment. The rotation's forward is the segment's tangent, and it's up is the segment's orientation Instead of computing the exact value, this method uses a linear interpolation between cached points for faster result

public Quaternion GetOrientationFast(float localF, bool inverse = false, Space space = Space.Self)

Parameters

localF float

localF stands for Local Fragment. It's a value ranging from 0 to 1 inclusive. 0 means the segment's start and 1 means the segment's end. This is the "time" parameter used in the splines' formulas. A point's localF is not proportional to its distance from the segment's start. Depending on the spline, a value of 0.5 does not always mean the middle, distance wise, of the segment

inverse bool

whether the orientation should look at the opposite direction of the tangent

space Space

The space (spline's local space or the world space) in which the returned result is expressed

Returns

Quaternion

GetOrientationUpFast(float, Space)

Gets the Up vector of a point on the spline segment. Instead of computing the exact value, this method uses a linear interpolation between cached points for faster result

public Vector3 GetOrientationUpFast(float localF, Space space = Space.Self)

Parameters

localF float

localF stands for Local Fragment. It's a value ranging from 0 to 1 inclusive. 0 means the segment's start and 1 means the segment's end. This is the "time" parameter used in the splines' formulas. A point's localF is not proportional to its distance from the segment's start. Depending on the spline, a value of 0.5 does not always mean the middle, distance wise, of the segment

space Space

The space (spline's local space or the world space) in which the returned result is expressed

Returns

Vector3

GetTangent(float, Space)

Gets the normalized tangent at a point on the spline segment

public Vector3 GetTangent(float localF, Space space = Space.Self)

Parameters

localF float

localF stands for Local Fragment. It's a value ranging from 0 to 1 inclusive. 0 means the segment's start and 1 means the segment's end. This is the "time" parameter used in the splines' formulas. A point's localF is not proportional to its distance from the segment's start. Depending on the spline, a value of 0.5 does not always mean the middle, distance wise, of the segment

space Space

The space (spline's local space or the world space) in which the returned result is expressed

Returns

Vector3

GetTangentFast(float, Space)

Gets the normalized tangent at a point on the spline segment. Instead of computing the exact value, this method uses a linear interpolation between cached points for faster result

public Vector3 GetTangentFast(float localF, Space space = Space.Self)

Parameters

localF float

localF stands for Local Fragment. It's a value ranging from 0 to 1 inclusive. 0 means the segment's start and 1 means the segment's end. This is the "time" parameter used in the splines' formulas. A point's localF is not proportional to its distance from the segment's start. Depending on the spline, a value of 0.5 does not always mean the middle, distance wise, of the segment

space Space

The space (spline's local space or the world space) in which the returned result is expressed

Returns

Vector3

Interpolate(float, Space)

Gets the position of a point on the spline segment

public Vector3 Interpolate(float localF, Space space = Space.Self)

Parameters

localF float

localF stands for Local Fragment. It's a value ranging from 0 to 1 inclusive. 0 means the segment's start and 1 means the segment's end. This is the "time" parameter used in the splines' formulas. A point's localF is not proportional to its distance from the segment's start. Depending on the spline, a value of 0.5 does not always mean the middle, distance wise, of the segment

space Space

The space (spline's local space or the world space) in which the returned result is expressed

Returns

Vector3

InterpolateAndGetTangentFast(float, out Vector3, out Vector3, Space)

Gets the position and normalized tangent at a point on the spline segment Is Faster than calling Interpolate(float, Space) and Interpolate(float, Space) separately Instead of computing the exact value, this method uses a linear interpolation between cached points for faster result

public void InterpolateAndGetTangentFast(float localF, out Vector3 position, out Vector3 tangent, Space space = Space.Self)

Parameters

localF float

localF stands for Local Fragment. It's a value ranging from 0 to 1 inclusive. 0 means the segment's start and 1 means the segment's end. This is the "time" parameter used in the splines' formulas. A point's localF is not proportional to its distance from the segment's start. Depending on the spline, a value of 0.5 does not always mean the middle, distance wise, of the segment

position Vector3

the output position

tangent Vector3

the output tangent

space Space

The space (spline's local space or the world space) in which the returned result is expressed

InterpolateFast(float, Space)

Gets the position of a point on the spline segment. Instead of computing the exact value, this method uses a linear interpolation between cached points for faster result

public Vector3 InterpolateFast(float localF, Space space = Space.Self)

Parameters

localF float

localF stands for Local Fragment. It's a value ranging from 0 to 1 inclusive. 0 means the segment's start and 1 means the segment's end. This is the "time" parameter used in the splines' formulas. A point's localF is not proportional to its distance from the segment's start. Depending on the spline, a value of 0.5 does not always mean the middle, distance wise, of the segment

space Space

The space (spline's local space or the world space) in which the returned result is expressed

Returns

Vector3

LinkToSpline(CurvySpline)

public void LinkToSpline(CurvySpline spline)

Parameters

spline CurvySpline

LocalFToDistance(float)

Gets the local distance of a point at a certain localF. Local distance is the distance between a point and the start of its segment. Value ranges from 0 to the segment's Length, inclusive

public float LocalFToDistance(float localF)

Parameters

localF float

localF stands for Local Fragment. It's a value ranging from 0 to 1 inclusive. 0 means the segment's start and 1 means the segment's end. This is the "time" parameter used in the splines' formulas. A point's localF is not proportional to its distance from the segment's start. Depending on the spline, a value of 0.5 does not always mean the middle, distance wise, of the segment

Returns

float

LocalFToTF(float)

Gets TF for a certain local F TF stands for Total Fragment. It's a value ranging from 0 to 1 inclusive. 0 means the spline's start and 1 means the spline's end. This is the "time" parameter used in the splines' formulas. A point's TF is not proportional to its distance from the spline's start. Depending on the spline, a value of 0.5 does not always mean the middle, distance wise, of the spline

public float LocalFToTF(float localF)

Parameters

localF float

localF stands for Local Fragment. It's a value ranging from 0 to 1 inclusive. 0 means the segment's start and 1 means the segment's end. This is the "time" parameter used in the splines' formulas. A point's localF is not proportional to its distance from the segment's start. Depending on the spline, a value of 0.5 does not always mean the middle, distance wise, of the segment

Returns

float

a TF value

OnAfterPop()

Is called after the object is popped from its associated pool

public void OnAfterPop()

OnBeforePush()

Is called before the object is pushed into its associated pool

public void OnBeforePush()

RegisterMetaData(CurvyMetadataBase)

Adds a MetaData instance to Metadata

public void RegisterMetaData(CurvyMetadataBase metaData)

Parameters

metaData CurvyMetadataBase

ResetConnectionUnrelatedProperties()

Resets the properties of this control point , except the ones related to connections. Use Disconnect() to reset connections related properties.

public void ResetConnectionUnrelatedProperties()

SetBezierHandleIn(Vector3, Space, CurvyBezierModeEnum)

Sets Bezier HandleIn

public void SetBezierHandleIn(Vector3 position, Space space = Space.Self, CurvyBezierModeEnum mode = CurvyBezierModeEnum.None)

Parameters

position Vector3

HandleIn position

space Space

The space (spline's local space or the world space) in which the position is expressed

mode CurvyBezierModeEnum

Handle synchronization mode

SetBezierHandleOut(Vector3, Space, CurvyBezierModeEnum)

Sets Bezier HandleOut

public void SetBezierHandleOut(Vector3 position, Space space = Space.Self, CurvyBezierModeEnum mode = CurvyBezierModeEnum.None)

Parameters

position Vector3

HandleOut position

space Space

The space (spline's local space or the world space) in which the position is expressed

mode CurvyBezierModeEnum

Handle synchronization mode

SetBezierHandles(float, bool, bool, bool)

Automatically place Bezier handles relative to neighbour Control Points

public void SetBezierHandles(float distanceFrag = -1, bool setIn = true, bool setOut = true, bool noDirtying = false)

Parameters

distanceFrag float

how much % distance between neighbouring CPs are applied to the handle length?

setIn bool

Set HandleIn?

setOut bool

Set HandleOut?

noDirtying bool

If true, the Bezier handles will be modified without dirtying any spline

SetBezierHandles(float, Vector3, Vector3, bool, bool, bool)

Automatically place Bezier handles

public void SetBezierHandles(float distanceFrag, Vector3 p, Vector3 n, bool setIn = true, bool setOut = true, bool noDirtying = false)

Parameters

distanceFrag float

how much % distance between neighbouring CPs are applied to the handle length?

p Vector3

Position the In-Handle relates to

n Vector3

Position the Out-Handle relates to

setIn bool

Set HandleIn?

setOut bool

Set HandleOut?

noDirtying bool

If true, the Bezier handles will be modified without dirtying any spline

SetFollowUp(CurvySplineSegment, ConnectionHeadingEnum)

Sets Follow-Up of this Control Point

public void SetFollowUp(CurvySplineSegment target, ConnectionHeadingEnum heading = ConnectionHeadingEnum.Auto)

Parameters

target CurvySplineSegment

the Control Point to follow to

heading ConnectionHeadingEnum

the Heading on the target's spline

SetLocalPosition(Vector3)

Sets the local position while dirtying the spline, dirtying the connected splines, and updating the connected control points' positions accordingly.

public void SetLocalPosition(Vector3 newPosition)

Parameters

newPosition Vector3

SetLocalRotation(Quaternion)

Sets the local rotation while dirtying the spline, dirtying the connected splines, and updating the connected control points' rotations accordingly.

public void SetLocalRotation(Quaternion value)

Parameters

value Quaternion

SetPosition(Vector3)

Sets the global position while dirtying the spline, dirtying the connected splines, and updating the connected control points' positions accordingly.

public void SetPosition(Vector3 value)

Parameters

value Vector3

SetRotation(Quaternion)

Sets the global rotation while dirtying the spline, dirtying the connected splines, and updating the connected control points' rotations accordingly.

public void SetRotation(Quaternion value)

Parameters

value Quaternion

ToString()

Returns the name of the object.

public override string ToString()

Returns

string

The name returned by ToString.

UnlinkFromSpline(CurvySpline)

public void UnlinkFromSpline(CurvySpline spline)

Parameters

spline CurvySpline

UnregisterMetaData(CurvyMetadataBase)

Removes a MetaData instance from Metadata

public void UnregisterMetaData(CurvyMetadataBase metaData)

Parameters

metaData CurvyMetadataBase

getApproximationIndexINTERNAL(float, out float)

Internal, gets the index of mApproximation by F and the remaining fragment

public int getApproximationIndexINTERNAL(float localF, out float frag)

Parameters

localF float
frag float

Returns

int