hyades.ShapeBuilder.IntersectPlane C# (CSharp) Method

IntersectPlane() public static method

public static IntersectPlane ( Plane p, List vertices, List indices, List &points, List &lines ) : void
p Plane
vertices List
indices List
points List
lines List
return void
        public static void IntersectPlane(Plane p, List<Vector3> vertices, List<Triangle> indices, out List<Vector3> points, out List<Line> lines)
        {
            lines = new List<Line>();
            points = new List<Vector3>();

            foreach (Triangle triangle in indices)
            {
                bool intersects = false;
                Vector3 a, b, q;

                a = vertices[triangle.a];
                b = vertices[triangle.b];
                if (IntersectSegmentPlane(a, b, p, out q))
                { points.Add(q); intersects = true; }

                a = vertices[triangle.b];
                b = vertices[triangle.c];
                if (IntersectSegmentPlane(a, b, p, out q))
                { points.Add(q); intersects = true; }

                a = vertices[triangle.c];
                b = vertices[triangle.a];
                if (IntersectSegmentPlane(a, b, p, out q))
                { points.Add(q); intersects = true; }

                if (intersects)
                {
                    Line line = new Line();
                    line.a = points.Count - 2;
                    line.b = points.Count - 1;
                    lines.Add(line);
                }
            }
        }