From fe31e1c1cedbe9ca08c105d5695287ea57e12e0e Mon Sep 17 00:00:00 2001 From: Eric Wasylishen Date: Sun, 5 Jun 2022 23:24:02 -0600 Subject: [PATCH] bsputil: add --decompile-ignore-brushes option for visualizing leafs in q2 maps --- bsputil/bsputil.cc | 4 +++- bsputil/decompile.cpp | 2 +- bsputil/decompile.h | 5 +++++ 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/bsputil/bsputil.cc b/bsputil/bsputil.cc index 2b7f2998..ac4ab030 100644 --- a/bsputil/bsputil.cc +++ b/bsputil/bsputil.cc @@ -617,8 +617,9 @@ int main(int argc, char **argv) WriteBSPFile(source, &bspdata); return 0; - } else if (!strcmp(argv[i], "--decompile") || !strcmp(argv[i], "--decompile-geomonly")) { + } else if (!strcmp(argv[i], "--decompile") || !strcmp(argv[i], "--decompile-geomonly") || !strcmp(argv[i], "--decompile-ignore-brushes")) { const bool geomOnly = !strcmp(argv[i], "--decompile-geomonly"); + const bool ignoreBrushes = !strcmp(argv[i], "--decompile-ignore-brushes"); source.replace_extension(""); source.replace_filename(source.stem().string() + "-decompile"); @@ -632,6 +633,7 @@ int main(int argc, char **argv) decomp_options options; options.geometryOnly = geomOnly; + options.ignoreBrushes = ignoreBrushes; DecompileBSP(&bsp, options, f); diff --git a/bsputil/decompile.cpp b/bsputil/decompile.cpp index 0088913e..049b4128 100644 --- a/bsputil/decompile.cpp +++ b/bsputil/decompile.cpp @@ -1053,7 +1053,7 @@ static void DecompileEntity( // If we have brush info, we'll use that directly // TODO: support BSPX brushes too - if (bsp->loadversion->game->id == GAME_QUAKE_II) { + if (bsp->loadversion->game->id == GAME_QUAKE_II && !options.ignoreBrushes) { std::unordered_map brushes; auto handle_leaf = [&brushes, bsp, model](const mleaf_t *leaf) { diff --git a/bsputil/decompile.h b/bsputil/decompile.h index a2bec388..777df663 100644 --- a/bsputil/decompile.h +++ b/bsputil/decompile.h @@ -14,6 +14,11 @@ struct decomp_options * For debugging (there's not much that can go wrong). */ bool geometryOnly = false; + /** + * If true, don't use brushes in Q2 .bsp's and instead decompile the leafs. + * Intended for visualizing leafs. + */ + bool ignoreBrushes = false; }; void DecompileBSP(const mbsp_t *bsp, const decomp_options &options, std::ofstream &file);