// Moves the actual point in the rageSpline we are editing (called while dragging the mouse) public void updateActiveControlPosition(Vector3 position) { switch (activeControlType) { case ControlType.Point: rageSpline.SetPointWorldSpace(activeControlPointIndex, position); break; case ControlType.InCtrl: rageSpline.SetInControlPositionWorldSpace(activeControlPointIndex, position); break; case ControlType.OutCtrl: rageSpline.SetOutControlPositionWorldSpace(activeControlPointIndex, position); break; } }
public static bool RemoveOverlap(this IRageSpline path, int index0, int index1, float snapRadius, bool debug) { if (index1 == 0) { index0 = path.GetPointCount() - 1; } if (Vector3.Distance(path.GetPositionWorldSpace(index0), path.GetPositionWorldSpace(index1)) <= snapRadius) { if (debug) { Debug.Log("overlap path pos = " + path.GetPositionWorldSpace(index0)); } path.SetNatural(index1, false); path.SetInControlPositionWorldSpace(index1, path.GetInControlPositionWorldSpace(index0)); path.RemovePoint(index0); // Then deletes the duplicate previous point return(true); } return(false); }
/// <summary> Special case for start-end points, where the out tangent must be copied instead of the in tangent </summary> public static bool MergeStartEndPoints(this IRageSpline rageSpline, bool debug) { if (rageSpline.GetPointCount() <= 2) { return(false); } var lastPointIdx = rageSpline.GetPointCount() - 1; var lastPointPos = rageSpline.GetPositionWorldSpace(lastPointIdx); var firstPointPos = rageSpline.GetPositionWorldSpace(0); if (Vector3.Distance(firstPointPos, lastPointPos) < 0.0001f) { if (debug) { Debug.Log("\t Removing endpoint overlap "); } rageSpline.SetInControlPositionWorldSpace(0, rageSpline.GetInControlPositionWorldSpace(lastPointIdx)); rageSpline.RemovePoint(lastPointIdx); // Then deletes the last point return(true); } return(false); }