From f66e4790a4a7ca304e18dd0ac8b39a5c8d799c3b Mon Sep 17 00:00:00 2001 From: Eric Wasylishen Date: Thu, 1 Dec 2022 01:16:17 -0700 Subject: [PATCH] qbsp/light: add no_phong texinfo flag (currently not used/exposed) --- common/bspfile.cc | 4 ++-- include/common/bspfile.hh | 3 +++ light/light.cc | 3 +++ light/phong.cc | 6 ++++++ qbsp/writebsp.cc | 3 +++ 5 files changed, 17 insertions(+), 2 deletions(-) diff --git a/common/bspfile.cc b/common/bspfile.cc index f417b518..d5488efe 100644 --- a/common/bspfile.cc +++ b/common/bspfile.cc @@ -1724,14 +1724,14 @@ const bspversion_t bspver_qbism{Q2_QBISMIDENT, Q2_BSPVERSION, "qbism", "Quake II bool surfflags_t::needs_write() const { - return no_dirt || no_shadow || no_bounce || no_minlight || no_expand || light_ignore || !surflight_rescale || phong_angle || + return no_dirt || no_shadow || no_bounce || no_minlight || no_expand || no_phong || light_ignore || !surflight_rescale || phong_angle || phong_angle_concave || phong_group || minlight || !qv::emptyExact(minlight_color) || light_alpha || maxlight || lightcolorscale != 1.0; } static auto as_tuple(const surfflags_t &flags) { return std::tie(flags.native, flags.is_nodraw, flags.is_hintskip, flags.is_hint, flags.no_dirt, flags.no_shadow, flags.no_bounce, flags.no_minlight, flags.no_expand, - flags.light_ignore, flags.surflight_rescale, flags.phong_angle, flags.phong_angle_concave, flags.phong_group, flags.minlight, flags.minlight_color, flags.light_alpha, flags.maxlight, flags.lightcolorscale); + flags.no_phong, flags.light_ignore, flags.surflight_rescale, flags.phong_angle, flags.phong_angle_concave, flags.phong_group, flags.minlight, flags.minlight_color, flags.light_alpha, flags.maxlight, flags.lightcolorscale); } bool surfflags_t::operator<(const surfflags_t &other) const diff --git a/include/common/bspfile.hh b/include/common/bspfile.hh index f1eaf7a6..5a737a8b 100644 --- a/include/common/bspfile.hh +++ b/include/common/bspfile.hh @@ -182,6 +182,9 @@ struct surfflags_t // don't expand this face for larger clip hulls bool no_expand; + // block any way phong can be enabled + bool no_phong; + // this face doesn't receive light bool light_ignore; diff --git a/light/light.cc b/light/light.cc index 23732a21..d16f0f75 100644 --- a/light/light.cc +++ b/light/light.cc @@ -1080,6 +1080,9 @@ static void LoadExtendedTexinfoFlags(const fs::path &sourcefilename, const mbsp_ if (val.contains("no_expand")) { flags.no_expand = val.at("no_expand").get(); } + if (val.contains("no_phong")) { + flags.no_expand = val.at("no_phong").get(); + } if (val.contains("light_ignore")) { flags.light_ignore = val.at("light_ignore").get(); } diff --git a/light/phong.cc b/light/phong.cc index f70ae4c4..dc9ac313 100644 --- a/light/phong.cc +++ b/light/phong.cc @@ -480,6 +480,9 @@ void CalculateVertexNormals(const mbsp_t *bsp) if (!f_wants_phong) continue; + if (extended_texinfo_flags[f.texinfo].no_phong) + continue; + for (int j = 0; j < f.numedges; j++) { const int v = Face_VertexAtIndex(bsp, &f, j); // walk over all faces incident to f (we will walk over neighbours multiple times, doesn't matter) @@ -503,6 +506,9 @@ void CalculateVertexNormals(const mbsp_t *bsp) if (!f2_wants_phong) continue; + if (extended_texinfo_flags[f2->texinfo].no_phong) + continue; + auto *f2_texinfo = Face_Texinfo(bsp, f2); if (f2_texinfo != nullptr && f_texinfo != nullptr) { if (!bsp->loadversion->game->surfflags_may_phong(f_texinfo->flags, f2_texinfo->flags)) { diff --git a/qbsp/writebsp.cc b/qbsp/writebsp.cc index f1181b46..f70517ea 100644 --- a/qbsp/writebsp.cc +++ b/qbsp/writebsp.cc @@ -365,6 +365,9 @@ static void WriteExtendedTexinfoFlags(void) if (tx.flags.no_expand) { t["no_expand"] = tx.flags.no_expand; } + if (tx.flags.no_phong) { + t["no_phong"] = tx.flags.no_phong; + } if (tx.flags.light_ignore) { t["light_ignore"] = tx.flags.light_ignore; }