From 989788cf71bf9d4389c4cf4da33a86d58407f05e Mon Sep 17 00:00:00 2001 From: Jonathan Date: Tue, 19 Jul 2022 08:41:59 -0400 Subject: [PATCH] add a switch to optimize compiles for no software mode (mainly for Q2) fix tjunc 3 vert faces being destroyed --- include/qbsp/qbsp.hh | 2 ++ qbsp/faces.cc | 4 ---- qbsp/qbsp.cc | 12 ++++++++---- qbsp/tjunc.cc | 7 +++++++ 4 files changed, 17 insertions(+), 8 deletions(-) diff --git a/include/qbsp/qbsp.hh b/include/qbsp/qbsp.hh index 5ff480f4..64e78f9c 100644 --- a/include/qbsp/qbsp.hh +++ b/include/qbsp/qbsp.hh @@ -200,6 +200,8 @@ public: setting_bool bsp2{this, "bsp2", false, &game_target_group, "target Quake's extended BSP2 format"}; setting_bool bsp2rmq{ this, "2psb", false, &game_target_group, "target Quake's extended 2PSB format (RMQ compatible)"}; + setting_func nosubdivide{this, "nosubdivide", [&](source src) { subdivide.setValue(0, src); }, &common_format_group, "disable subdivision"}; + setting_invertible_bool software{this, "software", true, &common_format_group, "change settings to allow for (or make adjustments to optimize for the lack of) software support"}; setting_int32 subdivide{this, "subdivide", 240, &common_format_group, "change the subdivide threshold, in luxels. 0 will disable subdivision entirely"}; setting_bool nofill{this, "nofill", false, &debugging_group, "don't perform outside filling"}; diff --git a/qbsp/faces.cc b/qbsp/faces.cc index 6b9cd407..ed585cb2 100644 --- a/qbsp/faces.cc +++ b/qbsp/faces.cc @@ -494,10 +494,6 @@ static std::unique_ptr FaceFromPortal(portal_t *p, int pside) qbsp_options.target_game->directional_visible_contents(p->nodes[pside]->contents, p->nodes[!pside]->contents); if (!make_face) { // content type / game rules requested to skip generating a face on this side - // todo-brushbsp: remove when appropriate - logging::print("skipped face for {} -> {} portal\n", - p->nodes[pside]->contents.to_string(qbsp_options.target_game), - p->nodes[!pside]->contents.to_string(qbsp_options.target_game)); return nullptr; } diff --git a/qbsp/qbsp.cc b/qbsp/qbsp.cc index b3a28de2..decd2e0c 100644 --- a/qbsp/qbsp.cc +++ b/qbsp/qbsp.cc @@ -236,13 +236,13 @@ void qbsp_settings::postinitialize(int argc, const char **argv) // side effects from q2rtx if (q2rtx.value()) { - if (!subdivide.isChanged()) { - subdivide.setValue(0, settings::source::GAME_TARGET); - } - if (!includeskip.isChanged()) { includeskip.setValue(true, settings::source::GAME_TARGET); } + + if (!software.isChanged()) { + software.setValue(false, settings::source::GAME_TARGET); + } } // side effects from Quake II @@ -250,6 +250,10 @@ void qbsp_settings::postinitialize(int argc, const char **argv) if (!maxedges.isChanged()) { maxedges.setValue(0, settings::source::GAME_TARGET); } + + if (!software.value() && !subdivide.isChanged()) { + subdivide.setValue(0, settings::source::GAME_TARGET); + } } // load texture defs diff --git a/qbsp/tjunc.cc b/qbsp/tjunc.cc index 1b1a3bbd..caa844fd 100644 --- a/qbsp/tjunc.cc +++ b/qbsp/tjunc.cc @@ -507,6 +507,7 @@ static void FixFaceEdges(node_t *headnode, face_t *f, tjunc_stats_t &stats) return; } else if (superface.size() == 3) { // no need to adjust this either + f->fragments.emplace_back(face_fragment_t { f->original_vertices }); return; } @@ -591,7 +592,9 @@ static void FixFaceEdges(node_t *headnode, face_t *f, tjunc_stats_t &stats) // split giant superfaces into subfaces if we have an edge limit. if (qbsp_options.maxedges.value()) { for (auto &face : faces) { + Q_assert(face.size() >= 3); SplitFaceIntoFragments(face, faces, stats); + Q_assert(face.size() >= 3); } } @@ -601,6 +604,10 @@ static void FixFaceEdges(node_t *headnode, face_t *f, tjunc_stats_t &stats) for (auto &face : faces) { f->fragments.emplace_back(face_fragment_t { std::move(face) }); } + + for (auto &frag : f->fragments) { + Q_assert(frag.output_vertices.size() >= 3); + } } #include