// Remove all polygons in this BSP tree that are inside the other BSP tree // `bsp`. void clipTo(csgjs_csgnode other) { polygons = other.clipPolygons(polygons); if (front != null) { front.clipTo(other); } if (back != null) { back.clipTo(other); } }
// Recursively remove all polygons in `polygons` that are inside this BSP // tree. List <csgjs_polygon> clipPolygons(List <csgjs_polygon> list) { if (!plane.ok()) { return(list); } List <csgjs_polygon> list_front = new List <csgjs_polygon>(); List <csgjs_polygon> list_back = new List <csgjs_polygon>(); for (int i = 0; i < list.Count; i++) { plane.splitPolygon(list[i], list_front, list_back, ref list_front, ref list_back); } if (front != null) { list_front = front.clipPolygons(list_front); } if (back != null) { list_back = back.clipPolygons(list_back); } else { //list_back.clear(); list_back.RemoveAll(delegate(csgjs_polygon v) { return(true); }); //list_back = new List<csgjs_polygon>(); // clear the list by creating a new one } //need to make sure to get this insert right... // if I'm reading this correctly, it's placing all the items in list_back // onto the end of list_front //list_front.insert(list_front.end(), list_back.begin(), list_back.end()); foreach (csgjs_polygon pb in list_back) { list_front.Add(pb.clone()); } // list_front.Insert( return(list_front); }