From b994bb750d05e68d3576a95be46d39c446c13a56 Mon Sep 17 00:00:00 2001 From: Eric Wasylishen Date: Fri, 5 May 2023 23:07:16 -0600 Subject: [PATCH] brushbsp: disable CheckPlaneAgainstVolume checks this check prevents splitting on small brush fragments, where we actually need to split. if we don't the small fragments cause incorrect leaf contents to be assigned. --- qbsp/brushbsp.cc | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/qbsp/brushbsp.cc b/qbsp/brushbsp.cc index 608c7c73..bb4509ab 100644 --- a/qbsp/brushbsp.cc +++ b/qbsp/brushbsp.cc @@ -46,6 +46,8 @@ constexpr int PSIDE_BOTH = (PSIDE_FRONT | PSIDE_BACK); // this gets OR'ed in in the return value of QuickTestBrushToPlanenum if one of the brush sides is on the input plane constexpr int PSIDE_FACING = 4; +#define CHECK_PLANE_AGAINST_VOLUME 0 + struct bspstats_t : logging::stat_tracker_t { std::unique_ptr leafstats; @@ -866,9 +868,11 @@ static side_t *ChooseMidPlaneFromList(const bspbrush_t::container &brushes, cons size_t positive_planenum = side.planenum & ~1; const qbsp_plane_t &plane = side.get_positive_plane(); +#if CHECK_PLANE_AGAINST_VOLUME if (!CheckPlaneAgainstVolume(positive_planenum, node)) { continue; // would produce a tiny volume } +#endif /* calculate the split metric, smaller values are better */ const vec_t metric = SplitPlaneMetric(plane, node->bounds); @@ -983,8 +987,10 @@ static side_t *SelectSplitPlane( CheckPlaneAgainstParents(positive_planenum, node); +#if CHECK_PLANE_AGAINST_VOLUME if (!CheckPlaneAgainstVolume(positive_planenum, node)) continue; // would produce a tiny volume +#endif int front = 0; int back = 0; @@ -1184,10 +1190,12 @@ static void BuildTree_r(tree_t &tree, int level, node_t *node, bspbrush_t::conta } // to save time/memory we can destroy node's volume at this point - auto children_volumes = SplitBrush(std::move(node->volume), bestplane, stats); - node->volume = nullptr; - node->children[0]->volume = std::move(children_volumes[0]); - node->children[1]->volume = std::move(children_volumes[1]); + if (node->volume) { + auto children_volumes = SplitBrush(std::move(node->volume), bestplane, stats); + node->volume = nullptr; + node->children[0]->volume = std::move(children_volumes[0]); + node->children[1]->volume = std::move(children_volumes[1]); + } // recursively process children tbb::task_group g;