From f7c0c80a264da9c4841ab27f729599cdee06ecb8 Mon Sep 17 00:00:00 2001 From: Eric Wasylishen Date: Sat, 25 Sep 2021 13:11:15 -0600 Subject: [PATCH] qbsp, light: allow _minlight to go up to 510 instead of 255 on func_detail/etc. --- include/common/bspfile.hh | 6 +++++- light/ltface.cc | 2 +- qbsp/map.cc | 2 +- 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/include/common/bspfile.hh b/include/common/bspfile.hh index b2ad9aad..78c29ba3 100644 --- a/include/common/bspfile.hh +++ b/include/common/bspfile.hh @@ -457,10 +457,14 @@ struct surfflags_t { // if non zero, enables phong shading and gives the angle threshold to use uint8_t phong_angle; - // minlight value for this face + // minlight value for this face, multiplied by 0.5, so we can store overbrights in 8 bits + // FIXME: skip the compression and just store a float? serialize all of these to a JSON .texinfo + // for better extensibility? uint8_t minlight; // red minlight colors for this face + // FIXME: this probably makes it illegal to memcpy() from a surfflags_t, which is done in + // WriteExtendedTexinfoFlags. Again, points to switching to JSON serialization. std::array minlight_color; // if non zero, overrides _phong_angle for concave joints diff --git a/light/ltface.cc b/light/ltface.cc index 8cba774f..4a2ef9fa 100644 --- a/light/ltface.cc +++ b/light/ltface.cc @@ -781,7 +781,7 @@ Lightsurf_Init(const modelinfo_t *modelinfo, const bsp2_dface_t *face, if (modelinfo->minlight.isChanged()) { lightsurf->minlight = modelinfo->minlight.floatValue(); } else { - lightsurf->minlight = extended_flags.minlight; + lightsurf->minlight = (float)extended_flags.minlight * 2; // see SurfFlagsForEntity } // minlight_color diff --git a/qbsp/map.cc b/qbsp/map.cc index 75d7247d..252dae4e 100644 --- a/qbsp/map.cc +++ b/qbsp/map.cc @@ -450,7 +450,7 @@ SurfFlagsForEntity(const mtexinfo_t &texinfo, const mapentity_t *entity) // handle "_minlight" const vec_t minlight = atof(ValueForKey(entity, "_minlight")); if (minlight > 0) { - flags.minlight = qclamp((int)rint(minlight), 0, 255); + flags.minlight = qclamp((int)rint(minlight), 0, 510) / 2; // map 0..510 to 0..255, so we can handle overbright } // handle "_mincolor"