qbsp: add -debugbspbrushes

This commit is contained in:
Eric Wasylishen 2022-09-12 00:18:32 -06:00
parent 4567f9b4b9
commit a926e5c397
2 changed files with 29 additions and 0 deletions

View File

@ -364,6 +364,8 @@ public:
"write a .map after outside filling showing non-visible brush sides"};
setting_bool debugchop{this, "debugchop", false, &debugging_group, "write a .map after ChopBrushes"};
setting_bool debugleak{this, "debugleak", false, &debugging_group, "write more diagnostic files for debugging leaks"};
setting_bool debugbspbrushes{
this, "debugbspbrushes", false, &debugging_group, "save bsp brushes after BrushBSP to a .map, for visualizing BSP splits"};
setting_debugexpand debugexpand{this, "debugexpand", &debugging_group, "write expanded hull .map for debugging/inspecting hulls/brush bevelling"};
setting_bool keepprt{this, "keepprt", false, &debugging_group, "avoid deleting the .prt file on leaking maps"};
setting_bool includeskip{this, "includeskip", false, &common_format_group,

View File

@ -389,6 +389,19 @@ static void CountLeafs(node_t *headnode)
qbsp_options.target_game->print_content_stats(*stats, "leafs");
}
static void GatherBspbrushes_r(node_t *node, bspbrush_t::container &container)
{
if (node->is_leaf) {
for (auto &brush : node->bsp_brushes) {
container.push_back(brush);
}
return;
}
GatherBspbrushes_r(node->children[0], container);
GatherBspbrushes_r(node->children[1], container);
}
/*
===============
ProcessEntity
@ -515,6 +528,13 @@ static void ProcessEntity(mapentity_t &entity, hull_index_t hullnum)
MakeTreePortals(tree);
if (map.is_world_entity(entity)) {
// debug output of bspbrushes
if (qbsp_options.debugbspbrushes.value() && (!hullnum.has_value() || hullnum.value() == 0)) {
bspbrush_t::container all_bspbrushes;
GatherBspbrushes_r(tree.headnode, all_bspbrushes);
WriteBspBrushMap("first-brushbsp", all_bspbrushes);
}
// 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"
@ -524,6 +544,13 @@ static void ProcessEntity(mapentity_t &entity, hull_index_t hullnum)
tree.clear();
BrushBSP(tree, entity, brushes, tree_split_t::PRECISE);
// debug output of bspbrushes
if (qbsp_options.debugbspbrushes.value() && (!hullnum.has_value() || hullnum.value() == 0)) {
bspbrush_t::container all_bspbrushes;
GatherBspbrushes_r(tree.headnode, all_bspbrushes);
WriteBspBrushMap("second-brushbsp", all_bspbrushes);
}
// make the real portals for vis tracing
MakeTreePortals(tree);