diff options
-rw-r--r-- | alc/effects/reverb.cpp | 14 | ||||
-rw-r--r-- | common/math_defs.h | 10 |
2 files changed, 12 insertions, 12 deletions
diff --git a/alc/effects/reverb.cpp b/alc/effects/reverb.cpp index 82a80198..4a85f640 100644 --- a/alc/effects/reverb.cpp +++ b/alc/effects/reverb.cpp @@ -844,6 +844,8 @@ void ReverbState::updateDelayLine(const ALfloat earlyDelay, const ALfloat lateDe */ alu::Matrix GetTransformFromVector(const ALfloat *vec) { + constexpr float sqrt_3{1.73205080756887719318f}; + /* Normalize the panning vector according to the N3D scale, which has an * extra sqrt(3) term on the directional components. Converting from OpenAL * to B-Format also requires negating X (ACN 1) and Z (ACN 3). Note however @@ -855,9 +857,9 @@ alu::Matrix GetTransformFromVector(const ALfloat *vec) ALfloat mag{std::sqrt(vec[0]*vec[0] + vec[1]*vec[1] + vec[2]*vec[2])}; if(mag > 1.0f) { - norm[0] = vec[0] / mag * -al::MathDefs<float>::Sqrt3(); - norm[1] = vec[1] / mag * al::MathDefs<float>::Sqrt3(); - norm[2] = vec[2] / mag * al::MathDefs<float>::Sqrt3(); + norm[0] = vec[0] / mag * -sqrt_3; + norm[1] = vec[1] / mag * sqrt_3; + norm[2] = vec[2] / mag * sqrt_3; mag = 1.0f; } else @@ -866,9 +868,9 @@ alu::Matrix GetTransformFromVector(const ALfloat *vec) * term. There's no need to renormalize the magnitude since it would * just be reapplied in the matrix. */ - norm[0] = vec[0] * -al::MathDefs<float>::Sqrt3(); - norm[1] = vec[1] * al::MathDefs<float>::Sqrt3(); - norm[2] = vec[2] * al::MathDefs<float>::Sqrt3(); + norm[0] = vec[0] * -sqrt_3; + norm[1] = vec[1] * sqrt_3; + norm[2] = vec[2] * sqrt_3; } return alu::Matrix{ diff --git a/common/math_defs.h b/common/math_defs.h index 9749bd53..0362a956 100644 --- a/common/math_defs.h +++ b/common/math_defs.h @@ -17,16 +17,14 @@ struct MathDefs { }; template<> struct MathDefs<float> { - static constexpr inline float Pi() noexcept { return 3.14159265358979323846f; } - static constexpr inline float Tau() noexcept { return 3.14159265358979323846f * 2.0f; } - static constexpr inline float Sqrt3() noexcept { return 1.73205080756887719318f; } + static constexpr inline float Pi() noexcept { return static_cast<float>(M_PI); } + static constexpr inline float Tau() noexcept { return static_cast<float>(M_PI * 2.0); } }; template<> struct MathDefs<double> { - static constexpr inline double Pi() noexcept { return 3.14159265358979323846; } - static constexpr inline double Tau() noexcept { return 3.14159265358979323846 * 2.0; } - static constexpr inline double Sqrt3() noexcept { return 1.73205080756887719318; } + static constexpr inline double Pi() noexcept { return M_PI; } + static constexpr inline double Tau() noexcept { return M_PI * 2.0; } }; } // namespace al |