예제 #1
0
        public void Invalidate()
        {
            if (shape == null || Points == null || Points.Length < 2)
            {
                return;
            }
            CatmullRomSpline spline = new CatmullRomSpline(Points);
            var step     = 1.0f / 1000.0f;
            var previous = new Vector3(Single.PositiveInfinity, Single.PositiveInfinity, Single.PositiveInfinity);

            for (int i = 0; i <= 1000; i++)
            {
                var position = spline.Evaluate(i * step);
                var d        = Vector3.Distance(position, previous);
                if (d > Step)
                {
                    pointList.Add(position);
                    previous = position;
                }
            }

            if (pointList.Count < 1)
            {
                return;
            }
            shape.SetPoints(pointList.ToArray());
            pointList.Clear();
        }