qbsp: add -debugleak for saving more info about leaks
This commit is contained in:
parent
ae37a4e667
commit
4567f9b4b9
|
|
@ -337,6 +337,6 @@ void ExportObj_Brushes(const std::string &filesuffix, const std::vector<const bs
|
|||
void ExportObj_Nodes(const std::string &filesuffix, const node_t *nodes);
|
||||
void ExportObj_Marksurfaces(const std::string &filesuffix, const node_t *nodes);
|
||||
|
||||
void WriteBspBrushMap(const fs::path &name, const bspbrush_t::container &list);
|
||||
void WriteBspBrushMap(std::string_view filename_suffix, const bspbrush_t::container &list);
|
||||
|
||||
bool IsValidTextureProjection(const qvec3f &faceNormal, const qvec3f &s_vec, const qvec3f &t_vec);
|
||||
|
|
|
|||
|
|
@ -363,6 +363,7 @@ public:
|
|||
setting_bool outsidedebug{this, "outsidedebug", false, &debugging_group,
|
||||
"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_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,
|
||||
|
|
@ -733,6 +734,7 @@ struct node_t
|
|||
uint32_t numleafbrushes;
|
||||
int32_t area;
|
||||
std::vector<bspbrush_t *> original_brushes;
|
||||
bspbrush_t::container bsp_brushes;
|
||||
};
|
||||
|
||||
void InitQBSP(int argc, const char **argv);
|
||||
|
|
|
|||
|
|
@ -354,7 +354,11 @@ static void LeafNode(node_t *leafnode, bspbrush_t::container brushes, bspstats_t
|
|||
|
||||
qbsp_options.target_game->count_contents_in_stats(leafnode->contents, *stats.leafstats);
|
||||
|
||||
leafnode->volume.reset();
|
||||
if (qbsp_options.debugleak.value()) {
|
||||
leafnode->bsp_brushes = brushes;
|
||||
} else {
|
||||
leafnode->volume.reset();
|
||||
}
|
||||
}
|
||||
|
||||
//============================================================
|
||||
|
|
@ -1486,6 +1490,6 @@ newlist:
|
|||
logging::print(logging::flag::STAT, "chopped {} brushes into {}\n", original_count, brushes.size());
|
||||
|
||||
if (qbsp_options.debugchop.value()) {
|
||||
WriteBspBrushMap("chopped.map", brushes);
|
||||
WriteBspBrushMap("chopped", brushes);
|
||||
}
|
||||
}
|
||||
|
|
@ -3334,8 +3334,11 @@ WriteBspBrushMap
|
|||
from q3map
|
||||
==================
|
||||
*/
|
||||
void WriteBspBrushMap(const fs::path &name, const bspbrush_t::container &list)
|
||||
void WriteBspBrushMap(std::string_view filename_suffix, const bspbrush_t::container &list)
|
||||
{
|
||||
fs::path name = qbsp_options.bsp_path;
|
||||
name.replace_extension(std::string(filename_suffix) + ".map");
|
||||
|
||||
logging::print("writing {}\n", name);
|
||||
std::ofstream f(name);
|
||||
|
||||
|
|
|
|||
|
|
@ -284,6 +284,27 @@ static void WriteLeakLine(const mapentity_t &leakentity, const std::vector<porta
|
|||
logging::print("Leak file written to {}\n", name);
|
||||
}
|
||||
|
||||
static void WriteLeafVolumes(const std::vector<portal_t *> &leakline, std::string_view filename_suffix)
|
||||
{
|
||||
std::set<node_t *> used_leafs;
|
||||
std::vector<bspbrush_t::ptr> volumes_to_write;
|
||||
|
||||
for (portal_t *portal : leakline) {
|
||||
for (node_t *node : portal->nodes) {
|
||||
// make sure we only visit each leaf once
|
||||
if (used_leafs.find(node) != used_leafs.end())
|
||||
continue;
|
||||
|
||||
used_leafs.insert(node);
|
||||
|
||||
// now output the leaf's volume as a brush
|
||||
volumes_to_write.push_back(node->volume);
|
||||
}
|
||||
}
|
||||
|
||||
WriteBspBrushMap(filename_suffix, volumes_to_write);
|
||||
}
|
||||
|
||||
/*
|
||||
==================
|
||||
FindOccupiedLeafs
|
||||
|
|
@ -671,6 +692,11 @@ bool FillOutside(tree_t &tree, hull_index_t hullnum, bspbrush_t::container &brus
|
|||
// also write the leak portals to `<bsp_path>.leak.prt`
|
||||
WriteDebugPortals(leakline, "leak");
|
||||
|
||||
// also write the leafs used in the leak line to <bsp_path>.leak-leaf-volumes.map`
|
||||
if (qbsp_options.debugleak.value()) {
|
||||
WriteLeafVolumes(leakline, "leak-leaf-volumes");
|
||||
}
|
||||
|
||||
/* Get rid of the .prt file since the map has a leak */
|
||||
if (!qbsp_options.keepprt.value()) {
|
||||
fs::path name = qbsp_options.bsp_path;
|
||||
|
|
|
|||
Loading…
Reference in New Issue