diff --git a/include/qbsp/brush.hh b/include/qbsp/brush.hh index c3f715e3..26a93d0a 100644 --- a/include/qbsp/brush.hh +++ b/include/qbsp/brush.hh @@ -36,8 +36,6 @@ class mapbrush_t; qplane3d Face_Plane(const face_t *face); -int Brush_NumFaces(const brush_t *brush); - enum class rotation_t { none, @@ -51,4 +49,3 @@ void FreeBrushes(mapentity_t *ent); int FindPlane(const qplane3d &plane, int *side); -void FreeBrush(brush_t *brush); diff --git a/qbsp/brush.cc b/qbsp/brush.cc index 52195739..14473e8b 100644 --- a/qbsp/brush.cc +++ b/qbsp/brush.cc @@ -442,16 +442,6 @@ void FreeBrushes(mapentity_t *ent) ent->brushes.clear(); } -/* -===================== -FreeBrush -===================== -*/ -void FreeBrush(brush_t *brush) -{ - delete brush; -} - /* ============================================================================== @@ -789,11 +779,6 @@ std::optional LoadBrush(const mapentity_t *src, const mapbrush_t *mapbr //============================================================================= -int Brush_NumFaces(const brush_t *brush) -{ - return brush->faces.size(); -} - // temporary brush lists to hold sorting data struct brush_types_t { diff --git a/qbsp/test_qbsp.cc b/qbsp/test_qbsp.cc index 33822e46..b9ef0ddd 100644 --- a/qbsp/test_qbsp.cc +++ b/qbsp/test_qbsp.cc @@ -7,15 +7,6 @@ // FIXME: Clear global data (planes, etc) between each test -static face_t *Brush_FirstFaceWithTextureName(brush_t *brush, const char *texname) -{ - for (face_t *face = brush->faces; face; face = face->next) { - if (map.texinfoTextureName(face->texinfo) == texname) - return face; - } - return nullptr; -} - static const mapface_t *Mapbrush_FirstFaceWithTextureName(const mapbrush_t *brush, const std::string &texname) { for (int i = 0; i < brush->numfaces; i++) { @@ -118,75 +109,12 @@ TEST(qbsp, duplicatePlanes) mapentity_t worldspawn = LoadMap(mapWithDuplicatePlanes); ASSERT_EQ(1, worldspawn.nummapbrushes); - EXPECT_EQ(0, worldspawn.numbrushes); + EXPECT_EQ(0, worldspawn.brushes.size()); EXPECT_EQ(6, worldspawn.mapbrush(0).numfaces); - brush_t *brush = LoadBrush(&worldspawn, &worldspawn.mapbrush(0), {CONTENTS_SOLID}, {}, rotation_t::none, 0); - ASSERT_NE(nullptr, brush); - EXPECT_EQ(6, Brush_NumFaces(brush)); - FreeBrush(brush); -} - -static brush_t *load128x128x32Brush() -{ - /* 128x128x32 rectangular brush */ - const char *map = R"( - { - "classname" "worldspawn" - { - ( -64 -64 -16 ) ( -64 -63 -16 ) ( -64 -64 -15 ) __TB_empty 0 0 0 1 1 - ( 64 64 16 ) ( 64 64 17 ) ( 64 65 16 ) __TB_empty 0 0 0 1 1 - ( -64 -64 -16 ) ( -64 -64 -15 ) ( -63 -64 -16 ) __TB_empty 0 0 0 1 1 - ( 64 64 16 ) ( 65 64 16 ) ( 64 64 17 ) __TB_empty 0 0 0 1 1 - ( 64 64 16 ) ( 64 65 16 ) ( 65 64 16 ) __TB_empty 0 0 0 1 1 - ( -64 -64 -16 ) ( -63 -64 -16 ) ( -64 -63 -16 ) __TB_empty 0 0 0 1 1 - } - } - )"; - - mapentity_t worldspawn = LoadMap(map); - Q_assert(1 == worldspawn.nummapbrushes); - - brush_t *brush = LoadBrush(&worldspawn, &worldspawn.mapbrush(0), {CONTENTS_SOLID}, {}, rotation_t::none, 0); - Q_assert(nullptr != brush); - - brush->contents = {CONTENTS_SOLID}; - - return brush; -} - -static void checkForAllCubeNormals(const brush_t *brush) -{ - const qvec3d wanted[6] = {{-1, 0, 0}, {1, 0, 0}, {0, -1, 0}, {0, 1, 0}, {0, 0, -1}, {0, 0, 1}}; - - bool found[6]; - for (int i = 0; i < 6; i++) { - found[i] = false; - } - - for (const face_t *face = brush->faces; face; face = face->next) { - const qplane3d faceplane = Face_Plane(face); - - for (int i = 0; i < 6; i++) { - if (qv::epsilonEqual(wanted[i], faceplane.normal, NORMAL_EPSILON)) { - EXPECT_FALSE(found[i]); - found[i] = true; - } - } - } - - for (int i = 0; i < 6; i++) { - EXPECT_TRUE(found[i]); - } -} - -static void checkCube(const brush_t *brush) -{ - EXPECT_EQ(6, Brush_NumFaces(brush)); - - checkForAllCubeNormals(brush); - - EXPECT_EQ(contentflags_t{CONTENTS_SOLID}, brush->contents); + std::optional brush = LoadBrush(&worldspawn, &worldspawn.mapbrush(0), {CONTENTS_SOLID}, {}, rotation_t::none, 0); + ASSERT_NE(std::nullopt, brush); + EXPECT_EQ(6, brush->faces.size()); } /**