mirror of
https://github.com/g-truc/glm.git
synced 2024-11-30 03:44:38 +00:00
Merge branch '0.9.3' into swizzle
This commit is contained in:
commit
dc7d8f5c0c
159
glm/core/_vectorize.hpp
Normal file
159
glm/core/_vectorize.hpp
Normal file
@ -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));
|
||||
}
|
||||
VECTORIZE_VEC(round)
|
||||
|
||||
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));
|
||||
}
|
||||
|
||||
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,8 +26,8 @@
|
||||
/// @author Christophe Riccio
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
namespace glm{
|
||||
|
||||
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)));
|
||||
@ -155,5 +155,4 @@ 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,8 +26,10 @@
|
||||
/// @author Christophe Riccio
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
namespace glm{
|
||||
#include "_vectorize.hpp"
|
||||
|
||||
namespace glm
|
||||
{
|
||||
// radians
|
||||
template <typename genType>
|
||||
GLM_FUNC_QUALIFIER genType radians
|
||||
@ -37,45 +39,11 @@ GLM_FUNC_QUALIFIER genType radians
|
||||
{
|
||||
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));
|
||||
}
|
||||
VECTORIZE_VEC(radians)
|
||||
|
||||
// degrees
|
||||
template <typename genType>
|
||||
@ -90,41 +58,7 @@ GLM_FUNC_QUALIFIER genType degrees
|
||||
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));
|
||||
}
|
||||
VECTORIZE_VEC(degrees)
|
||||
|
||||
// sin
|
||||
template <typename genType>
|
||||
@ -138,41 +72,7 @@ GLM_FUNC_QUALIFIER genType sin
|
||||
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));
|
||||
}
|
||||
VECTORIZE_VEC(sin)
|
||||
|
||||
// cos
|
||||
template <typename genType>
|
||||
@ -183,41 +83,7 @@ GLM_FUNC_QUALIFIER genType cos(genType const & angle)
|
||||
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));
|
||||
}
|
||||
VECTORIZE_VEC(cos)
|
||||
|
||||
// tan
|
||||
template <typename genType>
|
||||
@ -231,41 +97,7 @@ GLM_FUNC_QUALIFIER genType tan
|
||||
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));
|
||||
}
|
||||
VECTORIZE_VEC(tan)
|
||||
|
||||
// asin
|
||||
template <typename genType>
|
||||
@ -279,41 +111,7 @@ GLM_FUNC_QUALIFIER genType asin
|
||||
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));
|
||||
}
|
||||
VECTORIZE_VEC(asin)
|
||||
|
||||
// acos
|
||||
template <typename genType>
|
||||
@ -327,41 +125,7 @@ GLM_FUNC_QUALIFIER genType acos
|
||||
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));
|
||||
}
|
||||
VECTORIZE_VEC(acos)
|
||||
|
||||
// atan
|
||||
template <typename genType>
|
||||
@ -376,44 +140,7 @@ GLM_FUNC_QUALIFIER genType atan
|
||||
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));
|
||||
}
|
||||
VECTORIZE_VEC_VEC(atan)
|
||||
|
||||
template <typename genType>
|
||||
GLM_FUNC_QUALIFIER genType atan
|
||||
@ -426,41 +153,7 @@ GLM_FUNC_QUALIFIER genType atan
|
||||
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));
|
||||
}
|
||||
VECTORIZE_VEC(atan)
|
||||
|
||||
// sinh
|
||||
template <typename genType>
|
||||
@ -474,41 +167,7 @@ GLM_FUNC_QUALIFIER genType sinh
|
||||
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));
|
||||
}
|
||||
VECTORIZE_VEC(sinh)
|
||||
|
||||
// cosh
|
||||
template <typename genType>
|
||||
@ -522,41 +181,7 @@ GLM_FUNC_QUALIFIER genType cosh
|
||||
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));
|
||||
}
|
||||
VECTORIZE_VEC(cosh)
|
||||
|
||||
// tanh
|
||||
template <typename genType>
|
||||
@ -570,41 +195,7 @@ GLM_FUNC_QUALIFIER genType tanh
|
||||
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));
|
||||
}
|
||||
VECTORIZE_VEC(tanh)
|
||||
|
||||
// asinh
|
||||
template <typename genType>
|
||||
@ -618,41 +209,7 @@ GLM_FUNC_QUALIFIER genType asinh
|
||||
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));
|
||||
}
|
||||
VECTORIZE_VEC(asinh)
|
||||
|
||||
// acosh
|
||||
template <typename genType>
|
||||
@ -668,41 +225,7 @@ GLM_FUNC_QUALIFIER genType acosh
|
||||
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));
|
||||
}
|
||||
VECTORIZE_VEC(acosh)
|
||||
|
||||
// atanh
|
||||
template <typename genType>
|
||||
@ -718,40 +241,6 @@ GLM_FUNC_QUALIFIER genType atanh
|
||||
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
|
||||
|
@ -27,8 +27,8 @@
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
namespace glm{
|
||||
namespace detail{
|
||||
|
||||
namespace detail
|
||||
{
|
||||
#ifndef _MSC_EXTENSIONS
|
||||
|
||||
//////////////////////////////////////
|
||||
|
@ -26,13 +26,15 @@
|
||||
/// @author Christophe Riccio
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
namespace glm{
|
||||
|
||||
namespace glm
|
||||
{
|
||||
template <typename genType>
|
||||
GLM_FUNC_QUALIFIER genType row(
|
||||
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)
|
||||
@ -41,9 +43,11 @@ GLM_FUNC_QUALIFIER genType row(
|
||||
}
|
||||
|
||||
template <typename genType>
|
||||
GLM_FUNC_QUALIFIER typename genType::row_type row(
|
||||
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)
|
||||
@ -52,10 +56,12 @@ GLM_FUNC_QUALIFIER typename genType::row_type row(
|
||||
}
|
||||
|
||||
template <typename genType>
|
||||
GLM_FUNC_QUALIFIER genType column(
|
||||
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;
|
||||
@ -63,12 +69,12 @@ GLM_FUNC_QUALIFIER genType column(
|
||||
}
|
||||
|
||||
template <typename genType>
|
||||
GLM_FUNC_QUALIFIER typename genType::col_type column(
|
||||
GLM_FUNC_QUALIFIER typename genType::col_type column
|
||||
(
|
||||
genType const & m,
|
||||
int index)
|
||||
int index
|
||||
)
|
||||
{
|
||||
return m[index];
|
||||
}
|
||||
|
||||
}//namespace glm
|
||||
|
||||
|
@ -26,8 +26,8 @@
|
||||
/// @author Christophe Riccio
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
namespace glm{
|
||||
|
||||
namespace glm
|
||||
{
|
||||
template <typename T>
|
||||
GLM_FUNC_QUALIFIER detail::tmat3x3<T> affineInverse
|
||||
(
|
||||
@ -57,8 +57,10 @@ GLM_FUNC_QUALIFIER detail::tmat4x4<T> affineInverse
|
||||
}
|
||||
|
||||
template <typename valType>
|
||||
GLM_FUNC_QUALIFIER detail::tmat2x2<valType> inverseTranspose(
|
||||
detail::tmat2x2<valType> const & m)
|
||||
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];
|
||||
|
||||
@ -72,8 +74,10 @@ GLM_FUNC_QUALIFIER detail::tmat2x2<valType> inverseTranspose(
|
||||
}
|
||||
|
||||
template <typename valType>
|
||||
GLM_FUNC_QUALIFIER detail::tmat3x3<valType> inverseTranspose(
|
||||
detail::tmat3x3<valType> const & m)
|
||||
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])
|
||||
@ -96,8 +100,10 @@ GLM_FUNC_QUALIFIER detail::tmat3x3<valType> inverseTranspose(
|
||||
}
|
||||
|
||||
template <typename valType>
|
||||
GLM_FUNC_QUALIFIER detail::tmat4x4<valType> inverseTranspose(
|
||||
detail::tmat4x4<valType> const & m)
|
||||
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];
|
||||
@ -150,5 +156,4 @@ GLM_FUNC_QUALIFIER detail::tmat4x4<valType> inverseTranspose(
|
||||
|
||||
return Inverse;
|
||||
}
|
||||
|
||||
}//namespace glm
|
||||
|
@ -26,8 +26,8 @@
|
||||
/// @author Christophe Riccio
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
namespace glm{
|
||||
|
||||
namespace glm
|
||||
{
|
||||
template <typename T>
|
||||
GLM_FUNC_QUALIFIER detail::tmat4x4<T> translate
|
||||
(
|
||||
@ -409,5 +409,4 @@ GLM_FUNC_QUALIFIER detail::tmat4x4<T> lookAt
|
||||
*/
|
||||
return translate(Result, -eye);
|
||||
}
|
||||
|
||||
}//namespace glm
|
||||
|
@ -15,8 +15,8 @@
|
||||
// - GLM core
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
namespace glm{
|
||||
|
||||
namespace glm
|
||||
{
|
||||
template <typename T>
|
||||
GLM_FUNC_QUALIFIER T mod289(T const & x)
|
||||
{
|
||||
@ -848,5 +848,4 @@ GLM_FUNC_QUALIFIER T simplex(detail::tvec4<T> const & v)
|
||||
(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,77 +9,51 @@
|
||||
|
||||
#include <ctime>
|
||||
#include <cassert>
|
||||
#include "../core/_vectorize.hpp"
|
||||
|
||||
namespace glm{
|
||||
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 glm::half linearRand
|
||||
(
|
||||
glm::half const & Min,
|
||||
glm::half const & Max
|
||||
)
|
||||
GLM_FUNC_QUALIFIER half compute_linearRand::operator()<half> (half const & Min, half const & Max) const
|
||||
{
|
||||
return glm::half(float(std::rand()) / float(RAND_MAX) * (float(Max) - float(Min)) + float(Min));
|
||||
return 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
|
||||
)
|
||||
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
|
||||
)
|
||||
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;
|
||||
}
|
||||
}//namespace detail
|
||||
|
||||
template <typename T>
|
||||
GLM_FUNC_QUALIFIER detail::tvec2<T> linearRand
|
||||
template <typename genType>
|
||||
GLM_FUNC_QUALIFIER genType linearRand
|
||||
(
|
||||
detail::tvec2<T> const & Min,
|
||||
detail::tvec2<T> const & Max
|
||||
genType const & Min,
|
||||
genType const & Max
|
||||
)
|
||||
{
|
||||
return detail::tvec2<T>(
|
||||
linearRand(Min.x, Max.x),
|
||||
linearRand(Min.y, Max.y));
|
||||
return detail::compute_linearRand()(Min, Max);
|
||||
}
|
||||
|
||||
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));
|
||||
}
|
||||
VECTORIZE_VEC_VEC(linearRand)
|
||||
|
||||
template <typename genType>
|
||||
GLM_FUNC_QUALIFIER genType gaussRand
|
||||
@ -101,44 +75,7 @@ GLM_FUNC_QUALIFIER genType gaussRand
|
||||
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));
|
||||
}
|
||||
VECTORIZE_VEC_VEC(gaussRand)
|
||||
|
||||
template <typename T>
|
||||
GLM_FUNC_QUALIFIER detail::tvec2<T> diskRand
|
||||
@ -204,5 +141,4 @@ GLM_FUNC_QUALIFIER detail::tvec3<T> sphericalRand
|
||||
|
||||
return detail::tvec3<T>(x, y, z) * Radius;
|
||||
}
|
||||
|
||||
}//namespace glm
|
||||
|
@ -26,8 +26,8 @@
|
||||
/// @author Christophe Riccio
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
namespace glm{
|
||||
|
||||
namespace glm
|
||||
{
|
||||
template <typename T, template <typename> class vecType>
|
||||
GLM_FUNC_QUALIFIER T swizzle
|
||||
(
|
||||
@ -113,78 +113,4 @@ GLM_FUNC_QUALIFIER detail::tref4<T> swizzle
|
||||
{
|
||||
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,13 +2,15 @@
|
||||
// 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"
|
||||
|
||||
namespace glm
|
||||
{
|
||||
// fastSqrt
|
||||
template <typename genType>
|
||||
GLM_FUNC_QUALIFIER genType fastSqrt
|
||||
@ -16,44 +18,12 @@ GLM_FUNC_QUALIFIER genType fastSqrt
|
||||
genType const & x
|
||||
)
|
||||
{
|
||||
GLM_STATIC_ASSERT(detail::type<genType>::is_float, "'fastSqrt' only accept floating-point input");
|
||||
|
||||
return genType(1) / fastInverseSqrt(x);
|
||||
}
|
||||
|
||||
template <typename valType>
|
||||
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));
|
||||
}
|
||||
VECTORIZE_VEC(fastSqrt)
|
||||
|
||||
// fastInversesqrt
|
||||
template <typename genType>
|
||||
@ -73,41 +43,7 @@ GLM_FUNC_QUALIFIER genType fastInverseSqrt
|
||||
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>
|
||||
@ -160,36 +96,6 @@ GLM_FUNC_QUALIFIER genType fastDistance
|
||||
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
|
||||
@ -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;
|
||||
return x * fastInverseSqrt(sqr);
|
||||
}
|
||||
|
||||
}//namespace glm
|
||||
|
Loading…
Reference in New Issue
Block a user