[PATCH] qbsp: Avoid some unnecessary face splits

Save some memory in CSGFaces by not splitting faces outside the brush being
processed. Normally these faces will be split by the planes of the brush, even
if the brush doesn't intersect with it at all. This also saves some time in
MergeFaces, since we don't need to re-assemble these faces again.

Signed-off-by: Tyrann <tyrann@disenchant.net>
This commit is contained in:
Tyrann 2006-10-02 20:14:01 +09:30
parent 118916b825
commit b05f86296d
1 changed files with 48 additions and 0 deletions

View File

@ -153,6 +153,53 @@ SplitFace(face_t *in, plane_t *split, face_t **front, face_t **back)
FreeMem(in, FACE, 1);
}
/*
=================
CheckInside
Quick test before running ClipInside; move any faces that are completely
outside the brush to the outside list, without splitting them. This saves us
time in mergefaces later on (and sometimes a lot of memory)
=================
*/
static void
CheckInside(brush_t *b)
{
face_t *f, *bf, *next;
face_t *insidelist;
plane_t *plane, clip;
winding_t *w;
insidelist = NULL;
f = inside;
while (f) {
next = f->next;
plane = &pPlanes[f->planenum];
w = CopyWinding(&f->w);
for (bf = b->faces; bf; bf = bf->next) {
clip = pPlanes[bf->planenum];
if (!bf->planeside) {
VectorSubtract(vec3_origin, clip.normal, clip.normal);
clip.dist = -clip.dist;
}
w = ClipWinding(w, &clip, true);
if (!w)
break;
}
if (!w) {
/* The face is completely outside this brush */
f->next = outside;
outside = f;
} else {
f->next = insidelist;
insidelist = f;
FreeMem(w, WINDING, 1);
}
f = next;
}
inside = insidelist;
}
/*
=================
ClipInside
@ -385,6 +432,7 @@ CSGFaces(void)
inside = outside;
outside = NULL;
CheckInside(b2);
for (f = b2->faces; f; f = f->next)
ClipInside(f->planenum, f->planeside, overwrite);