From 3c7ea88c373f9d0b2ced0043239ef81fbe0401ed Mon Sep 17 00:00:00 2001 From: Eric Wasylishen Date: Sat, 22 Jul 2017 18:20:03 -0600 Subject: [PATCH] qbsp: add CopyBrush --- qbsp/brush.cc | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/qbsp/brush.cc b/qbsp/brush.cc index 95e2c67b..46ff4beb 100644 --- a/qbsp/brush.cc +++ b/qbsp/brush.cc @@ -1310,3 +1310,41 @@ int BrushMostlyOnSide (const brush_t *brush, const plane_t *plane) return side; } + +/* +================== +CopyBrush + +from q3map + +Duplicates the brush, the sides, and the windings +================== +*/ +brush_t *CopyBrush (const brush_t *brush) +{ + brush_t *newbrush = (brush_t *)AllocMem(BRUSH, 1, true); + + memcpy(newbrush, brush, sizeof(brush_t)); + + newbrush->next = nullptr; + newbrush->faces = nullptr; + + for (const face_t *face = brush->faces; face; face = face->next) { + + face_t *newface = (face_t *)AllocMem(FACE, 1, true); + + memcpy(newface, face, sizeof(face_t)); + + // clear stuff that shouldn't be copied. + newface->original = nullptr; + newface->outputnumber = -1; + newface->edges = nullptr; + + // link into newbrush + newface->next = newbrush->faces; + newbrush->faces = newface; + } + + return newbrush; +} +