Revert "- Use std::fma() in the interpolation code."

This reverts commit ff7e0afa6f.

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.
This commit is contained in:
Christoph Oelckers 2022-11-07 10:36:34 +01:00
parent 3444991e4e
commit 2290f05dcb

View file

@ -41,7 +41,7 @@
#define VECTORS_H
#include <cstddef>
#include <cmath>
#include <math.h>
#include <float.h>
#include <string.h>
#include "xs_Float.h"
@ -1548,27 +1548,15 @@ inline TVector2<T> clamp(const TVector2<T> &vec, const TVector2<T> &min, const T
}
template<class T>
inline T interpolatedvalue(const T oval, const T val, const double interpfrac)
inline TAngle<T> interpolatedvalue(const TAngle<T> &oang, const TAngle<T> &ang, const double interpfrac)
{
return std::fma(interpfrac, val, std::fma(-interpfrac, oval, oval));
return oang + (deltaangle(oang, ang) * interpfrac);
}
template<class T>
inline TVector2<T> interpolatedvalue(const TVector2<T>& oval, const TVector2<T>& val, const double interpfrac)
template <class T>
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<class T>
inline TVector3<T> interpolatedvalue(const TVector3<T>& oval, const TVector3<T>& val, const double interpfrac)
{
return { interpolatedvalue(oval.X, val.X, interpfrac), interpolatedvalue(oval.Y, val.Y, interpfrac), interpolatedvalue(oval.Z, val.Z, interpfrac) };
}
template<class T>
inline TAngle<T> interpolatedvalue(const TAngle<T> oang, const TAngle<T> ang, const double interpfrac)
{
return TAngle<T>::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?