public void Build(List <CsgPolygon> polygons)
            {
                if (polygons.Count == 0)
                {
                    return;
                }

                if (Plane == null)
                {
                    // Don't randomly choose a split plane. Coherent results are important.
                    Plane = polygons[polygons.Count / 2].Plane.Clone();
                }
                var frontPolygons = new List <CsgPolygon>();
                var backPolygons  = new List <CsgPolygon>();

                for (int i = 0; i < polygons.Count; i++)
                {
                    Plane.SplitPolygon(polygons[i], Polygons, Polygons, frontPolygons, backPolygons);
                }

                if (frontPolygons.Count > 0)
                {
                    if (Front == null)
                    {
                        Front = new CsgNode();
                    }
                    Front.Build(frontPolygons);
                }
                if (backPolygons.Count > 0)
                {
                    if (Back == null)
                    {
                        Back = new CsgNode();
                    }
                    Back.Build(backPolygons);
                }
            }
 public CsgPolygon(List <CsgVertex> vertices, CsgSurfaceSharedData shared = null, CsgPlane plane = null)
 {
     Vertices = vertices;
     Shared   = shared;
     Plane    = plane?.Clone() ?? CsgPlane.FromPoints(vertices);
 }