qbsp: import CreateVisPortals_r from qbsp3

This commit is contained in:
Eric Wasylishen 2022-06-17 23:59:19 -06:00
parent 65e6fafb3e
commit 1fb5753f60
3 changed files with 29 additions and 4 deletions

View File

@ -50,7 +50,13 @@ public:
bool uses_detail;
};
struct portalstats_t {
std::atomic<int> c_tinyportals;
};
contentflags_t ClusterContents(const node_t *node);
void MakeNodePortal(node_t *node, portalstats_t &stats);
void SplitNodePortals(node_t *node, portalstats_t &stats);
void MakeTreePortals(tree_t *tree);
void FreeTreePortals_r(node_t *node);
void AssertNoPortals(node_t *node);

View File

@ -262,10 +262,6 @@ std::optional<winding_t> BaseWindingForNode(node_t *node)
return w;
}
struct portalstats_t {
std::atomic<int> c_tinyportals;
};
/*
==================
MakeNodePortal

View File

@ -28,6 +28,8 @@
#include <fstream>
#include <fmt/ostream.h>
#include "tbb/task_group.h"
/*
==============================================================================
@ -263,6 +265,27 @@ static void WritePortalfile(node_t *headnode, portal_state_t *state)
}
}
/*
================
CreateVisPortals_r
================
*/
void CreateVisPortals_r(node_t *node, portalstats_t &stats)
{
// stop as soon as we get to a detail_seperator, which
// means that everything below is in a single cluster
if (node->planenum == PLANENUM_LEAF || node->detail_separator )
return;
MakeNodePortal(node, stats);
SplitNodePortals(node, stats);
tbb::task_group g;
g.run([&]() { CreateVisPortals_r(node->children[0], stats); });
g.run([&]() { CreateVisPortals_r(node->children[1], stats); });
g.wait();
}
/*
==================
WritePortalFile