Vectorized
This commit is contained in:
parent
6eba3a9db9
commit
6f6d161afb
@ -2,13 +2,15 @@
|
|||||||
// OpenGL Mathematics Copyright (c) 2005 - 2011 G-Truc Creation (www.g-truc.net)
|
// OpenGL Mathematics Copyright (c) 2005 - 2011 G-Truc Creation (www.g-truc.net)
|
||||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
// Created : 2006-01-04
|
// Created : 2006-01-04
|
||||||
// Updated : 2008-10-07
|
// Updated : 2011-10-14
|
||||||
// Licence : This source is under MIT License
|
// Licence : This source is under MIT License
|
||||||
// File : glm/gtx/fast_square_root.inl
|
// File : glm/gtx/fast_square_root.inl
|
||||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
namespace glm{
|
#include "../core/_vectorize.hpp"
|
||||||
|
|
||||||
|
namespace glm
|
||||||
|
{
|
||||||
// fastSqrt
|
// fastSqrt
|
||||||
template <typename genType>
|
template <typename genType>
|
||||||
GLM_FUNC_QUALIFIER genType fastSqrt
|
GLM_FUNC_QUALIFIER genType fastSqrt
|
||||||
@ -16,44 +18,12 @@ GLM_FUNC_QUALIFIER genType fastSqrt
|
|||||||
genType const & x
|
genType const & x
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
|
GLM_STATIC_ASSERT(detail::type<genType>::is_float, "'fastSqrt' only accept floating-point input");
|
||||||
|
|
||||||
return genType(1) / fastInverseSqrt(x);
|
return genType(1) / fastInverseSqrt(x);
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename valType>
|
VECTORIZE_VEC(fastSqrt)
|
||||||
GLM_FUNC_QUALIFIER detail::tvec2<valType> fastSqrt
|
|
||||||
(
|
|
||||||
detail::tvec2<valType> const & x
|
|
||||||
)
|
|
||||||
{
|
|
||||||
return detail::tvec2<valType>(
|
|
||||||
fastSqrt(x.x),
|
|
||||||
fastSqrt(x.y));
|
|
||||||
}
|
|
||||||
|
|
||||||
template <typename valType>
|
|
||||||
GLM_FUNC_QUALIFIER detail::tvec3<valType> fastSqrt
|
|
||||||
(
|
|
||||||
detail::tvec3<valType> const & x
|
|
||||||
)
|
|
||||||
{
|
|
||||||
return detail::tvec3<valType>(
|
|
||||||
fastSqrt(x.x),
|
|
||||||
fastSqrt(x.y),
|
|
||||||
fastSqrt(x.z));
|
|
||||||
}
|
|
||||||
|
|
||||||
template <typename valType>
|
|
||||||
GLM_FUNC_QUALIFIER detail::tvec4<valType> fastSqrt
|
|
||||||
(
|
|
||||||
detail::tvec4<valType> const & x
|
|
||||||
)
|
|
||||||
{
|
|
||||||
return detail::tvec4<valType>(
|
|
||||||
fastSqrt(x.x),
|
|
||||||
fastSqrt(x.y),
|
|
||||||
fastSqrt(x.z),
|
|
||||||
fastSqrt(x.w));
|
|
||||||
}
|
|
||||||
|
|
||||||
// fastInversesqrt
|
// fastInversesqrt
|
||||||
template <typename genType>
|
template <typename genType>
|
||||||
@ -73,41 +43,7 @@ GLM_FUNC_QUALIFIER genType fastInverseSqrt
|
|||||||
return genType(tmp);
|
return genType(tmp);
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename valType>
|
VECTORIZE_VEC(fastInverseSqrt)
|
||||||
GLM_FUNC_QUALIFIER detail::tvec2<valType> fastInverseSqrt
|
|
||||||
(
|
|
||||||
detail::tvec2<valType> const & x
|
|
||||||
)
|
|
||||||
{
|
|
||||||
return detail::tvec2<valType>(
|
|
||||||
fastInverseSqrt(x.x),
|
|
||||||
fastInverseSqrt(x.y));
|
|
||||||
}
|
|
||||||
|
|
||||||
template <typename valType>
|
|
||||||
GLM_FUNC_QUALIFIER detail::tvec3<valType> fastInverseSqrt
|
|
||||||
(
|
|
||||||
detail::tvec3<valType> const & x
|
|
||||||
)
|
|
||||||
{
|
|
||||||
return detail::tvec3<valType>(
|
|
||||||
fastInverseSqrt(x.x),
|
|
||||||
fastInverseSqrt(x.y),
|
|
||||||
fastInverseSqrt(x.z));
|
|
||||||
}
|
|
||||||
|
|
||||||
template <typename valType>
|
|
||||||
GLM_FUNC_QUALIFIER detail::tvec4<valType> fastInverseSqrt
|
|
||||||
(
|
|
||||||
detail::tvec4<valType> const & x
|
|
||||||
)
|
|
||||||
{
|
|
||||||
return detail::tvec4<valType>(
|
|
||||||
fastInverseSqrt(x.x),
|
|
||||||
fastInverseSqrt(x.y),
|
|
||||||
fastInverseSqrt(x.z),
|
|
||||||
fastInverseSqrt(x.w));
|
|
||||||
}
|
|
||||||
|
|
||||||
// fastLength
|
// fastLength
|
||||||
template <typename genType>
|
template <typename genType>
|
||||||
@ -160,36 +96,6 @@ GLM_FUNC_QUALIFIER genType fastDistance
|
|||||||
return fastLength(y - x);
|
return fastLength(y - x);
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename valType>
|
|
||||||
GLM_FUNC_QUALIFIER valType fastDistance
|
|
||||||
(
|
|
||||||
detail::tvec2<valType> const & x,
|
|
||||||
detail::tvec2<valType> const & y
|
|
||||||
)
|
|
||||||
{
|
|
||||||
return fastLength(y - x);
|
|
||||||
}
|
|
||||||
|
|
||||||
template <typename valType>
|
|
||||||
GLM_FUNC_QUALIFIER valType fastDistance
|
|
||||||
(
|
|
||||||
detail::tvec3<valType> const & x,
|
|
||||||
detail::tvec3<valType> const & y
|
|
||||||
)
|
|
||||||
{
|
|
||||||
return fastLength(y - x);
|
|
||||||
}
|
|
||||||
|
|
||||||
template <typename valType>
|
|
||||||
GLM_FUNC_QUALIFIER valType fastDistance
|
|
||||||
(
|
|
||||||
detail::tvec4<valType> const & x,
|
|
||||||
detail::tvec4<valType> const & y
|
|
||||||
)
|
|
||||||
{
|
|
||||||
return fastLength(y - x);
|
|
||||||
}
|
|
||||||
|
|
||||||
// fastNormalize
|
// fastNormalize
|
||||||
template <typename genType>
|
template <typename genType>
|
||||||
GLM_FUNC_QUALIFIER genType fastNormalize
|
GLM_FUNC_QUALIFIER genType fastNormalize
|
||||||
@ -229,5 +135,4 @@ GLM_FUNC_QUALIFIER detail::tvec4<valType> fastNormalize
|
|||||||
valType sqr = x.x * x.x + x.y * x.y + x.z * x.z + x.w * x.w;
|
valType sqr = x.x * x.x + x.y * x.y + x.z * x.z + x.w * x.w;
|
||||||
return x * fastInverseSqrt(sqr);
|
return x * fastInverseSqrt(sqr);
|
||||||
}
|
}
|
||||||
|
|
||||||
}//namespace glm
|
}//namespace glm
|
||||||
|
Loading…
x
Reference in New Issue
Block a user