public Vector3 GetPoint(float inPercent, Curve inSegmentCurve = Curve.Linear) { if (m_Dirty) { Process(); } return(SplineMath.Quadratic(m_Start, m_Control, m_End, inSegmentCurve.Evaluate(inPercent))); }
public bool Process() { if (!m_Dirty) { return(false); } m_Distance = Vector3.Distance(m_Start, m_End); float preciseDist = 0; float segmentDist = 0; Vector3 prev = m_Start; Vector3 next; if (m_PreciseSegmentCount < 1) { m_PreciseSegmentCount = 1; } Array.Resize(ref m_PreciseSegmentData, Mathf.NextPowerOfTwo(m_PreciseSegmentCount)); for (int i = 0; i < m_PreciseSegmentCount; ++i) { next = SplineMath.Quadratic(m_Start, m_Control, m_End, (float)(i + 1) / m_PreciseSegmentCount); segmentDist = Vector3.Distance(prev, next); m_PreciseSegmentData[i].Marker = preciseDist; m_PreciseSegmentData[i].Length = segmentDist; preciseDist += segmentDist; prev = next; } m_PreciseDistance = preciseDist; float invPreciseDist = 1f / preciseDist; for (int i = 0; i < m_PreciseSegmentCount; ++i) { m_PreciseSegmentData[i].Marker *= invPreciseDist; m_PreciseSegmentData[i].Length *= invPreciseDist; } m_Dirty = false; if (m_OnUpdated != null) { m_OnUpdated(this); } return(true); }