From b205127e81b97d5863587cea3628598996282903 Mon Sep 17 00:00:00 2001 From: Jonathan Date: Mon, 27 Sep 2021 21:03:24 -0400 Subject: [PATCH] Fix exactEmpty Simplify output_dir --- include/common/qvec.hh | 2 +- light/ltface.cc | 10 ++++++---- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/include/common/qvec.hh b/include/common/qvec.hh index 6083c2fb..55b1a8d3 100644 --- a/include/common/qvec.hh +++ b/include/common/qvec.hh @@ -343,7 +343,7 @@ template bool emptyExact(const qvec &v1) { for (size_t i = 0; i < N; i++) { - if (!v1[i]) + if (v1[i]) return false; } return true; diff --git a/light/ltface.cc b/light/ltface.cc index dd0c85af..236cf9e5 100644 --- a/light/ltface.cc +++ b/light/ltface.cc @@ -3153,9 +3153,11 @@ static void WriteSingleLightmap(const mbsp_t *bsp, const mface_t *face, const li const std::vector output_color = IntegerDownsampleImage(fullres, oversampled_width, oversampled_height, oversample); - const std::vector output_dir = (lux ? IntegerDownsampleImage(LightmapNormalsToGLMVector(lightsurf, lm), - oversampled_width, oversampled_height, oversample) - : std::vector()); // mxd. Skip when lux isn't needed + std::optional> output_dir; + + if (lux) { + output_dir = IntegerDownsampleImage(LightmapNormalsToGLMVector(lightsurf, lm), oversampled_width, oversampled_height, oversample); + } // copy from the float buffers to byte buffers in .bsp / .lit / .lux @@ -3185,7 +3187,7 @@ static void WriteSingleLightmap(const mbsp_t *bsp, const mface_t *face, const li if (lux) { vec3_t temp; int v; - const qvec4f &direction = output_dir.at(sampleindex); + const qvec4f &direction = output_dir->at(sampleindex); temp[0] = qv::dot(qvec3f(direction), qvec3f(lightsurf->snormal)); temp[1] = qv::dot(qvec3f(direction), qvec3f(lightsurf->tnormal)); temp[2] = qv::dot(qvec3f(direction), qvec3f(lightsurf->plane.normal));