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,134 +26,133 @@
|
||||
/// @author Christophe Riccio
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
namespace glm{
|
||||
|
||||
GLM_FUNC_QUALIFIER detail::uint32 packUnorm2x16(detail::tvec2<detail::float32> const & v)
|
||||
namespace glm
|
||||
{
|
||||
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)
|
||||
{
|
||||
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)
|
||||
{
|
||||
union iu
|
||||
GLM_FUNC_QUALIFIER detail::uint32 packUnorm2x16(detail::tvec2<detail::float32> const & v)
|
||||
{
|
||||
detail::int16 i;
|
||||
detail::uint16 u;
|
||||
} A, B;
|
||||
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)
|
||||
{
|
||||
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)
|
||||
{
|
||||
union iu
|
||||
{
|
||||
detail::int16 i;
|
||||
detail::uint16 u;
|
||||
} A, B;
|
||||
|
||||
detail::tvec2<detail::float32> Unpack = clamp(v ,-1.0f, 1.0f) * 32767.0f;
|
||||
A.i = detail::int16(round(Unpack.x));
|
||||
B.i = detail::int16(round(Unpack.y));
|
||||
detail::uint32 Pack = (detail::uint32(B.u) << 16) | (detail::uint32(A.u) << 0);
|
||||
return Pack;
|
||||
}
|
||||
detail::tvec2<detail::float32> Unpack = clamp(v ,-1.0f, 1.0f) * 32767.0f;
|
||||
A.i = detail::int16(round(Unpack.x));
|
||||
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)
|
||||
{
|
||||
union iu
|
||||
GLM_FUNC_QUALIFIER detail::tvec2<detail::float32> unpackSnorm2x16(detail::uint32 const & p)
|
||||
{
|
||||
detail::int16 i;
|
||||
detail::uint16 u;
|
||||
} A, B;
|
||||
union iu
|
||||
{
|
||||
detail::int16 i;
|
||||
detail::uint16 u;
|
||||
} A, B;
|
||||
|
||||
detail::uint32 Mask16((1 << 16) - 1);
|
||||
A.u = detail::uint16((p >> 0) & Mask16);
|
||||
B.u = detail::uint16((p >> 16) & Mask16);
|
||||
detail::tvec2<detail::float32> Pack(A.i, B.i);
|
||||
detail::uint32 Mask16((1 << 16) - 1);
|
||||
A.u = detail::uint16((p >> 0) & Mask16);
|
||||
B.u = detail::uint16((p >> 16) & Mask16);
|
||||
detail::tvec2<detail::float32> Pack(A.i, B.i);
|
||||
|
||||
return clamp(Pack * 1.0f / 32767.0f, -1.0f, 1.0f);
|
||||
}
|
||||
return clamp(Pack * 1.0f / 32767.0f, -1.0f, 1.0f);
|
||||
}
|
||||
|
||||
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)
|
||||
{
|
||||
detail::uint32 Mask8((1 << 8) - 1);
|
||||
detail::uint32 A((p >> 0) & Mask8);
|
||||
detail::uint32 B((p >> 8) & Mask8);
|
||||
detail::uint32 C((p >> 16) & Mask8);
|
||||
detail::uint32 D((p >> 24) & Mask8);
|
||||
return detail::tvec4<detail::float32>(
|
||||
A * 1.0f / 255.0f,
|
||||
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)
|
||||
{
|
||||
union iu
|
||||
GLM_FUNC_QUALIFIER detail::uint32 packUnorm4x8(detail::tvec4<detail::float32> const & v)
|
||||
{
|
||||
detail::int8 i;
|
||||
detail::uint8 u;
|
||||
} A, B, C, D;
|
||||
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)
|
||||
{
|
||||
detail::uint32 Mask8((1 << 8) - 1);
|
||||
detail::uint32 A((p >> 0) & Mask8);
|
||||
detail::uint32 B((p >> 8) & Mask8);
|
||||
detail::uint32 C((p >> 16) & Mask8);
|
||||
detail::uint32 D((p >> 24) & Mask8);
|
||||
return detail::tvec4<detail::float32>(
|
||||
A * 1.0f / 255.0f,
|
||||
B * 1.0f / 255.0f,
|
||||
C * 1.0f / 255.0f,
|
||||
D * 1.0f / 255.0f);
|
||||
}
|
||||
|
||||
detail::tvec4<detail::float32> Unpack = clamp(v ,-1.0f, 1.0f) * 127.0f;
|
||||
A.i = detail::int8(round(Unpack.x));
|
||||
B.i = detail::int8(round(Unpack.y));
|
||||
C.i = detail::int8(round(Unpack.z));
|
||||
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)
|
||||
{
|
||||
union iu
|
||||
GLM_FUNC_QUALIFIER detail::uint32 packSnorm4x8(detail::tvec4<detail::float32> const & v)
|
||||
{
|
||||
detail::int8 i;
|
||||
detail::uint8 u;
|
||||
} A, B, C, D;
|
||||
union iu
|
||||
{
|
||||
detail::int8 i;
|
||||
detail::uint8 u;
|
||||
} A, B, C, D;
|
||||
|
||||
detail::uint32 Mask8((1 << 8) - 1);
|
||||
A.u = detail::uint8((p >> 0) & Mask8);
|
||||
B.u = detail::uint8((p >> 8) & Mask8);
|
||||
C.u = detail::uint8((p >> 16) & Mask8);
|
||||
D.u = detail::uint8((p >> 24) & Mask8);
|
||||
detail::tvec4<detail::float32> Pack(A.i, B.i, C.i, D.i);
|
||||
detail::tvec4<detail::float32> Unpack = clamp(v ,-1.0f, 1.0f) * 127.0f;
|
||||
A.i = detail::int8(round(Unpack.x));
|
||||
B.i = detail::int8(round(Unpack.y));
|
||||
C.i = detail::int8(round(Unpack.z));
|
||||
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;
|
||||
}
|
||||
|
||||
return clamp(Pack * 1.0f / 127.0f, -1.0f, 1.0f);
|
||||
}
|
||||
GLM_FUNC_QUALIFIER detail::tvec4<detail::float32> unpackSnorm4x8(detail::uint32 const & p)
|
||||
{
|
||||
union iu
|
||||
{
|
||||
detail::int8 i;
|
||||
detail::uint8 u;
|
||||
} A, B, C, D;
|
||||
|
||||
detail::uint32 Mask8((1 << 8) - 1);
|
||||
A.u = detail::uint8((p >> 0) & Mask8);
|
||||
B.u = detail::uint8((p >> 8) & Mask8);
|
||||
C.u = detail::uint8((p >> 16) & Mask8);
|
||||
D.u = detail::uint8((p >> 24) & Mask8);
|
||||
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)
|
||||
{
|
||||
return *(double*)&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)
|
||||
{
|
||||
return *(detail::tvec2<uint>*)&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)
|
||||
{
|
||||
detail::tvec2<detail::hdata> Pack(detail::toFloat16(v.x), detail::toFloat16(v.y));
|
||||
return *(uint*)&Pack;
|
||||
}
|
||||
|
||||
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));
|
||||
}
|
||||
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)
|
||||
{
|
||||
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
|
||||
{
|
||||
GLM_STATIC_ASSERT(detail::type<genType>::is_float, "'radians' only accept floating-point input");
|
||||
// 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);
|
||||
return degrees * (pi / genType(180));
|
||||
}
|
||||
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));
|
||||
}
|
||||
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");
|
||||
|
||||
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));
|
||||
}
|
||||
const genType pi = genType(3.1415926535897932384626433832795);
|
||||
return radians * (genType(180) / pi);
|
||||
}
|
||||
|
||||
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(degrees)
|
||||
|
||||
// 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");
|
||||
// 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");
|
||||
|
||||
const genType pi = genType(3.1415926535897932384626433832795);
|
||||
return radians * (genType(180) / pi);
|
||||
}
|
||||
return ::std::sin(angle);
|
||||
}
|
||||
|
||||
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));
|
||||
}
|
||||
VECTORIZE_VEC(sin)
|
||||
|
||||
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));
|
||||
}
|
||||
// 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");
|
||||
|
||||
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));
|
||||
}
|
||||
return ::std::cos(angle);
|
||||
}
|
||||
|
||||
// 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");
|
||||
VECTORIZE_VEC(cos)
|
||||
|
||||
return ::std::sin(angle);
|
||||
}
|
||||
// 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");
|
||||
|
||||
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));
|
||||
}
|
||||
return ::std::tan(angle);
|
||||
}
|
||||
|
||||
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));
|
||||
}
|
||||
VECTORIZE_VEC(tan)
|
||||
|
||||
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));
|
||||
}
|
||||
// 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");
|
||||
|
||||
// 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::asin(x);
|
||||
}
|
||||
|
||||
return ::std::cos(angle);
|
||||
}
|
||||
VECTORIZE_VEC(asin)
|
||||
|
||||
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));
|
||||
}
|
||||
// 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");
|
||||
|
||||
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));
|
||||
}
|
||||
return ::std::acos(x);
|
||||
}
|
||||
|
||||
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(acos)
|
||||
|
||||
// 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");
|
||||
// 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::tan(angle);
|
||||
}
|
||||
return ::std::atan2(y, x);
|
||||
}
|
||||
|
||||
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));
|
||||
}
|
||||
VECTORIZE_VEC_VEC(atan)
|
||||
|
||||
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 genType>
|
||||
GLM_FUNC_QUALIFIER genType atan
|
||||
(
|
||||
genType const & x
|
||||
)
|
||||
{
|
||||
GLM_STATIC_ASSERT(detail::type<genType>::is_float, "'atan' only accept floating-point input");
|
||||
|
||||
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));
|
||||
}
|
||||
return ::std::atan(x);
|
||||
}
|
||||
|
||||
// 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");
|
||||
VECTORIZE_VEC(atan)
|
||||
|
||||
return ::std::asin(x);
|
||||
}
|
||||
// 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");
|
||||
|
||||
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));
|
||||
}
|
||||
return std::sinh(angle);
|
||||
}
|
||||
|
||||
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));
|
||||
}
|
||||
VECTORIZE_VEC(sinh)
|
||||
|
||||
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));
|
||||
}
|
||||
// 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");
|
||||
|
||||
// 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::cosh(angle);
|
||||
}
|
||||
|
||||
return ::std::acos(x);
|
||||
}
|
||||
VECTORIZE_VEC(cosh)
|
||||
|
||||
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));
|
||||
}
|
||||
// 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");
|
||||
|
||||
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));
|
||||
}
|
||||
return std::tanh(angle);
|
||||
}
|
||||
|
||||
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(tanh)
|
||||
|
||||
// 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
|
||||
(
|
||||
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
|
||||
(
|
||||
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
|
||||
(
|
||||
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
|
||||
(
|
||||
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
|
||||
(
|
||||
genType const & x
|
||||
)
|
||||
{
|
||||
GLM_STATIC_ASSERT(detail::type<genType>::is_float, "'asinh' only accept floating-point input");
|
||||
// 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));
|
||||
}
|
||||
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));
|
||||
}
|
||||
VECTORIZE_VEC(asinh)
|
||||
|
||||
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));
|
||||
}
|
||||
// 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");
|
||||
|
||||
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));
|
||||
}
|
||||
if(x < genType(1))
|
||||
return genType(0);
|
||||
return log(x + sqrt(x * x - genType(1)));
|
||||
}
|
||||
|
||||
// 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");
|
||||
VECTORIZE_VEC(acosh)
|
||||
|
||||
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
|
||||
(
|
||||
genType const & x
|
||||
)
|
||||
{
|
||||
GLM_STATIC_ASSERT(detail::type<genType>::is_float, "'atanh' only accept floating-point input");
|
||||
// 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));
|
||||
}
|
||||
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(
|
||||
genType const & m,
|
||||
int index,
|
||||
typename genType::row_type const & x)
|
||||
namespace glm
|
||||
{
|
||||
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 genType row
|
||||
(
|
||||
genType const & m,
|
||||
int index,
|
||||
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(
|
||||
genType const & m,
|
||||
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 typename genType::row_type row
|
||||
(
|
||||
genType const & m,
|
||||
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(
|
||||
genType const & m,
|
||||
int index,
|
||||
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(
|
||||
genType const & m,
|
||||
int index)
|
||||
{
|
||||
return m[index];
|
||||
}
|
||||
template <typename genType>
|
||||
GLM_FUNC_QUALIFIER genType column
|
||||
(
|
||||
genType const & m,
|
||||
int index,
|
||||
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
|
||||
(
|
||||
genType const & m,
|
||||
int index
|
||||
)
|
||||
{
|
||||
return m[index];
|
||||
}
|
||||
}//namespace glm
|
||||
|
||||
|
@ -26,129 +26,134 @@
|
||||
/// @author Christophe Riccio
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
namespace glm{
|
||||
|
||||
template <typename T>
|
||||
GLM_FUNC_QUALIFIER detail::tmat3x3<T> affineInverse
|
||||
(
|
||||
detail::tmat3x3<T> const & m
|
||||
)
|
||||
namespace glm
|
||||
{
|
||||
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::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
|
||||
(
|
||||
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 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)
|
||||
{
|
||||
valType Determinant = m[0][0] * m[1][1] - m[1][0] * m[0][1];
|
||||
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(
|
||||
+ m[1][1] / Determinant,
|
||||
- m[0][1] / Determinant,
|
||||
- m[1][0] / Determinant,
|
||||
+ m[0][0] / Determinant);
|
||||
detail::tmat2x2<valType> Inverse(
|
||||
+ m[1][1] / Determinant,
|
||||
- m[0][1] / Determinant,
|
||||
- m[1][0] / Determinant,
|
||||
+ m[0][0] / Determinant);
|
||||
|
||||
return Inverse;
|
||||
}
|
||||
return Inverse;
|
||||
}
|
||||
|
||||
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])
|
||||
+ m[0][2] * (m[1][0] * m[2][1] - m[1][1] * m[2][0]);
|
||||
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])
|
||||
+ m[0][2] * (m[1][0] * m[2][1] - m[1][1] * m[2][0]);
|
||||
|
||||
detail::tmat3x3<valType> Inverse;
|
||||
Inverse[0][0] = + (m[1][1] * m[2][2] - m[2][1] * m[1][2]);
|
||||
Inverse[0][1] = - (m[1][0] * m[2][2] - m[2][0] * m[1][2]);
|
||||
Inverse[0][2] = + (m[1][0] * m[2][1] - m[2][0] * m[1][1]);
|
||||
Inverse[1][0] = - (m[0][1] * m[2][2] - m[2][1] * m[0][2]);
|
||||
Inverse[1][1] = + (m[0][0] * m[2][2] - m[2][0] * m[0][2]);
|
||||
Inverse[1][2] = - (m[0][0] * m[2][1] - m[2][0] * m[0][1]);
|
||||
Inverse[2][0] = + (m[0][1] * m[1][2] - m[1][1] * m[0][2]);
|
||||
Inverse[2][1] = - (m[0][0] * m[1][2] - m[1][0] * m[0][2]);
|
||||
Inverse[2][2] = + (m[0][0] * m[1][1] - m[1][0] * m[0][1]);
|
||||
Inverse /= Determinant;
|
||||
detail::tmat3x3<valType> Inverse;
|
||||
Inverse[0][0] = + (m[1][1] * m[2][2] - m[2][1] * m[1][2]);
|
||||
Inverse[0][1] = - (m[1][0] * m[2][2] - m[2][0] * m[1][2]);
|
||||
Inverse[0][2] = + (m[1][0] * m[2][1] - m[2][0] * m[1][1]);
|
||||
Inverse[1][0] = - (m[0][1] * m[2][2] - m[2][1] * m[0][2]);
|
||||
Inverse[1][1] = + (m[0][0] * m[2][2] - m[2][0] * m[0][2]);
|
||||
Inverse[1][2] = - (m[0][0] * m[2][1] - m[2][0] * m[0][1]);
|
||||
Inverse[2][0] = + (m[0][1] * m[1][2] - m[1][1] * m[0][2]);
|
||||
Inverse[2][1] = - (m[0][0] * m[1][2] - m[1][0] * m[0][2]);
|
||||
Inverse[2][2] = + (m[0][0] * m[1][1] - m[1][0] * m[0][1]);
|
||||
Inverse /= Determinant;
|
||||
|
||||
return Inverse;
|
||||
}
|
||||
return Inverse;
|
||||
}
|
||||
|
||||
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];
|
||||
valType SubFactor03 = m[2][0] * m[3][3] - m[3][0] * m[2][3];
|
||||
valType SubFactor04 = m[2][0] * m[3][2] - m[3][0] * m[2][2];
|
||||
valType SubFactor05 = m[2][0] * m[3][1] - m[3][0] * m[2][1];
|
||||
valType SubFactor06 = m[1][2] * m[3][3] - m[3][2] * m[1][3];
|
||||
valType SubFactor07 = m[1][1] * m[3][3] - m[3][1] * m[1][3];
|
||||
valType SubFactor08 = m[1][1] * m[3][2] - m[3][1] * m[1][2];
|
||||
valType SubFactor09 = m[1][0] * m[3][3] - m[3][0] * m[1][3];
|
||||
valType SubFactor10 = m[1][0] * m[3][2] - m[3][0] * m[1][2];
|
||||
valType SubFactor11 = m[1][1] * m[3][3] - m[3][1] * m[1][3];
|
||||
valType SubFactor12 = m[1][0] * m[3][1] - m[3][0] * m[1][1];
|
||||
valType SubFactor13 = m[1][2] * m[2][3] - m[2][2] * m[1][3];
|
||||
valType SubFactor14 = m[1][1] * m[2][3] - m[2][1] * m[1][3];
|
||||
valType SubFactor15 = m[1][1] * m[2][2] - m[2][1] * m[1][2];
|
||||
valType SubFactor16 = m[1][0] * m[2][3] - m[2][0] * m[1][3];
|
||||
valType SubFactor17 = m[1][0] * m[2][2] - m[2][0] * m[1][2];
|
||||
valType SubFactor18 = m[1][0] * m[2][1] - m[2][0] * m[1][1];
|
||||
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];
|
||||
valType SubFactor03 = m[2][0] * m[3][3] - m[3][0] * m[2][3];
|
||||
valType SubFactor04 = m[2][0] * m[3][2] - m[3][0] * m[2][2];
|
||||
valType SubFactor05 = m[2][0] * m[3][1] - m[3][0] * m[2][1];
|
||||
valType SubFactor06 = m[1][2] * m[3][3] - m[3][2] * m[1][3];
|
||||
valType SubFactor07 = m[1][1] * m[3][3] - m[3][1] * m[1][3];
|
||||
valType SubFactor08 = m[1][1] * m[3][2] - m[3][1] * m[1][2];
|
||||
valType SubFactor09 = m[1][0] * m[3][3] - m[3][0] * m[1][3];
|
||||
valType SubFactor10 = m[1][0] * m[3][2] - m[3][0] * m[1][2];
|
||||
valType SubFactor11 = m[1][1] * m[3][3] - m[3][1] * m[1][3];
|
||||
valType SubFactor12 = m[1][0] * m[3][1] - m[3][0] * m[1][1];
|
||||
valType SubFactor13 = m[1][2] * m[2][3] - m[2][2] * m[1][3];
|
||||
valType SubFactor14 = m[1][1] * m[2][3] - m[2][1] * m[1][3];
|
||||
valType SubFactor15 = m[1][1] * m[2][2] - m[2][1] * m[1][2];
|
||||
valType SubFactor16 = m[1][0] * m[2][3] - m[2][0] * m[1][3];
|
||||
valType SubFactor17 = m[1][0] * m[2][2] - m[2][0] * m[1][2];
|
||||
valType SubFactor18 = m[1][0] * m[2][1] - m[2][0] * m[1][1];
|
||||
|
||||
detail::tmat4x4<valType> Inverse;
|
||||
Inverse[0][0] = + (m[1][1] * SubFactor00 - m[1][2] * SubFactor01 + m[1][3] * SubFactor02);
|
||||
Inverse[0][1] = - (m[1][0] * SubFactor00 - m[1][2] * SubFactor03 + m[1][3] * SubFactor04);
|
||||
Inverse[0][2] = + (m[1][0] * SubFactor01 - m[1][1] * SubFactor03 + m[1][3] * SubFactor05);
|
||||
Inverse[0][3] = - (m[1][0] * SubFactor02 - m[1][1] * SubFactor04 + m[1][2] * SubFactor05);
|
||||
detail::tmat4x4<valType> Inverse;
|
||||
Inverse[0][0] = + (m[1][1] * SubFactor00 - m[1][2] * SubFactor01 + m[1][3] * SubFactor02);
|
||||
Inverse[0][1] = - (m[1][0] * SubFactor00 - m[1][2] * SubFactor03 + m[1][3] * SubFactor04);
|
||||
Inverse[0][2] = + (m[1][0] * SubFactor01 - m[1][1] * SubFactor03 + m[1][3] * SubFactor05);
|
||||
Inverse[0][3] = - (m[1][0] * SubFactor02 - m[1][1] * SubFactor04 + m[1][2] * SubFactor05);
|
||||
|
||||
Inverse[1][0] = - (m[0][1] * SubFactor00 - m[0][2] * SubFactor01 + m[0][3] * SubFactor02);
|
||||
Inverse[1][1] = + (m[0][0] * SubFactor00 - m[0][2] * SubFactor03 + m[0][3] * SubFactor04);
|
||||
Inverse[1][2] = - (m[0][0] * SubFactor01 - m[0][1] * SubFactor03 + m[0][3] * SubFactor05);
|
||||
Inverse[1][3] = + (m[0][0] * SubFactor02 - m[0][1] * SubFactor04 + m[0][2] * SubFactor05);
|
||||
Inverse[1][0] = - (m[0][1] * SubFactor00 - m[0][2] * SubFactor01 + m[0][3] * SubFactor02);
|
||||
Inverse[1][1] = + (m[0][0] * SubFactor00 - m[0][2] * SubFactor03 + m[0][3] * SubFactor04);
|
||||
Inverse[1][2] = - (m[0][0] * SubFactor01 - m[0][1] * SubFactor03 + m[0][3] * SubFactor05);
|
||||
Inverse[1][3] = + (m[0][0] * SubFactor02 - m[0][1] * SubFactor04 + m[0][2] * SubFactor05);
|
||||
|
||||
Inverse[2][0] = + (m[0][1] * SubFactor06 - m[0][2] * SubFactor07 + m[0][3] * SubFactor08);
|
||||
Inverse[2][1] = - (m[0][0] * SubFactor06 - m[0][2] * SubFactor09 + m[0][3] * SubFactor10);
|
||||
Inverse[2][2] = + (m[0][0] * SubFactor11 - m[0][1] * SubFactor09 + m[0][3] * SubFactor12);
|
||||
Inverse[2][3] = - (m[0][0] * SubFactor08 - m[0][1] * SubFactor10 + m[0][2] * SubFactor12);
|
||||
Inverse[2][0] = + (m[0][1] * SubFactor06 - m[0][2] * SubFactor07 + m[0][3] * SubFactor08);
|
||||
Inverse[2][1] = - (m[0][0] * SubFactor06 - m[0][2] * SubFactor09 + m[0][3] * SubFactor10);
|
||||
Inverse[2][2] = + (m[0][0] * SubFactor11 - m[0][1] * SubFactor09 + m[0][3] * SubFactor12);
|
||||
Inverse[2][3] = - (m[0][0] * SubFactor08 - m[0][1] * SubFactor10 + m[0][2] * SubFactor12);
|
||||
|
||||
Inverse[3][0] = - (m[0][1] * SubFactor13 - m[0][2] * SubFactor14 + m[0][3] * SubFactor15);
|
||||
Inverse[3][1] = + (m[0][0] * SubFactor13 - m[0][2] * SubFactor16 + m[0][3] * SubFactor17);
|
||||
Inverse[3][2] = - (m[0][0] * SubFactor14 - m[0][1] * SubFactor16 + m[0][3] * SubFactor18);
|
||||
Inverse[3][3] = + (m[0][0] * SubFactor15 - m[0][1] * SubFactor17 + m[0][2] * SubFactor18);
|
||||
Inverse[3][0] = - (m[0][1] * SubFactor13 - m[0][2] * SubFactor14 + m[0][3] * SubFactor15);
|
||||
Inverse[3][1] = + (m[0][0] * SubFactor13 - m[0][2] * SubFactor16 + m[0][3] * SubFactor17);
|
||||
Inverse[3][2] = - (m[0][0] * SubFactor14 - m[0][1] * SubFactor16 + m[0][3] * SubFactor18);
|
||||
Inverse[3][3] = + (m[0][0] * SubFactor15 - m[0][1] * SubFactor17 + m[0][2] * SubFactor18);
|
||||
|
||||
valType Determinant =
|
||||
+ m[0][0] * Inverse[0][0]
|
||||
+ m[0][1] * Inverse[0][1]
|
||||
+ m[0][2] * Inverse[0][2]
|
||||
+ m[0][3] * Inverse[0][3];
|
||||
valType Determinant =
|
||||
+ m[0][0] * Inverse[0][0]
|
||||
+ m[0][1] * Inverse[0][1]
|
||||
+ m[0][2] * Inverse[0][2]
|
||||
+ m[0][3] * Inverse[0][3];
|
||||
|
||||
Inverse /= Determinant;
|
||||
Inverse /= Determinant;
|
||||
|
||||
return Inverse;
|
||||
}
|
||||
|
||||
return Inverse;
|
||||
}
|
||||
}//namespace glm
|
||||
|
@ -26,388 +26,387 @@
|
||||
/// @author Christophe Riccio
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
namespace glm{
|
||||
|
||||
template <typename T>
|
||||
GLM_FUNC_QUALIFIER detail::tmat4x4<T> translate
|
||||
(
|
||||
detail::tmat4x4<T> const & m,
|
||||
detail::tvec3<T> const & v
|
||||
)
|
||||
namespace glm
|
||||
{
|
||||
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> 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
|
||||
(
|
||||
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);
|
||||
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);
|
||||
|
||||
detail::tvec3<T> axis = normalize(v);
|
||||
detail::tvec3<T> axis = normalize(v);
|
||||
|
||||
detail::tvec3<T> temp = (T(1) - c) * axis;
|
||||
detail::tvec3<T> temp = (T(1) - c) * axis;
|
||||
|
||||
detail::tmat4x4<T> Rotate(detail::tmat4x4<T>::null);
|
||||
Rotate[0][0] = c + temp[0] * axis[0];
|
||||
Rotate[0][1] = 0 + temp[0] * axis[1] + s * axis[2];
|
||||
Rotate[0][2] = 0 + temp[0] * axis[2] - s * axis[1];
|
||||
detail::tmat4x4<T> Rotate(detail::tmat4x4<T>::null);
|
||||
Rotate[0][0] = c + temp[0] * axis[0];
|
||||
Rotate[0][1] = 0 + temp[0] * axis[1] + s * axis[2];
|
||||
Rotate[0][2] = 0 + temp[0] * axis[2] - s * axis[1];
|
||||
|
||||
Rotate[1][0] = 0 + temp[1] * axis[0] - s * axis[2];
|
||||
Rotate[1][1] = c + temp[1] * axis[1];
|
||||
Rotate[1][2] = 0 + temp[1] * axis[2] + s * axis[0];
|
||||
Rotate[1][0] = 0 + temp[1] * axis[0] - s * axis[2];
|
||||
Rotate[1][1] = c + temp[1] * axis[1];
|
||||
Rotate[1][2] = 0 + temp[1] * axis[2] + s * axis[0];
|
||||
|
||||
Rotate[2][0] = 0 + temp[2] * axis[0] + s * axis[1];
|
||||
Rotate[2][1] = 0 + temp[2] * axis[1] - s * axis[0];
|
||||
Rotate[2][2] = c + temp[2] * axis[2];
|
||||
Rotate[2][0] = 0 + temp[2] * axis[0] + s * axis[1];
|
||||
Rotate[2][1] = 0 + temp[2] * axis[1] - s * axis[0];
|
||||
Rotate[2][2] = c + temp[2] * axis[2];
|
||||
|
||||
detail::tmat4x4<T> Result(detail::tmat4x4<T>::null);
|
||||
Result[0] = m[0] * Rotate[0][0] + m[1] * Rotate[0][1] + m[2] * Rotate[0][2];
|
||||
Result[1] = m[0] * Rotate[1][0] + m[1] * Rotate[1][1] + m[2] * Rotate[1][2];
|
||||
Result[2] = m[0] * Rotate[2][0] + m[1] * Rotate[2][1] + m[2] * Rotate[2][2];
|
||||
Result[3] = m[3];
|
||||
return Result;
|
||||
}
|
||||
detail::tmat4x4<T> Result(detail::tmat4x4<T>::null);
|
||||
Result[0] = m[0] * Rotate[0][0] + m[1] * Rotate[0][1] + m[2] * Rotate[0][2];
|
||||
Result[1] = m[0] * Rotate[1][0] + m[1] * Rotate[1][1] + m[2] * Rotate[1][2];
|
||||
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
|
||||
(
|
||||
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> 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
|
||||
(
|
||||
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;
|
||||
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;
|
||||
|
||||
//detail::tmat4x4<valType> Result(m);
|
||||
Result[3] = m[0] * v[0] + m[1] * v[1] + m[2] * v[2] + m[3];
|
||||
//Result[3][0] = m[0][0] * v[0] + m[1][0] * v[1] + m[2][0] * v[2] + m[3][0];
|
||||
//Result[3][1] = m[0][1] * v[0] + m[1][1] * v[1] + m[2][1] * v[2] + m[3][1];
|
||||
//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;
|
||||
}
|
||||
//detail::tmat4x4<valType> Result(m);
|
||||
Result[3] = m[0] * v[0] + m[1] * v[1] + m[2] * v[2] + m[3];
|
||||
//Result[3][0] = m[0][0] * v[0] + m[1][0] * v[1] + m[2][0] * v[2] + m[3][0];
|
||||
//Result[3][1] = m[0][1] * v[0] + m[1][1] * v[1] + m[2][1] * v[2] + m[3][1];
|
||||
//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
|
||||
(
|
||||
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);
|
||||
detail::tmat4x4<T> Result;
|
||||
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);
|
||||
detail::tmat4x4<T> Result;
|
||||
|
||||
detail::tvec3<T> axis = normalize(v);
|
||||
detail::tvec3<T> axis = normalize(v);
|
||||
|
||||
Result[0][0] = c + (1 - c) * axis.x * axis.x;
|
||||
Result[0][1] = (1 - c) * axis.x * axis.y + s * axis.z;
|
||||
Result[0][2] = (1 - c) * axis.x * axis.z - s * axis.y;
|
||||
Result[0][3] = 0;
|
||||
Result[0][0] = c + (1 - c) * axis.x * axis.x;
|
||||
Result[0][1] = (1 - c) * axis.x * axis.y + s * axis.z;
|
||||
Result[0][2] = (1 - c) * axis.x * axis.z - s * axis.y;
|
||||
Result[0][3] = 0;
|
||||
|
||||
Result[1][0] = (1 - c) * axis.y * axis.x - s * axis.z;
|
||||
Result[1][1] = c + (1 - c) * axis.y * axis.y;
|
||||
Result[1][2] = (1 - c) * axis.y * axis.z + s * axis.x;
|
||||
Result[1][3] = 0;
|
||||
Result[1][0] = (1 - c) * axis.y * axis.x - s * axis.z;
|
||||
Result[1][1] = c + (1 - c) * axis.y * axis.y;
|
||||
Result[1][2] = (1 - c) * axis.y * axis.z + s * axis.x;
|
||||
Result[1][3] = 0;
|
||||
|
||||
Result[2][0] = (1 - c) * axis.z * axis.x + s * axis.y;
|
||||
Result[2][1] = (1 - c) * axis.z * axis.y - s * axis.x;
|
||||
Result[2][2] = c + (1 - c) * axis.z * axis.z;
|
||||
Result[2][3] = 0;
|
||||
Result[2][0] = (1 - c) * axis.z * axis.x + s * axis.y;
|
||||
Result[2][1] = (1 - c) * axis.z * axis.y - s * axis.x;
|
||||
Result[2][2] = c + (1 - c) * axis.z * axis.z;
|
||||
Result[2][3] = 0;
|
||||
|
||||
Result[3] = detail::tvec4<T>(0, 0, 0, 1);
|
||||
return m * Result;
|
||||
}
|
||||
Result[3] = detail::tvec4<T>(0, 0, 0, 1);
|
||||
return m * Result;
|
||||
}
|
||||
|
||||
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 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
|
||||
(
|
||||
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);
|
||||
Result[2][2] = - valType(2) / (zFar - zNear);
|
||||
Result[3][0] = - (right + left) / (right - left);
|
||||
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
|
||||
(
|
||||
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);
|
||||
Result[2][2] = - valType(2) / (zFar - zNear);
|
||||
Result[3][0] = - (right + left) / (right - left);
|
||||
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(
|
||||
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);
|
||||
Result[2][2] = - valType(1);
|
||||
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> 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);
|
||||
Result[2][2] = - valType(1);
|
||||
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
|
||||
(
|
||||
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);
|
||||
Result[2][0] = (right + left) / (right - left);
|
||||
Result[2][1] = (top + bottom) / (top - bottom);
|
||||
Result[2][2] = -(farVal + nearVal) / (farVal - nearVal);
|
||||
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> 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);
|
||||
Result[2][0] = (right + left) / (right - left);
|
||||
Result[2][1] = (top + bottom) / (top - bottom);
|
||||
Result[2][2] = -(farVal + nearVal) / (farVal - nearVal);
|
||||
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
|
||||
(
|
||||
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;
|
||||
valType bottom = -range;
|
||||
valType top = range;
|
||||
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;
|
||||
valType bottom = -range;
|
||||
valType top = range;
|
||||
|
||||
detail::tmat4x4<valType> Result(valType(0));
|
||||
Result[0][0] = (valType(2) * zNear) / (right - left);
|
||||
Result[1][1] = (valType(2) * zNear) / (top - bottom);
|
||||
Result[2][2] = - (zFar + zNear) / (zFar - zNear);
|
||||
Result[2][3] = - valType(1);
|
||||
Result[3][2] = - (valType(2) * zFar * zNear) / (zFar - zNear);
|
||||
return Result;
|
||||
}
|
||||
detail::tmat4x4<valType> Result(valType(0));
|
||||
Result[0][0] = (valType(2) * zNear) / (right - left);
|
||||
Result[1][1] = (valType(2) * zNear) / (top - bottom);
|
||||
Result[2][2] = - (zFar + zNear) / (zFar - zNear);
|
||||
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
|
||||
(
|
||||
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;
|
||||
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;
|
||||
|
||||
detail::tmat4x4<valType> Result(valType(0));
|
||||
Result[0][0] = w;
|
||||
Result[1][1] = h;
|
||||
Result[2][2] = (zFar + zNear) / (zFar - zNear);
|
||||
Result[2][3] = valType(1);
|
||||
Result[3][2] = -(valType(2) * zFar * zNear) / (zFar - zNear);
|
||||
return Result;
|
||||
}
|
||||
detail::tmat4x4<valType> Result(valType(0));
|
||||
Result[0][0] = w;
|
||||
Result[1][1] = h;
|
||||
Result[2][2] = (zFar + zNear) / (zFar - zNear);
|
||||
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
|
||||
(
|
||||
T fovy,
|
||||
T aspect,
|
||||
T zNear
|
||||
)
|
||||
{
|
||||
T range = tan(radians(fovy / T(2))) * zNear;
|
||||
T left = -range * aspect;
|
||||
T right = range * aspect;
|
||||
T bottom = -range;
|
||||
T top = range;
|
||||
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;
|
||||
T bottom = -range;
|
||||
T top = range;
|
||||
|
||||
detail::tmat4x4<T> Result(T(0));
|
||||
Result[0][0] = (T(2) * zNear) / (right - left);
|
||||
Result[1][1] = (T(2) * zNear) / (top - bottom);
|
||||
Result[2][2] = - T(1);
|
||||
Result[2][3] = - T(1);
|
||||
Result[3][2] = - T(2) * zNear;
|
||||
return Result;
|
||||
}
|
||||
detail::tmat4x4<T> Result(T(0));
|
||||
Result[0][0] = (T(2) * zNear) / (right - left);
|
||||
Result[1][1] = (T(2) * zNear) / (top - bottom);
|
||||
Result[2][2] = - T(1);
|
||||
Result[2][3] = - T(1);
|
||||
Result[3][2] = - T(2) * zNear;
|
||||
return Result;
|
||||
}
|
||||
|
||||
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;
|
||||
T bottom = -range;
|
||||
T top = range;
|
||||
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;
|
||||
T bottom = -range;
|
||||
T top = range;
|
||||
|
||||
detail::tmat4x4<T> Result(T(0));
|
||||
Result[0][0] = (T(2) * zNear) / (right - left);
|
||||
Result[1][1] = (T(2) * zNear) / (top - bottom);
|
||||
Result[2][2] = T(0.0001) - T(1);
|
||||
Result[2][3] = T(-1);
|
||||
Result[3][2] = - (T(0.0001) - T(2)) * zNear;
|
||||
return Result;
|
||||
}
|
||||
detail::tmat4x4<T> Result(T(0));
|
||||
Result[0][0] = (T(2) * zNear) / (right - left);
|
||||
Result[1][1] = (T(2) * zNear) / (top - bottom);
|
||||
Result[2][2] = T(0.0001) - T(1);
|
||||
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
|
||||
(
|
||||
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;
|
||||
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;
|
||||
|
||||
tmp /= tmp.w;
|
||||
tmp = tmp * T(0.5) + T(0.5);
|
||||
tmp[0] = tmp[0] * T(viewport[2]) + T(viewport[0]);
|
||||
tmp[1] = tmp[1] * T(viewport[3]) + T(viewport[1]);
|
||||
tmp /= tmp.w;
|
||||
tmp = tmp * T(0.5) + T(0.5);
|
||||
tmp[0] = tmp[0] * T(viewport[2]) + T(viewport[0]);
|
||||
tmp[1] = tmp[1] * T(viewport[3]) + T(viewport[1]);
|
||||
|
||||
return detail::tvec3<T>(tmp);
|
||||
}
|
||||
return detail::tvec3<T>(tmp);
|
||||
}
|
||||
|
||||
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);
|
||||
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));
|
||||
tmp.x = (tmp.x - T(viewport[0])) / T(viewport[2]);
|
||||
tmp.y = (tmp.y - T(viewport[1])) / T(viewport[3]);
|
||||
tmp = tmp * T(2) - T(1);
|
||||
detail::tvec4<T> tmp = detail::tvec4<T>(win, T(1));
|
||||
tmp.x = (tmp.x - T(viewport[0])) / T(viewport[2]);
|
||||
tmp.y = (tmp.y - T(viewport[1])) / T(viewport[3]);
|
||||
tmp = tmp * T(2) - T(1);
|
||||
|
||||
detail::tvec4<T> obj = inverse * tmp;
|
||||
obj /= obj.w;
|
||||
detail::tvec4<T> obj = inverse * tmp;
|
||||
obj /= obj.w;
|
||||
|
||||
return detail::tvec3<T>(obj);
|
||||
}
|
||||
return detail::tvec3<T>(obj);
|
||||
}
|
||||
|
||||
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);
|
||||
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);
|
||||
|
||||
if(!(delta.x > T(0) && delta.y > T(0)))
|
||||
return Result; // Error
|
||||
if(!(delta.x > T(0) && delta.y > T(0)))
|
||||
return Result; // Error
|
||||
|
||||
detail::tvec3<T> Temp(
|
||||
(T(viewport[2]) - T(2) * (center.x - T(viewport[0]))) / delta.x,
|
||||
(T(viewport[3]) - T(2) * (center.y - T(viewport[1]))) / delta.y,
|
||||
T(0));
|
||||
detail::tvec3<T> Temp(
|
||||
(T(viewport[2]) - T(2) * (center.x - T(viewport[0]))) / delta.x,
|
||||
(T(viewport[3]) - T(2) * (center.y - T(viewport[1]))) / delta.y,
|
||||
T(0));
|
||||
|
||||
// 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)));
|
||||
}
|
||||
// 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
|
||||
(
|
||||
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));
|
||||
u = cross(s, f);
|
||||
|
||||
detail::tmat4x4<T> Result(1);
|
||||
Result[0][0] = s.x;
|
||||
Result[1][0] = s.y;
|
||||
Result[2][0] = s.z;
|
||||
Result[0][1] = u.x;
|
||||
Result[1][1] = u.y;
|
||||
Result[2][1] = u.z;
|
||||
Result[0][2] =-f.x;
|
||||
Result[1][2] =-f.y;
|
||||
Result[2][2] =-f.z;
|
||||
/* 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);
|
||||
}
|
||||
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));
|
||||
u = cross(s, f);
|
||||
|
||||
detail::tmat4x4<T> Result(1);
|
||||
Result[0][0] = s.x;
|
||||
Result[1][0] = s.y;
|
||||
Result[2][0] = s.z;
|
||||
Result[0][1] = u.x;
|
||||
Result[1][1] = u.y;
|
||||
Result[2][1] = u.z;
|
||||
Result[0][2] =-f.x;
|
||||
Result[1][2] =-f.y;
|
||||
Result[2][2] =-f.z;
|
||||
/* 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
|
||||
|
1659
glm/gtc/noise.inl
1659
glm/gtc/noise.inl
File diff suppressed because it is too large
Load Diff
@ -29,8 +29,8 @@
|
||||
#include <limits>
|
||||
|
||||
namespace glm{
|
||||
namespace detail{
|
||||
|
||||
namespace detail
|
||||
{
|
||||
template <typename T>
|
||||
GLM_FUNC_QUALIFIER tquat<T>::tquat() :
|
||||
x(0),
|
||||
|
@ -9,200 +9,136 @@
|
||||
|
||||
#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
|
||||
)
|
||||
namespace detail
|
||||
{
|
||||
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
|
||||
)
|
||||
{
|
||||
return float(std::rand()) / float(RAND_MAX) * (Max - Min) + Min;
|
||||
}
|
||||
|
||||
template <>
|
||||
GLM_FUNC_QUALIFIER double linearRand
|
||||
(
|
||||
double const & Min,
|
||||
double const & Max
|
||||
)
|
||||
{
|
||||
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
|
||||
(
|
||||
genType const & Mean,
|
||||
genType const & Deviation
|
||||
)
|
||||
{
|
||||
genType w, x1, x2;
|
||||
|
||||
do
|
||||
{
|
||||
x1 = linearRand(genType(-1), genType(1));
|
||||
x2 = linearRand(genType(-1), genType(1));
|
||||
|
||||
w = x1 * x1 + x2 * x2;
|
||||
} 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
|
||||
(
|
||||
T const & Radius
|
||||
)
|
||||
{
|
||||
detail::tvec2<T> Result(T(0));
|
||||
T LenRadius(T(0));
|
||||
|
||||
do
|
||||
struct compute_linearRand
|
||||
{
|
||||
Result = linearRand(detail::tvec2<T>(-Radius), detail::tvec2<T>(Radius));
|
||||
LenRadius = length(Result);
|
||||
}
|
||||
while(LenRadius > Radius);
|
||||
|
||||
return Result;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
GLM_FUNC_QUALIFIER detail::tvec3<T> ballRand
|
||||
(
|
||||
T const & Radius
|
||||
)
|
||||
{
|
||||
detail::tvec3<T> Result(T(0));
|
||||
T LenRadius(T(0));
|
||||
|
||||
do
|
||||
{
|
||||
Result = linearRand(detail::tvec3<T>(-Radius), detail::tvec3<T>(Radius));
|
||||
LenRadius = length(Result);
|
||||
}
|
||||
while(LenRadius > Radius);
|
||||
|
||||
return Result;
|
||||
}
|
||||
|
||||
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
|
||||
(
|
||||
T const & Radius
|
||||
)
|
||||
{
|
||||
T z = linearRand(T(-1), T(1));
|
||||
T a = linearRand(T(0), T(6.283185307179586476925286766559f));
|
||||
|
||||
T r = sqrt(T(1) - z * z);
|
||||
|
||||
T x = r * cos(a);
|
||||
T y = r * sin(a);
|
||||
|
||||
return detail::tvec3<T>(x, y, z) * Radius;
|
||||
}
|
||||
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 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 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
|
||||
{
|
||||
x1 = linearRand(genType(-1), genType(1));
|
||||
x2 = linearRand(genType(-1), genType(1));
|
||||
|
||||
w = x1 * x1 + x2 * x2;
|
||||
} while(w > genType(1));
|
||||
|
||||
return x2 * Deviation * Deviation * sqrt((genType(-2) * log(w)) / w) + Mean;
|
||||
}
|
||||
|
||||
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));
|
||||
|
||||
do
|
||||
{
|
||||
Result = linearRand(detail::tvec2<T>(-Radius), detail::tvec2<T>(Radius));
|
||||
LenRadius = length(Result);
|
||||
}
|
||||
while(LenRadius > Radius);
|
||||
|
||||
return Result;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
GLM_FUNC_QUALIFIER detail::tvec3<T> ballRand
|
||||
(
|
||||
T const & Radius
|
||||
)
|
||||
{
|
||||
detail::tvec3<T> Result(T(0));
|
||||
T LenRadius(T(0));
|
||||
|
||||
do
|
||||
{
|
||||
Result = linearRand(detail::tvec3<T>(-Radius), detail::tvec3<T>(Radius));
|
||||
LenRadius = length(Result);
|
||||
}
|
||||
while(LenRadius > Radius);
|
||||
|
||||
return Result;
|
||||
}
|
||||
|
||||
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
|
||||
(
|
||||
T const & Radius
|
||||
)
|
||||
{
|
||||
T z = linearRand(T(-1), T(1));
|
||||
T a = linearRand(T(0), T(6.283185307179586476925286766559f));
|
||||
|
||||
T r = sqrt(T(1) - z * z);
|
||||
|
||||
T x = r * cos(a);
|
||||
T y = r * sin(a);
|
||||
|
||||
return detail::tvec3<T>(x, y, z) * Radius;
|
||||
}
|
||||
}//namespace glm
|
||||
|
@ -26,165 +26,91 @@
|
||||
/// @author Christophe Riccio
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
namespace glm{
|
||||
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 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
|
||||
(
|
||||
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::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
|
||||
(
|
||||
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::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
|
||||
(
|
||||
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, 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
|
||||
(
|
||||
detail::tvec4<T> & v,
|
||||
comp x
|
||||
)
|
||||
{
|
||||
return v[x];
|
||||
}
|
||||
|
||||
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
|
||||
(
|
||||
detail::tvec4<T> & v,
|
||||
comp x, comp y
|
||||
)
|
||||
{
|
||||
return detail::tref2<T>(v[x], v[y]);
|
||||
}
|
||||
|
||||
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
|
||||
(
|
||||
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
|
||||
(
|
||||
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]);
|
||||
}
|
||||
*/
|
||||
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
|
||||
(
|
||||
detail::tvec4<T> & v,
|
||||
comp x, comp y, comp z, comp w
|
||||
)
|
||||
{
|
||||
return detail::tref4<T>(v[x], v[y], v[z], v[w]);
|
||||
}
|
||||
}//namespace glm
|
||||
|
@ -2,232 +2,137 @@
|
||||
// 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
|
||||
)
|
||||
namespace glm
|
||||
{
|
||||
return genType(1) / fastInverseSqrt(x);
|
||||
}
|
||||
// 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::tvec2<valType> fastSqrt
|
||||
(
|
||||
detail::tvec2<valType> const & x
|
||||
)
|
||||
{
|
||||
return detail::tvec2<valType>(
|
||||
fastSqrt(x.x),
|
||||
fastSqrt(x.y));
|
||||
}
|
||||
return genType(1) / fastInverseSqrt(x);
|
||||
}
|
||||
|
||||
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));
|
||||
}
|
||||
VECTORIZE_VEC(fastSqrt)
|
||||
|
||||
template <typename valType>
|
||||
GLM_FUNC_QUALIFIER detail::tvec4<valType> fastSqrt
|
||||
(
|
||||
detail::tvec4<valType> const & x
|
||||
)
|
||||
{
|
||||
return detail::tvec4<valType>(
|
||||
fastSqrt(x.x),
|
||||
fastSqrt(x.y),
|
||||
fastSqrt(x.z),
|
||||
fastSqrt(x.w));
|
||||
}
|
||||
// fastInversesqrt
|
||||
template <typename genType>
|
||||
GLM_FUNC_QUALIFIER genType fastInverseSqrt
|
||||
(
|
||||
genType const & x
|
||||
)
|
||||
{
|
||||
genType tmp = x;
|
||||
float xhalf = 0.5f * float(tmp);
|
||||
uint i = *(uint*)&x;
|
||||
i = 0x5f375a86 - (i >> 1);
|
||||
//x = *(float*)&i;
|
||||
//x = *((float*)(char*)&i);
|
||||
tmp = detail::uif(i).f;
|
||||
tmp = tmp * (1.5f - xhalf * tmp * tmp);
|
||||
return genType(tmp);
|
||||
}
|
||||
|
||||
// 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;
|
||||
i = 0x5f375a86 - (i >> 1);
|
||||
//x = *(float*)&i;
|
||||
//x = *((float*)(char*)&i);
|
||||
tmp = detail::uif(i).f;
|
||||
tmp = tmp * (1.5f - xhalf * tmp * tmp);
|
||||
return genType(tmp);
|
||||
}
|
||||
VECTORIZE_VEC(fastInverseSqrt)
|
||||
|
||||
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));
|
||||
}
|
||||
// fastLength
|
||||
template <typename genType>
|
||||
GLM_FUNC_QUALIFIER genType fastLength
|
||||
(
|
||||
genType const & x
|
||||
)
|
||||
{
|
||||
return abs(x);
|
||||
}
|
||||
|
||||
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 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 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));
|
||||
}
|
||||
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);
|
||||
}
|
||||
|
||||
// fastLength
|
||||
template <typename genType>
|
||||
GLM_FUNC_QUALIFIER genType fastLength
|
||||
(
|
||||
genType const & x
|
||||
)
|
||||
{
|
||||
return abs(x);
|
||||
}
|
||||
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);
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
// 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 fastLength
|
||||
(
|
||||
detail::tvec3<valType> const & x
|
||||
)
|
||||
{
|
||||
valType sqr = x.x * x.x + x.y * x.y + x.z * x.z;
|
||||
return fastSqrt(sqr);
|
||||
}
|
||||
// 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 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);
|
||||
}
|
||||
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);
|
||||
}
|
||||
|
||||
// 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
|
||||
(
|
||||
genType const & x
|
||||
)
|
||||
{
|
||||
return x > genType(0) ? genType(1) : -genType(1);
|
||||
}
|
||||
|
||||
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
|
||||
(
|
||||
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
|
||||
(
|
||||
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);
|
||||
}
|
||||
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
|
||||
(
|
||||
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…
Reference in New Issue
Block a user