qbsp: mark invisible sides on brush entities

fixes brush_clipping_order test failure
This commit is contained in:
Eric Wasylishen 2022-05-01 00:01:11 -06:00
parent 5b4a9956c6
commit 81e0da4d62
5 changed files with 27 additions and 9 deletions

View File

@ -22,4 +22,6 @@
#pragma once
bool FillOutside(mapentity_t *entity, node_t *node, const int hullnum);
std::vector<node_t *> FindOccupiedClusters(node_t *headnode);
std::vector<node_t *> FindOccupiedClusters(node_t *headnode);
void FillBrushEntity(mapentity_t *entity, node_t *node, const int hullnum);

View File

@ -35,5 +35,5 @@ struct portal_t
extern node_t outside_node; // portals outside the world face this
contentflags_t ClusterContents(const node_t *node);
void PortalizeWorld(const mapentity_t *entity, node_t *headnode, const int hullnum);
void PortalizeEntity(const mapentity_t *entity, node_t *headnode, const int hullnum);
void FreeAllPortals(node_t *node);

View File

@ -585,3 +585,15 @@ bool FillOutside(mapentity_t *entity, node_t *node, const int hullnum)
logging::print(logging::flag::STAT, " {:8} outleafs\n", outleafs);
return true;
}
void FillBrushEntity(mapentity_t* entity, node_t* node, const int hullnum)
{
logging::print(logging::flag::PROGRESS, "---- {} ----\n", __func__);
// Clear the outside filling state on all nodes
ClearOccupied_r(node);
MarkBrushSidesInvisible(entity);
MarkVisibleBrushSides_R(node);
}

View File

@ -617,7 +617,7 @@ PortalizeWorld
Builds the exact polyhedrons for the nodes and leafs
==================
*/
void PortalizeWorld(const mapentity_t *entity, node_t *headnode, const int hullnum)
void PortalizeEntity(const mapentity_t *entity, node_t *headnode, const int hullnum)
{
logging::print(logging::flag::PROGRESS, "---- {} ----\n", __func__);
@ -630,7 +630,7 @@ void PortalizeWorld(const mapentity_t *entity, node_t *headnode, const int hulln
logging::percent(splitnodes, splitnodes, entity == map.world_entity());
if (hullnum <= 0) {
if (hullnum <= 0 && entity == map.world_entity()) {
/* save portal file for vis tracing */
WritePortalfile(headnode, &state);

View File

@ -699,7 +699,7 @@ static void ProcessEntity(mapentity_t *entity, const int hullnum)
nodes = SolidBSP(entity, true);
if (entity == map.world_entity() && !options.nofill.value()) {
// assume non-world bmodels are simple
PortalizeWorld(entity, nodes, hullnum);
PortalizeEntity(entity, nodes, hullnum);
if (FillOutside(entity, nodes, hullnum)) {
// fixme-brushbsp: re-add
// FreeNodes(nodes);
@ -732,10 +732,9 @@ static void ProcessEntity(mapentity_t *entity, const int hullnum)
// build all the portals in the bsp tree
// some portals are solid polygons, and some are paths to other leafs
if (entity == map.world_entity()) {
// assume non-world bmodels are simple
PortalizeWorld(entity, nodes, hullnum);
PortalizeEntity(entity, nodes, hullnum);
if (entity == map.world_entity()) {
// flood fills from the void.
// marks brush sides which are *only* touching void;
// we can skip using them as BSP splitters on the "really good tree"
@ -748,7 +747,7 @@ static void ProcessEntity(mapentity_t *entity, const int hullnum)
nodes = SolidBSP(entity, false);
// make the real portals for vis tracing
PortalizeWorld(entity, nodes, hullnum);
PortalizeEntity(entity, nodes, hullnum);
}
// Area portals
@ -756,6 +755,11 @@ static void ProcessEntity(mapentity_t *entity, const int hullnum)
FloodAreas(entity, nodes);
EmitAreaPortals(nodes);
}
} else {
FillBrushEntity(entity, nodes, hullnum);
// rebuild BSP now that we've marked invisible brush sides
nodes = SolidBSP(entity, false);
}
PruneNodes(nodes);