From a0e98242a4c1913878196f2b28787d5231766d01 Mon Sep 17 00:00:00 2001 From: Jonathan Date: Mon, 3 Apr 2023 05:26:41 -0400 Subject: [PATCH] fix hintskip; when loading a hint brush, mark all other sides as hintskip --- include/common/bspfile.hh | 6 +++--- light/light.cc | 3 +++ qbsp/map.cc | 22 ++++++++++++++++++++++ 3 files changed, 28 insertions(+), 3 deletions(-) diff --git a/include/common/bspfile.hh b/include/common/bspfile.hh index 79682897..06baf4d7 100644 --- a/include/common/bspfile.hh +++ b/include/common/bspfile.hh @@ -161,12 +161,12 @@ struct surfflags_t // an invisible surface (Q1 "skip" texture, Q2 SURF_NODRAW) bool is_nodraw; - // completely ignore, allowing non-closed brushes (Q2 SURF_SKIP) - bool is_hintskip; - // hint surface bool is_hint; + // is a skip surface from a hint brush + bool is_hintskip; + // don't receive dirtmapping bool no_dirt; diff --git a/light/light.cc b/light/light.cc index f2159360..0d1927d0 100644 --- a/light/light.cc +++ b/light/light.cc @@ -1092,6 +1092,9 @@ static void LoadExtendedTexinfoFlags(const fs::path &sourcefilename, const mbsp_ if (val.contains("is_hint")) { flags.is_hint = val.at("is_hint").get(); } + if (val.contains("is_hintskip")) { + flags.is_hintskip = val.at("is_hintskip").get(); + } if (val.contains("no_dirt")) { flags.no_dirt = val.at("no_dirt").get(); } diff --git a/qbsp/map.cc b/qbsp/map.cc index 98163e2d..526b0b94 100644 --- a/qbsp/map.cc +++ b/qbsp/map.cc @@ -2409,6 +2409,8 @@ static mapbrush_t ParseBrush(parser_t &parser, mapentity_t &entity, texture_def_ } // ericw -- end brush primitives + bool is_hint = false; + while (parser.parse_token()) { // set linenum after first parsed token @@ -2444,10 +2446,30 @@ static mapbrush_t ParseBrush(parser_t &parser, mapentity_t &entity, texture_def_ continue; } + if (face->get_texinfo().flags.is_hint) { + is_hint = true; + } + /* Save the face, update progress */ brush.faces.emplace_back(std::move(face.value())); } + // mark hintskip faces + if (is_hint) { + int32_t num_hintskip = 0; + + for (auto &face : brush.faces) { + if (qbsp_options.target_game->texinfo_is_hintskip(face.get_texinfo().flags, map.miptexTextureName(face.get_texinfo().miptex))) { + auto copy = face.get_texinfo(); + copy.flags.is_hintskip = true; + face.texinfo = FindTexinfo(copy); + num_hintskip++; + } + } + + //logging::print("{}: {} hintskip faces\n", parser.location, num_hintskip); + } + // ericw -- brush primitives - there should be another closing } if (brush.format == brushformat_t::BRUSH_PRIMITIVES) { if (!parser.parse_token())