From 6dc27e7948c12c44cd05d23fffba6c12f2565a65 Mon Sep 17 00:00:00 2001 From: SirLynix Date: Sat, 23 Dec 2023 13:37:22 +0100 Subject: [PATCH] Math/Angle: Fix Normalization range ([0;360] => [-180;180]) --- include/Nazara/Math/Angle.inl | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/include/Nazara/Math/Angle.inl b/include/Nazara/Math/Angle.inl index ee405c6a5..d7ec7cb94 100644 --- a/include/Nazara/Math/Angle.inl +++ b/include/Nazara/Math/Angle.inl @@ -2,6 +2,7 @@ // This file is part of the "Nazara Engine - Math module" // For conditions of distribution and use, see copyright notice in Config.hpp +#include #include #include #include @@ -285,11 +286,13 @@ namespace Nz constexpr Angle& Angle::Normalize() { constexpr T limit = Detail::AngleUtils::template GetLimit(); + constexpr T halfLimit = limit / T(2); - value = std::fmod(value, limit); + value = Nz::Mod(value + halfLimit, limit); if (value < T(0)) value += limit; + value -= halfLimit; return *this; }