From 225a155efdbbd091cda40ffb06ac360ea7a50873 Mon Sep 17 00:00:00 2001 From: Eric Wasylishen Date: Fri, 29 Jul 2016 19:48:28 -0600 Subject: [PATCH] light: fix unwanted phong on everything --- include/light/light.hh | 16 +++++++++++++++- light/light.cc | 2 +- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/include/light/light.hh b/include/light/light.hh index 453c3e07..b59c9bec 100644 --- a/include/light/light.hh +++ b/include/light/light.hh @@ -626,6 +626,9 @@ public: class modelinfo_t { +private: + static constexpr float DEFAULT_PHONG_ANGLE = 89.0f; + public: const dmodel_t *model; float lightmapscale; @@ -637,6 +640,17 @@ public: lockable_vec3_t minlight_color; settingsdict_t settings; + float getResolvedPhongAngle() const { + const float s = phong_angle.floatValue(); + if (s != 0) { + return s; + } + if (phong.boolValue()) { + return DEFAULT_PHONG_ANGLE; + } + return 0; + } + public: modelinfo_t(const dmodel_t *m, float lmscale) : model { m }, @@ -647,7 +661,7 @@ public: shadowself { "shadowself", 0 }, dirt { "dirt", 0 }, phong { "phong", 0 }, - phong_angle { "phong_angle", 89 }, + phong_angle { "phong_angle", 0 }, minlight_exclude { "minlight_exclude", "" }, minlight_color { "minlight_color", 255, 255, 255, vec3_transformer_t::NORMALIZE_COLOR_TO_255 }, settings {{ diff --git a/light/light.cc b/light/light.cc index 564a50b4..f4c07f92 100644 --- a/light/light.cc +++ b/light/light.cc @@ -590,7 +590,7 @@ CalcualateVertexNormals(const bsp2_t *bsp) // support on func_detail/func_group for (int i=0; inummodels; i++) { const modelinfo_t *info = modelinfo.at(i); - const uint8_t phongangle_byte = (uint8_t) qmax(0, qmin(255, (int)rint(info->phong_angle.floatValue()))); + const uint8_t phongangle_byte = (uint8_t) qmax(0, qmin(255, (int)rint(info->getResolvedPhongAngle()))); if (!phongangle_byte) continue;