Beispiel #1
0
        private PointInfo FindCrossPointOnWholePath(Vector3 vx, Vector3 vx1, Vector3 vx2, List <int> excludesIndex = null)
        {
            PointInfo info = null;

            for (int i = 0; i < movePoints.Length - 1; i++)
            {
                if (null != excludesIndex && excludesIndex.Contains(i))
                {
                    continue;
                }
                Vector3 p1     = movePoints[i];
                Vector3 p2     = movePoints [i + 1];
                Vector3 pInter = Vector3.zero;
                bool    cross  = Vector2DUtils.LineLineIntersection(out pInter, p1, p2 - p1, vx, vx1 - vx);
                if (!cross)
                {
                    cross = Vector2DUtils.LineLineIntersection(out pInter, p1, p2 - p1, vx, vx2 - vx);
                }
                if (!cross)
                {
                    continue;
                }
                if (0 != Vector2DUtils.PointOnWhichSideOfLineSegment(p1, p2, pInter))
                {
                    continue;
                }
                info            = new PointInfo();
                info.position   = pInter;
                info.startIndex = i;
                break;
            }

            return(info);
        }