Revert "very slight speedup (~3% improvement) on normalize; don't sqrt if we don't need to (rare), and use multiplication instead of division"

This reverts commit 8fe525f5b2.
This commit is contained in:
Jonathan 2022-06-26 01:24:47 -04:00
parent 00485553f3
commit 2264de71a2
1 changed files with 6 additions and 6 deletions

View File

@ -420,23 +420,23 @@ template<size_t N, class T>
template<size_t N, class T>
[[nodiscard]] inline qvec<T, N> normalize(const qvec<T, N> &v1, T &len)
{
len = length2(v1);
return len ? (v1 * (1.0 / std::sqrt(len))) : v1;
len = length(v1);
return len ? (v1 / len) : v1;
}
template<size_t N, class T>
[[nodiscard]] inline qvec<T, N> normalize(const qvec<T, N> &v1)
{
T len = length2(v1);
return len ? (v1 * (1.0 / std::sqrt(len))) : v1;
T len = length(v1);
return len ? (v1 / len) : v1;
}
template<size_t N, class T>
inline T normalizeInPlace(qvec<T, N> &v1)
{
T len = length2(v1);
T len = length(v1);
if (len) {
v1 *= (1.0 / std::sqrt(len));
v1 /= len;
}
return len;
}