qbsp: FillOutside: count portals yourself
This commit is contained in:
parent
3069996a6f
commit
bb3e296a0d
|
|
@ -171,7 +171,7 @@ void Entity_SortBrushes(mapentity_t *dst);
|
|||
|
||||
|
||||
surface_t *CSGFaces(const mapentity_t *entity);
|
||||
int PortalizeWorld(const mapentity_t *entity, node_t *headnode, const int hullnum);
|
||||
void PortalizeWorld(const mapentity_t *entity, node_t *headnode, const int hullnum);
|
||||
void TJunc(const mapentity_t *entity, node_t *headnode);
|
||||
node_t *SolidBSP(const mapentity_t *entity, surface_t *surfhead, bool midsplit);
|
||||
int MakeFaceEdges(mapentity_t *entity, node_t *headnode, const std::vector<face_t *> &extrafaces);
|
||||
|
|
|
|||
|
|
@ -22,6 +22,6 @@
|
|||
#ifndef QBSP_OUTSIDE_HH
|
||||
#define QBSP_OUTSIDE_HH
|
||||
|
||||
bool FillOutside(node_t *node, const int hullnum, const int numportals);
|
||||
bool FillOutside(node_t *node, const int hullnum);
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -447,6 +447,26 @@ ClearOutFaces(node_t *node)
|
|||
|
||||
//=============================================================================
|
||||
|
||||
static void
|
||||
CountPortals_r(node_t *node, int *count)
|
||||
{
|
||||
/* decision node */
|
||||
if (!node->contents) {
|
||||
CountPortals_r(node->children[0], count);
|
||||
CountPortals_r(node->children[1], count);
|
||||
return;
|
||||
}
|
||||
|
||||
/* leaf */
|
||||
for (const portal_t *portal = node->portals; portal;) {
|
||||
const bool isFront = (portal->nodes[0] == node);
|
||||
/* only write out from front leafs, so we don't count portals twice */
|
||||
if (isFront)
|
||||
*count += 1;
|
||||
portal = portal->next[isFront ? 0 : 1];
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
===========
|
||||
FillOutside
|
||||
|
|
@ -454,16 +474,16 @@ FillOutside
|
|||
===========
|
||||
*/
|
||||
bool
|
||||
FillOutside(node_t *node, const int hullnum, const int numportals)
|
||||
FillOutside(node_t *node, const int hullnum)
|
||||
{
|
||||
int i, side, outleafs;
|
||||
bool inside, leak_found;
|
||||
leakstate_t leak;
|
||||
const mapentity_t *entity;
|
||||
node_t *fillnode;
|
||||
|
||||
|
||||
Message(msgProgress, "FillOutside");
|
||||
|
||||
|
||||
if (options.fNofill) {
|
||||
Message(msgStat, "skipped");
|
||||
return false;
|
||||
|
|
@ -483,6 +503,10 @@ FillOutside(node_t *node, const int hullnum, const int numportals)
|
|||
return false;
|
||||
}
|
||||
|
||||
/* Count portals */
|
||||
int numportals = 0;
|
||||
CountPortals_r(node, &numportals);
|
||||
|
||||
/* Set up state for the recursive fill */
|
||||
memset(&leak, 0, sizeof(leak));
|
||||
if (!map.leakfile) {
|
||||
|
|
|
|||
|
|
@ -215,7 +215,6 @@ CountPortals(const node_t *node, portal_state_t *state)
|
|||
portal = portal->next[1];
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
@ -672,7 +671,7 @@ PortalizeWorld
|
|||
Builds the exact polyhedrons for the nodes and leafs
|
||||
==================
|
||||
*/
|
||||
int
|
||||
void
|
||||
PortalizeWorld(const mapentity_t *entity, node_t *headnode, const int hullnum)
|
||||
{
|
||||
Message(msgProgress, "Portalize");
|
||||
|
|
@ -693,8 +692,6 @@ PortalizeWorld(const mapentity_t *entity, node_t *headnode, const int hullnum)
|
|||
Message(msgStat, "%8d vis clusters", state.num_visclusters);
|
||||
Message(msgStat, "%8d vis portals", state.num_visportals);
|
||||
}
|
||||
|
||||
return state.num_visportals;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
12
qbsp/qbsp.cc
12
qbsp/qbsp.cc
|
|
@ -39,7 +39,7 @@ ProcessEntity
|
|||
void
|
||||
ProcessEntity(mapentity_t *entity, const int hullnum)
|
||||
{
|
||||
int i, numportals, firstface;
|
||||
int i, firstface;
|
||||
surface_t *surfs;
|
||||
node_t *nodes;
|
||||
|
||||
|
|
@ -163,8 +163,8 @@ ProcessEntity(mapentity_t *entity, const int hullnum)
|
|||
nodes = SolidBSP(entity, surfs, true);
|
||||
if (entity == pWorldEnt() && !options.fNofill) {
|
||||
// assume non-world bmodels are simple
|
||||
numportals = PortalizeWorld(entity, nodes, hullnum);
|
||||
if (FillOutside(nodes, hullnum, numportals)) {
|
||||
PortalizeWorld(entity, nodes, hullnum);
|
||||
if (FillOutside(nodes, hullnum)) {
|
||||
// Free portals before regenerating new nodes
|
||||
FreeAllPortals(nodes);
|
||||
surfs = GatherNodeFaces(nodes);
|
||||
|
|
@ -198,8 +198,8 @@ ProcessEntity(mapentity_t *entity, const int hullnum)
|
|||
// some portals are solid polygons, and some are paths to other leafs
|
||||
if (entity == pWorldEnt() && !options.fNofill) {
|
||||
// assume non-world bmodels are simple
|
||||
numportals = PortalizeWorld(entity, nodes, hullnum);
|
||||
if (FillOutside(nodes, hullnum, numportals)) {
|
||||
PortalizeWorld(entity, nodes, hullnum);
|
||||
if (FillOutside(nodes, hullnum)) {
|
||||
FreeAllPortals(nodes);
|
||||
|
||||
// get the remaining faces together into surfaces again
|
||||
|
|
@ -215,7 +215,7 @@ ProcessEntity(mapentity_t *entity, const int hullnum)
|
|||
DetailToSolid(nodes);
|
||||
|
||||
// make the real portals for vis tracing
|
||||
numportals = PortalizeWorld(entity, nodes, hullnum);
|
||||
PortalizeWorld(entity, nodes, hullnum);
|
||||
|
||||
TJunc(entity, nodes);
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue