// AJM: MVD // ===================================================================================== // ClipWindingsToBounds // clips all the windings with all the planes (including original face) and outputs // what's left int "out" // ===================================================================================== static void ClipWindingsToBounds(winding_t *windings, int numwindings, plane_t *bounds, int numbounds, plane_t &original_plane, winding_t **out, int &num_out) { hlassert(windings); hlassert(bounds); winding_t out_windings[MAX_PORTALS_ON_LEAF]; num_out = 0; int h, i; *out = NULL; Winding wind; for(h = 0; h < numwindings; h++) { // For each winding... // Create a winding with CWinding wind.initFromPoints(windings[h].points, windings[h].numpoints); // Clip winding to original plane wind.Chop(original_plane.normal, original_plane.dist); for(i = 0; i < numbounds, wind.Valid(); i++) { // For each bound... // Chop the winding to the bounds wind.Chop(bounds[i].normal, bounds[i].dist); } if(wind.Valid()) { // We have a valid winding, copy to array wind.CopyPoints(&out_windings[num_out].points[0], out_windings[num_out].numpoints); num_out++; } } if(!num_out) // Everything was clipped away return; // Otherwise, create out *out = new winding_t[num_out]; memcpy(*out, out_windings, num_out * sizeof(winding_t)); }