From 27996d16d9269925863cb11cb25ce5640fdf6fb1 Mon Sep 17 00:00:00 2001 From: SirLynix Date: Sun, 19 Mar 2023 12:06:29 +0100 Subject: [PATCH] Math/Quaternion: Fix RotationBetween with non-normalized vecs --- include/Nazara/Math/Quaternion.inl | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/include/Nazara/Math/Quaternion.inl b/include/Nazara/Math/Quaternion.inl index af2835d5d..3ce61972b 100644 --- a/include/Nazara/Math/Quaternion.inl +++ b/include/Nazara/Math/Quaternion.inl @@ -288,8 +288,9 @@ namespace Nz } else { + T norm = std::sqrt(from.GetSquaredLength() * to.GetSquaredLength()); Vector3 crossProduct = from.CrossProduct(to); - Set(T(1) + dot, crossProduct.x, crossProduct.y, crossProduct.z); + Set(norm + dot, crossProduct.x, crossProduct.y, crossProduct.z); return Normalize(); } }