namespace: CurveArchitect.Utilites
file: HelperArchitectCurve.cs

General

ArchitectCurve Create(GameObject go)

Description:
Creates an ArchitectCurve component on the specified GameObject.

Params:

  • go: The GameObject to add the ArchitectCurve component to.

Returns:
The created ArchitectCurve component.

void CreateId(ArchitectCurve ac)

Description:
Generates and assigns a unique ID to the specified ArchitectCurve.

Params:

  • ac: The ArchitectCurve to assign the ID to.

void CreateIdSegment(Segment s)

Description:
Generates and assigns a unique ID to the specified Segment.

Params:

  • s: The Segment to assign the ID to.

Vector3 GetCenter(List<Segment> segments, bool skipLast, Space space = Space.World)

Description:
Calculates the center position of a list of segments.

Params:

  • segments: The list of segments to calculate the center for.
  • skipLast: Indicates whether to skip the last segment in the calculation.
  • space: The coordinate space (World or Local) to use for the calculation.

Returns:
The calculated center position as a Vector3.

void TransformToCenter(ArchitectCurve ac, out Vector3 dif)

Description:
Moves an ArchitectCurve to its center position, calculated from all control points, and adjusts its segments accordingly.

Params:

  • ac: The ArchitectCurve to be moved.
  • dif: The output difference between the original and new positions.

void Join(ArchitectCurve primary, ArchitectCurve secondary, ArchitectCurveJoinType joinType)

Description:
Joins two ArchitectCurves together based on the specified join type.

Params:

  • primary: The primary ArchitectCurve to which the secondary will be joined.
  • secondary: The secondary ArchitectCurve to join to the primary.
  • joinType: The type of join operation to perform (e.g., END_TO_START, END_TO_END).

void JoinAndDeleteSecondary(ArchitectCurve primary, ArchitectCurve secondary, ArchitectCurveJoinType joinType)

Description:
Joins two ArchitectCurves together based on the specified join type and deletes the secondary curve.

Params:

  • primary: The primary ArchitectCurve to which the secondary will be joined.
  • secondary: The secondary ArchitectCurve to join and delete after joining.
  • joinType: The type of join operation to perform (e.g., END_TO_START, END_TO_END).

void Split(ArchitectCurve ac, ArchitectCurve split, int segmentIndex)

Description:
Splits an ArchitectCurve at the specified segment index and transfers the remaining segments to a new curve.

Params:

  • ac: The original ArchitectCurve to be split.
  • split: The new ArchitectCurve that will receive the segments after the split.
  • segmentIndex: The index of the segment at which to split the original curve.

void UnlinkAll(ArchitectCurve ac)

Description:
Unlinks all linked control points within the specified ArchitectCurve.

Params:

  • ac: The ArchitectCurve whose linked control points will be unlinked.

void Unlink(Segment segment, Action<ArchitectCurve, Segment> beforeUnlinking = null)

Description:
Unlinks the specified segment from all connected segments and optionally invokes an action before unlinking.

Params:

  • segment: The segment to be unlinked.
  • beforeUnlinking: An optional action to invoke before each unlink operation, providing the connected ArchitectCurve and segment.

void LinkAll(ArchitectCurve ac)

Description:
Links all control points within the specified ArchitectCurve that have existing links at their anchor positions.

Params:

  • ac: The ArchitectCurve whose control points will be linked.

void Link(Segment segment, Vector3 linkPoint, Action<ArchitectCurve, Segment> beforeLinking = null)

Description:
Links all control points on all curves at the specified link point.

Params:

  • segment: The segment to be linked.
  • linkPoint: The position at which the control points will be linked.
  • beforeLinking: An optional action to invoke before each linking operation, providing the connected ArchitectCurve and segment.

List<Link> TryFindLinkCrossings(ArchitectCurve ac, Vector3 curvePosition, Vector3 oldCurvePosition, out Segment segment)

Description:
Attempts to find link crossings within an ArchitectCurve based on the provided curve positions.

Params:

  • ac: The ArchitectCurve to search for link crossings.
  • curvePosition: The current position of the curve.
  • oldCurvePosition: The previous position of the curve.
  • segment: The segment where a link crossing is found, if any.

Returns:
A list of links at the crossing segment, or an empty list if none are found.

int SegementIndexToControlPointId(int segementIndex, Segment.Type type)

Description:
Converts a segment index and control point type to a unique control point ID in an ArchitectCurve.

Params:

  • segementIndex: The index of the segment in the curve.
  • type: The type of control point (Anchor, Tangent A, Tangent B).

Returns:
A unique control point ID starting at 1000, calculated using the segment index and type.

int ControlPointIdToSegementIndex(int controlPointId)

Description:
Converts a control point ID back to its corresponding segment index in an ArchitectCurve.

Params:

  • controlPointId: The unique ID of the control point, starting at 1000.

Returns:
The segment index associated with the given control point ID.

Segment.Type GetOppositeTangentType(Segment.Type type)

Description:
Returns the opposite tangent type for a given tangent type in a segment.

Params:

  • type: The current tangent type (Tangent A or Tangent B).

Returns:
The opposite tangent type (Tangent B if input is Tangent A, and vice versa).

Vector3 GetContinuousTangentPosition(Segment.Type type, Segment segement, Vector3 newTangentPos)

Description:
Calculates the position of the opposite tangent to maintain continuous symmetry relative to the anchor point.

Params:

  • type: The type of the tangent being moved (Tangent A or Tangent B).
  • segement: The segment containing the tangents and anchor.
  • newTangentPos: The new position of the tangent being moved.

Returns:
The calculated position of the opposite tangent to maintain continuity.

Vector3 GetMirroredTangentPosition(Segment.Type type, Segment segement, Vector3 newTangentPos)

Description:
Calculates the mirrored position of a tangent relative to the anchor point.

Params:

  • type: The type of the tangent being mirrored (Tangent A or Tangent B).
  • segement: The segment containing the tangents and anchor.
  • newTangentPos: The new position of the tangent being mirrored.

Returns:
The calculated mirrored position of the tangent.

Segment.Type GetControlPointType(int controlPointId)

Description:
Determines the type of control point (Anchor, Tangent A, or Tangent B) based on the control point ID.

Params:

  • controlPointId: The unique ID of the control point.

Returns:
The type of control point (Anchor, Tangent A, Tangent B, or NONE).

void UpdateFollowers(ArchitectCurve ac)

Description:
Updates the positions and rotations of all followers on the specified ArchitectCurve.

Params:

  • ac: The ArchitectCurve whose followers will be updated.

void TryDeformRealtime(ArchitectCurve ac, bool deformLinks = true)

Description:
Attempts to deform the specified ArchitectCurve and its associated objects in real-time, handling both followers and deformations.

Params:

  • ac: The ArchitectCurve to be deformed in real-time.
  • deformLinks: Specifies whether linked control points should also be deformed. Default is true.

void TryDeformRealtimeLinks(ArchitectCurve ac)

Description:
Attempts to deform linked ArchitectCurves in real-time based on the changes in the specified ArchitectCurve.

Params:

  • ac: The ArchitectCurve whose linked curves will be checked and deformed if necessary.

DeformJob CreateDeformJob(ArchitectCurve ac, NativeArray<Vector3> vertices, NativeHashMap<int, float4x4> localSpaces, NativeArray<int> localSpaceMap, NativeArray<bool> mirrorMap, ArchitectCurveObject.Type deformationType)

Description:
Creates a deform job for mesh deformations.

Params:

  • ac: The ArchitectCurve for which the job is created.
  • vertices: The vertices for the deformation.
  • localSpaces: The local space transformations.
  • localSpaceMap: The map of local spaces.
  • mirrorMap: The map indicating mirrored positions.
  • deformationType: The type of deformation.

Returns:
The created deform job instance.

void DisposeDeformJob(DeformJob deformJob)

Description:
Completes and disposes of a deformation job.

Params:

  • deformJob: The deform job to be disposed of.

List<(ArchitectCurve, Segment)> GetSegmentsAtPoint(Dictionary<string, ArchitectCurve> acitveArchitectCurves, Vector3 point, float epsilon = 0.001f)

Description:
Retrieves segments from active ArchitectCurves that are located at a specified point within a given tolerance.

Params:

  • acitveArchitectCurves: A dictionary of active ArchitectCurves to search.
  • point: The point in world space to check for segments.
  • epsilon: The tolerance within which a segment's anchor point is considered to match the specified point. Default is 0.001f.

Returns:
A list of tuples containing the ArchitectCurve and Segment found at the specified point.

void CaluclateControlpointBounds(ArchitectCurve ac, bool calculateControlPointsBounds = true)

Description:
Calculates the bounding box for all control points in the specified ArchitectCurve.

Params:

  • ac: The ArchitectCurve for which to calculate the control point bounds.
  • calculateControlPointsBounds: Indicates whether the bounds should be calculated. Default is true.

void CalculatePositionMap(ArchitectCurve ac, NativeList<Vector3> positionMap, Space space, bool calculatePositionMap = true)

Description:
Computes and caches positions along an ArchitectCurve.

Params:

  • ac: The ArchitectCurve for which to calculate the position map.
  • positionMap: The native list to store position data.
  • space: The coordinate space used for calculations.
  • calculatePositionMap: Indicates whether the position map should be calculated. Default is true.

void CalculateLengthMapAndLength(ArchitectCurve ac, bool calculateLengthMap = true)

Description:
Computes and stores a mapping of time values to their corresponding positions along an ArchitectCurve, ensuring accurate length proportionality.

Params:

  • ac: The ArchitectCurve for which to calculate the length map.
  • calculateLengthMap: Indicates whether the length map should be calculated. Default is true.

void CalculateCachedNormals(ArchitectCurve ac, bool calculateNormals = true)

Description:
Calculates and caches the normals for a dynamic ArchitectCurve, allowing for consistent orientation adjustments during deformations.

Params:

  • ac: The ArchitectCurve for which to calculate normals.
  • calculateNormals: Indicates whether the normals should be calculated. Default is true.

void CalculateSegmentData(ArchitectCurve ac, bool calculateSegmentData = true)

Description:
Calculates and updates the segment data, including z-positions and lengths, for all segments in the specified ArchitectCurve.

Params:

  • ac: The ArchitectCurve for which to calculate segment data.
  • calculateSegmentData: Indicates whether the segment data should be calculated. Default is true.

void CalculateLength(ArchitectCurve ac, bool calculateLength = true)

Description:
Calculates and updates the total length of the specified ArchitectCurve.

Params:

  • ac: The ArchitectCurve for which to calculate the length.
  • calculateLength: Indicates whether the length should be calculated. Default is true.