move `visible` to mapface_t since we only need to store one boolean for it

This commit is contained in:
Jonathan 2022-08-10 01:29:34 -04:00
parent f8f0e903a2
commit bca6bda7c3
6 changed files with 14 additions and 16 deletions

View File

@ -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

View File

@ -59,6 +59,10 @@ struct mapface_t
// for convert
std::optional<extended_texinfo_t> 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<qvec3d, 3> &pts);
const texvecf &get_texvecs() const;

View File

@ -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<std::unique_ptr<bspbrush_t>> SplitBrush(std::unique_ptr<bspbrush
// (the face that is touching the plane) should have a normal opposite the plane's normal
cs.planenum = planenum ^ i ^ 1;
cs.texinfo = map.skip_texinfo;
cs.visible = false;
//cs.source->visible = false;
cs.tested = false;
cs.onnode = true;
// fixme-brushbsp: configure any other settings on the face?
@ -818,7 +818,7 @@ static std::optional<size_t> SelectSplitPlane(const std::vector<std::unique_ptr<
continue; // we allready have metrics for this plane
if (side.get_texinfo().flags.is_hintskip)
continue; // skip surfaces are never chosen
if (side.visible ^ (pass < 2))
if (side.source->visible ^ (pass < 2))
continue; // only check visible faces on first pass
size_t positive_planenum = side.planenum & ~1;
@ -912,7 +912,7 @@ static std::optional<size_t> SelectSplitPlane(const std::vector<std::unique_ptr<
return std::nullopt;
}
if (!bestside->visible) {
if (!bestside->source->visible) {
stats.c_nonvis++;
}
@ -1064,7 +1064,7 @@ static std::unique_ptr<tree_t> BrushBSP_internal(mapentity_t *entity, std::vecto
continue;
if (side.onnode)
continue;
if (side.visible)
if (side.source->visible)
c_faces++;
else
c_nonvisfaces++;

View File

@ -2820,7 +2820,7 @@ void WriteBspBrushMap(const fs::path &name, const std::vector<std::unique_ptr<bs
fmt::print(f, "( {} ) ", w[1]);
fmt::print(f, "( {} ) ", w[2]);
if (face.visible) {
if (face.source->visible) {
fmt::print(f, "skip 0 0 0 1 1\n");
} else {
fmt::print(f, "nonvisible 0 0 0 1 1\n");

View File

@ -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;
}
}
}

View File

@ -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;
}
}