add chop control to settings

only chop if desired or if hull is -1 or > 0 since those can be chopped without affecting visuals
farewell, shared_lock
fix brush contents issue
This commit is contained in:
Jonathan 2022-08-11 00:27:28 -04:00
parent 129dedb268
commit 0db1e0fc01
4 changed files with 17 additions and 10 deletions

View File

@ -266,6 +266,7 @@ public:
setting_bool noclip{this, "noclip", false, &common_format_group, "don't write clip nodes (Q1-like BSP formats)"};
setting_bool noskip{this, "noskip", false, &debugging_group, "don't remove faces with the 'skip' texture"};
setting_bool nodetail{this, "nodetail", false, &debugging_group, "treat all detail brushes to structural"};
setting_invertible_bool chop{this, "chop", false, &debugging_group, "adjust brushes to remove intersections if possible"};
setting_bool onlyents{this, "onlyents", false, &map_development_group, "only updates .MAP entities"};
setting_bool splitsky{this, "splitsky", false, &debugging_group, "doesn't combine sky faces into one large face"};
setting_bool splitturb{

View File

@ -801,9 +801,9 @@ static std::optional<size_t> SelectSplitPlane(const bspbrush_t::container &brush
constexpr int numpasses = 4;
for (int pass = 0; pass < numpasses; pass++) {
for (auto &brush : brushes) {
if ((pass & 1) && !brush->mapbrush->contents.is_any_detail(qbsp_options.target_game))
if ((pass & 1) && !brush->contents.is_any_detail(qbsp_options.target_game))
continue;
if (!(pass & 1) && brush->mapbrush->contents.is_any_detail(qbsp_options.target_game))
if (!(pass & 1) && brush->contents.is_any_detail(qbsp_options.target_game))
continue;
for (auto &side : brush->sides) {
if (side.bevel)
@ -1165,11 +1165,11 @@ Returns true if b1 is allowed to bite b2
inline bool BrushGE(const bspbrush_t &b1, const bspbrush_t &b2)
{
// detail brushes never bite structural brushes
if ((b1.mapbrush->contents.is_any_detail(qbsp_options.target_game))
&& !(b2.mapbrush->contents.is_any_detail(qbsp_options.target_game))) {
if ((b1.contents.is_any_detail(qbsp_options.target_game))
&& !(b2.contents.is_any_detail(qbsp_options.target_game))) {
return false;
}
if (b1.mapbrush->contents.is_solid(qbsp_options.target_game)) {
if (b1.contents.is_any_solid(qbsp_options.target_game)) {
return true;
}
return false;
@ -1370,5 +1370,5 @@ newlist:
brushes.insert(brushes.begin(), std::make_move_iterator(list.begin()), std::make_move_iterator(list.end()));
logging::print(logging::flag::STAT, "chopped {} brushes into {}\n", original_count, brushes.size());
//WriteBspBrushMap("test.map", brushes);
//WriteBspBrushMap("chopped.map", brushes);
}

View File

@ -42,7 +42,6 @@
#include <common/qvec.hh>
mapdata_t map;
std::shared_mutex map_planes_lock;
const std::optional<img::texture_meta> &mapdata_t::load_image_meta(const std::string_view &name)
{
@ -2805,8 +2804,6 @@ from q3map
*/
void WriteBspBrushMap(const fs::path &name, const bspbrush_t::container &list)
{
std::shared_lock lock(map_planes_lock);
logging::print("writing {}\n", name);
std::ofstream f(name);
@ -2839,6 +2836,8 @@ void WriteBspBrushMap(const fs::path &name, const bspbrush_t::container &list)
}
fmt::print(f, "}}\n");
f.close();
}
/*

View File

@ -272,6 +272,10 @@ void qbsp_settings::postinitialize(int argc, const char **argv)
if (!software.value() && !subdivide.isChanged()) {
subdivide.setValue(496, settings::source::GAME_TARGET);
}
if (!qbsp_options.chop.isChanged()) {
qbsp_options.chop.setValue(true, settings::source::GAME_TARGET);
}
}
// load texture defs
@ -456,7 +460,10 @@ static void ProcessEntity(mapentity_t *entity, const int hullnum)
logging::print(logging::flag::STAT, "INFO: calculating BSP for {} brushes with {} sides\n", brushes.size(), num_sides);
ChopBrushes(brushes);
// always chop the other hulls
if (qbsp_options.chop.value() || hullnum != 0) {
ChopBrushes(brushes);
}
// we're discarding the brush
if (discarded_trigger) {