Exemplo n.º 1
0
        private void IntersectTriangleEdge(Vector3 pointA, Vector3 pointB, List <Egress> egresses, Triangle boundsTriangle, bool debug = false)
        {
            Vertex intersectionPoint;

            intersectionPoint = EdgeIntersectsTriangle(pointA, pointB, boundsTriangle);

            if (intersectionPoint != null)
            {
                bool alreadyExists = false;
                foreach (Egress egress in egresses)
                {
                    if (Vector3.Distance(intersectionPoint.value, egress.value) < error)
                    {
                        egress.triangles.Add(boundsTriangle);
                        alreadyExists = true;
                        break;
                    }
                }
                if (!alreadyExists)
                {
                    intersectionPoint.triangles.Add(boundsTriangle);
                    egresses.Add(Egress.CreateFromVertex(intersectionPoint));
                }

                if (debug)
                {
                    Debug.DrawRay(transform.localToWorldMatrix.MultiplyPoint3x4(intersectionPoint.value), Vector3.back * 0.1f, Color.red, Time.deltaTime);
                }
            }
        }
Exemplo n.º 2
0
        public static Egress CreateFromVertex(Vertex vertex)
        {
            Egress egress = new Egress(vertex.index, vertex.value, vertex.containedByBound);

            egress.usedInLoop = vertex.usedInLoop;
            egress.loops      = vertex.loops;
            egress.triangles  = vertex.triangles;

            return(egress);
        }