//=========================================================================== // Returns a list of brushes that remain after B is subtracted from A. // May by empty if A is contained inside B. // The originals are undisturbed. // // Parameter: - // Returns: - // Changes Globals: - //=========================================================================== bspbrush_t *SubtractBrush (bspbrush_t *a, bspbrush_t *b) { // a - b = out (list) int i; bspbrush_t *front, *back; bspbrush_t *out, *in; in = a; out = NULL; for (i = 0; i < b->numsides && in; i++) { SplitBrush2(in, b->sides[i].planenum, &front, &back); if (in != a) FreeBrush(in); if (front) { // add to list front->next = out; out = front; } //end if in = back; } //end for if (in) { FreeBrush (in); } //end if else { // didn't really intersect FreeBrushList (out); return a; } //end else return out; } //end of the function SubtractBrush
//=========================================================================== // Returns a single brush made up by the intersection of the // two provided brushes, or NULL if they are disjoint. // // The originals are undisturbed. // // Parameter: - // Returns: - // Changes Globals: - //=========================================================================== bspbrush_t *IntersectBrush( bspbrush_t *a, bspbrush_t *b ) { int i; bspbrush_t *front, *back; bspbrush_t *in; in = a; for ( i = 0 ; i < b->numsides && in ; i++ ) { SplitBrush2( in, b->sides[i].planenum, &front, &back ); if ( in != a ) { FreeBrush( in ); } if ( front ) { FreeBrush( front ); } in = back; } //end for if ( in == a ) { return NULL; } in->next = NULL; return in; } //end of the function IntersectBrush