From 2290f05dcb698cbede085807091c365d99c462eb Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Mon, 7 Nov 2022 10:36:34 +0100 Subject: [PATCH] Revert "- Use `std::fma()` in the interpolation code." This reverts commit ff7e0afa6fdbb93f1c8ac5ab465a40e85b8edd41. On Visual Studio with precise math, which is our main target this generates a very expensive function call instead of optimized assembly which renders the function's purpose ad absurdum. --- source/common/utility/vectors.h | 24 ++++++------------------ 1 file changed, 6 insertions(+), 18 deletions(-) diff --git a/source/common/utility/vectors.h b/source/common/utility/vectors.h index 5f619923a..019eb9db1 100644 --- a/source/common/utility/vectors.h +++ b/source/common/utility/vectors.h @@ -41,7 +41,7 @@ #define VECTORS_H #include -#include +#include #include #include #include "xs_Float.h" @@ -1548,27 +1548,15 @@ inline TVector2 clamp(const TVector2 &vec, const TVector2 &min, const T } template -inline T interpolatedvalue(const T oval, const T val, const double interpfrac) +inline TAngle interpolatedvalue(const TAngle &oang, const TAngle &ang, const double interpfrac) { - return std::fma(interpfrac, val, std::fma(-interpfrac, oval, oval)); + return oang + (deltaangle(oang, ang) * interpfrac); } -template -inline TVector2 interpolatedvalue(const TVector2& oval, const TVector2& val, const double interpfrac) +template +inline T interpolatedvalue(const T& oval, const T& val, const double interpfrac) { - return { interpolatedvalue(oval.X, val.X, interpfrac), interpolatedvalue(oval.Y, val.Y, interpfrac) }; -} - -template -inline TVector3 interpolatedvalue(const TVector3& oval, const TVector3& val, const double interpfrac) -{ - return { interpolatedvalue(oval.X, val.X, interpfrac), interpolatedvalue(oval.Y, val.Y, interpfrac), interpolatedvalue(oval.Z, val.Z, interpfrac) }; -} - -template -inline TAngle interpolatedvalue(const TAngle oang, const TAngle ang, const double interpfrac) -{ - return TAngle::fromDeg(interpolatedvalue(oang.Degrees(), (oang + deltaangle(oang, ang)).Degrees(), interpfrac)); + return T(oval + (val - oval) * interpfrac); } // Much of this is copied from TVector3. Is all that functionality really appropriate?