From 8efb6f689b05c838e4fa044640acc24949f7e5eb Mon Sep 17 00:00:00 2001 From: Eric Wasylishen Date: Wed, 27 Apr 2022 19:18:27 -0600 Subject: [PATCH] qbsp: add -outsidedebug flag --- include/qbsp/map.hh | 2 +- include/qbsp/qbsp.hh | 1 + qbsp/map.cc | 6 +++++- qbsp/outside.cc | 7 +++++++ 4 files changed, 14 insertions(+), 2 deletions(-) diff --git a/include/qbsp/map.hh b/include/qbsp/map.hh index d8c99302..2ee2fcb1 100644 --- a/include/qbsp/map.hh +++ b/include/qbsp/map.hh @@ -242,6 +242,6 @@ void ExportObj_Brushes(const std::string &filesuffix, const std::vector &list); +void WriteBspBrushMap(const fs::path &name, const std::vector &list); bool IsValidTextureProjection(const qvec3f &faceNormal, const qvec3f &s_vec, const qvec3f &t_vec); diff --git a/include/qbsp/qbsp.hh b/include/qbsp/qbsp.hh index 073b4502..ddd61cc2 100644 --- a/include/qbsp/qbsp.hh +++ b/include/qbsp/qbsp.hh @@ -182,6 +182,7 @@ public: setting_bool contenthack{this, "contenthack", false, &debugging_group, "hack to fix leaks through solids. causes missing faces in some cases so disabled by default"}; setting_bool leaktest{this, "leaktest", false, &map_development_group, "make compilation fail if the map leaks"}; + setting_bool outsidedebug{this, "outsidedebug", false, &debugging_group, "write a .map after outside filling showing non-visible brush sides"}; 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/map.cc b/qbsp/map.cc index 9f02afb4..c2f0b48a 100644 --- a/qbsp/map.cc +++ b/qbsp/map.cc @@ -2295,7 +2295,11 @@ void WriteBspBrushMap(const fs::path &name, const std::vector &list) fmt::print(f, "( {} ) ", w[1]); fmt::print(f, "( {} ) ", w[2]); - fmt::print(f, "notexture 0 0 0 1 1\n"); + if (face.visible) { + fmt::print(f, "skip 0 0 0 1 1\n"); + } else { + fmt::print(f, "nonvisible 0 0 0 1 1\n"); + } } fmt::print(f, "}}\n"); diff --git a/qbsp/outside.cc b/qbsp/outside.cc index ac3c7b52..17f23f42 100644 --- a/qbsp/outside.cc +++ b/qbsp/outside.cc @@ -543,6 +543,13 @@ bool FillOutside(mapentity_t *entity, node_t *node, const int hullnum) MarkVisibleBrushSides_R(node); + if (options.outsidedebug.value() && hullnum == 0) { + fs::path path = options.bsp_path; + path.replace_extension(".outside.map"); + + WriteBspBrushMap(path, map.entities[0].brushes); + } + logging::print(logging::flag::STAT, " {:8} outleafs\n", outleafs); return true; }