From 4fa745af850bf9ec644b0148071ef22c2e62fc22 Mon Sep 17 00:00:00 2001 From: Kawe Mazidjatari <48657826+Mauler125@users.noreply.github.com> Date: Sun, 25 Feb 2024 23:41:38 +0100 Subject: [PATCH] Mathlib: enable SIMD quaternions Should match output code with the code in the game executable, as that has been compiled with SIMD enabled. --- r5dev/mathlib/CMakeLists.txt | 1 + r5dev/mathlib/ssequaternion.h | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/r5dev/mathlib/CMakeLists.txt b/r5dev/mathlib/CMakeLists.txt index 092c68ef..027e689a 100644 --- a/r5dev/mathlib/CMakeLists.txt +++ b/r5dev/mathlib/CMakeLists.txt @@ -62,5 +62,6 @@ target_precompile_headers( ${PROJECT_NAME} PRIVATE ) target_compile_definitions( ${PROJECT_NAME} PRIVATE "BUILDING_MATHLIB" + "ALLOW_SIMD_QUATERNION_MATH" $<$,$>:DEBUG_MATHLIB> ) diff --git a/r5dev/mathlib/ssequaternion.h b/r5dev/mathlib/ssequaternion.h index 5cb9bc33..5c024cbe 100644 --- a/r5dev/mathlib/ssequaternion.h +++ b/r5dev/mathlib/ssequaternion.h @@ -421,8 +421,8 @@ FORCEINLINE fltx4 QuaternionSlerpNoAlignSIMD(const fltx4& p, const fltx4& q, flo SubFloat(result, 1) = SubFloat(q, 0); SubFloat(result, 2) = -SubFloat(q, 3); SubFloat(result, 3) = SubFloat(q, 2); - sclp = sin((1.0f - t) * (0.5f * M_PI)); - sclq = sin(t * (0.5f * M_PI)); + sclp = (float)sin((1.0f - t) * (0.5f * M_PI)); + sclq = (float)sin(t * (0.5f * M_PI)); SubFloat(result, 0) = sclp * SubFloat(p, 0) + sclq * SubFloat(result, 0); SubFloat(result, 1) = sclp * SubFloat(p, 1) + sclq * SubFloat(result, 1); SubFloat(result, 2) = sclp * SubFloat(p, 2) + sclq * SubFloat(result, 2);