diff --git a/include/qbsp/brush.hh b/include/qbsp/brush.hh index 8dabb872..3d1a572c 100644 --- a/include/qbsp/brush.hh +++ b/include/qbsp/brush.hh @@ -37,9 +37,6 @@ struct side_t int texinfo; bool onnode; // has this face been used as a BSP node plane yet? - 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) bool bevel; // don't ever use for bsp splitting mapface_t *source; // the mapface we were generated from diff --git a/include/qbsp/map.hh b/include/qbsp/map.hh index 013fa1f6..62433f07 100644 --- a/include/qbsp/map.hh +++ b/include/qbsp/map.hh @@ -59,6 +59,10 @@ struct mapface_t // for convert std::optional raw_info; + bool visible = false; // 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) + bool set_planepts(const std::array &pts); const texvecf &get_texvecs() const; diff --git a/qbsp/brushbsp.cc b/qbsp/brushbsp.cc index 8275666b..6fb0cd44 100644 --- a/qbsp/brushbsp.cc +++ b/qbsp/brushbsp.cc @@ -285,7 +285,7 @@ static int TestBrushToPlanenum( for (const side_t &side : brush.sides) { if (side.onnode) continue; // on node, don't worry about splits - if (!side.visible) + if (!side.source->visible) continue; // we don't care about non-visible auto &w = side.w; if (!w) @@ -574,7 +574,7 @@ static twosided> SplitBrush(std::unique_ptrvisible = false; cs.tested = false; cs.onnode = true; // fixme-brushbsp: configure any other settings on the face? @@ -818,7 +818,7 @@ static std::optional SelectSplitPlane(const std::vectorvisible ^ (pass < 2)) continue; // only check visible faces on first pass size_t positive_planenum = side.planenum & ~1; @@ -912,7 +912,7 @@ static std::optional SelectSplitPlane(const std::vectorvisible) { + if (!bestside->source->visible) { stats.c_nonvis++; } @@ -1064,7 +1064,7 @@ static std::unique_ptr BrushBSP_internal(mapentity_t *entity, std::vecto continue; if (side.onnode) continue; - if (side.visible) + if (side.source->visible) c_faces++; else c_nonvisfaces++; diff --git a/qbsp/map.cc b/qbsp/map.cc index 0f7ee536..4000bff3 100644 --- a/qbsp/map.cc +++ b/qbsp/map.cc @@ -2820,7 +2820,7 @@ void WriteBspBrushMap(const fs::path &name, const std::vectorvisible) { fmt::print(f, "skip 0 0 0 1 1\n"); } else { fmt::print(f, "nonvisible 0 0 0 1 1\n"); diff --git a/qbsp/outside.cc b/qbsp/outside.cc index 62a69608..d4cd4008 100644 --- a/qbsp/outside.cc +++ b/qbsp/outside.cc @@ -353,7 +353,7 @@ static void MarkBrushSidesInvisible(mapentity_t *entity, bspbrush_vector_t &brus { for (auto &brush : brushes) { for (auto &face : brush->sides) { - face.visible = false; + face.source->visible = false; } } } @@ -418,7 +418,7 @@ static void MarkVisibleBrushSides_R(node_t *node) if (qv::epsilonEqual(side.get_positive_plane(), portal->plane)) { // we've found a brush side in an original brush in the neighbouring // leaf, on a portal to this (non-opaque) leaf, so mark it as visible. - side.visible = true; + side.source->visible = true; } } } diff --git a/qbsp/portals.cc b/qbsp/portals.cc index 6226916d..5696fe09 100644 --- a/qbsp/portals.cc +++ b/qbsp/portals.cc @@ -816,9 +816,6 @@ static void FindPortalSide(portal_t *p) for (auto &side : brush->sides) { if (side.bevel) continue; - // fixme-brushbsp: restore - // if (!side.visible) - // continue; // non-visible if ((side.planenum & ~1) == p->onnode->planenum) { // exact match (undirectional) @@ -902,7 +899,7 @@ static void MarkVisibleSides_r(node_t *node) FindPortalSide(p); for (int i = 0; i < 2; ++i) { if (p->sides[i]) { - p->sides[i]->visible = true; + p->sides[i]->source->visible = true; } } } @@ -921,7 +918,7 @@ void MarkVisibleSides(tree_t *tree, mapentity_t *entity, bspbrush_vector_t &brus // clear all the visible flags for (auto &brush : brushes) { for (auto &face : brush->sides) { - face.visible = false; + face.source->visible = false; } }