Beispiel #1
0
 protected virtual void EnsureMaskClean()
 {
     if (_distanceMask == null || _distanceMask.Count <= 0)
     {
         _distanceMask = new PathDistanceMask(SmoothPoints, _mapToSmooth, _closed);
     }
 }
Beispiel #2
0
        public List <Vector2> GetSubPathDistance(float aStart, float aLength)
        {
            PathDistanceMask mask      = DistanceMask;
            float            totalDist = mask.GetTotalDistance();
            float            left      = Mathf.Clamp(aStart, 0, totalDist);
            float            right     = Mathf.Clamp(aStart + aLength, 0, totalDist);

            List <Vector2> source = GetFinalPath();
            float          p1     = 0;
            int            index1 = mask.GetRawPointIndexAtDistance(left, out p1, _closed);
            float          p2     = 0;
            int            index2 = mask.GetRawPointIndexAtDistance(right, out p2, _closed);

            List <Vector2> result = new List <Vector2>((index2 - index1) + 2);

            if (p1 != 0)
            {
                result.Add(PathUtil.GetBezierPoint(index1, p1, _points, PointControls, Closed));
            }

            if (index2 - index1 > 0)
            {
                result.AddRange(source.GetRange(index1 + 1, (index2 - (index1 + 1))));
            }
            if (p2 != 0)
            {
                result.Add(PathUtil.GetBezierPoint(index2, p2, _points, PointControls, Closed));
            }

            return(result);
        }