qbsp: enable new outside filling

This commit is contained in:
Eric Wasylishen 2022-04-10 00:00:28 -06:00
parent a3d54cf48d
commit b7fbb48763
4 changed files with 34 additions and 32 deletions

View File

@ -328,7 +328,7 @@ struct face_t : face_fragment_t
// fixme-brushbsp: move to a brush_side_t struct
bool onnode; // has this face been used as a BSP node plane yet?
bool visible; // can any part of this side be seen from non-void parts of the level?
bool visible = true; // can any part of this side be seen from non-void parts of the level?
// non-visible means we can discard the brush side
// (avoiding generating a BSP spit, so expanding it outwards)
};

View File

@ -325,17 +325,11 @@ std::vector<node_t *> FindOccupiedClusters(node_t *headnode)
//=============================================================================
static void AssertBrushSidesInvisible(node_t *node)
static void MarkBrushSidesInvisible(mapentity_t *entity)
{
if (node->planenum != PLANENUM_LEAF) {
AssertBrushSidesInvisible(node->children[0]);
AssertBrushSidesInvisible(node->children[1]);
return;
}
for (auto *brush : node->original_brushes) {
for (const auto &face : brush->faces) {
Q_assert(!face.visible);
for (auto &brush : entity->brushes) {
for (auto &face : brush.faces) {
face.visible = false;
}
}
}
@ -507,25 +501,11 @@ bool FillOutside(mapentity_t *entity, node_t *node, const int hullnum)
const int outleafs = OutLeafsToSolid(node);
// See missing_face_simple.map for a test case with a brush that straddles between void and non-void
AssertBrushSidesInvisible(node);
MarkBrushSidesInvisible(entity);
MarkVisibleBrushSides(node);
// Count brush sides
int visible_brush_sides = 0;
int invisible_brush_sides = 0;
for (const auto &brush : entity->brushes) {
for (auto &side : brush.faces) {
if (side.visible) {
++visible_brush_sides;
} else {
++invisible_brush_sides;
}
}
}
logging::print(logging::flag::STAT, " {:8} outleafs\n", outleafs);
logging::print(logging::flag::STAT, " {:8} visible brush sides\n", visible_brush_sides);
logging::print(logging::flag::STAT, " {:8} invisible brush sides\n", invisible_brush_sides);
return true;
}

View File

@ -287,6 +287,10 @@ static face_t *ChooseMidPlaneFromList(std::vector<brush_t> &brushes, const aabb3
for (auto &face : brush.faces) {
if (face.onnode)
continue;
if (!face.visible) {
// never use as a bsp splitter, efffectively filling the brush outwards
continue;
}
const qbsp_plane_t &plane = map.planes[face.planenum];
bool axial = false;
@ -350,6 +354,10 @@ static face_t *ChoosePlaneFromList(std::vector<brush_t> &brushes, const aabb3d &
if (face.onnode) {
continue;
}
if (!face.visible) {
// never use as a bsp splitter, efffectively filling the brush outwards
continue;
}
const bool hintsplit = map.mtexinfos.at(face.texinfo).flags.is_hint;
@ -915,6 +923,22 @@ node_t *SolidBSP(mapentity_t *entity, bool midsplit)
logging::print(logging::flag::PROGRESS, "---- {} ----\n", __func__);
// Count visible/nonvisible brush sides (this is the side effect of FillOutside)
int visible_brush_sides = 0;
int invisible_brush_sides = 0;
for (const auto &brush : entity->brushes) {
for (auto &side : brush.faces) {
if (side.visible) {
++visible_brush_sides;
} else {
++invisible_brush_sides;
}
}
}
logging::print(logging::flag::STAT, " {:8} visible brush sides\n", visible_brush_sides);
logging::print(logging::flag::STAT, " {:8} invisible brush sides\n", invisible_brush_sides);
node_t *headnode = new node_t{};
usemidsplit = midsplit;

View File

@ -526,11 +526,9 @@ void MakeMarkFaces(mapentity_t* entity, node_t* node)
static void AddFaceToTree_r(mapentity_t* entity, face_t *face, brush_t *srcbrush, node_t* node)
{
if (node->planenum == PLANENUM_LEAF) {
if (!face->w.size()) {
// spurious
return;
}
FError("couldn't find node for face");
//FError("couldn't find node for face");
// after outside filling, this is completely expected
return;
}
if (face->planenum == node->planenum) {