Merge branch '0.9.3' into swizzle

master
Christophe Riccio ago%!(EXTRA string=14 years)
commit dc7d8f5c0c
  1. 159
      glm/core/_vectorize.hpp
  2. 513
      glm/core/func_common.inl
  3. 260
      glm/core/func_exponential.inl
  4. 2
      glm/core/func_geometric.inl
  5. 37
      glm/core/func_integer.inl
  6. 2
      glm/core/func_matrix.inl
  7. 75
      glm/core/func_packing.inl
  8. 783
      glm/core/func_trigonometric.inl
  9. 904
      glm/gtc/half_float.inl
  10. 54
      glm/gtc/matrix_access.inl
  11. 71
      glm/gtc/matrix_inverse.inl
  12. 209
      glm/gtc/matrix_transform.inl
  13. 157
      glm/gtc/noise.inl
  14. 4
      glm/gtc/quaternion.inl
  15. 212
      glm/gtc/random.inl
  16. 174
      glm/gtc/swizzle.inl
  17. 253
      glm/gtx/fast_square_root.inl

@ -0,0 +1,159 @@
///////////////////////////////////////////////////////////////////////////////////
/// OpenGL Mathematics (glm.g-truc.net)
///
/// Copyright (c) 2005 - 2011 G-Truc Creation (www.g-truc.net)
/// Permission is hereby granted, free of charge, to any person obtaining a copy
/// of this software and associated documentation files (the "Software"), to deal
/// in the Software without restriction, including without limitation the rights
/// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
/// copies of the Software, and to permit persons to whom the Software is
/// furnished to do so, subject to the following conditions:
///
/// The above copyright notice and this permission notice shall be included in
/// all copies or substantial portions of the Software.
///
/// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
/// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
/// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
/// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
/// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
/// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
/// THE SOFTWARE.
///
/// @ref core
/// @file glm/core/_vectorize.hpp
/// @date 2011-10-14 / 2011-10-14
/// @author Christophe Riccio
///////////////////////////////////////////////////////////////////////////////////
#define VECTORIZE2_VEC(func) \
template <typename T> \
GLM_FUNC_QUALIFIER detail::tvec2<T> func( \
detail::tvec2<T> const & v) \
{ \
return detail::tvec2<T>( \
func(v.x), \
func(v.y)); \
}
#define VECTORIZE3_VEC(func) \
template <typename T> \
GLM_FUNC_QUALIFIER detail::tvec3<T> func( \
detail::tvec3<T> const & v) \
{ \
return detail::tvec3<T>( \
func(v.x), \
func(v.y), \
func(v.z)); \
}
#define VECTORIZE4_VEC(func) \
template <typename T> \
GLM_FUNC_QUALIFIER detail::tvec4<T> func( \
detail::tvec4<T> const & v) \
{ \
return detail::tvec4<T>( \
func(v.x), \
func(v.y), \
func(v.z), \
func(v.w)); \
}
#define VECTORIZE_VEC(func) \
VECTORIZE2_VEC(func) \
VECTORIZE3_VEC(func) \
VECTORIZE4_VEC(func)
#define VECTORIZE2_VEC_SCA(func) \
template <typename T> \
GLM_FUNC_QUALIFIER detail::tvec2<T> func \
( \
detail::tvec2<T> const & x, \
typename detail::tvec2<T>::value_type const & y \
) \
{ \
return detail::tvec2<T>( \
func(x.x, y), \
func(x.y, y)); \
}
#define VECTORIZE3_VEC_SCA(func) \
template <typename T> \
GLM_FUNC_QUALIFIER detail::tvec3<T> func \
( \
detail::tvec3<T> const & x, \
typename detail::tvec3<T>::value_type const & y \
) \
{ \
return detail::tvec3<T>( \
func(x.x, y), \
func(x.y, y), \
func(x.z, y)); \
}
#define VECTORIZE4_VEC_SCA(func) \
template <typename T> \
GLM_FUNC_QUALIFIER detail::tvec4<T> func \
( \
detail::tvec4<T> const & x, \
typename detail::tvec4<T>::value_type const & y \
) \
{ \
return detail::tvec4<T>( \
func(x.x, y), \
func(x.y, y), \
func(x.z, y), \
func(x.w, y)); \
}
#define VECTORIZE_VEC_SCA(func) \
VECTORIZE2_VEC_SCA(func) \
VECTORIZE3_VEC_SCA(func) \
VECTORIZE4_VEC_SCA(func)
#define VECTORIZE2_VEC_VEC(func) \
template <typename T> \
GLM_FUNC_QUALIFIER detail::tvec2<T> func \
( \
detail::tvec2<T> const & x, \
detail::tvec2<T> const & y \
) \
{ \
return detail::tvec2<T>( \
func(x.x, y.x), \
func(x.y, y.y)); \
}
#define VECTORIZE3_VEC_VEC(func) \
template <typename T> \
GLM_FUNC_QUALIFIER detail::tvec3<T> func \
( \
detail::tvec3<T> const & x, \
detail::tvec3<T> const & y \
) \
{ \
return detail::tvec3<T>( \
func(x.x, y.x), \
func(x.y, y.y), \
func(x.z, y.z)); \
}
#define VECTORIZE4_VEC_VEC(func) \
template <typename T> \
GLM_FUNC_QUALIFIER detail::tvec4<T> func \
( \
detail::tvec4<T> const & x, \
detail::tvec4<T> const & y \
) \
{ \
return detail::tvec4<T>( \
func(x.x, y.x), \
func(x.y, y.y), \
func(x.z, y.z), \
func(x.w, y.w)); \
}
#define VECTORIZE_VEC_VEC(func) \
VECTORIZE2_VEC_VEC(func) \
VECTORIZE3_VEC_VEC(func) \
VECTORIZE4_VEC_VEC(func)

@ -26,6 +26,8 @@
/// @author Christophe Riccio
///////////////////////////////////////////////////////////////////////////////////
#include "_vectorize.hpp"
namespace glm{
namespace detail
{
@ -60,56 +62,23 @@ namespace detail
// abs
template <typename genFIType>
GLM_FUNC_QUALIFIER genFIType abs(
genFIType const & x)
GLM_FUNC_QUALIFIER genFIType abs
(
genFIType const & x
)
{
return detail::Abs_<genFIType, std::numeric_limits<genFIType>::is_signed>::get(x);
}
//template <typename T>
//GLM_FUNC_QUALIFIER detail::tvec1<T> abs(
// detail::tvec1<T> const & v)
//{
// return detail::tvec1<T>(
// abs(v.x));
//}
template <typename T>
GLM_FUNC_QUALIFIER detail::tvec2<T> abs(
detail::tvec2<T> const & v)
{
return detail::tvec2<T>(
abs(v.x),
abs(v.y));
}
template <typename T>
GLM_FUNC_QUALIFIER detail::tvec3<T> abs(
detail::tvec3<T> const & v)
{
return detail::tvec3<T>(
abs(v.x),
abs(v.y),
abs(v.z));
}
template <typename T>
GLM_FUNC_QUALIFIER detail::tvec4<T> abs(
detail::tvec4<T> const & v)
{
return detail::tvec4<T>(
abs(v.x),
abs(v.y),
abs(v.z),
abs(v.w));
}
VECTORIZE_VEC(abs)
// sign
//Try something like based on x >> 31 to get the sign bit
template <typename genFIType>
GLM_FUNC_QUALIFIER genFIType sign(
genFIType const & x)
GLM_FUNC_QUALIFIER genFIType sign
(
genFIType const & x
)
{
GLM_STATIC_ASSERT(
detail::type<genFIType>::is_float ||
@ -125,35 +94,7 @@ namespace detail
return result;
}
template <typename valFIType>
GLM_FUNC_QUALIFIER detail::tvec2<valFIType> sign(
detail::tvec2<valFIType> const & x)
{
return detail::tvec2<valFIType>(
sign(x.x),
sign(x.y));
}
template <typename valFIType>
GLM_FUNC_QUALIFIER detail::tvec3<valFIType> sign(
detail::tvec3<valFIType> const & x)
{
return detail::tvec3<valFIType>(
sign(x.x),
sign(x.y),
sign(x.z));
}
template <typename valFIType>
GLM_FUNC_QUALIFIER detail::tvec4<valFIType> sign(
detail::tvec4<valFIType> const & x)
{
return detail::tvec4<valFIType>(
sign(x.x),
sign(x.y),
sign(x.z),
sign(x.w));
}
VECTORIZE_VEC(sign)
// floor
template <>
@ -170,32 +111,7 @@ namespace detail
return ::std::floor(x);
}
template <typename valType>
GLM_FUNC_QUALIFIER detail::tvec2<valType> floor(detail::tvec2<valType> const& x)
{
return detail::tvec2<valType>(
floor(x.x),
floor(x.y));
}
template <typename valType>
GLM_FUNC_QUALIFIER detail::tvec3<valType> floor(detail::tvec3<valType> const& x)
{
return detail::tvec3<valType>(
floor(x.x),
floor(x.y),
floor(x.z));
}
template <typename valType>
GLM_FUNC_QUALIFIER detail::tvec4<valType> floor(detail::tvec4<valType> const& x)
{
return detail::tvec4<valType>(
floor(x.x),
floor(x.y),
floor(x.z),
floor(x.w));
}
VECTORIZE_VEC(floor)
// trunc
template <typename genType>
@ -205,32 +121,7 @@ namespace detail
return x < 0 ? -floor(-x) : floor(x);
}
template <typename valType>
GLM_FUNC_QUALIFIER detail::tvec2<valType> trunc(detail::tvec2<valType> const & x)
{
return detail::tvec2<valType>(
trunc(x.x),
trunc(x.y));
}
template <typename valType>
GLM_FUNC_QUALIFIER detail::tvec3<valType> trunc(detail::tvec3<valType> const & x)
{
return detail::tvec3<valType>(
trunc(x.x),
trunc(x.y),
trunc(x.z));
}
template <typename valType>
GLM_FUNC_QUALIFIER detail::tvec4<valType> trunc(detail::tvec4<valType> const & x)
{
return detail::tvec4<valType>(
trunc(x.x),
trunc(x.y),
trunc(x.z),
trunc(x.w));
}
VECTORIZE_VEC(trunc)
// round
template <typename genType>
@ -243,32 +134,8 @@ namespace detail
return genType(int(x + genType(0.5)));
}
template <typename valType>
GLM_FUNC_QUALIFIER detail::tvec2<valType> round(detail::tvec2<valType> const& x)
{
return detail::tvec2<valType>(
round(x.x),
round(x.y));
}
template <typename valType>
GLM_FUNC_QUALIFIER detail::tvec3<valType> round(detail::tvec3<valType> const& x)
{
return detail::tvec3<valType>(
round(x.x),
round(x.y),
round(x.z));
}
VECTORIZE_VEC(round)
template <typename valType>
GLM_FUNC_QUALIFIER detail::tvec4<valType> round(detail::tvec4<valType> const& x)
{
return detail::tvec4<valType>(
round(x.x),
round(x.y),
round(x.z),
round(x.w));
}
/*
// roundEven
template <typename genType>
@ -294,32 +161,7 @@ namespace detail
return genType(int(x + RoundValue));
}
template <typename valType>
GLM_FUNC_QUALIFIER detail::tvec2<valType> roundEven(detail::tvec2<valType> const& x)
{
return detail::tvec2<valType>(
roundEven(x.x),
roundEven(x.y));
}
template <typename valType>
GLM_FUNC_QUALIFIER detail::tvec3<valType> roundEven(detail::tvec3<valType> const& x)
{
return detail::tvec3<valType>(
roundEven(x.x),
roundEven(x.y),
roundEven(x.z));
}
template <typename valType>
GLM_FUNC_QUALIFIER detail::tvec4<valType> roundEven(detail::tvec4<valType> const& x)
{
return detail::tvec4<valType>(
roundEven(x.x),
roundEven(x.y),
roundEven(x.z),
roundEven(x.w));
}
VECTORIZE_VEC(roundEven)
// ceil
template <typename genType>
@ -330,32 +172,7 @@ namespace detail
return ::std::ceil(x);
}
template <typename valType>
GLM_FUNC_QUALIFIER detail::tvec2<valType> ceil(detail::tvec2<valType> const & x)
{
return detail::tvec2<valType>(
ceil(x.x),
ceil(x.y));
}
template <typename valType>
GLM_FUNC_QUALIFIER detail::tvec3<valType> ceil(detail::tvec3<valType> const & x)
{
return detail::tvec3<valType>(
ceil(x.x),
ceil(x.y),
ceil(x.z));
}
template <typename valType>
GLM_FUNC_QUALIFIER detail::tvec4<valType> ceil(detail::tvec4<valType> const & x)
{
return detail::tvec4<valType>(
ceil(x.x),
ceil(x.y),
ceil(x.z),
ceil(x.w));
}
VECTORIZE_VEC(ceil)
// fract
template <typename genType>
@ -369,41 +186,7 @@ namespace detail
return x - ::std::floor(x);
}
template <typename valType>
GLM_FUNC_QUALIFIER detail::tvec2<valType> fract
(
detail::tvec2<valType> const & x
)
{
return detail::tvec2<valType>(
fract(x.x),
fract(x.y));
}
template <typename valType>
GLM_FUNC_QUALIFIER detail::tvec3<valType> fract
(
detail::tvec3<valType> const & x
)
{
return detail::tvec3<valType>(
fract(x.x),
fract(x.y),
fract(x.z));
}
template <typename valType>
GLM_FUNC_QUALIFIER detail::tvec4<valType> fract
(
detail::tvec4<valType> const & x
)
{
return detail::tvec4<valType>(
fract(x.x),
fract(x.y),
fract(x.z),
fract(x.w));
}
VECTORIZE_VEC(fract)
// mod
template <typename genType>
@ -418,83 +201,8 @@ namespace detail
return x - y * floor(x / y);
}
template <typename T>
GLM_FUNC_QUALIFIER detail::tvec2<T> mod
(
detail::tvec2<T> const & x,
typename detail::tvec2<T>::value_type const & y
)
{
return detail::tvec2<T>(
mod(x.x, y),
mod(x.y, y));
}
template <typename T>
GLM_FUNC_QUALIFIER detail::tvec3<T> mod
(
detail::tvec3<T> const & x,
typename detail::tvec3<T>::value_type const & y
)
{
return detail::tvec3<T>(
mod(x.x, y),
mod(x.y, y),
mod(x.z, y));
}
template <typename T>
GLM_FUNC_QUALIFIER detail::tvec4<T> mod
(
detail::tvec4<T> const & x,
typename detail::tvec4<T>::value_type const & y
)
{
return detail::tvec4<T>(
mod(x.x, y),
mod(x.y, y),
mod(x.z, y),
mod(x.w, y));
}
template <typename T>
GLM_FUNC_QUALIFIER detail::tvec2<T> mod
(
detail::tvec2<T> const & x,
detail::tvec2<T> const & y
)
{
return detail::tvec2<T>(
mod(x.x, y.x),
mod(x.y, y.y));
}
template <typename T>
GLM_FUNC_QUALIFIER detail::tvec3<T> mod
(
detail::tvec3<T> const & x,
detail::tvec3<T> const & y
)
{
return detail::tvec3<T>(
mod(x.x, y.x),
mod(x.y, y.y),
mod(x.z, y.z));
}
template <typename T>
GLM_FUNC_QUALIFIER detail::tvec4<T> mod
(
detail::tvec4<T> const & x,
detail::tvec4<T> const & y
)
{
return detail::tvec4<T>(
mod(x.x, y.x),
mod(x.y, y.y),
mod(x.z, y.z),
mod(x.w, y.w));
}
VECTORIZE_VEC_SCA(mod)
VECTORIZE_VEC_VEC(mod)
// modf
template <typename genType>
@ -515,39 +223,39 @@ namespace detail
GLM_FUNC_QUALIFIER detail::tvec2<valType> modf
(
detail::tvec2<valType> const & x,
detail::tvec2<valType> const & y
detail::tvec2<valType> & i
)
{
return detail::tvec2<valType>(
modf(x.x, y.x),
modf(x.y, y.y));
modf(x.x, i.x),
modf(x.y, i.y));
}
template <typename valType>
GLM_FUNC_QUALIFIER detail::tvec3<valType> modf
(
detail::tvec3<valType> const & x,
detail::tvec3<valType> const & y
detail::tvec3<valType> & i
)
{
return detail::tvec3<valType>(
modf(x.x, y.x),
modf(x.y, y.y),
modf(x.z, y.z));
modf(x.x, i.x),
modf(x.y, i.y),
modf(x.z, i.z));
}
template <typename valType>
GLM_FUNC_QUALIFIER detail::tvec4<valType> modf
(
detail::tvec4<valType> const & x,
detail::tvec4<valType> const & y
detail::tvec4<valType> & i
)
{
return detail::tvec4<valType>(
modf(x.x, y.x),
modf(x.y, y.y),
modf(x.z, y.z),
modf(x.w, y.w));
modf(x.x, i.x),
modf(x.y, i.y),
modf(x.z, i.z),
modf(x.w, i.w));
}
//// Only valid if (INT_MIN <= x-y <= INT_MAX)
@ -574,83 +282,8 @@ namespace detail
return x < y ? x : y;
}
template <typename T>
GLM_FUNC_QUALIFIER detail::tvec2<T> min
(
detail::tvec2<T> const & x,
typename detail::tvec2<T>::value_type const & y
)
{
return detail::tvec2<T>(
min(x.x, y),
min(x.y, y));
}
template <typename T>
GLM_FUNC_QUALIFIER detail::tvec3<T> min
(
detail::tvec3<T> const & x,
typename detail::tvec3<T>::value_type const & y
)
{
return detail::tvec3<T>(
min(x.x, y),
min(x.y, y),
min(x.z, y));
}
template <typename T>
GLM_FUNC_QUALIFIER detail::tvec4<T> min
(
detail::tvec4<T> const & x,
typename detail::tvec4<T>::value_type const & y
)
{
return detail::tvec4<T>(
min(x.x, y),
min(x.y, y),
min(x.z, y),
min(x.w, y));
}
template <typename T>
GLM_FUNC_QUALIFIER detail::tvec2<T> min
(
detail::tvec2<T> const & x,
detail::tvec2<T> const & y
)
{
return detail::tvec2<T>(
min(x.x, y.x),
min(x.y, y.y));
}
template <typename T>
GLM_FUNC_QUALIFIER detail::tvec3<T> min
(
detail::tvec3<T> const & x,
detail::tvec3<T> const & y
)
{
return detail::tvec3<T>(
min(x.x, y.x),
min(x.y, y.y),
min(x.z, y.z));
}
template <typename T>
GLM_FUNC_QUALIFIER detail::tvec4<T> min
(
detail::tvec4<T> const & x,
detail::tvec4<T> const & y
)
{
return detail::tvec4<T>(
min(x.x, y.x),
min(x.y, y.y),
min(x.z, y.z),
min(x.w, y.w));
}
VECTORIZE_VEC_SCA(min)
VECTORIZE_VEC_VEC(min)
// max
template <typename genType>
@ -668,82 +301,8 @@ namespace detail
return x > y ? x : y;
}
template <typename T>
GLM_FUNC_QUALIFIER detail::tvec2<T> max
(
detail::tvec2<T> const & x,
typename detail::tvec2<T>::value_type y
)
{
return detail::tvec2<T>(
max(x.x, y),
max(x.y, y));
}
template <typename T>
GLM_FUNC_QUALIFIER detail::tvec3<T> max
(
detail::tvec3<T> const & x,
typename detail::tvec3<T>::value_type y
)
{
return detail::tvec3<T>(
max(x.x, y),
max(x.y, y),
max(x.z, y));
}
template <typename T>
GLM_FUNC_QUALIFIER detail::tvec4<T> max
(
detail::tvec4<T> const & x,
typename detail::tvec4<T>::value_type y
)
{
return detail::tvec4<T>(
max(x.x, y),
max(x.y, y),
max(x.z, y),
max(x.w, y));
}
template <typename T>
GLM_FUNC_QUALIFIER detail::tvec2<T> max
(
detail::tvec2<T> const & x,
detail::tvec2<T> const & y
)
{
return detail::tvec2<T>(
max(x.x, y.x),
max(x.y, y.y));
}
template <typename T>
GLM_FUNC_QUALIFIER detail::tvec3<T> max
(
detail::tvec3<T> const & x,
detail::tvec3<T> const & y
)
{
return detail::tvec3<T>(
max(x.x, y.x),
max(x.y, y.y),
max(x.z, y.z));
}
template <typename T>
GLM_FUNC_QUALIFIER detail::tvec4<T> max
(
detail::tvec4<T> const & x,
detail::tvec4<T> const & y)
{
return detail::tvec4<T>(
max(x.x, y.x),
max(x.y, y.y),
max(x.z, y.z),
max(x.w, y.w));
}
VECTORIZE_VEC_SCA(max)
VECTORIZE_VEC_VEC(max)
// clamp
template <typename valType>

@ -26,6 +26,8 @@
/// @author Christophe Riccio
///////////////////////////////////////////////////////////////////////////////////
#include "_vectorize.hpp"
namespace glm
{
// pow
@ -41,44 +43,7 @@ namespace glm
return ::std::pow(x, y);
}
template <typename T>
GLM_FUNC_QUALIFIER detail::tvec2<T> pow
(
detail::tvec2<T> const & x,
detail::tvec2<T> const & y
)
{
return detail::tvec2<T>(
pow(x.x, y.x),
pow(x.y, y.y));
}
template <typename T>
GLM_FUNC_QUALIFIER detail::tvec3<T> pow
(
detail::tvec3<T> const & x,
detail::tvec3<T> const & y
)
{
return detail::tvec3<T>(
pow(x.x, y.x),
pow(x.y, y.y),
pow(x.z, y.z));
}
template <typename T>
GLM_FUNC_QUALIFIER detail::tvec4<T> pow
(
detail::tvec4<T> const & x,
detail::tvec4<T> const & y
)
{
return detail::tvec4<T>(
pow(x.x, y.x),
pow(x.y, y.y),
pow(x.z, y.z),
pow(x.w, y.w));
}
VECTORIZE_VEC_VEC(pow)
// exp
template <typename genType>
@ -92,41 +57,7 @@ namespace glm
return ::std::exp(x);
}
template <typename T>
GLM_FUNC_QUALIFIER detail::tvec2<T> exp
(
detail::tvec2<T> const & x
)
{
return detail::tvec2<T>(
exp(x.x),
exp(x.y));
}
template <typename T>
GLM_FUNC_QUALIFIER detail::tvec3<T> exp
(
detail::tvec3<T> const & x
)
{
return detail::tvec3<T>(
exp(x.x),
exp(x.y),
exp(x.z));
}
template <typename T>
GLM_FUNC_QUALIFIER detail::tvec4<T> exp
(
detail::tvec4<T> const & x
)
{
return detail::tvec4<T>(
exp(x.x),
exp(x.y),
exp(x.z),
exp(x.w));
}
VECTORIZE_VEC(exp)
// log
template <typename genType>
@ -140,41 +71,7 @@ namespace glm
return ::std::log(x);
}
template <typename T>
GLM_FUNC_QUALIFIER detail::tvec2<T> log
(
detail::tvec2<T> const & x
)
{
return detail::tvec2<T>(
log(x.x),
log(x.y));
}
template <typename T>
GLM_FUNC_QUALIFIER detail::tvec3<T> log
(
detail::tvec3<T> const & x
)
{
return detail::tvec3<T>(
log(x.x),
log(x.y),
log(x.z));
}
template <typename T>
GLM_FUNC_QUALIFIER detail::tvec4<T> log
(
detail::tvec4<T> const & x
)
{
return detail::tvec4<T>(
log(x.x),
log(x.y),
log(x.z),
log(x.w));
}
VECTORIZE_VEC(log)
//exp2, ln2 = 0.69314718055994530941723212145818f
template <typename genType>
@ -188,41 +85,7 @@ namespace glm
return ::std::exp(genType(0.69314718055994530941723212145818) * x);
}
template <typename T>
GLM_FUNC_QUALIFIER detail::tvec2<T> exp2
(
detail::tvec2<T> const & x
)
{
return detail::tvec2<T>(
exp2(x.x),
exp2(x.y));
}
template <typename T>
GLM_FUNC_QUALIFIER detail::tvec3<T> exp2
(
detail::tvec3<T> const & x
)
{
return detail::tvec3<T>(
exp2(x.x),
exp2(x.y),
exp2(x.z));
}
template <typename T>
GLM_FUNC_QUALIFIER detail::tvec4<T> exp2
(
detail::tvec4<T> const & x
)
{
return detail::tvec4<T>(
exp2(x.x),
exp2(x.y),
exp2(x.z),
exp2(x.w));
}
VECTORIZE_VEC(exp2)
namespace detail
{
@ -232,7 +95,7 @@ namespace detail
template <typename T>
T operator() (T const & Value) const
{
static_assert(0, "'log2' parameter has an invalid template parameter type");
GLM_STATIC_ASSERT(0, "'log2' parameter has an invalid template parameter type. GLM core features only supports floating-point types, include <glm/gtx/integer.hpp> for integer types support. Others types are not supported.");
return Value;
}
};
@ -255,44 +118,11 @@ namespace detail
genType const & x
)
{
assert(x > genType(0)); // log2 is only defined on the range (0, inf]
return detail::compute_log2<detail::float_or_int_trait<genType>::ID>()(x);
}
template <typename T>
GLM_FUNC_QUALIFIER detail::tvec2<T> log2
(
detail::tvec2<T> const & x
)
{
return detail::tvec2<T>(
log2(x.x),
log2(x.y));
}
template <typename T>
GLM_FUNC_QUALIFIER detail::tvec3<T> log2
(
detail::tvec3<T> const & x
)
{
return detail::tvec3<T>(
log2(x.x),
log2(x.y),
log2(x.z));
}
template <typename T>
GLM_FUNC_QUALIFIER detail::tvec4<T> log2
(
detail::tvec4<T> const & x
)
{
return detail::tvec4<T>(
log2(x.x),
log2(x.y),
log2(x.z),
log2(x.w));
}
VECTORIZE_VEC(log2)
// sqrt
template <typename genType>
@ -306,41 +136,7 @@ namespace detail
return genType(::std::sqrt(x));
}
template <typename T>
GLM_FUNC_QUALIFIER detail::tvec2<T> sqrt
(
detail::tvec2<T> const & x
)
{
return detail::tvec2<T>(
glm::sqrt(x.x),
glm::sqrt(x.y));
}
template <typename T>
GLM_FUNC_QUALIFIER detail::tvec3<T> sqrt
(
detail::tvec3<T> const & x
)
{
return detail::tvec3<T>(
glm::sqrt(x.x),
glm::sqrt(x.y),
glm::sqrt(x.z));
}
template <typename T>
GLM_FUNC_QUALIFIER detail::tvec4<T> sqrt
(
detail::tvec4<T> const & x
)
{
return detail::tvec4<T>(
glm::sqrt(x.x),
glm::sqrt(x.y),
glm::sqrt(x.z),
glm::sqrt(x.w));
}
VECTORIZE_VEC(sqrt)
template <typename genType>
GLM_FUNC_QUALIFIER genType inversesqrt
@ -353,40 +149,6 @@ namespace detail
return genType(1) / ::std::sqrt(x);
}
template <typename T>
GLM_FUNC_QUALIFIER detail::tvec2<T> inversesqrt
(
detail::tvec2<T> const & x
)
{
return detail::tvec2<T>(
inversesqrt(x.x),
inversesqrt(x.y));
}
template <typename T>
GLM_FUNC_QUALIFIER detail::tvec3<T> inversesqrt
(
detail::tvec3<T> const & x
)
{
return detail::tvec3<T>(
inversesqrt(x.x),
inversesqrt(x.y),
inversesqrt(x.z));
}
template <typename T>
GLM_FUNC_QUALIFIER detail::tvec4<T> inversesqrt
(
detail::tvec4<T> const & x
)
{
return detail::tvec4<T>(
inversesqrt(x.x),
inversesqrt(x.y),
inversesqrt(x.z),
inversesqrt(x.w));
}
VECTORIZE_VEC(inversesqrt)
}//namespace glm

@ -26,6 +26,8 @@
/// @author Christophe Riccio
///////////////////////////////////////////////////////////////////////////////////
#include "_vectorize.hpp"
namespace glm
{
// length

@ -26,6 +26,7 @@
/// @author Christophe Riccio
///////////////////////////////////////////////////////////////////////////////////
#include "_vectorize.hpp"
#if(GLM_COMPILER & GLM_COMPILER_VC)
#include <intrin.h>
#pragma intrinsic(_BitScanReverse)
@ -415,41 +416,7 @@ namespace glm
return Out;
}
template <typename T>
GLM_FUNC_QUALIFIER detail::tvec2<T> bitfieldReverse
(
detail::tvec2<T> const & value
)
{
return detail::tvec2<T>(
bitfieldReverse(value[0]),
bitfieldReverse(value[1]));
}
template <typename T>
GLM_FUNC_QUALIFIER detail::tvec3<T> bitfieldReverse
(
detail::tvec3<T> const & value
)
{
return detail::tvec3<T>(
bitfieldReverse(value[0]),
bitfieldReverse(value[1]),
bitfieldReverse(value[2]));
}
template <typename T>
GLM_FUNC_QUALIFIER detail::tvec4<T> bitfieldReverse
(
detail::tvec4<T> const & value
)
{
return detail::tvec4<T>(
bitfieldReverse(value[0]),
bitfieldReverse(value[1]),
bitfieldReverse(value[2]),
bitfieldReverse(value[3]));
}
VECTORIZE_VEC(bitfieldReverse)
// bitCount
template <typename genIUType>

@ -26,6 +26,8 @@
/// @author Christophe Riccio
///////////////////////////////////////////////////////////////////////////////////
#include "_vectorize.hpp"
namespace glm
{
// matrixCompMult

@ -26,27 +26,27 @@
/// @author Christophe Riccio
///////////////////////////////////////////////////////////////////////////////////
namespace glm{
GLM_FUNC_QUALIFIER detail::uint32 packUnorm2x16(detail::tvec2<detail::float32> const & v)
namespace glm
{
GLM_FUNC_QUALIFIER detail::uint32 packUnorm2x16(detail::tvec2<detail::float32> const & v)
{
detail::uint16 A(detail::uint16(round(clamp(v.x, 0.0f, 1.0f) * 65535.0f)));
detail::uint16 B(detail::uint16(round(clamp(v.y, 0.0f, 1.0f) * 65535.0f)));
return detail::uint32((B << 16) | A);
}
}
GLM_FUNC_QUALIFIER detail::tvec2<detail::float32> unpackUnorm2x16(detail::uint32 const & p)
{
GLM_FUNC_QUALIFIER detail::tvec2<detail::float32> unpackUnorm2x16(detail::uint32 const & p)
{
detail::uint32 Mask16((1 << 16) - 1);
detail::uint32 A((p >> 0) & Mask16);
detail::uint32 B((p >> 16) & Mask16);
return detail::tvec2<detail::float32>(
A * 1.0f / 65535.0f,
B * 1.0f / 65535.0f);
}
}
GLM_FUNC_QUALIFIER detail::uint32 packSnorm2x16(detail::tvec2<detail::float32> const & v)
{
GLM_FUNC_QUALIFIER detail::uint32 packSnorm2x16(detail::tvec2<detail::float32> const & v)
{
union iu
{
detail::int16 i;
@ -58,10 +58,10 @@ GLM_FUNC_QUALIFIER detail::uint32 packSnorm2x16(detail::tvec2<detail::float32> c
B.i = detail::int16(round(Unpack.y));
detail::uint32 Pack = (detail::uint32(B.u) << 16) | (detail::uint32(A.u) << 0);
return Pack;
}
}
GLM_FUNC_QUALIFIER detail::tvec2<detail::float32> unpackSnorm2x16(detail::uint32 const & p)
{
GLM_FUNC_QUALIFIER detail::tvec2<detail::float32> unpackSnorm2x16(detail::uint32 const & p)
{
union iu
{
detail::int16 i;
@ -74,19 +74,19 @@ GLM_FUNC_QUALIFIER detail::tvec2<detail::float32> unpackSnorm2x16(detail::uint32
detail::tvec2<detail::float32> Pack(A.i, B.i);
return clamp(Pack * 1.0f / 32767.0f, -1.0f, 1.0f);
}
}
GLM_FUNC_QUALIFIER detail::uint32 packUnorm4x8(detail::tvec4<detail::float32> const & v)
{
GLM_FUNC_QUALIFIER detail::uint32 packUnorm4x8(detail::tvec4<detail::float32> const & v)
{
detail::uint8 A((detail::uint8)round(clamp(v.x, 0.0f, 1.0f) * 255.0f));
detail::uint8 B((detail::uint8)round(clamp(v.y, 0.0f, 1.0f) * 255.0f));
detail::uint8 C((detail::uint8)round(clamp(v.z, 0.0f, 1.0f) * 255.0f));
detail::uint8 D((detail::uint8)round(clamp(v.w, 0.0f, 1.0f) * 255.0f));
return detail::uint32((D << 24) | (C << 16) | (B << 8) | A);
}
}
GLM_FUNC_QUALIFIER detail::tvec4<detail::float32> unpackUnorm4x8(detail::uint32 const & p)
{
GLM_FUNC_QUALIFIER detail::tvec4<detail::float32> unpackUnorm4x8(detail::uint32 const & p)
{
detail::uint32 Mask8((1 << 8) - 1);
detail::uint32 A((p >> 0) & Mask8);
detail::uint32 B((p >> 8) & Mask8);
@ -97,10 +97,10 @@ GLM_FUNC_QUALIFIER detail::tvec4<detail::float32> unpackUnorm4x8(detail::uint32
B * 1.0f / 255.0f,
C * 1.0f / 255.0f,
D * 1.0f / 255.0f);
}
}
GLM_FUNC_QUALIFIER detail::uint32 packSnorm4x8(detail::tvec4<detail::float32> const & v)
{
GLM_FUNC_QUALIFIER detail::uint32 packSnorm4x8(detail::tvec4<detail::float32> const & v)
{
union iu
{
detail::int8 i;
@ -114,10 +114,10 @@ GLM_FUNC_QUALIFIER detail::uint32 packSnorm4x8(detail::tvec4<detail::float32> co
D.i = detail::int8(round(Unpack.w));
detail::uint32 Pack = (detail::uint32(D.u) << 24) | (detail::uint32(C.u) << 16) | (detail::uint32(B.u) << 8) | (detail::uint32(A.u) << 0);
return Pack;
}
}
GLM_FUNC_QUALIFIER detail::tvec4<detail::float32> unpackSnorm4x8(detail::uint32 const & p)
{
GLM_FUNC_QUALIFIER detail::tvec4<detail::float32> unpackSnorm4x8(detail::uint32 const & p)
{
union iu
{
detail::int8 i;
@ -132,28 +132,27 @@ GLM_FUNC_QUALIFIER detail::tvec4<detail::float32> unpackSnorm4x8(detail::uint32
detail::tvec4<detail::float32> Pack(A.i, B.i, C.i, D.i);
return clamp(Pack * 1.0f / 127.0f, -1.0f, 1.0f);
}
}
GLM_FUNC_QUALIFIER double packDouble2x32(detail::tvec2<detail::uint32> const & v)
{
GLM_FUNC_QUALIFIER double packDouble2x32(detail::tvec2<detail::uint32> const & v)
{
return *(double*)&v;
}
}
GLM_FUNC_QUALIFIER detail::tvec2<uint> unpackDouble2x32(double const & v)
{
GLM_FUNC_QUALIFIER detail::tvec2<uint> unpackDouble2x32(double const & v)
{
return *(detail::tvec2<uint>*)&v;
}
}
GLM_FUNC_QUALIFIER uint packHalf2x16(detail::tvec2<float> const & v)
{
GLM_FUNC_QUALIFIER uint packHalf2x16(detail::tvec2<float> const & v)
{
detail::tvec2<detail::hdata> Pack(detail::toFloat16(v.x), detail::toFloat16(v.y));
return *(uint*)&Pack;
}
}
GLM_FUNC_QUALIFIER vec2 unpackHalf2x16(uint const & v)
{
GLM_FUNC_QUALIFIER vec2 unpackHalf2x16(uint const & v)
{
detail::tvec2<detail::hdata> Unpack = *(detail::tvec2<detail::hdata>*)&v;
return vec2(detail::toFloat32(Unpack.x), detail::toFloat32(Unpack.y));
}
}
}//namespace glm

@ -26,732 +26,221 @@
/// @author Christophe Riccio
///////////////////////////////////////////////////////////////////////////////////
namespace glm{
#include "_vectorize.hpp"
// radians
template <typename genType>
GLM_FUNC_QUALIFIER genType radians
(
genType const & degrees
)
namespace glm
{
// radians
template <typename genType>
GLM_FUNC_QUALIFIER genType radians
(
genType const & degrees
)
{
GLM_STATIC_ASSERT(detail::type<genType>::is_float, "'radians' only accept floating-point input");
const genType pi = genType(3.1415926535897932384626433832795);
genType const pi = genType(3.1415926535897932384626433832795);
return degrees * (pi / genType(180));
}
}
template <typename T>
GLM_FUNC_QUALIFIER detail::tvec2<T> radians
(
detail::tvec2<T> const & degrees
)
{
return detail::tvec2<T>(
radians(degrees.x),
radians(degrees.y));
}
template <typename T>
GLM_FUNC_QUALIFIER detail::tvec3<T> radians
(
detail::tvec3<T> const & degrees
)
{
return detail::tvec3<T>(
radians(degrees.x),
radians(degrees.y),
radians(degrees.z));
}
template <typename T>
GLM_FUNC_QUALIFIER detail::tvec4<T> radians
(
detail::tvec4<T> const & degrees
)
{
return detail::tvec4<T>(
radians(degrees.x),
radians(degrees.y),
radians(degrees.z),
radians(degrees.w));
}
// degrees
template <typename genType>
GLM_FUNC_QUALIFIER genType degrees
(
VECTORIZE_VEC(radians)
// degrees
template <typename genType>
GLM_FUNC_QUALIFIER genType degrees
(
genType const & radians
)
{
)
{
GLM_STATIC_ASSERT(detail::type<genType>::is_float, "'degrees' only accept floating-point input");
const genType pi = genType(3.1415926535897932384626433832795);
return radians * (genType(180) / pi);
}
}
template <typename T>
GLM_FUNC_QUALIFIER detail::tvec2<T> degrees
(
detail::tvec2<T> const & radians
)
{
return detail::tvec2<T>(
degrees(radians.x),
degrees(radians.y));
}
template <typename T>
GLM_FUNC_QUALIFIER detail::tvec3<T> degrees
(
detail::tvec3<T> const & radians
)
{
return detail::tvec3<T>(
degrees(radians.x),
degrees(radians.y),
degrees(radians.z));
}
template <typename T>
GLM_FUNC_QUALIFIER detail::tvec4<T> degrees
(
detail::tvec4<T> const & radians
)
{
return detail::tvec4<T>(
degrees(radians.x),
degrees(radians.y),
degrees(radians.z),
degrees(radians.w));
}
// sin
template <typename genType>
GLM_FUNC_QUALIFIER genType sin
(
VECTORIZE_VEC(degrees)
// sin
template <typename genType>
GLM_FUNC_QUALIFIER genType sin
(
genType const & angle
)
{
)
{
GLM_STATIC_ASSERT(detail::type<genType>::is_float, "'sin' only accept floating-point input");
return ::std::sin(angle);
}
}
template <typename T>
GLM_FUNC_QUALIFIER detail::tvec2<T> sin
(
detail::tvec2<T> const & angle
)
{
return detail::tvec2<T>(
sin(angle.x),
sin(angle.y));
}
template <typename T>
GLM_FUNC_QUALIFIER detail::tvec3<T> sin
(
detail::tvec3<T> const & angle
)
{
return detail::tvec3<T>(
sin(angle.x),
sin(angle.y),
sin(angle.z));
}
template <typename T>
GLM_FUNC_QUALIFIER detail::tvec4<T> sin
(
detail::tvec4<T> const & angle
)
{
return detail::tvec4<T>(
sin(angle.x),
sin(angle.y),
sin(angle.z),
sin(angle.w));
}
// cos
template <typename genType>
GLM_FUNC_QUALIFIER genType cos(genType const & angle)
{
VECTORIZE_VEC(sin)
// cos
template <typename genType>
GLM_FUNC_QUALIFIER genType cos(genType const & angle)
{
GLM_STATIC_ASSERT(detail::type<genType>::is_float, "'cos' only accept floating-point input");
return ::std::cos(angle);
}
}
template <typename T>
GLM_FUNC_QUALIFIER detail::tvec2<T> cos
(
detail::tvec2<T> const & angle
)
{
return detail::tvec2<T>(
cos(angle.x),
cos(angle.y));
}
template <typename T>
GLM_FUNC_QUALIFIER detail::tvec3<T> cos
(
detail::tvec3<T> const & angle
)
{
return detail::tvec3<T>(
cos(angle.x),
cos(angle.y),
cos(angle.z));
}
template <typename T>
GLM_FUNC_QUALIFIER detail::tvec4<T> cos
(
detail::tvec4<T> const & angle
)
{
return detail::tvec4<T>(
cos(angle.x),
cos(angle.y),
cos(angle.z),
cos(angle.w));
}
// tan
template <typename genType>
GLM_FUNC_QUALIFIER genType tan
(
VECTORIZE_VEC(cos)
// tan
template <typename genType>
GLM_FUNC_QUALIFIER genType tan
(
genType const & angle
)
{
)
{
GLM_STATIC_ASSERT(detail::type<genType>::is_float, "'tan' only accept floating-point input");
return ::std::tan(angle);
}
}
template <typename T>
GLM_FUNC_QUALIFIER detail::tvec2<T> tan
(
detail::tvec2<T> const & angle
)
{
return detail::tvec2<T>(
tan(angle.x),
tan(angle.y));
}
template <typename T>
GLM_FUNC_QUALIFIER detail::tvec3<T> tan
(
detail::tvec3<T> const & angle
)
{
return detail::tvec3<T>(
tan(angle.x),
tan(angle.y),
tan(angle.z));
}
template <typename T>
GLM_FUNC_QUALIFIER detail::tvec4<T> tan
(
detail::tvec4<T> const & angle
)
{
return detail::tvec4<T>(
tan(angle.x),
tan(angle.y),
tan(angle.z),
tan(angle.w));
}
// asin
template <typename genType>
GLM_FUNC_QUALIFIER genType asin
(
VECTORIZE_VEC(tan)
// asin
template <typename genType>
GLM_FUNC_QUALIFIER genType asin
(
genType const & x
)
{
)
{
GLM_STATIC_ASSERT(detail::type<genType>::is_float, "'asin' only accept floating-point input");
return ::std::asin(x);
}
}
template <typename T>
GLM_FUNC_QUALIFIER detail::tvec2<T> asin
(
detail::tvec2<T> const & x
)
{
return detail::tvec2<T>(
asin(x.x),
asin(x.y));
}
template <typename T>
GLM_FUNC_QUALIFIER detail::tvec3<T> asin
(
detail::tvec3<T> const & x
)
{
return detail::tvec3<T>(
asin(x.x),
asin(x.y),
asin(x.z));
}
template <typename T>
GLM_FUNC_QUALIFIER detail::tvec4<T> asin
(
detail::tvec4<T> const & x
)
{
return detail::tvec4<T>(
asin(x.x),
asin(x.y),
asin(x.z),
asin(x.w));
}
// acos
template <typename genType>
GLM_FUNC_QUALIFIER genType acos
(
VECTORIZE_VEC(asin)
// acos
template <typename genType>
GLM_FUNC_QUALIFIER genType acos
(
genType const & x
)
{
)
{
GLM_STATIC_ASSERT(detail::type<genType>::is_float, "'acos' only accept floating-point input");
return ::std::acos(x);
}
}
template <typename T>
GLM_FUNC_QUALIFIER detail::tvec2<T> acos
(
detail::tvec2<T> const & x
)
{
return detail::tvec2<T>(
acos(x.x),
acos(x.y));
}
template <typename T>
GLM_FUNC_QUALIFIER detail::tvec3<T> acos
(
detail::tvec3<T> const & x
)
{
return detail::tvec3<T>(
acos(x.x),
acos(x.y),
acos(x.z));
}
template <typename T>
GLM_FUNC_QUALIFIER detail::tvec4<T> acos
(
detail::tvec4<T> const & x
)
{
return detail::tvec4<T>(
acos(x.x),
acos(x.y),
acos(x.z),
acos(x.w));
}
// atan
template <typename genType>
GLM_FUNC_QUALIFIER genType atan
(
VECTORIZE_VEC(acos)
// atan
template <typename genType>
GLM_FUNC_QUALIFIER genType atan
(
genType const & y,
genType const & x
)
{
)
{
GLM_STATIC_ASSERT(detail::type<genType>::is_float, "'atan' only accept floating-point input");
return ::std::atan2(y, x);
}
template <typename T>
GLM_FUNC_QUALIFIER detail::tvec2<T> atan
(
detail::tvec2<T> const & y,
detail::tvec2<T> const & x
)
{
return detail::tvec2<T>(
atan(y.x, x.x),
atan(y.y, x.y));
}
template <typename T>
GLM_FUNC_QUALIFIER detail::tvec3<T> atan
(
detail::tvec3<T> const & y,
detail::tvec3<T> const & x
)
{
return detail::tvec3<T>(
atan(y.x, x.x),
atan(y.y, x.y),
atan(y.z, x.z));
}
template <typename T>
GLM_FUNC_QUALIFIER detail::tvec4<T> atan
(
detail::tvec4<T> const & y,
detail::tvec4<T> const & x
)
{
return detail::tvec4<T>(
atan(y.x, x.x),
atan(y.y, x.y),
atan(y.z, x.z),
atan(y.w, x.w));
}
template <typename genType>
GLM_FUNC_QUALIFIER genType atan
(
}
VECTORIZE_VEC_VEC(atan)
template <typename genType>
GLM_FUNC_QUALIFIER genType atan
(
genType const & x
)
{
)
{
GLM_STATIC_ASSERT(detail::type<genType>::is_float, "'atan' only accept floating-point input");
return ::std::atan(x);
}
}
template <typename T>
GLM_FUNC_QUALIFIER detail::tvec2<T> atan
(
detail::tvec2<T> const & x
)
{
return detail::tvec2<T>(
atan(x.x),
atan(x.y));
}
template <typename T>
GLM_FUNC_QUALIFIER detail::tvec3<T> atan
(
detail::tvec3<T> const & x
)
{
return detail::tvec3<T>(
atan(x.x),
atan(x.y),
atan(x.z));
}
template <typename T>
GLM_FUNC_QUALIFIER detail::tvec4<T> atan
(
detail::tvec4<T> const & x
)
{
return detail::tvec4<T>(
atan(x.x),
atan(x.y),
atan(x.z),
atan(x.w));
}
// sinh
template <typename genType>
GLM_FUNC_QUALIFIER genType sinh
(
VECTORIZE_VEC(atan)
// sinh
template <typename genType>
GLM_FUNC_QUALIFIER genType sinh
(
genType const & angle
)
{
)
{
GLM_STATIC_ASSERT(detail::type<genType>::is_float, "'sinh' only accept floating-point input");
return std::sinh(angle);
}
}
template <typename T>
GLM_FUNC_QUALIFIER detail::tvec2<T> sinh
(
detail::tvec2<T> const & angle
)
{
return detail::tvec2<T>(
sinh(angle.x),
sinh(angle.y));
}
template <typename T>
GLM_FUNC_QUALIFIER detail::tvec3<T> sinh
(
detail::tvec3<T> const & angle
)
{
return detail::tvec3<T>(
sinh(angle.x),
sinh(angle.y),
sinh(angle.z));
}
template <typename T>
GLM_FUNC_QUALIFIER detail::tvec4<T> sinh
(
detail::tvec4<T> const & angle
)
{
return detail::tvec4<T>(
sinh(angle.x),
sinh(angle.y),
sinh(angle.z),
sinh(angle.w));
}
// cosh
template <typename genType>
GLM_FUNC_QUALIFIER genType cosh
(
VECTORIZE_VEC(sinh)
// cosh
template <typename genType>
GLM_FUNC_QUALIFIER genType cosh
(
genType const & angle
)
{
)
{
GLM_STATIC_ASSERT(detail::type<genType>::is_float, "'cosh' only accept floating-point input");
return std::cosh(angle);
}
}
template <typename T>
GLM_FUNC_QUALIFIER detail::tvec2<T> cosh
(
detail::tvec2<T> const & angle
)
{
return detail::tvec2<T>(
cosh(angle.x),
cosh(angle.y));
}
template <typename T>
GLM_FUNC_QUALIFIER detail::tvec3<T> cosh
(
detail::tvec3<T> const & angle
)
{
return detail::tvec3<T>(
cosh(angle.x),
cosh(angle.y),
cosh(angle.z));
}
template <typename T>
GLM_FUNC_QUALIFIER detail::tvec4<T> cosh
(
detail::tvec4<T> const & angle
)
{
return detail::tvec4<T>(
cosh(angle.x),
cosh(angle.y),
cosh(angle.z),
cosh(angle.w));
}
// tanh
template <typename genType>
GLM_FUNC_QUALIFIER genType tanh
(
VECTORIZE_VEC(cosh)
// tanh
template <typename genType>
GLM_FUNC_QUALIFIER genType tanh
(
genType const & angle
)
{
)
{
GLM_STATIC_ASSERT(detail::type<genType>::is_float, "'tanh' only accept floating-point input");
return std::tanh(angle);
}
}
template <typename T>
GLM_FUNC_QUALIFIER detail::tvec2<T> tanh
(
detail::tvec2<T> const & angle
)
{
return detail::tvec2<T>(
tanh(angle.x),
tanh(angle.y));
}
template <typename T>
GLM_FUNC_QUALIFIER detail::tvec3<T> tanh
(
detail::tvec3<T> const & angle
)
{
return detail::tvec3<T>(
tanh(angle.x),
tanh(angle.y),
tanh(angle.z));
}
template <typename T>
GLM_FUNC_QUALIFIER detail::tvec4<T> tanh
(
detail::tvec4<T> const & angle
)
{
return detail::tvec4<T>(
tanh(angle.x),
tanh(angle.y),
tanh(angle.z),
tanh(angle.w));
}
// asinh
template <typename genType>
GLM_FUNC_QUALIFIER genType asinh
(
VECTORIZE_VEC(tanh)
// asinh
template <typename genType>
GLM_FUNC_QUALIFIER genType asinh
(
genType const & x
)
{
)
{
GLM_STATIC_ASSERT(detail::type<genType>::is_float, "'asinh' only accept floating-point input");
return (x < genType(0) ? genType(-1) : (x > genType(0) ? genType(1) : genType(0))) * log(abs(x) + sqrt(genType(1) + x * x));
}
}
template <typename T>
GLM_FUNC_QUALIFIER detail::tvec2<T> asinh
(
detail::tvec2<T> const & x
)
{
return detail::tvec2<T>(
asinh(x.x),
asinh(x.y));
}
template <typename T>
GLM_FUNC_QUALIFIER detail::tvec3<T> asinh
(
detail::tvec3<T> const & x
)
{
return detail::tvec3<T>(
asinh(x.x),
asinh(x.y),
asinh(x.z));
}
template <typename T>
GLM_FUNC_QUALIFIER detail::tvec4<T> asinh
(
detail::tvec4<T> const & x
)
{
return detail::tvec4<T>(
asinh(x.x),
asinh(x.y),
asinh(x.z),
asinh(x.w));
}
// acosh
template <typename genType>
GLM_FUNC_QUALIFIER genType acosh
(
VECTORIZE_VEC(asinh)
// acosh
template <typename genType>
GLM_FUNC_QUALIFIER genType acosh
(
genType const & x
)
{
)
{
GLM_STATIC_ASSERT(detail::type<genType>::is_float, "'acosh' only accept floating-point input");
if(x < genType(1))
return genType(0);
return log(x + sqrt(x * x - genType(1)));
}
}
template <typename T>
GLM_FUNC_QUALIFIER detail::tvec2<T> acosh
(
detail::tvec2<T> const & x
)
{
return detail::tvec2<T>(
acosh(x.x),
acosh(x.y));
}
template <typename T>
GLM_FUNC_QUALIFIER detail::tvec3<T> acosh
(
detail::tvec3<T> const & x
)
{
return detail::tvec3<T>(
acosh(x.x),
acosh(x.y),
acosh(x.z));
}
template <typename T>
GLM_FUNC_QUALIFIER detail::tvec4<T> acosh
(
detail::tvec4<T> const & x
)
{
return detail::tvec4<T>(
acosh(x.x),
acosh(x.y),
acosh(x.z),
acosh(x.w));
}
// atanh
template <typename genType>
GLM_FUNC_QUALIFIER genType atanh
(
VECTORIZE_VEC(acosh)
// atanh
template <typename genType>
GLM_FUNC_QUALIFIER genType atanh
(
genType const & x
)
{
)
{
GLM_STATIC_ASSERT(detail::type<genType>::is_float, "'atanh' only accept floating-point input");
if(abs(x) >= genType(1))
return 0;
return genType(0.5) * log((genType(1) + x) / (genType(1) - x));
}
}
template <typename T>
GLM_FUNC_QUALIFIER detail::tvec2<T> atanh
(
detail::tvec2<T> const & x
)
{
return detail::tvec2<T>(
atanh(x.x),
atanh(x.y));
}
template <typename T>
GLM_FUNC_QUALIFIER detail::tvec3<T> atanh
(
detail::tvec3<T> const & x
)
{
return detail::tvec3<T>(
atanh(x.x),
atanh(x.y),
atanh(x.z));
}
template <typename T>
GLM_FUNC_QUALIFIER detail::tvec4<T> atanh
(
detail::tvec4<T> const & x
)
{
return detail::tvec4<T>(
atanh(x.x),
atanh(x.y),
atanh(x.z),
atanh(x.w));
}
VECTORIZE_VEC(atanh)
}//namespace glm

File diff suppressed because it is too large Load Diff

@ -26,49 +26,55 @@
/// @author Christophe Riccio
///////////////////////////////////////////////////////////////////////////////////
namespace glm{
template <typename genType>
GLM_FUNC_QUALIFIER genType row(
namespace glm
{
template <typename genType>
GLM_FUNC_QUALIFIER genType row
(
genType const & m,
int index,
typename genType::row_type const & x)
{
typename genType::row_type const & x
)
{
genType Result = m;
for(typename genType::size_type i = 0; i < genType::row_size(); ++i)
Result[i][index] = x[i];
return Result;
}
}
template <typename genType>
GLM_FUNC_QUALIFIER typename genType::row_type row(
template <typename genType>
GLM_FUNC_QUALIFIER typename genType::row_type row
(
genType const & m,
int index)
{
int index
)
{
typename genType::row_type Result;
for(typename genType::size_type i = 0; i < genType::row_size(); ++i)
Result[i] = m[i][index];
return Result;
}
}
template <typename genType>
GLM_FUNC_QUALIFIER genType column(
template <typename genType>
GLM_FUNC_QUALIFIER genType column
(
genType const & m,
int index,
typename genType::col_type const & x)
{
typename genType::col_type const & x
)
{
genType Result = m;
Result[index] = x;
return Result;
}
}
template <typename genType>
GLM_FUNC_QUALIFIER typename genType::col_type column(
template <typename genType>
GLM_FUNC_QUALIFIER typename genType::col_type column
(
genType const & m,
int index)
{
int index
)
{
return m[index];
}
}
}//namespace glm

@ -26,40 +26,42 @@
/// @author Christophe Riccio
///////////////////////////////////////////////////////////////////////////////////
namespace glm{
template <typename T>
GLM_FUNC_QUALIFIER detail::tmat3x3<T> affineInverse
(
detail::tmat3x3<T> const & m
)
namespace glm
{
template <typename T>
GLM_FUNC_QUALIFIER detail::tmat3x3<T> affineInverse
(
detail::tmat3x3<T> const & m
)
{
detail::tmat3x3<T> Result(m);
Result[2] = detail::tvec3<T>(0, 0, 1);
Result = transpose(Result);
detail::tvec3<T> Translation = Result * detail::tvec3<T>(-detail::tvec2<T>(m[2]), m[2][2]);
Result[2] = Translation;
return Result;
}
}
template <typename T>
GLM_FUNC_QUALIFIER detail::tmat4x4<T> affineInverse
(
template <typename T>
GLM_FUNC_QUALIFIER detail::tmat4x4<T> affineInverse
(
detail::tmat4x4<T> const & m
)
{
)
{
detail::tmat4x4<T> Result(m);
Result[3] = detail::tvec4<T>(0, 0, 0, 1);
Result = transpose(Result);
detail::tvec4<T> Translation = Result * detail::tvec4<T>(-detail::tvec3<T>(m[3]), m[3][3]);
Result[3] = Translation;
return Result;
}
template <typename valType>
GLM_FUNC_QUALIFIER detail::tmat2x2<valType> inverseTranspose(
detail::tmat2x2<valType> const & m)
{
}
template <typename valType>
GLM_FUNC_QUALIFIER detail::tmat2x2<valType> inverseTranspose
(
detail::tmat2x2<valType> const & m
)
{
valType Determinant = m[0][0] * m[1][1] - m[1][0] * m[0][1];
detail::tmat2x2<valType> Inverse(
@ -69,12 +71,14 @@ GLM_FUNC_QUALIFIER detail::tmat2x2<valType> inverseTranspose(
+ m[0][0] / Determinant);
return Inverse;
}
template <typename valType>
GLM_FUNC_QUALIFIER detail::tmat3x3<valType> inverseTranspose(
detail::tmat3x3<valType> const & m)
{
}
template <typename valType>
GLM_FUNC_QUALIFIER detail::tmat3x3<valType> inverseTranspose
(
detail::tmat3x3<valType> const & m
)
{
valType Determinant =
+ m[0][0] * (m[1][1] * m[2][2] - m[1][2] * m[2][1])
- m[0][1] * (m[1][0] * m[2][2] - m[1][2] * m[2][0])
@ -93,12 +97,14 @@ GLM_FUNC_QUALIFIER detail::tmat3x3<valType> inverseTranspose(
Inverse /= Determinant;
return Inverse;
}
template <typename valType>
GLM_FUNC_QUALIFIER detail::tmat4x4<valType> inverseTranspose(
detail::tmat4x4<valType> const & m)
{
}
template <typename valType>
GLM_FUNC_QUALIFIER detail::tmat4x4<valType> inverseTranspose
(
detail::tmat4x4<valType> const & m
)
{
valType SubFactor00 = m[2][2] * m[3][3] - m[3][2] * m[2][3];
valType SubFactor01 = m[2][1] * m[3][3] - m[3][1] * m[2][3];
valType SubFactor02 = m[2][1] * m[3][2] - m[3][1] * m[2][2];
@ -149,6 +155,5 @@ GLM_FUNC_QUALIFIER detail::tmat4x4<valType> inverseTranspose(
Inverse /= Determinant;
return Inverse;
}
}
}//namespace glm

@ -26,28 +26,28 @@
/// @author Christophe Riccio
///////////////////////////////////////////////////////////////////////////////////
namespace glm{
template <typename T>
GLM_FUNC_QUALIFIER detail::tmat4x4<T> translate
(
namespace glm
{
template <typename T>
GLM_FUNC_QUALIFIER detail::tmat4x4<T> translate
(
detail::tmat4x4<T> const & m,
detail::tvec3<T> const & v
)
{
)
{
detail::tmat4x4<T> Result(m);
Result[3] = m[0] * v[0] + m[1] * v[1] + m[2] * v[2] + m[3];
return Result;
}
}
template <typename T>
GLM_FUNC_QUALIFIER detail::tmat4x4<T> rotate
(
template <typename T>
GLM_FUNC_QUALIFIER detail::tmat4x4<T> rotate
(
detail::tmat4x4<T> const & m,
T const & angle,
detail::tvec3<T> const & v
)
{
)
{
T a = radians(angle);
T c = cos(a);
T s = sin(a);
@ -75,30 +75,30 @@ GLM_FUNC_QUALIFIER detail::tmat4x4<T> rotate
Result[2] = m[0] * Rotate[2][0] + m[1] * Rotate[2][1] + m[2] * Rotate[2][2];
Result[3] = m[3];
return Result;
}
}
template <typename T>
GLM_FUNC_QUALIFIER detail::tmat4x4<T> scale
(
template <typename T>
GLM_FUNC_QUALIFIER detail::tmat4x4<T> scale
(
detail::tmat4x4<T> const & m,
detail::tvec3<T> const & v
)
{
)
{
detail::tmat4x4<T> Result(detail::tmat4x4<T>::null);
Result[0] = m[0] * v[0];
Result[1] = m[1] * v[1];
Result[2] = m[2] * v[2];
Result[3] = m[3];
return Result;
}
}
template <typename T>
GLM_FUNC_QUALIFIER detail::tmat4x4<T> translate_slow
(
template <typename T>
GLM_FUNC_QUALIFIER detail::tmat4x4<T> translate_slow
(
detail::tmat4x4<T> const & m,
detail::tvec3<T> const & v
)
{
)
{
detail::tmat4x4<T> Result(T(1));
Result[3] = detail::tvec4<T>(v, T(1));
return m * Result;
@ -110,16 +110,16 @@ GLM_FUNC_QUALIFIER detail::tmat4x4<T> translate_slow
//Result[3][2] = m[0][2] * v[0] + m[1][2] * v[1] + m[2][2] * v[2] + m[3][2];
//Result[3][3] = m[0][3] * v[0] + m[1][3] * v[1] + m[2][3] * v[2] + m[3][3];
//return Result;
}
}
template <typename T>
GLM_FUNC_QUALIFIER detail::tmat4x4<T> rotate_slow
(
template <typename T>
GLM_FUNC_QUALIFIER detail::tmat4x4<T> rotate_slow
(
detail::tmat4x4<T> const & m,
T const & angle,
detail::tvec3<T> const & v
)
{
)
{
T a = radians(angle);
T c = cos(a);
T s = sin(a);
@ -144,33 +144,33 @@ GLM_FUNC_QUALIFIER detail::tmat4x4<T> rotate_slow
Result[3] = detail::tvec4<T>(0, 0, 0, 1);
return m * Result;
}
}
template <typename T>
GLM_FUNC_QUALIFIER detail::tmat4x4<T> scale_slow
(
template <typename T>
GLM_FUNC_QUALIFIER detail::tmat4x4<T> scale_slow
(
detail::tmat4x4<T> const & m,
detail::tvec3<T> const & v
)
{
)
{
detail::tmat4x4<T> Result(T(1));
Result[0][0] = v.x;
Result[1][1] = v.y;
Result[2][2] = v.z;
return m * Result;
}
}
template <typename valType>
GLM_FUNC_QUALIFIER detail::tmat4x4<valType> ortho
(
template <typename valType>
GLM_FUNC_QUALIFIER detail::tmat4x4<valType> ortho
(
valType const & left,
valType const & right,
valType const & bottom,
valType const & top,
valType const & zNear,
valType const & zFar
)
{
)
{
detail::tmat4x4<valType> Result(1);
Result[0][0] = valType(2) / (right - left);
Result[1][1] = valType(2) / (top - bottom);
@ -179,15 +179,15 @@ GLM_FUNC_QUALIFIER detail::tmat4x4<valType> ortho
Result[3][1] = - (top + bottom) / (top - bottom);
Result[3][2] = - (zFar + zNear) / (zFar - zNear);
return Result;
}
}
template <typename valType>
GLM_FUNC_QUALIFIER detail::tmat4x4<valType> ortho(
template <typename valType>
GLM_FUNC_QUALIFIER detail::tmat4x4<valType> ortho(
valType const & left,
valType const & right,
valType const & bottom,
valType const & top)
{
{
detail::tmat4x4<valType> Result(1);
Result[0][0] = valType(2) / (right - left);
Result[1][1] = valType(2) / (top - bottom);
@ -195,19 +195,19 @@ GLM_FUNC_QUALIFIER detail::tmat4x4<valType> ortho(
Result[3][0] = - (right + left) / (right - left);
Result[3][1] = - (top + bottom) / (top - bottom);
return Result;
}
}
template <typename valType>
GLM_FUNC_QUALIFIER detail::tmat4x4<valType> frustum
(
template <typename valType>
GLM_FUNC_QUALIFIER detail::tmat4x4<valType> frustum
(
valType const & left,
valType const & right,
valType const & bottom,
valType const & top,
valType const & nearVal,
valType const & farVal
)
{
)
{
detail::tmat4x4<valType> Result(0);
Result[0][0] = (valType(2) * nearVal) / (right - left);
Result[1][1] = (valType(2) * nearVal) / (top - bottom);
@ -217,17 +217,17 @@ GLM_FUNC_QUALIFIER detail::tmat4x4<valType> frustum
Result[2][3] = valType(-1);
Result[3][2] = -(valType(2) * farVal * nearVal) / (farVal - nearVal);
return Result;
}
}
template <typename valType>
GLM_FUNC_QUALIFIER detail::tmat4x4<valType> perspective
(
template <typename valType>
GLM_FUNC_QUALIFIER detail::tmat4x4<valType> perspective
(
valType const & fovy,
valType const & aspect,
valType const & zNear,
valType const & zFar
)
{
)
{
valType range = tan(radians(fovy / valType(2))) * zNear;
valType left = -range * aspect;
valType right = range * aspect;
@ -241,18 +241,18 @@ GLM_FUNC_QUALIFIER detail::tmat4x4<valType> perspective
Result[2][3] = - valType(1);
Result[3][2] = - (valType(2) * zFar * zNear) / (zFar - zNear);
return Result;
}
}
template <typename valType>
GLM_FUNC_QUALIFIER detail::tmat4x4<valType> perspectiveFov
(
template <typename valType>
GLM_FUNC_QUALIFIER detail::tmat4x4<valType> perspectiveFov
(
valType const & fov,
valType const & width,
valType const & height,
valType const & zNear,
valType const & zFar
)
{
)
{
valType rad = glm::radians(fov);
valType h = glm::cos(valType(0.5) * rad) / glm::sin(valType(0.5) * rad);
valType w = h * height / width;
@ -264,16 +264,16 @@ GLM_FUNC_QUALIFIER detail::tmat4x4<valType> perspectiveFov
Result[2][3] = valType(1);
Result[3][2] = -(valType(2) * zFar * zNear) / (zFar - zNear);
return Result;
}
}
template <typename T>
GLM_FUNC_QUALIFIER detail::tmat4x4<T> infinitePerspective
(
template <typename T>
GLM_FUNC_QUALIFIER detail::tmat4x4<T> infinitePerspective
(
T fovy,
T aspect,
T zNear
)
{
)
{
T range = tan(radians(fovy / T(2))) * zNear;
T left = -range * aspect;
T right = range * aspect;
@ -287,16 +287,16 @@ GLM_FUNC_QUALIFIER detail::tmat4x4<T> infinitePerspective
Result[2][3] = - T(1);
Result[3][2] = - T(2) * zNear;
return Result;
}
}
template <typename T>
GLM_FUNC_QUALIFIER detail::tmat4x4<T> tweakedInfinitePerspective
(
template <typename T>
GLM_FUNC_QUALIFIER detail::tmat4x4<T> tweakedInfinitePerspective
(
T fovy,
T aspect,
T zNear
)
{
)
{
T range = tan(radians(fovy / T(2))) * zNear;
T left = -range * aspect;
T right = range * aspect;
@ -310,17 +310,17 @@ GLM_FUNC_QUALIFIER detail::tmat4x4<T> tweakedInfinitePerspective
Result[2][3] = T(-1);
Result[3][2] = - (T(0.0001) - T(2)) * zNear;
return Result;
}
}
template <typename T, typename U>
GLM_FUNC_QUALIFIER detail::tvec3<T> project
(
template <typename T, typename U>
GLM_FUNC_QUALIFIER detail::tvec3<T> project
(
detail::tvec3<T> const & obj,
detail::tmat4x4<T> const & model,
detail::tmat4x4<T> const & proj,
detail::tvec4<U> const & viewport
)
{
)
{
detail::tvec4<T> tmp = detail::tvec4<T>(obj, T(1));
tmp = model * tmp;
tmp = proj * tmp;
@ -331,17 +331,17 @@ GLM_FUNC_QUALIFIER detail::tvec3<T> project
tmp[1] = tmp[1] * T(viewport[3]) + T(viewport[1]);
return detail::tvec3<T>(tmp);
}
}
template <typename T, typename U>
GLM_FUNC_QUALIFIER detail::tvec3<T> unProject
(
template <typename T, typename U>
GLM_FUNC_QUALIFIER detail::tvec3<T> unProject
(
detail::tvec3<T> const & win,
detail::tmat4x4<T> const & model,
detail::tmat4x4<T> const & proj,
detail::tvec4<U> const & viewport
)
{
)
{
detail::tmat4x4<T> inverse = glm::inverse(proj * model);
detail::tvec4<T> tmp = detail::tvec4<T>(win, T(1));
@ -353,16 +353,16 @@ GLM_FUNC_QUALIFIER detail::tvec3<T> unProject
obj /= obj.w;
return detail::tvec3<T>(obj);
}
}
template <typename T, typename U>
detail::tmat4x4<T> pickMatrix
(
template <typename T, typename U>
detail::tmat4x4<T> pickMatrix
(
detail::tvec2<T> const & center,
detail::tvec2<T> const & delta,
detail::tvec4<U> const & viewport
)
{
)
{
assert(delta.x > T(0) && delta.y > T(0));
detail::tmat4x4<T> Result(1.0f);
@ -377,16 +377,16 @@ detail::tmat4x4<T> pickMatrix
// Translate and scale the picked region to the entire window
Result = translate(Result, Temp);
return scale(Result, detail::tvec3<T>(T(viewport[2]) / delta.x, T(viewport[3]) / delta.y, T(1)));
}
}
template <typename T>
GLM_FUNC_QUALIFIER detail::tmat4x4<T> lookAt
(
template <typename T>
GLM_FUNC_QUALIFIER detail::tmat4x4<T> lookAt
(
detail::tvec3<T> const & eye,
detail::tvec3<T> const & center,
detail::tvec3<T> const & up
)
{
)
{
detail::tvec3<T> f = normalize(center - eye);
detail::tvec3<T> u = normalize(up);
detail::tvec3<T> s = normalize(cross(f, u));
@ -402,12 +402,11 @@ GLM_FUNC_QUALIFIER detail::tmat4x4<T> lookAt
Result[0][2] =-f.x;
Result[1][2] =-f.y;
Result[2][2] =-f.z;
/* Test this instead of translate3D
/* Test this instead of translate3D
Result[3][0] =-dot(s, eye);
Result[3][1] =-dot(y, eye);
Result[3][2] = dot(f, eye);
*/
*/
return translate(Result, -eye);
}
}
}//namespace glm

@ -15,58 +15,58 @@
// - GLM core
///////////////////////////////////////////////////////////////////////////////////////////////////
namespace glm{
template <typename T>
GLM_FUNC_QUALIFIER T mod289(T const & x)
namespace glm
{
template <typename T>
GLM_FUNC_QUALIFIER T mod289(T const & x)
{
return x - floor(x * T(1.0 / 289.0)) * T(289.0);
}
}
template <typename T>
GLM_FUNC_QUALIFIER T permute(T const & x)
{
template <typename T>
GLM_FUNC_QUALIFIER T permute(T const & x)
{
return mod289(((x * T(34)) + T(1)) * x);
}
}
template <typename T, template<typename> class vecType>
GLM_FUNC_QUALIFIER vecType<T> permute(vecType<T> const & x)
{
template <typename T, template<typename> class vecType>
GLM_FUNC_QUALIFIER vecType<T> permute(vecType<T> const & x)
{
return mod289(((x * T(34)) + T(1)) * x);
}
}
template <typename T>
GLM_FUNC_QUALIFIER T taylorInvSqrt(T const & r)
{
template <typename T>
GLM_FUNC_QUALIFIER T taylorInvSqrt(T const & r)
{
return T(1.79284291400159) - T(0.85373472095314) * r;
}
}
template <typename T, template<typename> class vecType>
GLM_FUNC_QUALIFIER vecType<T> taylorInvSqrt(vecType<T> const & r)
{
template <typename T, template<typename> class vecType>
GLM_FUNC_QUALIFIER vecType<T> taylorInvSqrt(vecType<T> const & r)
{
return T(1.79284291400159) - T(0.85373472095314) * r;
}
}
template <typename T, template <typename> class vecType>
GLM_FUNC_QUALIFIER vecType<T> fade(vecType<T> const & t)
{
template <typename T, template <typename> class vecType>
GLM_FUNC_QUALIFIER vecType<T> fade(vecType<T> const & t)
{
return t * t * t * (t * (t * T(6) - T(15)) + T(10));
}
}
template <typename T>
GLM_FUNC_QUALIFIER detail::tvec4<T> grad4(T const & j, detail::tvec4<T> const & ip)
{
template <typename T>
GLM_FUNC_QUALIFIER detail::tvec4<T> grad4(T const & j, detail::tvec4<T> const & ip)
{
detail::tvec3<T> pXYZ = floor(fract(detail::tvec3<T>(j) * detail::tvec3<T>(ip)) * T(7)) * ip[2] - T(1);
T pW = T(1.5) - dot(abs(pXYZ), detail::tvec3<T>(1));
detail::tvec4<T> s = detail::tvec4<T>(lessThan(detail::tvec4<T>(pXYZ, pW), detail::tvec4<T>(0.0)));
pXYZ = pXYZ + (detail::tvec3<T>(s) * T(2) - T(1)) * s.w;
return detail::tvec4<T>(pXYZ, pW);
}
}
// Classic Perlin noise
template <typename T>
GLM_FUNC_QUALIFIER T perlin(detail::tvec2<T> const & P)
{
// Classic Perlin noise
template <typename T>
GLM_FUNC_QUALIFIER T perlin(detail::tvec2<T> const & P)
{
detail::tvec4<T> Pi = glm::floor(detail::tvec4<T>(P.x, P.y, P.x, P.y)) + detail::tvec4<T>(0.0, 0.0, 1.0, 1.0);
detail::tvec4<T> Pf = glm::fract(detail::tvec4<T>(P.x, P.y, P.x, P.y)) - detail::tvec4<T>(0.0, 0.0, 1.0, 1.0);
Pi = mod(Pi, T(289)); // To avoid truncation effects in permutation
@ -102,12 +102,12 @@ GLM_FUNC_QUALIFIER T perlin(detail::tvec2<T> const & P)
detail::tvec2<T> n_x = mix(detail::tvec2<T>(n00, n01), detail::tvec2<T>(n10, n11), fade_xy.x);
T n_xy = mix(n_x.x, n_x.y, fade_xy.y);
return T(2.3) * n_xy;
}
}
// Classic Perlin noise
template <typename T>
GLM_FUNC_QUALIFIER T perlin(detail::tvec3<T> const & P)
{
// Classic Perlin noise
template <typename T>
GLM_FUNC_QUALIFIER T perlin(detail::tvec3<T> const & P)
{
detail::tvec3<T> Pi0 = floor(P); // Integer part for indexing
detail::tvec3<T> Pi1 = Pi0 + T(1); // Integer part + 1
Pi0 = mod289(Pi0);
@ -173,12 +173,12 @@ GLM_FUNC_QUALIFIER T perlin(detail::tvec3<T> const & P)
detail::tvec2<T> n_yz = mix(detail::tvec2<T>(n_z.x, n_z.y), detail::tvec2<T>(n_z.z, n_z.w), fade_xyz.y);
T n_xyz = mix(n_yz.x, n_yz.y, fade_xyz.x);
return T(2.2) * n_xyz;
}
/*
// Classic Perlin noise
template <typename T>
GLM_FUNC_QUALIFIER T perlin(detail::tvec3<T> const & P)
{
}
/*
// Classic Perlin noise
template <typename T>
GLM_FUNC_QUALIFIER T perlin(detail::tvec3<T> const & P)
{
detail::tvec3<T> Pi0 = floor(P); // Integer part for indexing
detail::tvec3<T> Pi1 = Pi0 + T(1); // Integer part + 1
Pi0 = mod(Pi0, T(289));
@ -246,12 +246,12 @@ GLM_FUNC_QUALIFIER T perlin(detail::tvec3<T> const & P)
detail::tvec2<T>(n_z.z, n_z.w), fade_xyz.y);
T n_xyz = mix(n_yz.x, n_yz.y, fade_xyz.x);
return T(2.2) * n_xyz;
}
*/
// Classic Perlin noise
template <typename T>
GLM_FUNC_QUALIFIER T perlin(detail::tvec4<T> const & P)
{
}
*/
// Classic Perlin noise
template <typename T>
GLM_FUNC_QUALIFIER T perlin(detail::tvec4<T> const & P)
{
detail::tvec4<T> Pi0 = floor(P); // Integer part for indexing
detail::tvec4<T> Pi1 = Pi0 + T(1); // Integer part + 1
Pi0 = mod(Pi0, T(289));
@ -382,12 +382,12 @@ GLM_FUNC_QUALIFIER T perlin(detail::tvec4<T> const & P)
detail::tvec2<T> n_yzw = mix(detail::tvec2<T>(n_zw.x, n_zw.y), detail::tvec2<T>(n_zw.z, n_zw.w), fade_xyzw.y);
T n_xyzw = mix(n_yzw.x, n_yzw.y, fade_xyzw.x);
return T(2.2) * n_xyzw;
}
}
// Classic Perlin noise, periodic variant
template <typename T>
GLM_FUNC_QUALIFIER T perlin(detail::tvec2<T> const & P, detail::tvec2<T> const & rep)
{
// Classic Perlin noise, periodic variant
template <typename T>
GLM_FUNC_QUALIFIER T perlin(detail::tvec2<T> const & P, detail::tvec2<T> const & rep)
{
detail::tvec4<T> Pi = floor(detail::tvec4<T>(P.x, P.y, P.x, P.y)) + detail::tvec4<T>(0.0, 0.0, 1.0, 1.0);
detail::tvec4<T> Pf = fract(detail::tvec4<T>(P.x, P.y, P.x, P.y)) - detail::tvec4<T>(0.0, 0.0, 1.0, 1.0);
Pi = mod(Pi, detail::tvec4<T>(rep.x, rep.y, rep.x, rep.y)); // To create noise with explicit period
@ -424,12 +424,12 @@ GLM_FUNC_QUALIFIER T perlin(detail::tvec2<T> const & P, detail::tvec2<T> const &
detail::tvec2<T> n_x = mix(detail::tvec2<T>(n00, n01), detail::tvec2<T>(n10, n11), fade_xy.x);
T n_xy = mix(n_x.x, n_x.y, fade_xy.y);
return T(2.3) * n_xy;
}
}
// Classic Perlin noise, periodic variant
template <typename T>
GLM_FUNC_QUALIFIER T perlin(detail::tvec3<T> const & P, detail::tvec3<T> const & rep)
{
// Classic Perlin noise, periodic variant
template <typename T>
GLM_FUNC_QUALIFIER T perlin(detail::tvec3<T> const & P, detail::tvec3<T> const & rep)
{
detail::tvec3<T> Pi0 = mod(floor(P), rep); // Integer part, modulo period
detail::tvec3<T> Pi1 = mod(Pi0 + detail::tvec3<T>(1.0), rep); // Integer part + 1, mod period
Pi0 = mod(Pi0, T(289));
@ -495,12 +495,12 @@ GLM_FUNC_QUALIFIER T perlin(detail::tvec3<T> const & P, detail::tvec3<T> const &
detail::tvec2<T> n_yz = mix(detail::tvec2<T>(n_z.x, n_z.y), detail::tvec2<T>(n_z.z, n_z.w), fade_xyz.y);
T n_xyz = mix(n_yz.x, n_yz.y, fade_xyz.x);
return T(2.2) * n_xyz;
}
}
// Classic Perlin noise, periodic version
template <typename T>
GLM_FUNC_QUALIFIER T perlin(detail::tvec4<T> const & P, detail::tvec4<T> const & rep)
{
// Classic Perlin noise, periodic version
template <typename T>
GLM_FUNC_QUALIFIER T perlin(detail::tvec4<T> const & P, detail::tvec4<T> const & rep)
{
detail::tvec4<T> Pi0 = mod(floor(P), rep); // Integer part modulo rep
detail::tvec4<T> Pi1 = mod(Pi0 + T(1), rep); // Integer part + 1 mod rep
detail::tvec4<T> Pf0 = fract(P); // Fractional part for interpolation
@ -629,11 +629,11 @@ GLM_FUNC_QUALIFIER T perlin(detail::tvec4<T> const & P, detail::tvec4<T> const &
detail::tvec2<T> n_yzw = mix(detail::tvec2<T>(n_zw.x, n_zw.y), detail::tvec2<T>(n_zw.z, n_zw.w), fade_xyzw.y);
T n_xyzw = mix(n_yzw.x, n_yzw.y, fade_xyzw.x);
return T(2.2) * n_xyzw;
}
}
template <typename T>
GLM_FUNC_QUALIFIER T simplex(glm::detail::tvec2<T> const & v)
{
template <typename T>
GLM_FUNC_QUALIFIER T simplex(glm::detail::tvec2<T> const & v)
{
detail::tvec4<T> const C = detail::tvec4<T>(
T( 0.211324865405187), // (3.0 - sqrt(3.0)) / 6.0
T( 0.366025403784439), // 0.5 * (sqrt(3.0) - 1.0)
@ -686,11 +686,11 @@ GLM_FUNC_QUALIFIER T simplex(glm::detail::tvec2<T> const & v)
g.y = a0.y * x12.x + h.y * x12.y;
g.z = a0.z * x12.z + h.z * x12.w;
return T(130) * dot(m, g);
}
}
template <typename T>
GLM_FUNC_QUALIFIER T simplex(detail::tvec3<T> const & v)
{
template <typename T>
GLM_FUNC_QUALIFIER T simplex(detail::tvec3<T> const & v)
{
detail::tvec2<T> const C(1.0 / 6.0, 1.0 / 3.0);
detail::tvec4<T> const D(0.0, 0.5, 1.0, 2.0);
@ -761,11 +761,11 @@ GLM_FUNC_QUALIFIER T simplex(detail::tvec3<T> const & v)
detail::tvec4<T> m = max(T(0.6) - detail::tvec4<T>(dot(x0, x0), dot(x1, x1), dot(x2, x2), dot(x3, x3)), T(0));
m = m * m;
return T(42) * dot(m * m, detail::tvec4<T>(dot(p0, x0), dot(p1, x1), dot(p2, x2), dot(p3, x3)));
}
}
template <typename T>
GLM_FUNC_QUALIFIER T simplex(detail::tvec4<T> const & v)
{
template <typename T>
GLM_FUNC_QUALIFIER T simplex(detail::tvec4<T> const & v)
{
detail::tvec4<T> const C(
0.138196601125011, // (5 - sqrt(5))/20 G4
0.276393202250021, // 2 * G4
@ -847,6 +847,5 @@ GLM_FUNC_QUALIFIER T simplex(detail::tvec4<T> const & v)
return T(49) *
(dot(m0 * m0, detail::tvec3<T>(dot(p0, x0), dot(p1, x1), dot(p2, x2))) +
dot(m1 * m1, detail::tvec2<T>(dot(p3, x3), dot(p4, x4))));
}
}
}//namespace glm

@ -29,8 +29,8 @@
#include <limits>
namespace glm{
namespace detail{
namespace detail
{
template <typename T>
GLM_FUNC_QUALIFIER tquat<T>::tquat() :
x(0),

@ -9,85 +9,59 @@
#include <ctime>
#include <cassert>
#include "../core/_vectorize.hpp"
namespace glm{
template <>
GLM_FUNC_QUALIFIER glm::half linearRand
(
glm::half const & Min,
glm::half const & Max
)
{
return glm::half(float(std::rand()) / float(RAND_MAX) * (float(Max) - float(Min)) + float(Min));
}
template <>
GLM_FUNC_QUALIFIER float linearRand
(
float const & Min,
float const & Max
)
namespace detail
{
struct compute_linearRand
{
template <typename T>
GLM_FUNC_QUALIFIER T operator() (T const & Min, T const & Max) const
{
GLM_STATIC_ASSERT(0, "'linearRand' invalid template parameter type. GLM_GTC_random only supports floating-point template types.");
return Min;
}
};
template <>
GLM_FUNC_QUALIFIER half compute_linearRand::operator()<half> (half const & Min, half const & Max) const
{
return half(float(std::rand()) / float(RAND_MAX) * (float(Max) - float(Min)) + float(Min));
}
template <>
GLM_FUNC_QUALIFIER float compute_linearRand::operator()<float> (float const & Min, float const & Max) const
{
return float(std::rand()) / float(RAND_MAX) * (Max - Min) + Min;
}
template <>
GLM_FUNC_QUALIFIER double linearRand
(
double const & Min,
double const & Max
)
{
}
template <>
GLM_FUNC_QUALIFIER double compute_linearRand::operator()<double> (double const & Min, double const & Max) const
{
return double(std::rand()) / double(RAND_MAX) * (Max - Min) + Min;
}
template <typename T>
GLM_FUNC_QUALIFIER detail::tvec2<T> linearRand
(
detail::tvec2<T> const & Min,
detail::tvec2<T> const & Max
)
{
return detail::tvec2<T>(
linearRand(Min.x, Max.x),
linearRand(Min.y, Max.y));
}
template <typename T>
GLM_FUNC_QUALIFIER detail::tvec3<T> linearRand
(
detail::tvec3<T> const & Min,
detail::tvec3<T> const & Max
)
{
return detail::tvec3<T>(
linearRand(Min.x, Max.x),
linearRand(Min.y, Max.y),
linearRand(Min.z, Max.z));
}
template <typename T>
GLM_FUNC_QUALIFIER detail::tvec4<T> linearRand
(
detail::tvec4<T> const & Min,
detail::tvec4<T> const & Max
)
{
return detail::tvec4<T>(
linearRand(Min.x, Max.x),
linearRand(Min.y, Max.y),
linearRand(Min.z, Max.z),
linearRand(Min.w, Max.w));
}
template <typename genType>
GLM_FUNC_QUALIFIER genType gaussRand
(
}
}//namespace detail
template <typename genType>
GLM_FUNC_QUALIFIER genType linearRand
(
genType const & Min,
genType const & Max
)
{
return detail::compute_linearRand()(Min, Max);
}
VECTORIZE_VEC_VEC(linearRand)
template <typename genType>
GLM_FUNC_QUALIFIER genType gaussRand
(
genType const & Mean,
genType const & Deviation
)
{
)
{
genType w, x1, x2;
do
@ -99,53 +73,16 @@ GLM_FUNC_QUALIFIER genType gaussRand
} while(w > genType(1));
return x2 * Deviation * Deviation * sqrt((genType(-2) * log(w)) / w) + Mean;
}
template <typename T>
GLM_FUNC_QUALIFIER detail::tvec2<T> gaussRand
(
detail::tvec2<T> const & Mean,
detail::tvec2<T> const & Deviation
)
{
return detail::tvec2<T>(
gaussRand(Mean.x, Deviation.x),
gaussRand(Mean.y, Deviation.y));
}
template <typename T>
GLM_FUNC_QUALIFIER detail::tvec3<T> gaussRand
(
detail::tvec3<T> const & Mean,
detail::tvec3<T> const & Deviation
)
{
return detail::tvec3<T>(
gaussRand(Mean.x, Deviation.x),
gaussRand(Mean.y, Deviation.y),
gaussRand(Mean.z, Deviation.z));
}
template <typename T>
GLM_FUNC_QUALIFIER detail::tvec4<T> gaussRand
(
detail::tvec4<T> const & Mean,
detail::tvec4<T> const & Deviation
)
{
return detail::tvec4<T>(
gaussRand(Mean.x, Deviation.x),
gaussRand(Mean.y, Deviation.y),
gaussRand(Mean.z, Deviation.z),
gaussRand(Mean.w, Deviation.w));
}
template <typename T>
GLM_FUNC_QUALIFIER detail::tvec2<T> diskRand
(
}
VECTORIZE_VEC_VEC(gaussRand)
template <typename T>
GLM_FUNC_QUALIFIER detail::tvec2<T> diskRand
(
T const & Radius
)
{
)
{
detail::tvec2<T> Result(T(0));
T LenRadius(T(0));
@ -157,14 +94,14 @@ GLM_FUNC_QUALIFIER detail::tvec2<T> diskRand
while(LenRadius > Radius);
return Result;
}
}
template <typename T>
GLM_FUNC_QUALIFIER detail::tvec3<T> ballRand
(
template <typename T>
GLM_FUNC_QUALIFIER detail::tvec3<T> ballRand
(
T const & Radius
)
{
)
{
detail::tvec3<T> Result(T(0));
T LenRadius(T(0));
@ -176,24 +113,24 @@ GLM_FUNC_QUALIFIER detail::tvec3<T> ballRand
while(LenRadius > Radius);
return Result;
}
}
template <typename T>
GLM_FUNC_QUALIFIER detail::tvec2<T> circularRand
(
template <typename T>
GLM_FUNC_QUALIFIER detail::tvec2<T> circularRand
(
T const & Radius
)
{
)
{
T a = linearRand(T(0), T(6.283185307179586476925286766559f));
return detail::tvec2<T>(cos(a), sin(a)) * Radius;
}
}
template <typename T>
GLM_FUNC_QUALIFIER detail::tvec3<T> sphericalRand
(
template <typename T>
GLM_FUNC_QUALIFIER detail::tvec3<T> sphericalRand
(
T const & Radius
)
{
)
{
T z = linearRand(T(-1), T(1));
T a = linearRand(T(0), T(6.283185307179586476925286766559f));
@ -203,6 +140,5 @@ GLM_FUNC_QUALIFIER detail::tvec3<T> sphericalRand
T y = r * sin(a);
return detail::tvec3<T>(x, y, z) * Radius;
}
}
}//namespace glm

@ -26,165 +26,91 @@
/// @author Christophe Riccio
///////////////////////////////////////////////////////////////////////////////////
namespace glm{
template <typename T, template <typename> class vecType>
GLM_FUNC_QUALIFIER T swizzle
(
namespace glm
{
template <typename T, template <typename> class vecType>
GLM_FUNC_QUALIFIER T swizzle
(
vecType<T> const & v,
comp x
)
{
)
{
assert(int(x) < int(vecType<T>::value_size));
return v[x];
}
}
template <typename T, template <typename> class vecType>
GLM_FUNC_QUALIFIER detail::tvec2<T> swizzle
(
template <typename T, template <typename> class vecType>
GLM_FUNC_QUALIFIER detail::tvec2<T> swizzle
(
vecType<T> const & v,
comp x, comp y
)
{
)
{
return detail::tvec2<T>(
v[x],
v[y]);
}
}
template <typename T, template <typename> class vecType>
GLM_FUNC_QUALIFIER detail::tvec3<T> swizzle
(
template <typename T, template <typename> class vecType>
GLM_FUNC_QUALIFIER detail::tvec3<T> swizzle
(
vecType<T> const & v,
comp x, comp y, comp z
)
{
)
{
return detail::tvec3<T>(
v[x],
v[y],
v[z]);
}
}
template <typename T, template <typename> class vecType>
GLM_FUNC_QUALIFIER detail::tvec4<T> swizzle
(
template <typename T, template <typename> class vecType>
GLM_FUNC_QUALIFIER detail::tvec4<T> swizzle
(
vecType<T> const & v,
comp x, comp y, comp z, comp w
)
{
)
{
return detail::tvec4<T>(v[x], v[y], v[z], v[w]);
}
}
template <typename T>
GLM_FUNC_QUALIFIER T& swizzle
(
template <typename T>
GLM_FUNC_QUALIFIER T& swizzle
(
detail::tvec4<T> & v,
comp x
)
{
)
{
return v[x];
}
}
template <typename T>
GLM_FUNC_QUALIFIER detail::tref2<T> swizzle
(
template <typename T>
GLM_FUNC_QUALIFIER detail::tref2<T> swizzle
(
detail::tvec4<T> & v,
comp x, comp y
)
{
)
{
return detail::tref2<T>(v[x], v[y]);
}
}
template <typename T>
GLM_FUNC_QUALIFIER detail::tref3<T> swizzle
(
template <typename T>
GLM_FUNC_QUALIFIER detail::tref3<T> swizzle
(
detail::tvec4<T> & v,
comp x, comp y, comp z
)
{
)
{
return detail::tref3<T>(v[x], v[y], v[z]);
}
}
template <typename T>
GLM_FUNC_QUALIFIER detail::tref4<T> swizzle
(
template <typename T>
GLM_FUNC_QUALIFIER detail::tref4<T> swizzle
(
detail::tvec4<T> & v,
comp x, comp y, comp z, comp w
)
{
)
{
return detail::tref4<T>(v[x], v[y], v[z], v[w]);
}
/*
template <comp x>
GLM_FUNC_QUALIFIER float& swizzle
(
detail::tvec4<float> & v
)
{
return v[x];
}
template <comp x>
GLM_FUNC_QUALIFIER int& swizzle
(
detail::tvec4<int> & v
)
{
return v[x];
}
template <comp x, comp y>
GLM_FUNC_QUALIFIER detail::tref2<float> swizzle
(
detail::tvec4<float> & v
)
{
return detail::tref2<float>(v[x], v[y]);
}
template <comp x, comp y>
GLM_FUNC_QUALIFIER detail::tref2<int> swizzle
(
detail::tvec4<int> & v
)
{
return detail::tref2<int>(v[x], v[y]);
}
template <comp x, comp y, comp z>
GLM_FUNC_QUALIFIER detail::tref3<float> swizzle
(
detail::tvec4<float> & v
)
{
return detail::tref3<float>(v[x], v[y], v[z]);
}
template <comp x, comp y, comp z>
GLM_FUNC_QUALIFIER detail::tref3<int> swizzle
(
detail::tvec4<int> & v
)
{
return detail::tref3<int>(v[x], v[y], v[z]);
}
template <comp x, comp y, comp z, comp w>
GLM_FUNC_QUALIFIER detail::tref4<float> swizzle
(
detail::tvec4<float> & v
)
{
return detail::tref4<float>(v[x], v[y], v[z], v[w]);
}
template <comp x, comp y, comp z, comp w>
GLM_FUNC_QUALIFIER detail::tref4<int> swizzle
(
detail::tvec4<int> & v
)
{
return detail::tref4<int>(v[x], v[y], v[z], v[w]);
}
*/
}
}//namespace glm

@ -2,66 +2,36 @@
// OpenGL Mathematics Copyright (c) 2005 - 2011 G-Truc Creation (www.g-truc.net)
///////////////////////////////////////////////////////////////////////////////////////////////////
// Created : 2006-01-04
// Updated : 2008-10-07
// Updated : 2011-10-14
// Licence : This source is under MIT License
// File : glm/gtx/fast_square_root.inl
///////////////////////////////////////////////////////////////////////////////////////////////////
namespace glm{
#include "../core/_vectorize.hpp"
// fastSqrt
template <typename genType>
GLM_FUNC_QUALIFIER genType fastSqrt
(
genType const & x
)
{
return genType(1) / fastInverseSqrt(x);
}
template <typename valType>
GLM_FUNC_QUALIFIER detail::tvec2<valType> fastSqrt
(
detail::tvec2<valType> const & x
)
namespace glm
{
return detail::tvec2<valType>(
fastSqrt(x.x),
fastSqrt(x.y));
}
// fastSqrt
template <typename genType>
GLM_FUNC_QUALIFIER genType fastSqrt
(
genType const & x
)
{
GLM_STATIC_ASSERT(detail::type<genType>::is_float, "'fastSqrt' only accept floating-point input");
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));
}
return genType(1) / fastInverseSqrt(x);
}
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));
}
VECTORIZE_VEC(fastSqrt)
// fastInversesqrt
template <typename genType>
GLM_FUNC_QUALIFIER genType fastInverseSqrt
(
// fastInversesqrt
template <typename genType>
GLM_FUNC_QUALIFIER genType fastInverseSqrt
(
genType const & x
)
{
)
{
genType tmp = x;
float xhalf = 0.5f * float(tmp);
uint i = *(uint*)&x;
@ -71,163 +41,98 @@ GLM_FUNC_QUALIFIER genType fastInverseSqrt
tmp = detail::uif(i).f;
tmp = tmp * (1.5f - xhalf * tmp * tmp);
return genType(tmp);
}
template <typename valType>
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));
}
VECTORIZE_VEC(fastInverseSqrt)
// fastLength
template <typename genType>
GLM_FUNC_QUALIFIER genType fastLength
(
// fastLength
template <typename genType>
GLM_FUNC_QUALIFIER genType fastLength
(
genType const & x
)
{
)
{
return abs(x);
}
}
template <typename valType>
GLM_FUNC_QUALIFIER valType fastLength
(
template <typename valType>
GLM_FUNC_QUALIFIER valType fastLength
(
detail::tvec2<valType> const & x
)
{
)
{
valType sqr = x.x * x.x + x.y * x.y;
return fastSqrt(sqr);
}
}
template <typename valType>
GLM_FUNC_QUALIFIER valType fastLength
(
template <typename valType>
GLM_FUNC_QUALIFIER valType fastLength
(
detail::tvec3<valType> const & x
)
{
)
{
valType sqr = x.x * x.x + x.y * x.y + x.z * x.z;
return fastSqrt(sqr);
}
}
template <typename valType>
GLM_FUNC_QUALIFIER valType fastLength
(
template <typename valType>
GLM_FUNC_QUALIFIER valType fastLength
(
detail::tvec4<valType> const & x
)
{
)
{
valType sqr = x.x * x.x + x.y * x.y + x.z * x.z + x.w * x.w;
return fastSqrt(sqr);
}
}
// fastDistance
template <typename genType>
GLM_FUNC_QUALIFIER genType fastDistance
(
// fastDistance
template <typename genType>
GLM_FUNC_QUALIFIER genType fastDistance
(
genType const & x,
genType const & y
)
{
)
{
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
template <typename genType>
GLM_FUNC_QUALIFIER genType fastNormalize
(
// fastNormalize
template <typename genType>
GLM_FUNC_QUALIFIER genType fastNormalize
(
genType const & x
)
{
)
{
return x > genType(0) ? genType(1) : -genType(1);
}
}
template <typename valType>
GLM_FUNC_QUALIFIER detail::tvec2<valType> fastNormalize
(
template <typename valType>
GLM_FUNC_QUALIFIER detail::tvec2<valType> fastNormalize
(
detail::tvec2<valType> const & x
)
{
)
{
valType sqr = x.x * x.x + x.y * x.y;
return x * fastInverseSqrt(sqr);
}
}
template <typename valType>
GLM_FUNC_QUALIFIER detail::tvec3<valType> fastNormalize
(
template <typename valType>
GLM_FUNC_QUALIFIER detail::tvec3<valType> fastNormalize
(
detail::tvec3<valType> const & x
)
{
)
{
valType sqr = x.x * x.x + x.y * x.y + x.z * x.z;
return x * fastInverseSqrt(sqr);
}
}
template <typename valType>
GLM_FUNC_QUALIFIER detail::tvec4<valType> fastNormalize
(
template <typename valType>
GLM_FUNC_QUALIFIER detail::tvec4<valType> fastNormalize
(
detail::tvec4<valType> const & x
)
{
)
{
valType sqr = x.x * x.x + x.y * x.y + x.z * x.z + x.w * x.w;
return x * fastInverseSqrt(sqr);
}
}
}//namespace glm

Loading…
Cancel
Save