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:
parent
00485553f3
commit
2264de71a2
|
|
@ -420,23 +420,23 @@ template<size_t N, class T>
|
||||||
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)
|
[[nodiscard]] inline qvec<T, N> normalize(const qvec<T, N> &v1, T &len)
|
||||||
{
|
{
|
||||||
len = length2(v1);
|
len = length(v1);
|
||||||
return len ? (v1 * (1.0 / std::sqrt(len))) : v1;
|
return len ? (v1 / len) : v1;
|
||||||
}
|
}
|
||||||
|
|
||||||
template<size_t N, class T>
|
template<size_t N, class T>
|
||||||
[[nodiscard]] inline qvec<T, N> normalize(const qvec<T, N> &v1)
|
[[nodiscard]] inline qvec<T, N> normalize(const qvec<T, N> &v1)
|
||||||
{
|
{
|
||||||
T len = length2(v1);
|
T len = length(v1);
|
||||||
return len ? (v1 * (1.0 / std::sqrt(len))) : v1;
|
return len ? (v1 / len) : v1;
|
||||||
}
|
}
|
||||||
|
|
||||||
template<size_t N, class T>
|
template<size_t N, class T>
|
||||||
inline T normalizeInPlace(qvec<T, N> &v1)
|
inline T normalizeInPlace(qvec<T, N> &v1)
|
||||||
{
|
{
|
||||||
T len = length2(v1);
|
T len = length(v1);
|
||||||
if (len) {
|
if (len) {
|
||||||
v1 *= (1.0 / std::sqrt(len));
|
v1 /= len;
|
||||||
}
|
}
|
||||||
return len;
|
return len;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue