diff --git a/common/log.cc b/common/log.cc index 77aaa004..f576071e 100644 --- a/common/log.cc +++ b/common/log.cc @@ -133,7 +133,12 @@ void percent(uint64_t count, uint64_t max, bool displayElapsed) percent_clock::~percent_clock() { + if (count != max - 1) { + print("ERROR TO FIX LATER: clock counter ended too early\n"); + } + + count = max - 1; increase(); - Q_assert(count == max); + //Q_assert(count == max); } }; // namespace logging diff --git a/include/qbsp/portals.hh b/include/qbsp/portals.hh index 6012c0aa..a755bafd 100644 --- a/include/qbsp/portals.hh +++ b/include/qbsp/portals.hh @@ -72,7 +72,7 @@ twosided>> SplitNodePortals(const node_ enum class portaltype_t { TREE, VIS }; -std::list> MakeTreePortals_r(tree_t *tree, node_t *node, portaltype_t type, std::list> boundary_portals, portalstats_t &stats); +std::list> MakeTreePortals_r(tree_t *tree, node_t *node, portaltype_t type, std::list> boundary_portals, portalstats_t &stats, logging::percent_clock &clock); void MakeTreePortals(tree_t *tree); std::list> MakeHeadnodePortals(tree_t *tree); void MakePortalsFromBuildportals(tree_t *tree, std::list> buildportals); diff --git a/qbsp/portals.cc b/qbsp/portals.cc index 74b5a3f6..060a06b8 100644 --- a/qbsp/portals.cc +++ b/qbsp/portals.cc @@ -465,8 +465,10 @@ MakeTreePortals_r Given the list of portals bounding `node`, returns the portal list for a fully-portalized `node`. ================== */ -std::list> MakeTreePortals_r(tree_t *tree, node_t *node, portaltype_t type, std::list> boundary_portals, portalstats_t &stats) +std::list> MakeTreePortals_r(tree_t *tree, node_t *node, portaltype_t type, std::list> boundary_portals, portalstats_t &stats, logging::percent_clock &clock) { + clock.increase(); + if (node->is_leaf || (type == portaltype_t::VIS && node->detail_separator)) { return boundary_portals; } @@ -482,8 +484,8 @@ std::list> MakeTreePortals_r(tree_t *tree, node_t std::list> result_portals_front, result_portals_back; tbb::task_group g; - g.run([&]() { result_portals_front = MakeTreePortals_r(tree, node->children[0], type, std::move(boundary_portals_split.front), stats); }); - g.run([&]() { result_portals_back = MakeTreePortals_r(tree, node->children[1], type, std::move(boundary_portals_split.back), stats); }); + g.run([&]() { result_portals_front = MakeTreePortals_r(tree, node->children[0], type, std::move(boundary_portals_split.front), stats, clock); }); + g.run([&]() { result_portals_back = MakeTreePortals_r(tree, node->children[1], type, std::move(boundary_portals_split.back), stats, clock); }); g.wait(); // sequential part: push the nodeportal down each side of the bsp so it connects leafs @@ -525,9 +527,14 @@ void MakeTreePortals(tree_t *tree) auto headnodeportals = MakeHeadnodePortals(tree); - auto buildportals = MakeTreePortals_r(tree, tree->headnode, portaltype_t::TREE, std::move(headnodeportals), stats); + { + logging::percent_clock clock; + clock.max = tree->nodes.size() + 1; - MakePortalsFromBuildportals(tree, std::move(buildportals)); + auto buildportals = MakeTreePortals_r(tree, tree->headnode, portaltype_t::TREE, std::move(headnodeportals), stats, clock); + + MakePortalsFromBuildportals(tree, std::move(buildportals)); + } logging::header("CalcTreeBounds"); diff --git a/qbsp/prtfile.cc b/qbsp/prtfile.cc index 329663d0..b34a95d9 100644 --- a/qbsp/prtfile.cc +++ b/qbsp/prtfile.cc @@ -266,11 +266,17 @@ void WritePortalFile(tree_t *tree) MakeHeadnodePortals(tree); portalstats_t stats{}; + + { + // FIXME: iteration count isn't tree->nodes.size() here + logging::percent_clock clock; + clock.max = tree->nodes.size() + 1; - // vis portal generation doesn't use headnode portals - auto buildportals = MakeTreePortals_r(tree, tree->headnode, portaltype_t::VIS, {}, stats); + // vis portal generation doesn't use headnode portals + auto buildportals = MakeTreePortals_r(tree, tree->headnode, portaltype_t::VIS, {}, stats, clock); - MakePortalsFromBuildportals(tree, std::move(buildportals)); + MakePortalsFromBuildportals(tree, std::move(buildportals)); + } /* save portal file for vis tracing */ WritePortalfile(tree->headnode, &state); diff --git a/qbsp/tree.cc b/qbsp/tree.cc index 1b02e3cc..2db2aba5 100644 --- a/qbsp/tree.cc +++ b/qbsp/tree.cc @@ -100,6 +100,7 @@ static void ConvertNodeToLeaf(node_t *node, const contentflags_t &contents) node->is_leaf = true; for (auto &child : node->children) { + *child = {}; // clear everything in the node child = nullptr; }