diff --git a/include/qbsp/qbsp.hh b/include/qbsp/qbsp.hh index aa488021..4d2608c9 100644 --- a/include/qbsp/qbsp.hh +++ b/include/qbsp/qbsp.hh @@ -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, diff --git a/qbsp/qbsp.cc b/qbsp/qbsp.cc index fd5f8f53..2202792c 100644 --- a/qbsp/qbsp.cc +++ b/qbsp/qbsp.cc @@ -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);