Example #1
0
        private void HandleTrigIntersection(List <Vector2> intersectList, Triangle triangle, VerticesSegmentor verticesSegmentor, Vector2 selfPos, Vector2 p_pointA, Vector2 p_pointB)
        {
            int pairNum = triangle.pairs.Count;

            for (int i = pairNum - 1; i >= 0; i--)
            {
                TrigPairs pair = triangle.pairs[i];

                Vector2 point = AddIntersectPoint(
                    pair.nodeA + selfPos,
                    pair.nodeB + selfPos,
                    p_pointA, p_pointB
                    );

                //Intersection has occur
                if (!point.Equals(Vector2.positiveInfinity))
                {
                    Triangle.Fragment fragmentA = FindVerticesSegment(verticesSegmentor, pair.nodeA, pair.nodeA + selfPos);
                    Triangle.Fragment fragmentB = FindVerticesSegment(verticesSegmentor, pair.nodeB, pair.nodeB + selfPos);
                    Triangle.Fragment fragmentC = new Triangle.Fragment(point - selfPos, "", Triangle.Fragment.Type.Cutted);

                    triangle.AddFragment(new Triangle.Fragment[] { fragmentA, fragmentB, fragmentC });
                    intersectList.Add(point);
                }
            }
        }