// Recursively remove all polygons in `polygons` that are inside this BSP // tree. public List <CSGPolygon> clipPolygons(List <CSGPolygon> polygons) { if (!validPlane) { return(new List <CSGPolygon>(polygons)); } List <CSGPolygon> front = new List <CSGPolygon>(); List <CSGPolygon> back = new List <CSGPolygon>(); for (int i = 0; i < polygons.Count; i++) { plane.splitPolygon(polygons[i], front, back, front, back); } if (this.front != null) { front = this.front.clipPolygons(front); } if (this.back != null) { back = this.back.clipPolygons(back); } else { back = new List <CSGPolygon>(); } front.AddRange(back); return(front); }