public Vector2 GetEdgeWindowPosition(int edgeIndex) { int nextIndex = SplineUtility.NextIndex(edgeIndex, m_Points.Count); Vector2 start = m_Points[edgeIndex].m_Position; Vector2 startTangent = (Vector2)m_Points[edgeIndex].m_RightTangent + start; Vector2 end = m_Points[nextIndex].m_Position; Vector2 endTangent = (Vector2)m_Points[nextIndex].m_LeftTangent + end; return(BezierUtility.BezierPoint(start, startTangent, endTangent, end, 0.5f) + Vector3.up * kWindowHeaderHeight); }
static void SampleCurve(float colliderDetail, Vector3 startPoint, Vector3 startTangent, Vector3 endPoint, Vector3 endTangent, ref List <IntPoint> path) { if (startTangent.sqrMagnitude > 0f || endTangent.sqrMagnitude > 0f) { for (int j = 0; j <= colliderDetail; ++j) { float t = j / (float)colliderDetail; Vector3 newPoint = BezierUtility.BezierPoint(startPoint, startTangent + startPoint, endTangent + endPoint, endPoint, t) * s_ClipperScale; path.Add(new IntPoint((System.Int64)newPoint.x, (System.Int64)newPoint.y)); } } else { Vector3 newPoint = startPoint * s_ClipperScale; path.Add(new IntPoint((System.Int64)newPoint.x, (System.Int64)newPoint.y)); newPoint = endPoint * s_ClipperScale; path.Add(new IntPoint((System.Int64)newPoint.x, (System.Int64)newPoint.y)); } }
public Vector2 GetPointAlongCurve(float progress) { var s = curve.spline; return(curve.transform.TransformPoint(BezierUtility.BezierPoint(s.GetPosition(0), s.GetPosition(0) + s.GetRightTangent(0), s.GetPosition(1) + s.GetLeftTangent(1), s.GetPosition(1), progress))); }