2 ===========================================================================
3 Copyright (C) 1997-2006 Id Software, Inc.
5 This file is part of Quake 2 Tools source code.
7 Quake 2 Tools source code is free software; you can redistribute it
8 and/or modify it under the terms of the GNU General Public License as
9 published by the Free Software Foundation; either version 2 of the License,
10 or (at your option) any later version.
12 Quake 2 Tools source code is distributed in the hope that it will be
13 useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with Quake 2 Tools source code; if not, write to the Free Software
19 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
20 ===========================================================================
29 The incoming brush is NOT freed.
30 The incoming face is NOT left referenced.
33 void CSG_SplitBrushByFace (brush_t *in, face_t *f, brush_t **front, brush_t **back)
42 nf->texdef = b->brush_faces->texdef;
43 nf->next = b->brush_faces;
47 Brush_RemoveEmptyFaces ( b );
48 if ( !b->brush_faces )
49 { // completely clipped away
55 Entity_LinkBrush (in->owner, b);
61 // swap the plane winding
62 VectorCopy (nf->planepts[0], temp);
63 VectorCopy (nf->planepts[1], nf->planepts[0]);
64 VectorCopy (temp, nf->planepts[1]);
66 nf->texdef = b->brush_faces->texdef;
67 nf->next = b->brush_faces;
71 Brush_RemoveEmptyFaces ( b );
72 if ( !b->brush_faces )
73 { // completely clipped away
79 Entity_LinkBrush (in->owner, b);
89 void CSG_MakeHollow (void)
91 brush_t *b, *front, *back, *next;
97 for (b = selected_brushes.next ; b != &selected_brushes ; b=next)
100 for (f = b->brush_faces ; f ; f=f->next)
103 VectorScale (f->plane.normal, g_qeglobals.d_gridsize, move);
104 for (i=0 ; i<3 ; i++)
105 VectorSubtract (split.planepts[i], move, split.planepts[i]);
107 CSG_SplitBrushByFace (b, &split, &front, &back);
111 Brush_AddToList (front, &selected_brushes);
115 Sys_UpdateWindows (W_ALL);
124 void CSG_Subtract (void)
126 brush_t *b, *s, *frag, *front, *back, *next, *snext;
130 Sys_Printf ("Subtracting...\n");
132 for (b = selected_brushes.next ; b != &selected_brushes ; b=next)
136 if (b->owner->eclass->fixedsize)
137 continue; // can't use texture from a fixed entity, so don't subtract
139 for (s=active_brushes.next ; s != &active_brushes ; s=snext)
142 if (s->owner->eclass->fixedsize)
145 for (i=0 ; i<3 ; i++)
146 if (b->mins[i] >= s->maxs[i] - ON_EPSILON
147 || b->maxs[i] <= s->mins[i] + ON_EPSILON)
150 continue; // definately don't touch
153 for (f = b->brush_faces ; f && frag ; f=f->next)
155 CSG_SplitBrushByFace (frag, f, &front, &back);
159 Brush_AddToList (front, &active_brushes);
166 Sys_Printf ("done.\n");
167 Sys_UpdateWindows (W_ALL);