Merge branch '0.9.3' of ssh://ogl-math.git.sourceforge.net/gitroot/ogl-math/ogl-math into 0.9.3

This commit is contained in:
Christophe Riccio 2011-06-14 20:26:56 +01:00
commit 8b919ffe54
146 changed files with 7915 additions and 8237 deletions

View File

@ -311,11 +311,11 @@ void foo()
<dl> <dl>
<dt>glRotate[fd]</dt> <dt>glRotate[fd]</dt>
<dd>\link glm::gtc::rotate glm::rotate \endlink</dd> <dd>\link glm::rotate glm::rotate \endlink</dd>
<dt>glScale[fd]</dt> <dt>glScale[fd]</dt>
<dd>\link glm::gtc::scale glm::scale \endlink</dd> <dd>\link glm::scale glm::scale \endlink</dd>
<dt>glTranslate[fd]</dt> <dt>glTranslate[fd]</dt>
<dd>\link glm::gtc::translate glm::translate \endlink</dd> <dd>\link glm::translate glm::translate \endlink</dd>
<dt>glLoadIdentity</dt> <dt>glLoadIdentity</dt>
<dd>The default constructor of all matrix types creates an identity matrix.</dd> <dd>The default constructor of all matrix types creates an identity matrix.</dd>
<dt>glMultMatrix[fd]</dt> <dt>glMultMatrix[fd]</dt>
@ -325,24 +325,24 @@ void foo()
<dt>glMultTransposeMatrix</dt> <dt>glMultTransposeMatrix</dt>
<dd>Combine the last two.</dd> <dd>Combine the last two.</dd>
<dt>glFrustum</dt> <dt>glFrustum</dt>
<dd>\link glm::gtc::frustum glm::frustum \endlink</dd> <dd>\link glm::frustum glm::frustum \endlink</dd>
<dt>glOrtho</dt> <dt>glOrtho</dt>
<dd>\link glm::gtc::ortho glm::ortho \endlink</dd> <dd>\link glm::ortho glm::ortho \endlink</dd>
<dt>gluLookAt</dt> <dt>gluLookAt</dt>
<dd>\link glm::gtc::lookAt glm::lookAt \endlink</dd> <dd>\link glm::lookAt glm::lookAt \endlink</dd>
</dl> </dl>
\section deprecated_glu GLU function replacements \section deprecated_glu GLU function replacements
<dl> <dl>
<dt>gluOrtho2D</dt> <dt>gluOrtho2D</dt>
<dd>\link glm::gtc::ortho glm::ortho \endlink</dd> <dd>\link glm::ortho glm::ortho \endlink</dd>
<dt>gluPerspective</dt> <dt>gluPerspective</dt>
<dd>\link glm::gtc::perspective glm::perspective \endlink</dd> <dd>\link glm::perspective glm::perspective \endlink</dd>
<dt>gluProject</dt> <dt>gluProject</dt>
<dd>\link glm::gtc::project glm::project \endlink</dd> <dd>\link glm::project glm::project \endlink</dd>
<dt>gluUnProject</dt> <dt>gluUnProject</dt>
<dd>\link glm::gtc::unProject glm::unProject \endlink</dd> <dd>\link glm::unProject glm::unProject \endlink</dd>
</dl> </dl>
**/ **/

View File

@ -31,8 +31,7 @@
#include "_fixes.hpp" #include "_fixes.hpp"
namespace glm{ namespace glm
namespace core
{ {
/// @addtogroup core_funcs /// @addtogroup core_funcs
/// @{ /// @{
@ -367,7 +366,6 @@ namespace core
genType ldexp(genType const & x, genIType const & exp); genType ldexp(genType const & x, genIType const & exp);
/// @} /// @}
}//namespace core
}//namespace glm }//namespace glm
#include "func_common.inl" #include "func_common.inl"

View File

@ -38,8 +38,6 @@ namespace detail
}; };
}//namespace detail }//namespace detail
namespace core
{
// abs // abs
template <typename genFIType> template <typename genFIType>
GLM_FUNC_QUALIFIER genFIType abs( GLM_FUNC_QUALIFIER genFIType abs(
@ -728,7 +726,7 @@ namespace core
//if(x >= maxVal) return maxVal; //if(x >= maxVal) return maxVal;
//if(x <= minVal) return minVal; //if(x <= minVal) return minVal;
//return x; //return x;
return glm::max(glm::min(x, maxVal), minVal); return max(min(x, maxVal), minVal);
} }
template <typename T> template <typename T>
@ -1566,5 +1564,4 @@ namespace core
return std::frexp(x, exp); return std::frexp(x, exp);
} }
}//namespace core
}//namespace glm }//namespace glm

View File

@ -29,10 +29,9 @@
#ifndef glm_core_func_exponential #ifndef glm_core_func_exponential
#define glm_core_func_exponential #define glm_core_func_exponential
namespace glm{ namespace glm
namespace core
{ {
/// \addtogroup core_funcs /// @addtogroup core_funcs
/// @{ /// @{
//! Returns x raised to the y power. //! Returns x raised to the y power.
@ -88,7 +87,6 @@ namespace core
genType inversesqrt(genType const & x); genType inversesqrt(genType const & x);
/// @} /// @}
}//namespace core
}//namespace glm }//namespace glm
#include "func_exponential.inl" #include "func_exponential.inl"

View File

@ -7,8 +7,7 @@
// File : glm/core/func_exponential.inl // File : glm/core/func_exponential.inl
/////////////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////////////
namespace glm{ namespace glm
namespace core
{ {
// pow // pow
template <typename genType> template <typename genType>
@ -349,5 +348,4 @@ namespace core
inversesqrt(x.w)); inversesqrt(x.w));
} }
}//namespace core
}//namespace glm }//namespace glm

View File

@ -29,8 +29,7 @@
#ifndef glm_core_func_geometric #ifndef glm_core_func_geometric
#define glm_core_func_geometric #define glm_core_func_geometric
namespace glm{ namespace glm
namespace core
{ {
/// \addtogroup core_funcs /// \addtogroup core_funcs
/// @{ /// @{
@ -111,7 +110,6 @@ namespace core
typename genType::value_type const & eta); typename genType::value_type const & eta);
/// @} /// @}
}//namespace core
}//namespace glm }//namespace glm
#include "func_geometric.inl" #include "func_geometric.inl"

View File

@ -7,8 +7,7 @@
// File : glm/core/func_geometric.inl // File : glm/core/func_geometric.inl
/////////////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////////////
namespace glm{ namespace glm
namespace core
{ {
// length // length
template <typename genType> template <typename genType>
@ -281,5 +280,4 @@ namespace core
return eta * I - (eta * dotValue + sqrt(k)) * N; return eta * I - (eta * dotValue + sqrt(k)) * N;
} }
}//namespace core
}//namespace glm }//namespace glm

View File

@ -29,10 +29,9 @@
#ifndef glm_core_func_integer #ifndef glm_core_func_integer
#define glm_core_func_integer #define glm_core_func_integer
namespace glm{ namespace glm
namespace core
{ {
/// \addtogroup core_funcs /// @addtogroup core_funcs
/// @{ /// @{
//! Adds 32-bit unsigned integer x and y, returning the sum //! Adds 32-bit unsigned integer x and y, returning the sum
@ -159,7 +158,6 @@ namespace core
typename C<T>::signed_type findMSB(C<T> const & Value); typename C<T>::signed_type findMSB(C<T> const & Value);
/// @} /// @}
}//namespace core
}//namespace glm }//namespace glm
#include "func_integer.inl" #include "func_integer.inl"

File diff suppressed because it is too large Load Diff

View File

@ -10,10 +10,9 @@
#ifndef glm_core_func_matrix #ifndef glm_core_func_matrix
#define glm_core_func_matrix #define glm_core_func_matrix
namespace glm{ namespace glm
namespace core
{ {
/// \addtogroup core_funcs /// @addtogroup core_funcs
/// @{ /// @{
//! Multiply matrix x by matrix y component-wise, i.e., //! Multiply matrix x by matrix y component-wise, i.e.,
@ -94,7 +93,6 @@ namespace core
detail::tmat4x4<T> const & m); detail::tmat4x4<T> const & m);
/// @} /// @}
}//namespace core
}//namespace glm }//namespace glm
#include "func_matrix.inl" #include "func_matrix.inl"

View File

@ -7,33 +7,32 @@
// File : glm/core/func_matrix.inl // File : glm/core/func_matrix.inl
/////////////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////////////
namespace glm{ namespace glm
namespace core
{ {
// matrixCompMult // matrixCompMult
template <typename matType> template <typename matType>
GLM_FUNC_QUALIFIER matType matrixCompMult GLM_FUNC_QUALIFIER matType matrixCompMult
( (
matType const & x, matType const & x,
matType const & y matType const & y
) )
{ {
GLM_STATIC_ASSERT(detail::type<typename matType::value_type>::is_float, "'matrixCompMult' only accept floating-point inputs"); GLM_STATIC_ASSERT(detail::type<typename matType::value_type>::is_float, "'matrixCompMult' only accept floating-point inputs");
matType result(matType::null); matType result(matType::null);
for(typename matType::size_type i = 0; i < matType::col_size(); ++i) for(typename matType::size_type i = 0; i < matType::col_size(); ++i)
result[i] = x[i] * y[i]; result[i] = x[i] * y[i];
return result; return result;
} }
// outerProduct // outerProduct
template <typename T> template <typename T>
GLM_FUNC_QUALIFIER detail::tmat2x2<T> outerProduct GLM_FUNC_QUALIFIER detail::tmat2x2<T> outerProduct
( (
detail::tvec2<T> const & c, detail::tvec2<T> const & c,
detail::tvec2<T> const & r detail::tvec2<T> const & r
) )
{ {
GLM_STATIC_ASSERT(detail::type<T>::is_float, "'outerProduct' only accept floating-point inputs"); GLM_STATIC_ASSERT(detail::type<T>::is_float, "'outerProduct' only accept floating-point inputs");
detail::tmat2x2<T> m(detail::tmat2x2<T>::null); detail::tmat2x2<T> m(detail::tmat2x2<T>::null);
@ -41,40 +40,40 @@ namespace core
m[0][1] = c[1] * r[0]; m[0][1] = c[1] * r[0];
m[1][0] = c[0] * r[1]; m[1][0] = c[0] * r[1];
m[1][1] = c[1] * r[1]; m[1][1] = c[1] * r[1];
return m; return m;
} }
template <typename T> template <typename T>
GLM_FUNC_QUALIFIER detail::tmat3x3<T> outerProduct GLM_FUNC_QUALIFIER detail::tmat3x3<T> outerProduct
( (
detail::tvec3<T> const & c, detail::tvec3<T> const & c,
detail::tvec3<T> const & r detail::tvec3<T> const & r
) )
{ {
GLM_STATIC_ASSERT(detail::type<T>::is_float, "'outerProduct' only accept floating-point inputs"); GLM_STATIC_ASSERT(detail::type<T>::is_float, "'outerProduct' only accept floating-point inputs");
detail::tmat3x3<T> m(detail::tmat3x3<T>::null); detail::tmat3x3<T> m(detail::tmat3x3<T>::null);
for(typename detail::tmat3x3<T>::size_type i = 0; i < detail::tmat3x3<T>::col_size(); ++i) for(typename detail::tmat3x3<T>::size_type i = 0; i < detail::tmat3x3<T>::col_size(); ++i)
m[i] = c * r[i]; m[i] = c * r[i];
return m; return m;
} }
template <typename T> template <typename T>
GLM_FUNC_QUALIFIER detail::tmat4x4<T> outerProduct GLM_FUNC_QUALIFIER detail::tmat4x4<T> outerProduct
( (
detail::tvec4<T> const & c, detail::tvec4<T> const & c,
detail::tvec4<T> const & r detail::tvec4<T> const & r
) )
{ {
GLM_STATIC_ASSERT(detail::type<T>::is_float, "'outerProduct' only accept floating-point inputs"); GLM_STATIC_ASSERT(detail::type<T>::is_float, "'outerProduct' only accept floating-point inputs");
detail::tmat4x4<T> m(detail::tmat4x4<T>::null); detail::tmat4x4<T> m(detail::tmat4x4<T>::null);
for(typename detail::tmat4x4<T>::size_type i = 0; i < detail::tmat4x4<T>::col_size(); ++i) for(typename detail::tmat4x4<T>::size_type i = 0; i < detail::tmat4x4<T>::col_size(); ++i)
m[i] = c * r[i]; m[i] = c * r[i];
return m; return m;
} }
template <typename T> template <typename T>
GLM_FUNC_QUALIFIER detail::tmat2x3<T> outerProduct GLM_FUNC_QUALIFIER detail::tmat2x3<T> outerProduct
( (
detail::tvec3<T> const & c, detail::tvec3<T> const & c,
@ -93,7 +92,7 @@ namespace core
return m; return m;
} }
template <typename T> template <typename T>
GLM_FUNC_QUALIFIER detail::tmat3x2<T> outerProduct GLM_FUNC_QUALIFIER detail::tmat3x2<T> outerProduct
( (
detail::tvec2<T> const & c, detail::tvec2<T> const & c,
@ -204,113 +203,113 @@ namespace core
return m; return m;
} }
template <typename T> template <typename T>
GLM_FUNC_QUALIFIER detail::tmat2x2<T> transpose GLM_FUNC_QUALIFIER detail::tmat2x2<T> transpose
( (
detail::tmat2x2<T> const & m detail::tmat2x2<T> const & m
) )
{ {
GLM_STATIC_ASSERT(detail::type<T>::is_float, "'transpose' only accept floating-point inputs"); GLM_STATIC_ASSERT(detail::type<T>::is_float, "'transpose' only accept floating-point inputs");
detail::tmat2x2<T> result(detail::tmat2x2<T>::null); detail::tmat2x2<T> result(detail::tmat2x2<T>::null);
result[0][0] = m[0][0]; result[0][0] = m[0][0];
result[0][1] = m[1][0]; result[0][1] = m[1][0];
result[1][0] = m[0][1]; result[1][0] = m[0][1];
result[1][1] = m[1][1]; result[1][1] = m[1][1];
return result; return result;
} }
template <typename T> template <typename T>
GLM_FUNC_QUALIFIER detail::tmat3x3<T> transpose GLM_FUNC_QUALIFIER detail::tmat3x3<T> transpose
( (
detail::tmat3x3<T> const & m detail::tmat3x3<T> const & m
) )
{ {
GLM_STATIC_ASSERT(detail::type<T>::is_float, "'transpose' only accept floating-point inputs"); GLM_STATIC_ASSERT(detail::type<T>::is_float, "'transpose' only accept floating-point inputs");
detail::tmat3x3<T> result(detail::tmat3x3<T>::null); detail::tmat3x3<T> result(detail::tmat3x3<T>::null);
result[0][0] = m[0][0]; result[0][0] = m[0][0];
result[0][1] = m[1][0]; result[0][1] = m[1][0];
result[0][2] = m[2][0]; result[0][2] = m[2][0];
result[1][0] = m[0][1]; result[1][0] = m[0][1];
result[1][1] = m[1][1]; result[1][1] = m[1][1];
result[1][2] = m[2][1]; result[1][2] = m[2][1];
result[2][0] = m[0][2]; result[2][0] = m[0][2];
result[2][1] = m[1][2]; result[2][1] = m[1][2];
result[2][2] = m[2][2]; result[2][2] = m[2][2];
return result; return result;
} }
template <typename T> template <typename T>
GLM_FUNC_QUALIFIER detail::tmat4x4<T> transpose GLM_FUNC_QUALIFIER detail::tmat4x4<T> transpose
( (
detail::tmat4x4<T> const & m detail::tmat4x4<T> const & m
) )
{ {
GLM_STATIC_ASSERT(detail::type<T>::is_float, "'transpose' only accept floating-point inputs"); GLM_STATIC_ASSERT(detail::type<T>::is_float, "'transpose' only accept floating-point inputs");
detail::tmat4x4<T> result(detail::tmat4x4<T>::null); detail::tmat4x4<T> result(detail::tmat4x4<T>::null);
result[0][0] = m[0][0]; result[0][0] = m[0][0];
result[0][1] = m[1][0]; result[0][1] = m[1][0];
result[0][2] = m[2][0]; result[0][2] = m[2][0];
result[0][3] = m[3][0]; result[0][3] = m[3][0];
result[1][0] = m[0][1]; result[1][0] = m[0][1];
result[1][1] = m[1][1]; result[1][1] = m[1][1];
result[1][2] = m[2][1]; result[1][2] = m[2][1];
result[1][3] = m[3][1]; result[1][3] = m[3][1];
result[2][0] = m[0][2]; result[2][0] = m[0][2];
result[2][1] = m[1][2]; result[2][1] = m[1][2];
result[2][2] = m[2][2]; result[2][2] = m[2][2];
result[2][3] = m[3][2]; result[2][3] = m[3][2];
result[3][0] = m[0][3]; result[3][0] = m[0][3];
result[3][1] = m[1][3]; result[3][1] = m[1][3];
result[3][2] = m[2][3]; result[3][2] = m[2][3];
result[3][3] = m[3][3]; result[3][3] = m[3][3];
return result; return result;
} }
template <typename T> template <typename T>
GLM_FUNC_QUALIFIER detail::tmat2x3<T> transpose GLM_FUNC_QUALIFIER detail::tmat2x3<T> transpose
( (
detail::tmat3x2<T> const & m detail::tmat3x2<T> const & m
) )
{ {
GLM_STATIC_ASSERT(detail::type<T>::is_float, "'transpose' only accept floating-point inputs"); GLM_STATIC_ASSERT(detail::type<T>::is_float, "'transpose' only accept floating-point inputs");
detail::tmat2x3<T> result(detail::tmat2x3<T>::null); detail::tmat2x3<T> result(detail::tmat2x3<T>::null);
result[0][0] = m[0][0]; result[0][0] = m[0][0];
result[0][1] = m[1][0]; result[0][1] = m[1][0];
result[0][2] = m[2][0]; result[0][2] = m[2][0];
result[1][0] = m[0][1]; result[1][0] = m[0][1];
result[1][1] = m[1][1]; result[1][1] = m[1][1];
result[1][2] = m[2][1]; result[1][2] = m[2][1];
return result; return result;
} }
template <typename T> template <typename T>
GLM_FUNC_QUALIFIER detail::tmat3x2<T> transpose GLM_FUNC_QUALIFIER detail::tmat3x2<T> transpose
( (
detail::tmat2x3<T> const & m detail::tmat2x3<T> const & m
) )
{ {
GLM_STATIC_ASSERT(detail::type<T>::is_float, "'transpose' only accept floating-point inputs"); GLM_STATIC_ASSERT(detail::type<T>::is_float, "'transpose' only accept floating-point inputs");
detail::tmat3x2<T> result(detail::tmat3x2<T>::null); detail::tmat3x2<T> result(detail::tmat3x2<T>::null);
result[0][0] = m[0][0]; result[0][0] = m[0][0];
result[0][1] = m[1][0]; result[0][1] = m[1][0];
result[1][0] = m[0][1]; result[1][0] = m[0][1];
result[1][1] = m[1][1]; result[1][1] = m[1][1];
result[2][0] = m[0][2]; result[2][0] = m[0][2];
result[2][1] = m[1][2]; result[2][1] = m[1][2];
return result; return result;
} }
template <typename T> template <typename T>
GLM_FUNC_QUALIFIER detail::tmat2x4<T> transpose GLM_FUNC_QUALIFIER detail::tmat2x4<T> transpose
( (
detail::tmat4x2<T> const & m detail::tmat4x2<T> const & m
@ -319,18 +318,18 @@ namespace core
GLM_STATIC_ASSERT(detail::type<T>::is_float, "'transpose' only accept floating-point inputs"); GLM_STATIC_ASSERT(detail::type<T>::is_float, "'transpose' only accept floating-point inputs");
detail::tmat2x4<T> result(detail::tmat2x4<T>::null); detail::tmat2x4<T> result(detail::tmat2x4<T>::null);
result[0][0] = m[0][0]; result[0][0] = m[0][0];
result[0][1] = m[1][0]; result[0][1] = m[1][0];
result[0][2] = m[2][0]; result[0][2] = m[2][0];
result[0][3] = m[3][0]; result[0][3] = m[3][0];
result[1][0] = m[0][1]; result[1][0] = m[0][1];
result[1][1] = m[1][1]; result[1][1] = m[1][1];
result[1][2] = m[2][1]; result[1][2] = m[2][1];
result[1][3] = m[3][1]; result[1][3] = m[3][1];
return result; return result;
} }
template <typename T> template <typename T>
GLM_FUNC_QUALIFIER detail::tmat4x2<T> transpose GLM_FUNC_QUALIFIER detail::tmat4x2<T> transpose
( (
detail::tmat2x4<T> const & m detail::tmat2x4<T> const & m
@ -338,19 +337,19 @@ namespace core
{ {
GLM_STATIC_ASSERT(detail::type<T>::is_float, "'transpose' only accept floating-point inputs"); GLM_STATIC_ASSERT(detail::type<T>::is_float, "'transpose' only accept floating-point inputs");
detail::tmat4x2<T> result(detail::tmat4x2<T>::null); detail::tmat4x2<T> result(detail::tmat4x2<T>::null);
result[0][0] = m[0][0]; result[0][0] = m[0][0];
result[0][1] = m[1][0]; result[0][1] = m[1][0];
result[1][0] = m[0][1]; result[1][0] = m[0][1];
result[1][1] = m[1][1]; result[1][1] = m[1][1];
result[2][0] = m[0][2]; result[2][0] = m[0][2];
result[2][1] = m[1][2]; result[2][1] = m[1][2];
result[3][0] = m[0][3]; result[3][0] = m[0][3];
result[3][1] = m[1][3]; result[3][1] = m[1][3];
return result; return result;
} }
template <typename T> template <typename T>
GLM_FUNC_QUALIFIER detail::tmat3x4<T> transpose GLM_FUNC_QUALIFIER detail::tmat3x4<T> transpose
( (
detail::tmat4x3<T> const & m detail::tmat4x3<T> const & m
@ -359,22 +358,22 @@ namespace core
GLM_STATIC_ASSERT(detail::type<T>::is_float, "'transpose' only accept floating-point inputs"); GLM_STATIC_ASSERT(detail::type<T>::is_float, "'transpose' only accept floating-point inputs");
detail::tmat3x4<T> result(detail::tmat3x4<T>::null); detail::tmat3x4<T> result(detail::tmat3x4<T>::null);
result[0][0] = m[0][0]; result[0][0] = m[0][0];
result[0][1] = m[1][0]; result[0][1] = m[1][0];
result[0][2] = m[2][0]; result[0][2] = m[2][0];
result[0][3] = m[3][0]; result[0][3] = m[3][0];
result[1][0] = m[0][1]; result[1][0] = m[0][1];
result[1][1] = m[1][1]; result[1][1] = m[1][1];
result[1][2] = m[2][1]; result[1][2] = m[2][1];
result[1][3] = m[3][1]; result[1][3] = m[3][1];
result[2][0] = m[0][2]; result[2][0] = m[0][2];
result[2][1] = m[1][2]; result[2][1] = m[1][2];
result[2][2] = m[2][2]; result[2][2] = m[2][2];
result[2][3] = m[3][2]; result[2][3] = m[3][2];
return result; return result;
} }
template <typename T> template <typename T>
GLM_FUNC_QUALIFIER detail::tmat4x3<T> transpose GLM_FUNC_QUALIFIER detail::tmat4x3<T> transpose
( (
detail::tmat3x4<T> const & m detail::tmat3x4<T> const & m
@ -382,20 +381,20 @@ namespace core
{ {
GLM_STATIC_ASSERT(detail::type<T>::is_float, "'transpose' only accept floating-point inputs"); GLM_STATIC_ASSERT(detail::type<T>::is_float, "'transpose' only accept floating-point inputs");
detail::tmat4x3<T> result(detail::tmat4x3<T>::null); detail::tmat4x3<T> result(detail::tmat4x3<T>::null);
result[0][0] = m[0][0]; result[0][0] = m[0][0];
result[0][1] = m[1][0]; result[0][1] = m[1][0];
result[0][2] = m[2][0]; result[0][2] = m[2][0];
result[1][0] = m[0][1]; result[1][0] = m[0][1];
result[1][1] = m[1][1]; result[1][1] = m[1][1];
result[1][2] = m[2][1]; result[1][2] = m[2][1];
result[2][0] = m[0][2]; result[2][0] = m[0][2];
result[2][1] = m[1][2]; result[2][1] = m[1][2];
result[2][2] = m[2][2]; result[2][2] = m[2][2];
result[3][0] = m[0][3]; result[3][0] = m[0][3];
result[3][1] = m[1][3]; result[3][1] = m[1][3];
result[3][2] = m[2][3]; result[3][2] = m[2][3];
return result; return result;
} }
template <typename T> template <typename T>
@ -445,9 +444,9 @@ namespace core
- (m[1][0] * SubFactor02 - m[1][1] * SubFactor04 + m[1][2] * SubFactor05)); - (m[1][0] * SubFactor02 - m[1][1] * SubFactor04 + m[1][2] * SubFactor05));
return m[0][0] * DetCof[0] return m[0][0] * DetCof[0]
+ m[0][1] * DetCof[1] + m[0][1] * DetCof[1]
+ m[0][2] * DetCof[2] + m[0][2] * DetCof[2]
+ m[0][3] * DetCof[3]; + m[0][3] * DetCof[3];
} }
template <typename T> template <typename T>
@ -561,6 +560,4 @@ namespace core
return Inverse; return Inverse;
} }
}//namespace core
}//namespace glm }//namespace glm

View File

@ -10,10 +10,9 @@
#ifndef glm_core_func_noise #ifndef glm_core_func_noise
#define glm_core_func_noise #define glm_core_func_noise
namespace glm{ namespace glm
namespace core
{ {
/// \addtogroup core_funcs /// @addtogroup core_funcs
/// @{ /// @{
//! Returns a 1D noise value based on the input value x. //! Returns a 1D noise value based on the input value x.
@ -45,7 +44,6 @@ namespace core
detail::tvec4<typename genType::value_type> noise4(genType const & x); detail::tvec4<typename genType::value_type> noise4(genType const & x);
/// @} /// @}
}//namespace core
}//namespace glm }//namespace glm
#include "func_noise.inl" #include "func_noise.inl"

View File

@ -10,11 +10,10 @@
#ifndef glm_core_func_packing #ifndef glm_core_func_packing
#define glm_core_func_packing #define glm_core_func_packing
namespace glm{ namespace glm
namespace core
{ {
/// \addtogroup core_funcs /// @addtogroup core_funcs
///@{ /// @{
//! First, converts each component of the normalized floating-point value v into 8- or 16-bit integer values. //! First, converts each component of the normalized floating-point value v into 8- or 16-bit integer values.
//! Then, the results are packed into the returned 32-bit unsigned integer. //! Then, the results are packed into the returned 32-bit unsigned integer.
@ -114,7 +113,6 @@ namespace core
detail::tvec2<detail::uint32> unpackDouble2x32(double const & v); detail::tvec2<detail::uint32> unpackDouble2x32(double const & v);
/// @} /// @}
}//namespace core
}//namespace glm }//namespace glm
#include "func_packing.inl" #include "func_packing.inl"

View File

@ -8,77 +8,75 @@
/////////////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////////////
namespace glm{ namespace glm{
namespace core
GLM_FUNC_QUALIFIER detail::uint32 packUnorm2x16(detail::tvec2<detail::float32> const & v)
{ {
GLM_FUNC_QUALIFIER detail::uint32 packUnorm2x16(detail::tvec2<detail::float32> const & v) detail::uint16 A((detail::uint16)round(clamp(v.x, 0.0f, 1.0f) * 65535.0f));
{ detail::uint16 B((detail::uint16)round(clamp(v.y, 0.0f, 1.0f) * 65535.0f));
detail::uint16 A((detail::uint16)round(clamp(v.x, 0.0f, 1.0f) * 65535.0f)); return detail::uint32((B << 16) | A);
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::uint32 packUnorm4x8(detail::tvec4<detail::float32> const & v) GLM_FUNC_QUALIFIER detail::uint32 packUnorm4x8(detail::tvec4<detail::float32> const & v)
{ {
detail::uint8 A((detail::uint8)round(clamp(v.x, 0.0f, 1.0f) * 255.0f)); detail::uint8 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 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 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)); 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); return detail::uint32((D << 24) | (C << 16) | (B << 8) | A);
} }
GLM_FUNC_QUALIFIER detail::uint32 packSnorm4x8(detail::tvec4<detail::float32> const & v) GLM_FUNC_QUALIFIER detail::uint32 packSnorm4x8(detail::tvec4<detail::float32> const & v)
{ {
detail::uint8 A((detail::uint8)round(clamp(v.x,-1.0f, 1.0f) * 255.0f)); detail::uint8 A((detail::uint8)round(clamp(v.x,-1.0f, 1.0f) * 255.0f));
detail::uint8 B((detail::uint8)round(clamp(v.y,-1.0f, 1.0f) * 255.0f)); detail::uint8 B((detail::uint8)round(clamp(v.y,-1.0f, 1.0f) * 255.0f));
detail::uint8 C((detail::uint8)round(clamp(v.z,-1.0f, 1.0f) * 255.0f)); detail::uint8 C((detail::uint8)round(clamp(v.z,-1.0f, 1.0f) * 255.0f));
detail::uint8 D((detail::uint8)round(clamp(v.w,-1.0f, 1.0f) * 255.0f)); detail::uint8 D((detail::uint8)round(clamp(v.w,-1.0f, 1.0f) * 255.0f));
return detail::uint32((D << 24) | (C << 16) | (B << 8) | A); return detail::uint32((D << 24) | (C << 16) | (B << 8) | A);
} }
GLM_FUNC_QUALIFIER detail::tvec2<detail::float32> unpackUnorm2x16(detail::uint32 const & p) GLM_FUNC_QUALIFIER detail::tvec2<detail::float32> unpackUnorm2x16(detail::uint32 const & p)
{ {
detail::uint16 A(detail::uint16(p >> 0)); detail::uint16 A(detail::uint16(p >> 0));
detail::uint16 B(detail::uint16(p >> 16)); detail::uint16 B(detail::uint16(p >> 16));
return detail::tvec2<detail::float32>( return detail::tvec2<detail::float32>(
A * 1.0f / 65535.0f, A * 1.0f / 65535.0f,
B * 1.0f / 65535.0f); B * 1.0f / 65535.0f);
} }
GLM_FUNC_QUALIFIER detail::tvec4<detail::float32> unpackUnorm4x8(detail::uint32 const & p) GLM_FUNC_QUALIFIER detail::tvec4<detail::float32> unpackUnorm4x8(detail::uint32 const & p)
{ {
detail::uint8 A(detail::uint8(p >> 0)); detail::uint8 A(detail::uint8(p >> 0));
detail::uint8 B(detail::uint8(p >> 8)); detail::uint8 B(detail::uint8(p >> 8));
detail::uint8 C(detail::uint8(p >> 16)); detail::uint8 C(detail::uint8(p >> 16));
detail::uint8 D(detail::uint8(p >> 24)); detail::uint8 D(detail::uint8(p >> 24));
return detail::tvec4<detail::float32>( return detail::tvec4<detail::float32>(
A * 1.0f / 255.0f, A * 1.0f / 255.0f,
B * 1.0f / 255.0f, B * 1.0f / 255.0f,
C * 1.0f / 255.0f, C * 1.0f / 255.0f,
D * 1.0f / 255.0f); D * 1.0f / 255.0f);
} }
GLM_FUNC_QUALIFIER detail::tvec4<detail::float32> unpackSnorm4x8(detail::uint32 const & p) GLM_FUNC_QUALIFIER detail::tvec4<detail::float32> unpackSnorm4x8(detail::uint32 const & p)
{ {
detail::uint8 A(detail::uint8(p >> 0)); detail::uint8 A(detail::uint8(p >> 0));
detail::uint8 B(detail::uint8(p >> 8)); detail::uint8 B(detail::uint8(p >> 8));
detail::uint8 C(detail::uint8(p >> 16)); detail::uint8 C(detail::uint8(p >> 16));
detail::uint8 D(detail::uint8(p >> 24)); detail::uint8 D(detail::uint8(p >> 24));
return clamp(detail::tvec4<detail::float32>( return clamp(detail::tvec4<detail::float32>(
A * 1.0f / 127.0f, A * 1.0f / 127.0f,
B * 1.0f / 127.0f, B * 1.0f / 127.0f,
C * 1.0f / 127.0f, C * 1.0f / 127.0f,
D * 1.0f / 127.0f), -1.0f, 1.0f); D * 1.0f / 127.0f), -1.0f, 1.0f);
} }
GLM_FUNC_QUALIFIER double packDouble2x32(detail::tvec2<detail::uint32> const & v) GLM_FUNC_QUALIFIER double packDouble2x32(detail::tvec2<detail::uint32> const & v)
{ {
return *(double*)&v; return *(double*)&v;
} }
GLM_FUNC_QUALIFIER detail::tvec2<detail::uint32> unpackDouble2x32(double const & v) GLM_FUNC_QUALIFIER detail::tvec2<detail::uint32> unpackDouble2x32(double const & v)
{ {
return *(detail::tvec2<detail::uint32>*)&v; return *(detail::tvec2<detail::uint32>*)&v;
} }
}//namespace core
}//namespace glm }//namespace glm

View File

@ -10,10 +10,9 @@
#ifndef glm_core_func_trigonometric #ifndef glm_core_func_trigonometric
#define glm_core_func_trigonometric #define glm_core_func_trigonometric
namespace glm{ namespace glm
namespace core
{ {
/// \addtogroup core_funcs /// @addtogroup core_funcs
/// @{ /// @{
//! Converts degrees to radians and returns the result. //! Converts degrees to radians and returns the result.
@ -135,7 +134,6 @@ namespace core
genType atanh(genType const & x); genType atanh(genType const & x);
/// @} /// @}
}//namespace core
}//namespace glm }//namespace glm
#include "func_trigonometric.inl" #include "func_trigonometric.inl"

File diff suppressed because it is too large Load Diff

View File

@ -12,10 +12,9 @@
#include "_detail.hpp" #include "_detail.hpp"
namespace glm{ namespace glm
namespace core
{ {
/// \addtogroup core_funcs /// @addtogroup core_funcs
/// @{ /// @{
//! Returns the component-wise comparison result of x < y. //! Returns the component-wise comparison result of x < y.
@ -197,7 +196,6 @@ namespace core
} }
/// @} /// @}
}//namespace core
}//namespace glm }//namespace glm
#include "func_vector_relational.inl" #include "func_vector_relational.inl"

View File

@ -16,6 +16,6 @@ namespace glm
class dont_care {}; class dont_care {};
class nicest {}; class nicest {};
class fastest {}; class fastest {};
}; }//namespace glm
#endif//glm_core_type #endif//glm_core_type

View File

@ -43,16 +43,6 @@
# pragma message("GLM: Core library included") # pragma message("GLM: Core library included")
#endif//GLM_MESSAGE #endif//GLM_MESSAGE
namespace glm
{
namespace gtc{}
namespace gtx{}
namespace virtrev{}
using namespace gtc;
using namespace gtx;
}//namespace glm
#include "./core/_detail.hpp" #include "./core/_detail.hpp"
#include "./core/type.hpp" #include "./core/type.hpp"

View File

@ -35,8 +35,8 @@
/// ///
/////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////
#ifndef glm_gtc_half_float #ifndef GLM_GTC_half_float
#define glm_gtc_half_float #define GLM_GTC_half_float 90
// Dependency: // Dependency:
#include "../glm.hpp" #include "../glm.hpp"
@ -349,8 +349,6 @@ namespace detail
} }
//namespace detail //namespace detail
namespace gtc
{
/// @addtogroup gtc_half_float /// @addtogroup gtc_half_float
/// @{ /// @{
@ -419,9 +417,8 @@ namespace gtc
typedef detail::tmat4x4<detail::thalf> hmat4x4; typedef detail::tmat4x4<detail::thalf> hmat4x4;
/// @} /// @}
}// namespace gtc
}// namespace glm }// namespace glm
#include "half_float.inl" #include "half_float.inl"
#endif//glm_gtc_half_float #endif//GLM_GTC_half_float

View File

@ -34,8 +34,8 @@
/// <glm/gtc/matrix_access.hpp> need to be included to use these functionalities. /// <glm/gtc/matrix_access.hpp> need to be included to use these functionalities.
/////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////
#ifndef glm_gtc_matrix_access #ifndef GLM_GTC_matrix_access
#define glm_gtc_matrix_access #define GLM_GTC_matrix_access 90
// Dependency: // Dependency:
#include "../glm.hpp" #include "../glm.hpp"
@ -44,9 +44,8 @@
# pragma message("GLM: GLM_GTC_matrix_access extension included") # pragma message("GLM: GLM_GTC_matrix_access extension included")
#endif #endif
namespace glm{ namespace glm
namespace gtc{ {
/// @addtogroup gtc_matrix_access /// @addtogroup gtc_matrix_access
/// @{ /// @{
@ -81,9 +80,8 @@ namespace gtc{
typename genType::col_type const & x); typename genType::col_type const & x);
/// @} /// @}
}//namespace gtc
}//namespace glm }//namespace glm
#include "matrix_access.inl" #include "matrix_access.inl"
#endif//glm_gtc_matrix_access #endif//GLM_GTC_matrix_access

View File

@ -8,50 +8,48 @@
/////////////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////////////
namespace glm{ namespace glm{
namespace gtc
template <typename genType>
GLM_FUNC_QUALIFIER genType row(
genType const & m,
int index,
typename genType::row_type const & x)
{ {
template <typename genType> genType Result = m;
GLM_FUNC_QUALIFIER genType row( for(typename genType::size_type i = 0; i < genType::row_size(); ++i)
genType const & m, Result[i][index] = x[i];
int index, return Result;
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> template <typename genType>
GLM_FUNC_QUALIFIER typename genType::row_type row( GLM_FUNC_QUALIFIER typename genType::row_type row(
genType const & m, genType const & m,
int index) int index)
{ {
typename genType::row_type Result; typename genType::row_type Result;
for(typename genType::size_type i = 0; i < genType::row_size(); ++i) for(typename genType::size_type i = 0; i < genType::row_size(); ++i)
Result[i] = m[i][index]; Result[i] = m[i][index];
return Result; return Result;
} }
template <typename genType> template <typename genType>
GLM_FUNC_QUALIFIER genType column( GLM_FUNC_QUALIFIER genType column(
genType const & m, genType const & m,
int index, int index,
typename genType::col_type const & x) typename genType::col_type const & x)
{ {
genType Result = m; genType Result = m;
Result[index] = x; Result[index] = x;
return Result; return Result;
} }
template <typename genType> template <typename genType>
GLM_FUNC_QUALIFIER typename genType::col_type column( GLM_FUNC_QUALIFIER typename genType::col_type column(
genType const & m, genType const & m,
int index) int index)
{ {
return m[index]; return m[index];
} }
}//namespace gtc
}//namespace glm }//namespace glm

View File

@ -34,8 +34,8 @@
/// <glm/gtc/matrix_integer.hpp> need to be included to use these functionalities. /// <glm/gtc/matrix_integer.hpp> need to be included to use these functionalities.
/////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////
#ifndef glm_gtc_matrix_integer #ifndef GLM_GTC_matrix_integer
#define glm_gtc_matrix_integer #define GLM_GTC_matrix_integer 90
// Dependency: // Dependency:
#include "../glm.hpp" #include "../glm.hpp"
@ -44,10 +44,9 @@
# pragma message("GLM: GLM_GTC_matrix_integer extension included") # pragma message("GLM: GLM_GTC_matrix_integer extension included")
#endif #endif
namespace glm{ namespace glm
namespace gtc{ {
/// @addtogroup gtc_matrix_integer
/// \addtogroup gtc_matrix_integer
/// @{ /// @{
typedef detail::tmat2x2<highp_int> highp_imat2; //!< \brief High-precision signed integer 2x2 matrix. (from GLM_GTC_matrix_integer extension) typedef detail::tmat2x2<highp_int> highp_imat2; //!< \brief High-precision signed integer 2x2 matrix. (from GLM_GTC_matrix_integer extension)
@ -217,7 +216,6 @@ namespace gtc{
#endif//GLM_PRECISION #endif//GLM_PRECISION
/// @} /// @}
}//namespace gtc
}//namespace glm }//namespace glm
#endif//glm_gtc_matrix_integer #endif//GLM_GTC_matrix_integer

View File

@ -34,8 +34,8 @@
/// <glm/gtc/matrix_inverse.hpp> need to be included to use these functionalities. /// <glm/gtc/matrix_inverse.hpp> need to be included to use these functionalities.
/////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////
#ifndef glm_gtc_matrix_inverse #ifndef GLM_GTC_matrix_inverse
#define glm_gtc_matrix_inverse #define GLM_GTC_matrix_inverse 90
// Dependency: // Dependency:
#include "../glm.hpp" #include "../glm.hpp"
@ -44,8 +44,7 @@
# pragma message("GLM: GLM_GTC_matrix_inverse extension included") # pragma message("GLM: GLM_GTC_matrix_inverse extension included")
#endif #endif
namespace glm{ namespace glm
namespace gtc
{ {
/// @addtogroup gtc_matrix_inverse /// @addtogroup gtc_matrix_inverse
/// @{ /// @{
@ -62,9 +61,8 @@ namespace gtc
genType const & m); genType const & m);
/// @} /// @}
}//namespace gtc
}//namespace glm }//namespace glm
#include "matrix_inverse.inl" #include "matrix_inverse.inl"
#endif//glm_gtc_matrix_inverse #endif//GLM_GTC_matrix_inverse

View File

@ -8,130 +8,128 @@
/////////////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////////////
namespace glm{ namespace glm{
namespace gtc{
template <typename T> template <typename T>
GLM_FUNC_QUALIFIER detail::tmat3x3<T> affineInverse GLM_FUNC_QUALIFIER detail::tmat3x3<T> affineInverse
( (
detail::tmat3x3<T> const & m detail::tmat3x3<T> const & m
) )
{ {
detail::tmat3x3<T> Result(m); detail::tmat3x3<T> Result(m);
Result[2] = detail::tvec3<T>(0, 0, 1); Result[2] = detail::tvec3<T>(0, 0, 1);
Result = transpose(Result); Result = transpose(Result);
detail::tvec3<T> Translation = Result * detail::tvec3<T>(-detail::tvec2<T>(m[2]), m[2][2]); detail::tvec3<T> Translation = Result * detail::tvec3<T>(-detail::tvec2<T>(m[2]), m[2][2]);
Result[2] = Translation; Result[2] = Translation;
return Result; return Result;
} }
template <typename T> template <typename T>
GLM_FUNC_QUALIFIER detail::tmat4x4<T> affineInverse GLM_FUNC_QUALIFIER detail::tmat4x4<T> affineInverse
( (
detail::tmat4x4<T> const & m detail::tmat4x4<T> const & m
) )
{ {
detail::tmat4x4<T> Result(m); detail::tmat4x4<T> Result(m);
Result[3] = detail::tvec4<T>(0, 0, 0, 1); Result[3] = detail::tvec4<T>(0, 0, 0, 1);
Result = transpose(Result); Result = transpose(Result);
detail::tvec4<T> Translation = Result * detail::tvec4<T>(-detail::tvec3<T>(m[3]), m[3][3]); detail::tvec4<T> Translation = Result * detail::tvec4<T>(-detail::tvec3<T>(m[3]), m[3][3]);
Result[3] = Translation; Result[3] = Translation;
return Result; return Result;
} }
template <typename valType> template <typename valType>
GLM_FUNC_QUALIFIER detail::tmat2x2<valType> inverseTranspose( GLM_FUNC_QUALIFIER detail::tmat2x2<valType> inverseTranspose(
detail::tmat2x2<valType> const & m) detail::tmat2x2<valType> const & m)
{ {
valType Determinant = m[0][0] * m[1][1] - m[1][0] * m[0][1]; valType Determinant = m[0][0] * m[1][1] - m[1][0] * m[0][1];
detail::tmat2x2<valType> Inverse( detail::tmat2x2<valType> Inverse(
+ m[1][1] / Determinant, + m[1][1] / Determinant,
- m[0][1] / Determinant, - m[0][1] / Determinant,
- m[1][0] / Determinant, - m[1][0] / Determinant,
+ m[0][0] / Determinant); + m[0][0] / Determinant);
return Inverse; return Inverse;
} }
template <typename valType> template <typename valType>
GLM_FUNC_QUALIFIER detail::tmat3x3<valType> inverseTranspose( GLM_FUNC_QUALIFIER detail::tmat3x3<valType> inverseTranspose(
detail::tmat3x3<valType> const & m) detail::tmat3x3<valType> const & m)
{ {
valType Determinant = valType Determinant =
+ m[0][0] * (m[1][1] * m[2][2] - m[1][2] * m[2][1]) + 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][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]); + m[0][2] * (m[1][0] * m[2][1] - m[1][1] * m[2][0]);
detail::tmat3x3<valType> Inverse; detail::tmat3x3<valType> Inverse;
Inverse[0][0] = + (m[1][1] * m[2][2] - m[2][1] * m[1][2]); 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][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[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][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][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[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][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][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[2][2] = + (m[0][0] * m[1][1] - m[1][0] * m[0][1]);
Inverse /= Determinant; Inverse /= Determinant;
return Inverse; return Inverse;
} }
template <typename valType> template <typename valType>
GLM_FUNC_QUALIFIER detail::tmat4x4<valType> inverseTranspose( GLM_FUNC_QUALIFIER detail::tmat4x4<valType> inverseTranspose(
detail::tmat4x4<valType> const & m) detail::tmat4x4<valType> const & m)
{ {
valType SubFactor00 = m[2][2] * m[3][3] - m[3][2] * m[2][3]; 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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]; valType SubFactor18 = m[1][0] * m[2][1] - m[2][0] * m[1][1];
detail::tmat4x4<valType> Inverse; detail::tmat4x4<valType> Inverse;
Inverse[0][0] = + (m[1][1] * SubFactor00 - m[1][2] * SubFactor01 + m[1][3] * SubFactor02); 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][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][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[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][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][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][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][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][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][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][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][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][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][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][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][3] = + (m[0][0] * SubFactor15 - m[0][1] * SubFactor17 + m[0][2] * SubFactor18);
valType Determinant = valType Determinant =
+ m[0][0] * Inverse[0][0] + m[0][0] * Inverse[0][0]
+ m[0][1] * Inverse[0][1] + m[0][1] * Inverse[0][1]
+ m[0][2] * Inverse[0][2] + m[0][2] * Inverse[0][2]
+ m[0][3] * Inverse[0][3]; + m[0][3] * Inverse[0][3];
Inverse /= Determinant; Inverse /= Determinant;
return Inverse; return Inverse;
} }
}//namespace gtc
}//namespace glm }//namespace glm

View File

@ -43,8 +43,8 @@
/// <glm/gtc/matrix_transform.hpp> need to be included to use these functionalities. /// <glm/gtc/matrix_transform.hpp> need to be included to use these functionalities.
/////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////
#ifndef glm_gtc_matrix_transform #ifndef GLM_GTC_matrix_transform
#define glm_gtc_matrix_transform #define GLM_GTC_matrix_transform 90
// Dependency: // Dependency:
#include "../glm.hpp" #include "../glm.hpp"
@ -53,8 +53,7 @@
# pragma message("GLM: GLM_GTC_matrix_transform extension included") # pragma message("GLM: GLM_GTC_matrix_transform extension included")
#endif #endif
namespace glm{ namespace glm
namespace gtc
{ {
/// @addtogroup gtc_matrix_transform /// @addtogroup gtc_matrix_transform
/// @{ /// @{
@ -62,9 +61,9 @@ namespace gtc
/// Builds a translation 4 * 4 matrix created from a vector of 3 components. /// Builds a translation 4 * 4 matrix created from a vector of 3 components.
/// @see - gtc_matrix_transform /// @see - gtc_matrix_transform
/// @see - gtx_transform: /// @see - gtx_transform:
/// - @link glm::gtx::translate(T x, T y, T z) translate(T x, T y, T z) @endlink /// - @link translate(T x, T y, T z) translate(T x, T y, T z) @endlink
/// - @link glm::gtx::translate(detail::tmat4x4<T> const & m, T x, T y, T z) translate(mat4x4<T> const & m, T x, T y, T z) @endlink /// - @link translate(detail::tmat4x4<T> const & m, T x, T y, T z) translate(mat4x4<T> const & m, T x, T y, T z) @endlink
/// - @link glm::gtx::translate(detail::tvec3<T> const & v) translate(vec3<T> const & v) @endlink /// - @link translate(detail::tvec3<T> const & v) translate(vec3<T> const & v) @endlink
template <typename T> template <typename T>
detail::tmat4x4<T> translate( detail::tmat4x4<T> translate(
detail::tmat4x4<T> const & m, detail::tmat4x4<T> const & m,
@ -73,9 +72,9 @@ namespace gtc
/// Builds a rotation 4 * 4 matrix created from an axis vector and an angle expressed in degrees. /// Builds a rotation 4 * 4 matrix created from an axis vector and an angle expressed in degrees.
/// @see - gtc_matrix_transform /// @see - gtc_matrix_transform
/// @see - gtx_transform: /// @see - gtx_transform:
/// - @link glm::gtx::rotate(T angle, T x, T y, T z) rotate(T const & angle, T const & x, T const & y, T const & z) @endlink /// - @link rotate(T angle, T x, T y, T z) rotate(T const & angle, T const & x, T const & y, T const & z) @endlink
/// - @link glm::gtx::rotate(detail::tmat4x4<T> const & m, T angle, T x, T y, T z) rotate(mat4x4<T> const & m, T const & angle, T const & x, T const & y, T const & z) @endlink /// - @link rotate(detail::tmat4x4<T> const & m, T angle, T x, T y, T z) rotate(mat4x4<T> const & m, T const & angle, T const & x, T const & y, T const & z) @endlink
/// - @link glm::gtx::rotate(T angle, detail::tvec3<T> const & v) rotate(T const & angle, vec3<T> const & v) @endlink /// - @link rotate(T angle, detail::tvec3<T> const & v) rotate(T const & angle, vec3<T> const & v) @endlink
template <typename T> template <typename T>
detail::tmat4x4<T> rotate( detail::tmat4x4<T> rotate(
detail::tmat4x4<T> const & m, detail::tmat4x4<T> const & m,
@ -85,9 +84,9 @@ namespace gtc
/// Builds a scale 4 * 4 matrix created from 3 scalars. /// Builds a scale 4 * 4 matrix created from 3 scalars.
/// @see - gtc_matrix_transform /// @see - gtc_matrix_transform
/// @see - gtx_transform: /// @see - gtx_transform:
/// - @link glm::gtx::scale(T x, T y, T z) scale(T const & x, T const & y, T const & z) @endlink /// - @link scale(T x, T y, T z) scale(T const & x, T const & y, T const & z) @endlink
/// - @link glm::gtx::scale(detail::tmat4x4<T> const & m, T x, T y, T z) scale(mat4x4<T> const & m, T const & angle, T const & x, T const & y, T const & z) @endlink /// - @link scale(detail::tmat4x4<T> const & m, T x, T y, T z) scale(mat4x4<T> const & m, T const & angle, T const & x, T const & y, T const & z) @endlink
/// - @link glm::gtx::scale(detail::tvec3<T> const & v) scale(vec3<T> const & v) @endlink /// - @link scale(detail::tvec3<T> const & v) scale(vec3<T> const & v) @endlink
template <typename T> template <typename T>
detail::tmat4x4<T> scale( detail::tmat4x4<T> scale(
detail::tmat4x4<T> const & m, detail::tmat4x4<T> const & m,
@ -95,7 +94,7 @@ namespace gtc
/// Creates a matrix for an orthographic parallel viewing volume. /// Creates a matrix for an orthographic parallel viewing volume.
/// @see - gtc_matrix_transform: /// @see - gtc_matrix_transform:
/// - @link glm::gtc::ortho(T const & left, T const & right, T const & bottom, T const & top) ortho(T const & left, T const & right, T const & bottom, T const & top) @endlink /// - @link glm::ortho(T const & left, T const & right, T const & bottom, T const & top) ortho(T const & left, T const & right, T const & bottom, T const & top) @endlink
template <typename T> template <typename T>
detail::tmat4x4<T> ortho( detail::tmat4x4<T> ortho(
T const & left, T const & left,
@ -107,7 +106,7 @@ namespace gtc
/// Creates a matrix for projecting two-dimensional coordinates onto the screen. /// Creates a matrix for projecting two-dimensional coordinates onto the screen.
/// @see - gtc_matrix_transform: /// @see - gtc_matrix_transform:
/// - @link glm::gtc::ortho(T const & left, T const & right, T const & bottom, T const & top, T const & zNear, T const & zFar) ortho(T const & left, T const & right, T const & bottom, T const & top, T const & zNear, T const & zFar) @endlink /// - @link glm::ortho(T const & left, T const & right, T const & bottom, T const & top, T const & zNear, T const & zFar) ortho(T const & left, T const & right, T const & bottom, T const & top, T const & zNear, T const & zFar) @endlink
template <typename T> template <typename T>
detail::tmat4x4<T> ortho( detail::tmat4x4<T> ortho(
T const & left, T const & left,
@ -196,9 +195,8 @@ namespace gtc
detail::tvec3<T> const & up); detail::tvec3<T> const & up);
/// @} /// @}
}//namespace gtc
}//namespace glm }//namespace glm
#include "matrix_transform.inl" #include "matrix_transform.inl"
#endif//glm_gtc_matrix_transform #endif//GLM_GTC_matrix_transform

View File

@ -8,389 +8,387 @@
/////////////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////////////
namespace glm{ namespace glm{
namespace gtc{
template <typename T> template <typename T>
GLM_FUNC_QUALIFIER detail::tmat4x4<T> translate GLM_FUNC_QUALIFIER detail::tmat4x4<T> translate
( (
detail::tmat4x4<T> const & m, detail::tmat4x4<T> const & m,
detail::tvec3<T> const & v detail::tvec3<T> const & v
) )
{ {
detail::tmat4x4<T> Result(m); detail::tmat4x4<T> Result(m);
Result[3] = m[0] * v[0] + m[1] * v[1] + m[2] * v[2] + m[3]; Result[3] = m[0] * v[0] + m[1] * v[1] + m[2] * v[2] + m[3];
return Result; return Result;
} }
template <typename T> template <typename T>
GLM_FUNC_QUALIFIER detail::tmat4x4<T> rotate GLM_FUNC_QUALIFIER detail::tmat4x4<T> rotate
( (
detail::tmat4x4<T> const & m, detail::tmat4x4<T> const & m,
T const & angle, T const & angle,
detail::tvec3<T> const & v detail::tvec3<T> const & v
) )
{ {
T a = radians(angle); T a = radians(angle);
T c = cos(a); T c = cos(a);
T s = sin(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); detail::tmat4x4<T> Rotate(detail::tmat4x4<T>::null);
Rotate[0][0] = c + temp[0] * axis[0]; Rotate[0][0] = c + temp[0] * axis[0];
Rotate[0][1] = 0 + temp[0] * axis[1] + s * axis[2]; Rotate[0][1] = 0 + temp[0] * axis[1] + s * axis[2];
Rotate[0][2] = 0 + temp[0] * axis[2] - s * axis[1]; Rotate[0][2] = 0 + temp[0] * axis[2] - s * axis[1];
Rotate[1][0] = 0 + temp[1] * axis[0] - s * axis[2]; Rotate[1][0] = 0 + temp[1] * axis[0] - s * axis[2];
Rotate[1][1] = c + temp[1] * axis[1]; Rotate[1][1] = c + temp[1] * axis[1];
Rotate[1][2] = 0 + temp[1] * axis[2] + s * axis[0]; Rotate[1][2] = 0 + temp[1] * axis[2] + s * axis[0];
Rotate[2][0] = 0 + temp[2] * axis[0] + s * axis[1]; Rotate[2][0] = 0 + temp[2] * axis[0] + s * axis[1];
Rotate[2][1] = 0 + temp[2] * axis[1] - s * axis[0]; Rotate[2][1] = 0 + temp[2] * axis[1] - s * axis[0];
Rotate[2][2] = c + temp[2] * axis[2]; Rotate[2][2] = c + temp[2] * axis[2];
detail::tmat4x4<T> Result(detail::tmat4x4<T>::null); 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[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[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[2] = m[0] * Rotate[2][0] + m[1] * Rotate[2][1] + m[2] * Rotate[2][2];
Result[3] = m[3]; Result[3] = m[3];
return Result; return Result;
} }
template <typename T> template <typename T>
GLM_FUNC_QUALIFIER detail::tmat4x4<T> scale GLM_FUNC_QUALIFIER detail::tmat4x4<T> scale
( (
detail::tmat4x4<T> const & m, detail::tmat4x4<T> const & m,
detail::tvec3<T> const & v detail::tvec3<T> const & v
) )
{ {
detail::tmat4x4<T> Result(detail::tmat4x4<T>::null); detail::tmat4x4<T> Result(detail::tmat4x4<T>::null);
Result[0] = m[0] * v[0]; Result[0] = m[0] * v[0];
Result[1] = m[1] * v[1]; Result[1] = m[1] * v[1];
Result[2] = m[2] * v[2]; Result[2] = m[2] * v[2];
Result[3] = m[3]; Result[3] = m[3];
return Result; return Result;
} }
template <typename T> template <typename T>
GLM_FUNC_QUALIFIER detail::tmat4x4<T> translate_slow GLM_FUNC_QUALIFIER detail::tmat4x4<T> translate_slow
( (
detail::tmat4x4<T> const & m, detail::tmat4x4<T> const & m,
detail::tvec3<T> const & v detail::tvec3<T> const & v
) )
{ {
detail::tmat4x4<T> Result(T(1)); detail::tmat4x4<T> Result(T(1));
Result[3] = detail::tvec4<T>(v, T(1)); Result[3] = detail::tvec4<T>(v, T(1));
return m * Result; return m * Result;
//detail::tmat4x4<valType> Result(m); //detail::tmat4x4<valType> Result(m);
Result[3] = m[0] * v[0] + m[1] * v[1] + m[2] * v[2] + m[3]; 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][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][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][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]; //Result[3][3] = m[0][3] * v[0] + m[1][3] * v[1] + m[2][3] * v[2] + m[3][3];
//return Result; //return Result;
} }
template <typename T> template <typename T>
GLM_FUNC_QUALIFIER detail::tmat4x4<T> rotate_slow GLM_FUNC_QUALIFIER detail::tmat4x4<T> rotate_slow
( (
detail::tmat4x4<T> const & m, detail::tmat4x4<T> const & m,
T const & angle, T const & angle,
detail::tvec3<T> const & v detail::tvec3<T> const & v
) )
{ {
T a = radians(angle); T a = radians(angle);
T c = cos(a); T c = cos(a);
T s = sin(a); T s = sin(a);
detail::tmat4x4<T> Result; 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][0] = c + (1 - c) * axis.x * axis.x;
Result[0][1] = (1 - c) * axis.x * axis.y + s * axis.z; 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][2] = (1 - c) * axis.x * axis.z - s * axis.y;
Result[0][3] = 0; Result[0][3] = 0;
Result[1][0] = (1 - c) * axis.y * axis.x - s * axis.z; Result[1][0] = (1 - c) * axis.y * axis.x - s * axis.z;
Result[1][1] = c + (1 - c) * axis.y * axis.y; Result[1][1] = c + (1 - c) * axis.y * axis.y;
Result[1][2] = (1 - c) * axis.y * axis.z + s * axis.x; Result[1][2] = (1 - c) * axis.y * axis.z + s * axis.x;
Result[1][3] = 0; Result[1][3] = 0;
Result[2][0] = (1 - c) * axis.z * axis.x + s * axis.y; 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][1] = (1 - c) * axis.z * axis.y - s * axis.x;
Result[2][2] = c + (1 - c) * axis.z * axis.z; Result[2][2] = c + (1 - c) * axis.z * axis.z;
Result[2][3] = 0; Result[2][3] = 0;
Result[3] = detail::tvec4<T>(0, 0, 0, 1); Result[3] = detail::tvec4<T>(0, 0, 0, 1);
return m * Result; return m * Result;
} }
template <typename T> template <typename T>
GLM_FUNC_QUALIFIER detail::tmat4x4<T> scale_slow GLM_FUNC_QUALIFIER detail::tmat4x4<T> scale_slow
( (
detail::tmat4x4<T> const & m, detail::tmat4x4<T> const & m,
detail::tvec3<T> const & v detail::tvec3<T> const & v
) )
{ {
detail::tmat4x4<T> Result(T(1)); detail::tmat4x4<T> Result(T(1));
Result[0][0] = v.x; Result[0][0] = v.x;
Result[1][1] = v.y; Result[1][1] = v.y;
Result[2][2] = v.z; Result[2][2] = v.z;
return m * Result; return m * Result;
} }
template <typename valType> template <typename valType>
GLM_FUNC_QUALIFIER detail::tmat4x4<valType> ortho GLM_FUNC_QUALIFIER detail::tmat4x4<valType> ortho
( (
valType const & left, valType const & left,
valType const & right, valType const & right,
valType const & bottom, valType const & bottom,
valType const & top, valType const & top,
valType const & zNear, valType const & zNear,
valType const & zFar valType const & zFar
) )
{ {
detail::tmat4x4<valType> Result(1); detail::tmat4x4<valType> Result(1);
Result[0][0] = valType(2) / (right - left); Result[0][0] = valType(2) / (right - left);
Result[1][1] = valType(2) / (top - bottom); Result[1][1] = valType(2) / (top - bottom);
Result[2][2] = - valType(2) / (zFar - zNear); Result[2][2] = - valType(2) / (zFar - zNear);
Result[3][0] = - (right + left) / (right - left); Result[3][0] = - (right + left) / (right - left);
Result[3][1] = - (top + bottom) / (top - bottom); Result[3][1] = - (top + bottom) / (top - bottom);
Result[3][2] = - (zFar + zNear) / (zFar - zNear); Result[3][2] = - (zFar + zNear) / (zFar - zNear);
return Result; return Result;
} }
template <typename valType> template <typename valType>
GLM_FUNC_QUALIFIER detail::tmat4x4<valType> ortho( GLM_FUNC_QUALIFIER detail::tmat4x4<valType> ortho(
valType const & left, valType const & left,
valType const & right, valType const & right,
valType const & bottom, valType const & bottom,
valType const & top) valType const & top)
{ {
detail::tmat4x4<valType> Result(1); detail::tmat4x4<valType> Result(1);
Result[0][0] = valType(2) / (right - left); Result[0][0] = valType(2) / (right - left);
Result[1][1] = valType(2) / (top - bottom); Result[1][1] = valType(2) / (top - bottom);
Result[2][2] = - valType(1); Result[2][2] = - valType(1);
Result[3][0] = - (right + left) / (right - left); Result[3][0] = - (right + left) / (right - left);
Result[3][1] = - (top + bottom) / (top - bottom); Result[3][1] = - (top + bottom) / (top - bottom);
return Result; return Result;
} }
template <typename valType> template <typename valType>
GLM_FUNC_QUALIFIER detail::tmat4x4<valType> frustum GLM_FUNC_QUALIFIER detail::tmat4x4<valType> frustum
( (
valType const & left, valType const & left,
valType const & right, valType const & right,
valType const & bottom, valType const & bottom,
valType const & top, valType const & top,
valType const & nearVal, valType const & nearVal,
valType const & farVal valType const & farVal
) )
{ {
detail::tmat4x4<valType> Result(0); detail::tmat4x4<valType> Result(0);
Result[0][0] = (valType(2) * nearVal) / (right - left); Result[0][0] = (valType(2) * nearVal) / (right - left);
Result[1][1] = (valType(2) * nearVal) / (top - bottom); Result[1][1] = (valType(2) * nearVal) / (top - bottom);
Result[2][0] = (right + left) / (right - left); Result[2][0] = (right + left) / (right - left);
Result[2][1] = (top + bottom) / (top - bottom); Result[2][1] = (top + bottom) / (top - bottom);
Result[2][2] = -(farVal + nearVal) / (farVal - nearVal); Result[2][2] = -(farVal + nearVal) / (farVal - nearVal);
Result[2][3] = valType(-1); Result[2][3] = valType(-1);
Result[3][2] = -(valType(2) * farVal * nearVal) / (farVal - nearVal); Result[3][2] = -(valType(2) * farVal * nearVal) / (farVal - nearVal);
return Result; return Result;
} }
template <typename valType> template <typename valType>
GLM_FUNC_QUALIFIER detail::tmat4x4<valType> perspective GLM_FUNC_QUALIFIER detail::tmat4x4<valType> perspective
( (
valType const & fovy, valType const & fovy,
valType const & aspect, valType const & aspect,
valType const & zNear, valType const & zNear,
valType const & zFar valType const & zFar
) )
{ {
valType range = tan(radians(fovy / valType(2))) * zNear; valType range = tan(radians(fovy / valType(2))) * zNear;
valType left = -range * aspect; valType left = -range * aspect;
valType right = range * aspect; valType right = range * aspect;
valType bottom = -range; valType bottom = -range;
valType top = range; valType top = range;
detail::tmat4x4<valType> Result(valType(0)); detail::tmat4x4<valType> Result(valType(0));
Result[0][0] = (valType(2) * zNear) / (right - left); Result[0][0] = (valType(2) * zNear) / (right - left);
Result[1][1] = (valType(2) * zNear) / (top - bottom); Result[1][1] = (valType(2) * zNear) / (top - bottom);
Result[2][2] = - (zFar + zNear) / (zFar - zNear); Result[2][2] = - (zFar + zNear) / (zFar - zNear);
Result[2][3] = - valType(1); Result[2][3] = - valType(1);
Result[3][2] = - (valType(2) * zFar * zNear) / (zFar - zNear); Result[3][2] = - (valType(2) * zFar * zNear) / (zFar - zNear);
return Result; return Result;
} }
template <typename valType> template <typename valType>
GLM_FUNC_QUALIFIER detail::tmat4x4<valType> perspectiveFov GLM_FUNC_QUALIFIER detail::tmat4x4<valType> perspectiveFov
( (
valType const & fov, valType const & fov,
valType const & width, valType const & width,
valType const & height, valType const & height,
valType const & zNear, valType const & zNear,
valType const & zFar valType const & zFar
) )
{ {
valType rad = glm::radians(fov); valType rad = glm::radians(fov);
valType h = glm::cos(valType(0.5) * rad) / glm::sin(valType(0.5) * rad); valType h = glm::cos(valType(0.5) * rad) / glm::sin(valType(0.5) * rad);
valType w = h * height / width; valType w = h * height / width;
detail::tmat4x4<valType> Result(valType(0)); detail::tmat4x4<valType> Result(valType(0));
Result[0][0] = w; Result[0][0] = w;
Result[1][1] = h; Result[1][1] = h;
Result[2][2] = (zFar + zNear) / (zFar - zNear); Result[2][2] = (zFar + zNear) / (zFar - zNear);
Result[2][3] = valType(1); Result[2][3] = valType(1);
Result[3][2] = -(valType(2) * zFar * zNear) / (zFar - zNear); Result[3][2] = -(valType(2) * zFar * zNear) / (zFar - zNear);
return Result; return Result;
} }
template <typename T> template <typename T>
GLM_FUNC_QUALIFIER detail::tmat4x4<T> infinitePerspective GLM_FUNC_QUALIFIER detail::tmat4x4<T> infinitePerspective
( (
T fovy, T fovy,
T aspect, T aspect,
T zNear T zNear
) )
{ {
T range = tan(radians(fovy / T(2))) * zNear; T range = tan(radians(fovy / T(2))) * zNear;
T left = -range * aspect; T left = -range * aspect;
T right = range * aspect; T right = range * aspect;
T bottom = -range; T bottom = -range;
T top = range; T top = range;
detail::tmat4x4<T> Result(T(0)); detail::tmat4x4<T> Result(T(0));
Result[0][0] = (T(2) * zNear) / (right - left); Result[0][0] = (T(2) * zNear) / (right - left);
Result[1][1] = (T(2) * zNear) / (top - bottom); Result[1][1] = (T(2) * zNear) / (top - bottom);
Result[2][2] = - T(1); Result[2][2] = - T(1);
Result[2][3] = - T(1); Result[2][3] = - T(1);
Result[3][2] = - T(2) * zNear; Result[3][2] = - T(2) * zNear;
return Result; return Result;
} }
template <typename T> template <typename T>
GLM_FUNC_QUALIFIER detail::tmat4x4<T> tweakedInfinitePerspective GLM_FUNC_QUALIFIER detail::tmat4x4<T> tweakedInfinitePerspective
( (
T fovy, T fovy,
T aspect, T aspect,
T zNear T zNear
) )
{ {
T range = tan(radians(fovy / T(2))) * zNear; T range = tan(radians(fovy / T(2))) * zNear;
T left = -range * aspect; T left = -range * aspect;
T right = range * aspect; T right = range * aspect;
T bottom = -range; T bottom = -range;
T top = range; T top = range;
detail::tmat4x4<T> Result(T(0)); detail::tmat4x4<T> Result(T(0));
Result[0][0] = (T(2) * zNear) / (right - left); Result[0][0] = (T(2) * zNear) / (right - left);
Result[1][1] = (T(2) * zNear) / (top - bottom); Result[1][1] = (T(2) * zNear) / (top - bottom);
Result[2][2] = T(0.0001) - T(1); Result[2][2] = T(0.0001) - T(1);
Result[2][3] = T(-1); Result[2][3] = T(-1);
Result[3][2] = - (T(0.0001) - T(2)) * zNear; Result[3][2] = - (T(0.0001) - T(2)) * zNear;
return Result; return Result;
} }
template <typename T, typename U> template <typename T, typename U>
GLM_FUNC_QUALIFIER detail::tvec3<T> project GLM_FUNC_QUALIFIER detail::tvec3<T> project
( (
detail::tvec3<T> const & obj, detail::tvec3<T> const & obj,
detail::tmat4x4<T> const & model, detail::tmat4x4<T> const & model,
detail::tmat4x4<T> const & proj, detail::tmat4x4<T> const & proj,
detail::tvec4<U> const & viewport detail::tvec4<U> const & viewport
) )
{ {
detail::tvec4<T> tmp = detail::tvec4<T>(obj, T(1)); detail::tvec4<T> tmp = detail::tvec4<T>(obj, T(1));
tmp = model * tmp; tmp = model * tmp;
tmp = proj * tmp; tmp = proj * tmp;
tmp /= tmp.w; tmp /= tmp.w;
tmp = tmp * T(0.5) + T(0.5); tmp = tmp * T(0.5) + T(0.5);
tmp[0] = tmp[0] * T(viewport[2]) + T(viewport[0]); tmp[0] = tmp[0] * T(viewport[2]) + T(viewport[0]);
tmp[1] = tmp[1] * T(viewport[3]) + T(viewport[1]); 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> template <typename T, typename U>
GLM_FUNC_QUALIFIER detail::tvec3<T> unProject GLM_FUNC_QUALIFIER detail::tvec3<T> unProject
( (
detail::tvec3<T> const & win, detail::tvec3<T> const & win,
detail::tmat4x4<T> const & model, detail::tmat4x4<T> const & model,
detail::tmat4x4<T> const & proj, detail::tmat4x4<T> const & proj,
detail::tvec4<U> const & viewport detail::tvec4<U> const & viewport
) )
{ {
detail::tmat4x4<T> inverse = glm::inverse(proj * model); detail::tmat4x4<T> inverse = glm::inverse(proj * model);
detail::tvec4<T> tmp = detail::tvec4<T>(win, T(1)); detail::tvec4<T> tmp = detail::tvec4<T>(win, T(1));
tmp.x = (tmp.x - T(viewport[0])) / T(viewport[2]); tmp.x = (tmp.x - T(viewport[0])) / T(viewport[2]);
tmp.y = (tmp.y - T(viewport[1])) / T(viewport[3]); tmp.y = (tmp.y - T(viewport[1])) / T(viewport[3]);
tmp = tmp * T(2) - T(1); tmp = tmp * T(2) - T(1);
detail::tvec4<T> obj = inverse * tmp; detail::tvec4<T> obj = inverse * tmp;
obj /= obj.w; obj /= obj.w;
return detail::tvec3<T>(obj); return detail::tvec3<T>(obj);
} }
template <typename T, typename U> template <typename T, typename U>
detail::tmat4x4<T> pickMatrix detail::tmat4x4<T> pickMatrix
( (
detail::tvec2<T> const & center, detail::tvec2<T> const & center,
detail::tvec2<T> const & delta, detail::tvec2<T> const & delta,
detail::tvec4<U> const & viewport detail::tvec4<U> const & viewport
) )
{ {
assert(delta.x > T(0) && delta.y > T(0)); assert(delta.x > T(0) && delta.y > T(0));
detail::tmat4x4<T> Result(1.0f); detail::tmat4x4<T> Result(1.0f);
if(!(delta.x > T(0) && delta.y > T(0))) if(!(delta.x > T(0) && delta.y > T(0)))
return Result; // Error return Result; // Error
detail::tvec3<T> Temp( detail::tvec3<T> Temp(
(T(viewport[2]) - T(2) * (center.x - T(viewport[0]))) / delta.x, (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(viewport[3]) - T(2) * (center.y - T(viewport[1]))) / delta.y,
T(0)); T(0));
// Translate and scale the picked region to the entire window // Translate and scale the picked region to the entire window
Result = translate(Result, Temp); Result = translate(Result, Temp);
return scale(Result, detail::tvec3<T>(T(viewport[2]) / delta.x, T(viewport[3]) / delta.y, T(1))); return scale(Result, detail::tvec3<T>(T(viewport[2]) / delta.x, T(viewport[3]) / delta.y, T(1)));
} }
template <typename T> template <typename T>
GLM_FUNC_QUALIFIER detail::tmat4x4<T> lookAt GLM_FUNC_QUALIFIER detail::tmat4x4<T> lookAt
( (
detail::tvec3<T> const & eye, detail::tvec3<T> const & eye,
detail::tvec3<T> const & center, detail::tvec3<T> const & center,
detail::tvec3<T> const & up detail::tvec3<T> const & up
) )
{ {
detail::tvec3<T> f = normalize(center - eye); detail::tvec3<T> f = normalize(center - eye);
detail::tvec3<T> u = normalize(up); detail::tvec3<T> u = normalize(up);
detail::tvec3<T> s = normalize(cross(f, u)); detail::tvec3<T> s = normalize(cross(f, u));
u = cross(s, f); u = cross(s, f);
detail::tmat4x4<T> Result(1); detail::tmat4x4<T> Result(1);
Result[0][0] = s.x; Result[0][0] = s.x;
Result[1][0] = s.y; Result[1][0] = s.y;
Result[2][0] = s.z; Result[2][0] = s.z;
Result[0][1] = u.x; Result[0][1] = u.x;
Result[1][1] = u.y; Result[1][1] = u.y;
Result[2][1] = u.z; Result[2][1] = u.z;
Result[0][2] =-f.x; Result[0][2] =-f.x;
Result[1][2] =-f.y; Result[1][2] =-f.y;
Result[2][2] =-f.z; Result[2][2] =-f.z;
/* Test this instead of translate3D /* Test this instead of translate3D
Result[3][0] =-dot(s, eye); Result[3][0] =-dot(s, eye);
Result[3][1] =-dot(y, eye); Result[3][1] =-dot(y, eye);
Result[3][2] = dot(f, eye); Result[3][2] = dot(f, eye);
*/ */
return gtc::translate(Result, -eye); return translate(Result, -eye);
} }
}//namespace gtc
}//namespace glm }//namespace glm

View File

@ -39,8 +39,8 @@
/// <glm/gtc/quaternion.hpp> need to be included to use these functionalities. /// <glm/gtc/quaternion.hpp> need to be included to use these functionalities.
/////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////
#ifndef glm_gtc_quaternion #ifndef GLM_GTC_quaternion
#define glm_gtc_quaternion #define GLM_GTC_quaternion 90
// Dependency: // Dependency:
#include "../glm.hpp" #include "../glm.hpp"
@ -73,7 +73,7 @@ namespace detail
tquat(); tquat();
explicit tquat( explicit tquat(
value_type const & s, value_type const & s,
tvec3<T> const & v); glm::detail::tvec3<T> const & v);
explicit tquat( explicit tquat(
value_type const & w, value_type const & w,
value_type const & x, value_type const & x,
@ -150,8 +150,6 @@ namespace detail
} //namespace detail } //namespace detail
namespace gtc{
/// @addtogroup gtc_quaternion /// @addtogroup gtc_quaternion
/// @{ /// @{
@ -255,9 +253,8 @@ namespace gtc{
typedef detail::tquat<highp_float> highp_quat; typedef detail::tquat<highp_float> highp_quat;
/// @} /// @}
} //namespace gtc
} //namespace glm } //namespace glm
#include "quaternion.inl" #include "quaternion.inl"
#endif//glm_gtc_quaternion #endif//GLM_GTC_quaternion

View File

@ -211,7 +211,7 @@ namespace detail{
detail::tquat<T> const & q detail::tquat<T> const & q
) )
{ {
return gtc::inverse(q) * v; return inverse(q) * v;
} }
template <typename T> template <typename T>
@ -231,7 +231,7 @@ namespace detail{
detail::tquat<T> const & q detail::tquat<T> const & q
) )
{ {
return gtc::inverse(q) * v; return inverse(q) * v;
} }
template <typename T> template <typename T>
@ -291,8 +291,6 @@ namespace detail{
}//namespace detail }//namespace detail
namespace gtc{
//////////////////////////////////////////////////////// ////////////////////////////////////////////////////////
template <typename T> template <typename T>
GLM_FUNC_QUALIFIER T length GLM_FUNC_QUALIFIER T length
@ -447,7 +445,7 @@ namespace gtc{
detail::tquat<T> const & q detail::tquat<T> const & q
) )
{ {
return gtc::conjugate(q) / gtc::dot(q, q); return conjugate(q) / dot(q, q);
} }
template <typename T> template <typename T>
@ -473,7 +471,7 @@ namespace gtc{
typename detail::tquat<T>::value_type AngleRad = radians(angle); typename detail::tquat<T>::value_type AngleRad = radians(angle);
typename detail::tquat<T>::value_type fSin = sin(AngleRad * T(0.5)); typename detail::tquat<T>::value_type fSin = sin(AngleRad * T(0.5));
return gtc::cross(q, detail::tquat<T>(cos(AngleRad * T(0.5)), Tmp.x * fSin, Tmp.y * fSin, Tmp.z * fSin)); return cross(q, detail::tquat<T>(cos(AngleRad * T(0.5)), Tmp.x * fSin, Tmp.y * fSin, Tmp.z * fSin));
} }
template <typename T> template <typename T>
@ -578,5 +576,4 @@ namespace gtc{
return quat_cast(detail::tmat3x3<T>(m4)); return quat_cast(detail::tmat3x3<T>(m4));
} }
}//namespace gtc
}//namespace glm }//namespace glm

View File

@ -35,8 +35,8 @@
/// <glm/gtc/swizzle.hpp> need to be included to use these functionalities. /// <glm/gtc/swizzle.hpp> need to be included to use these functionalities.
/////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////
#ifndef glm_gtc_swizzle #ifndef GLM_GTC_swizzle
#define glm_gtc_swizzle #define GLM_GTC_swizzle 90
// Dependency: // Dependency:
#include "../glm.hpp" #include "../glm.hpp"
@ -46,8 +46,7 @@
# pragma message("GLM: GLM_GTC_swizzle extension included") # pragma message("GLM: GLM_GTC_swizzle extension included")
#endif #endif
namespace glm{ namespace glm
namespace gtc
{ {
/// @addtogroup gtc_swizzle /// @addtogroup gtc_swizzle
/// @{ /// @{
@ -369,9 +368,8 @@ namespace gtc
static_swizzle4_ref(glm::u64, 4) static_swizzle4_ref(glm::u64, 4)
/// @} /// @}
}//namespace gtc
}//namespace glm }//namespace glm
#include "swizzle.inl" #include "swizzle.inl"
#endif//glm_gtc_swizzle #endif//GLM_GTC_swizzle

View File

@ -11,7 +11,6 @@
/////////////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////////////
namespace glm{ namespace glm{
namespace gtc{
template <typename T, template <typename> class vecType> template <typename T, template <typename> class vecType>
GLM_FUNC_QUALIFIER T swizzle GLM_FUNC_QUALIFIER T swizzle
@ -172,5 +171,4 @@ GLM_FUNC_QUALIFIER detail::tref4<int> swizzle
} }
*/ */
}//namespace gtc
}//namespace glm }//namespace glm

View File

@ -40,8 +40,8 @@
/// <glm/gtc/type_precision.hpp> need to be included to use these functionalities. /// <glm/gtc/type_precision.hpp> need to be included to use these functionalities.
/////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////
#ifndef glm_gtc_type_precision #ifndef GLM_GTC_type_precision
#define glm_gtc_type_precision #define GLM_GTC_type_precision 100
// Dependency: // Dependency:
#include "../glm.hpp" #include "../glm.hpp"
@ -52,9 +52,8 @@
# pragma message("GLM: GLM_GTC_type_precision extension included") # pragma message("GLM: GLM_GTC_type_precision extension included")
#endif #endif
namespace glm{ namespace glm
namespace gtc{ {
/////////////////////////// ///////////////////////////
// Signed int vector types // Signed int vector types
@ -229,9 +228,8 @@ namespace gtc{
typedef detail::tquat<f64> f64quat; //!< \brief Double-precision floating-point quaternion. (from GLM_GTC_type_precision extension) typedef detail::tquat<f64> f64quat; //!< \brief Double-precision floating-point quaternion. (from GLM_GTC_type_precision extension)
/// @} /// @}
}//namespace gtc
}//namespace glm }//namespace glm
#include "type_precision.inl" #include "type_precision.inl"
#endif//glm_gtc_type_precision #endif//GLM_GTC_type_precision

View File

@ -56,8 +56,8 @@
/// <glm/gtc/type_ptr.hpp> need to be included to use these functionalities. /// <glm/gtc/type_ptr.hpp> need to be included to use these functionalities.
/////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////
#ifndef glm_gtc_type_ptr #ifndef GLM_GTC_type_ptr
#define glm_gtc_type_ptr #define GLM_GTC_type_ptr 90
// Dependency: // Dependency:
#include "../glm.hpp" #include "../glm.hpp"
@ -69,8 +69,7 @@
# pragma message("GLM: GLM_GTC_type_ptr extension included") # pragma message("GLM: GLM_GTC_type_ptr extension included")
#endif #endif
namespace glm{ namespace glm
namespace gtc
{ {
/// @addtogroup gtc_type_ptr /// @addtogroup gtc_type_ptr
/// @{ /// @{
@ -502,10 +501,9 @@ namespace gtc
} }
/// @} /// @}
}//namespace gtc
}//namespace glm }//namespace glm
#include "type_ptr.inl" #include "type_ptr.inl"
#endif//glm_gtx_type_ptr #endif//GLM_GTC_type_ptr

View File

@ -45,8 +45,7 @@
# pragma message("GLM: GLM_GTX_associated_min_max extension included") # pragma message("GLM: GLM_GTX_associated_min_max extension included")
#endif #endif
namespace glm{ namespace glm
namespace gtx
{ {
/// @addtogroup gtx_associated_min_max /// @addtogroup gtx_associated_min_max
/// @{ /// @{
@ -94,7 +93,6 @@ namespace gtx
const genTypeT& w, const genTypeU& d); const genTypeT& w, const genTypeU& d);
/// @} /// @}
} //namespace gtx
} //namespace glm } //namespace glm
#include "associated_min_max.inl" #include "associated_min_max.inl"

File diff suppressed because it is too large Load Diff

View File

@ -47,8 +47,7 @@
# pragma message("GLM: GLM_GTX_bit extension included") # pragma message("GLM: GLM_GTX_bit extension included")
#endif #endif
namespace glm{ namespace glm
namespace gtx
{ {
/// @addtogroup gtx_bit /// @addtogroup gtx_bit
/// @{ /// @{
@ -134,7 +133,6 @@ namespace gtx
int const & ToBit); int const & ToBit);
/// @} /// @}
}// namespace gtx
}// namespace glm }// namespace glm
#include "bit.inl" #include "bit.inl"

View File

@ -10,7 +10,6 @@
#include "../core/_detail.hpp" #include "../core/_detail.hpp"
namespace glm{ namespace glm{
namespace gtx{
template <typename genIType> template <typename genIType>
GLM_FUNC_QUALIFIER genIType mask GLM_FUNC_QUALIFIER genIType mask
@ -61,13 +60,13 @@ GLM_FUNC_QUALIFIER detail::tvec4<valIType> mask
template <typename genIType> template <typename genIType>
GLM_FUNC_QUALIFIER genIType extractField GLM_FUNC_QUALIFIER genIType extractField
( (
gtc::half const & value, half const & value,
genIType const & first, genIType const & first,
genIType const & count genIType const & count
) )
{ {
assert(first + count < sizeof(gtc::half)); assert(first + count < sizeof(half));
return (value._data() << first) >> ((sizeof(gtc::half) << 3) - count); return (value._data() << first) >> ((sizeof(half) << 3) - count);
} }
template <typename genIType> template <typename genIType>
@ -771,5 +770,4 @@ GLM_FUNC_QUALIFIER genIUType fillBitfieldWithZero
return Result; return Result;
} }
}//namespace gtx
}//namespace glm }//namespace glm

View File

@ -45,8 +45,7 @@
# pragma message("GLM: GLM_GTX_closest_point extension included") # pragma message("GLM: GLM_GTX_closest_point extension included")
#endif #endif
namespace glm{ namespace glm
namespace gtx
{ {
/// @addtogroup gtx_closest_point /// @addtogroup gtx_closest_point
/// @{ /// @{
@ -60,7 +59,6 @@ namespace gtx
detail::tvec3<T> const & b); detail::tvec3<T> const & b);
/// @} /// @}
}// namespace gtx
}// namespace glm }// namespace glm
#include "closest_point.inl" #include "closest_point.inl"

View File

@ -11,7 +11,6 @@
#define glm_gtx_closest_point #define glm_gtx_closest_point
namespace glm{ namespace glm{
namespace gtx{
template <typename valType> template <typename valType>
GLM_FUNC_QUALIFIER detail::tvec3<valType> closestPointOnLine GLM_FUNC_QUALIFIER detail::tvec3<valType> closestPointOnLine
@ -33,7 +32,6 @@ GLM_FUNC_QUALIFIER detail::tvec3<valType> closestPointOnLine
return a + LineDirection * Distance; return a + LineDirection * Distance;
} }
}//namespace gtx
}//namespace glm }//namespace glm
#endif//glm_gtx_closest_point #endif//glm_gtx_closest_point

View File

@ -47,78 +47,76 @@
# pragma message("GLM: GLM_GTX_color_cast extension included") # pragma message("GLM: GLM_GTX_color_cast extension included")
#endif #endif
namespace glm{ namespace glm
namespace gtx
{ {
/// @addtogroup gtx_color_cast /// @addtogroup gtx_color_cast
/// @{ /// @{
//! Conversion of a floating value into a 8bit unsigned int value. //! Conversion of a floating value into a 8bit unsigned int value.
//! From GLM_GTX_color_cast extension. //! From GLM_GTX_color_cast extension.
template <typename valType> gtc::uint8 u8channel_cast(valType a); template <typename valType> uint8 u8channel_cast(valType a);
//! Conversion of a floating value into a 16bit unsigned int value. //! Conversion of a floating value into a 16bit unsigned int value.
//! From GLM_GTX_color_cast extension. //! From GLM_GTX_color_cast extension.
template <typename valType> gtc::uint16 u16channel_cast(valType a); template <typename valType> uint16 u16channel_cast(valType a);
template <typename T> gtc::uint32 u32_rgbx_cast(const detail::tvec3<T>& c); //!< \brief Conversion of a 3 components color into an 32bit unsigned int value. (From GLM_GTX_color_cast extension) template <typename T> uint32 u32_rgbx_cast(const detail::tvec3<T>& c); //!< \brief Conversion of a 3 components color into an 32bit unsigned int value. (From GLM_GTX_color_cast extension)
template <typename T> gtc::uint32 u32_xrgb_cast(const detail::tvec3<T>& c); //!< \brief Conversion of a 3 components color into an 32bit unsigned int value. (From GLM_GTX_color_cast extension) template <typename T> uint32 u32_xrgb_cast(const detail::tvec3<T>& c); //!< \brief Conversion of a 3 components color into an 32bit unsigned int value. (From GLM_GTX_color_cast extension)
template <typename T> gtc::uint32 u32_bgrx_cast(const detail::tvec3<T>& c); //!< \brief Conversion of a 3 components color into an 32bit unsigned int value. (From GLM_GTX_color_cast extension) template <typename T> uint32 u32_bgrx_cast(const detail::tvec3<T>& c); //!< \brief Conversion of a 3 components color into an 32bit unsigned int value. (From GLM_GTX_color_cast extension)
template <typename T> gtc::uint32 u32_xbgr_cast(const detail::tvec3<T>& c); //!< \brief Conversion of a 3 components color into an 32bit unsigned int value. (From GLM_GTX_color_cast extension) template <typename T> uint32 u32_xbgr_cast(const detail::tvec3<T>& c); //!< \brief Conversion of a 3 components color into an 32bit unsigned int value. (From GLM_GTX_color_cast extension)
template <typename T> gtc::uint32 u32_rgba_cast(const detail::tvec4<T>& c); //!< \brief Conversion of a 4 components color into an 32bit unsigned int value. (From GLM_GTX_color_cast extension) template <typename T> uint32 u32_rgba_cast(const detail::tvec4<T>& c); //!< \brief Conversion of a 4 components color into an 32bit unsigned int value. (From GLM_GTX_color_cast extension)
template <typename T> gtc::uint32 u32_argb_cast(const detail::tvec4<T>& c); //!< \brief Conversion of a 4 components color into an 32bit unsigned int value. (From GLM_GTX_color_cast extension) template <typename T> uint32 u32_argb_cast(const detail::tvec4<T>& c); //!< \brief Conversion of a 4 components color into an 32bit unsigned int value. (From GLM_GTX_color_cast extension)
template <typename T> gtc::uint32 u32_bgra_cast(const detail::tvec4<T>& c); //!< \brief Conversion of a 4 components color into an 32bit unsigned int value. (From GLM_GTX_color_cast extension) template <typename T> uint32 u32_bgra_cast(const detail::tvec4<T>& c); //!< \brief Conversion of a 4 components color into an 32bit unsigned int value. (From GLM_GTX_color_cast extension)
template <typename T> gtc::uint32 u32_abgr_cast(const detail::tvec4<T>& c); //!< \brief Conversion of a 4 components color into an 32bit unsigned int value. (From GLM_GTX_color_cast extension) template <typename T> uint32 u32_abgr_cast(const detail::tvec4<T>& c); //!< \brief Conversion of a 4 components color into an 32bit unsigned int value. (From GLM_GTX_color_cast extension)
template <typename T> gtc::uint64 u64_rgbx_cast(const detail::tvec3<T>& c); //!< \brief Conversion of a 3 components color into an 64bit unsigned int value. (From GLM_GTX_color_cast extension) template <typename T> uint64 u64_rgbx_cast(const detail::tvec3<T>& c); //!< \brief Conversion of a 3 components color into an 64bit unsigned int value. (From GLM_GTX_color_cast extension)
template <typename T> gtc::uint64 u64_xrgb_cast(const detail::tvec3<T>& c); //!< \brief Conversion of a 3 components color into an 64bit unsigned int value. (From GLM_GTX_color_cast extension) template <typename T> uint64 u64_xrgb_cast(const detail::tvec3<T>& c); //!< \brief Conversion of a 3 components color into an 64bit unsigned int value. (From GLM_GTX_color_cast extension)
template <typename T> gtc::uint64 u64_bgrx_cast(const detail::tvec3<T>& c); //!< \brief Conversion of a 3 components color into an 64bit unsigned int value. (From GLM_GTX_color_cast extension) template <typename T> uint64 u64_bgrx_cast(const detail::tvec3<T>& c); //!< \brief Conversion of a 3 components color into an 64bit unsigned int value. (From GLM_GTX_color_cast extension)
template <typename T> gtc::uint64 u64_xbgr_cast(const detail::tvec3<T>& c); //!< \brief Conversion of a 3 components color into an 64bit unsigned int value. (From GLM_GTX_color_cast extension) template <typename T> uint64 u64_xbgr_cast(const detail::tvec3<T>& c); //!< \brief Conversion of a 3 components color into an 64bit unsigned int value. (From GLM_GTX_color_cast extension)
template <typename T> gtc::uint64 u64_rgba_cast(const detail::tvec4<T>& c); //!< \brief Conversion of a 4 components color into an 64bit unsigned int value. (From GLM_GTX_color_cast extension) template <typename T> uint64 u64_rgba_cast(const detail::tvec4<T>& c); //!< \brief Conversion of a 4 components color into an 64bit unsigned int value. (From GLM_GTX_color_cast extension)
template <typename T> gtc::uint64 u64_argb_cast(const detail::tvec4<T>& c); //!< \brief Conversion of a 4 components color into an 64bit unsigned int value. (From GLM_GTX_color_cast extension) template <typename T> uint64 u64_argb_cast(const detail::tvec4<T>& c); //!< \brief Conversion of a 4 components color into an 64bit unsigned int value. (From GLM_GTX_color_cast extension)
template <typename T> gtc::uint64 u64_bgra_cast(const detail::tvec4<T>& c); //!< \brief Conversion of a 4 components color into an 64bit unsigned int value. (From GLM_GTX_color_cast extension) template <typename T> uint64 u64_bgra_cast(const detail::tvec4<T>& c); //!< \brief Conversion of a 4 components color into an 64bit unsigned int value. (From GLM_GTX_color_cast extension)
template <typename T> gtc::uint64 u64_abgr_cast(const detail::tvec4<T>& c); //!< \brief Conversion of a 4 components color into an 64bit unsigned int value. (From GLM_GTX_color_cast extension) template <typename T> uint64 u64_abgr_cast(const detail::tvec4<T>& c); //!< \brief Conversion of a 4 components color into an 64bit unsigned int value. (From GLM_GTX_color_cast extension)
template <typename T> gtx::f16vec1 f16_channel_cast(T a); //!< \brief Conversion of a u8 or u16 value to a single channel floating value. (From GLM_GTX_color_cast extension) template <typename T> f16 f16_channel_cast(T a); //!< \brief Conversion of a u8 or u16 value to a single channel floating value. (From GLM_GTX_color_cast extension)
template <typename T> gtc::f16vec3 f16_rgbx_cast(T c); //!< \brief Conversion of a u32 or u64 color into 3 components floating color. (From GLM_GTX_color_cast extension) template <typename T> f16vec3 f16_rgbx_cast(T c); //!< \brief Conversion of a u32 or u64 color into 3 components floating color. (From GLM_GTX_color_cast extension)
template <typename T> gtc::f16vec3 f16_xrgb_cast(T c); //!< \brief Conversion of a u32 or u64 color into 3 components floating color. (From GLM_GTX_color_cast extension) template <typename T> f16vec3 f16_xrgb_cast(T c); //!< \brief Conversion of a u32 or u64 color into 3 components floating color. (From GLM_GTX_color_cast extension)
template <typename T> gtc::f16vec3 f16_bgrx_cast(T c); //!< \brief Conversion of a u32 or u64 color into 3 components floating color. (From GLM_GTX_color_cast extension) template <typename T> f16vec3 f16_bgrx_cast(T c); //!< \brief Conversion of a u32 or u64 color into 3 components floating color. (From GLM_GTX_color_cast extension)
template <typename T> gtc::f16vec3 f16_xbgr_cast(T c); //!< \brief Conversion of a u32 or u64 color into 3 components floating color. (From GLM_GTX_color_cast extension) template <typename T> f16vec3 f16_xbgr_cast(T c); //!< \brief Conversion of a u32 or u64 color into 3 components floating color. (From GLM_GTX_color_cast extension)
template <typename T> gtc::f16vec4 f16_rgba_cast(T c); //!< \brief Conversion of a u32 or u64 color into 4 components floating color. (From GLM_GTX_color_cast extension) template <typename T> f16vec4 f16_rgba_cast(T c); //!< \brief Conversion of a u32 or u64 color into 4 components floating color. (From GLM_GTX_color_cast extension)
template <typename T> gtc::f16vec4 f16_argb_cast(T c); //!< \brief Conversion of a u32 or u64 color into 4 components floating color. (From GLM_GTX_color_cast extension) template <typename T> f16vec4 f16_argb_cast(T c); //!< \brief Conversion of a u32 or u64 color into 4 components floating color. (From GLM_GTX_color_cast extension)
template <typename T> gtc::f16vec4 f16_bgra_cast(T c); //!< \brief Conversion of a u32 or u64 color into 4 components floating color. (From GLM_GTX_color_cast extension) template <typename T> f16vec4 f16_bgra_cast(T c); //!< \brief Conversion of a u32 or u64 color into 4 components floating color. (From GLM_GTX_color_cast extension)
template <typename T> gtc::f16vec4 f16_abgr_cast(T c); //!< \brief Conversion of a u32 or u64 color into 4 components floating color. (From GLM_GTX_color_cast extension) template <typename T> f16vec4 f16_abgr_cast(T c); //!< \brief Conversion of a u32 or u64 color into 4 components floating color. (From GLM_GTX_color_cast extension)
template <typename T> gtx::f32vec1 f32_channel_cast(T a); //!< \brief Conversion of a u8 or u16 value to a single channel floating value. (From GLM_GTX_color_cast extension) template <typename T> f32 f32_channel_cast(T a); //!< \brief Conversion of a u8 or u16 value to a single channel floating value. (From GLM_GTX_color_cast extension)
template <typename T> gtc::f32vec3 f32_rgbx_cast(T c); //!< \brief Conversion of a u32 or u64 color into 3 components floating color. (From GLM_GTX_color_cast extension) template <typename T> f32vec3 f32_rgbx_cast(T c); //!< \brief Conversion of a u32 or u64 color into 3 components floating color. (From GLM_GTX_color_cast extension)
template <typename T> gtc::f32vec3 f32_xrgb_cast(T c); //!< \brief Conversion of a u32 or u64 color into 3 components floating color. (From GLM_GTX_color_cast extension) template <typename T> f32vec3 f32_xrgb_cast(T c); //!< \brief Conversion of a u32 or u64 color into 3 components floating color. (From GLM_GTX_color_cast extension)
template <typename T> gtc::f32vec3 f32_bgrx_cast(T c); //!< \brief Conversion of a u32 or u64 color into 3 components floating color. (From GLM_GTX_color_cast extension) template <typename T> f32vec3 f32_bgrx_cast(T c); //!< \brief Conversion of a u32 or u64 color into 3 components floating color. (From GLM_GTX_color_cast extension)
template <typename T> gtc::f32vec3 f32_xbgr_cast(T c); //!< \brief Conversion of a u32 or u64 color into 3 components floating color. (From GLM_GTX_color_cast extension) template <typename T> f32vec3 f32_xbgr_cast(T c); //!< \brief Conversion of a u32 or u64 color into 3 components floating color. (From GLM_GTX_color_cast extension)
template <typename T> gtc::f32vec4 f32_rgba_cast(T c); //!< \brief Conversion of a u32 or u64 color into 4 components floating color. (From GLM_GTX_color_cast extension) template <typename T> f32vec4 f32_rgba_cast(T c); //!< \brief Conversion of a u32 or u64 color into 4 components floating color. (From GLM_GTX_color_cast extension)
template <typename T> gtc::f32vec4 f32_argb_cast(T c); //!< \brief Conversion of a u32 or u64 color into 4 components floating color. (From GLM_GTX_color_cast extension) template <typename T> f32vec4 f32_argb_cast(T c); //!< \brief Conversion of a u32 or u64 color into 4 components floating color. (From GLM_GTX_color_cast extension)
template <typename T> gtc::f32vec4 f32_bgra_cast(T c); //!< \brief Conversion of a u32 or u64 color into 4 components floating color. (From GLM_GTX_color_cast extension) template <typename T> f32vec4 f32_bgra_cast(T c); //!< \brief Conversion of a u32 or u64 color into 4 components floating color. (From GLM_GTX_color_cast extension)
template <typename T> gtc::f32vec4 f32_abgr_cast(T c); //!< \brief Conversion of a u32 or u64 color into 4 components floating color. (From GLM_GTX_color_cast extension) template <typename T> f32vec4 f32_abgr_cast(T c); //!< \brief Conversion of a u32 or u64 color into 4 components floating color. (From GLM_GTX_color_cast extension)
template <typename T> gtx::f64vec1 f64_channel_cast(T a); //!< \brief Conversion of a u8 or u16 value to a single channel floating value. (From GLM_GTX_color_cast extension) template <typename T> f64 f64_channel_cast(T a); //!< \brief Conversion of a u8 or u16 value to a single channel floating value. (From GLM_GTX_color_cast extension)
template <typename T> gtc::f64vec3 f64_rgbx_cast(T c); //!< \brief Conversion of a u32 or u64 color into 3 components floating color. (From GLM_GTX_color_cast extension) template <typename T> f64vec3 f64_rgbx_cast(T c); //!< \brief Conversion of a u32 or u64 color into 3 components floating color. (From GLM_GTX_color_cast extension)
template <typename T> gtc::f64vec3 f64_xrgb_cast(T c); //!< \brief Conversion of a u32 or u64 color into 3 components floating color. (From GLM_GTX_color_cast extension) template <typename T> f64vec3 f64_xrgb_cast(T c); //!< \brief Conversion of a u32 or u64 color into 3 components floating color. (From GLM_GTX_color_cast extension)
template <typename T> gtc::f64vec3 f64_bgrx_cast(T c); //!< \brief Conversion of a u32 or u64 color into 3 components floating color. (From GLM_GTX_color_cast extension) template <typename T> f64vec3 f64_bgrx_cast(T c); //!< \brief Conversion of a u32 or u64 color into 3 components floating color. (From GLM_GTX_color_cast extension)
template <typename T> gtc::f64vec3 f64_xbgr_cast(T c); //!< \brief Conversion of a u32 or u64 color into 3 components floating color. (From GLM_GTX_color_cast extension) template <typename T> f64vec3 f64_xbgr_cast(T c); //!< \brief Conversion of a u32 or u64 color into 3 components floating color. (From GLM_GTX_color_cast extension)
template <typename T> gtc::f64vec4 f64_rgba_cast(T c); //!< \brief Conversion of a u32 or u64 color into 4 components floating color. (From GLM_GTX_color_cast extension) template <typename T> f64vec4 f64_rgba_cast(T c); //!< \brief Conversion of a u32 or u64 color into 4 components floating color. (From GLM_GTX_color_cast extension)
template <typename T> gtc::f64vec4 f64_argb_cast(T c); //!< \brief Conversion of a u32 or u64 color into 4 components floating color. (From GLM_GTX_color_cast extension) template <typename T> f64vec4 f64_argb_cast(T c); //!< \brief Conversion of a u32 or u64 color into 4 components floating color. (From GLM_GTX_color_cast extension)
template <typename T> gtc::f64vec4 f64_bgra_cast(T c); //!< \brief Conversion of a u32 or u64 color into 4 components floating color. (From GLM_GTX_color_cast extension) template <typename T> f64vec4 f64_bgra_cast(T c); //!< \brief Conversion of a u32 or u64 color into 4 components floating color. (From GLM_GTX_color_cast extension)
template <typename T> gtc::f64vec4 f64_abgr_cast(T c); //!< \brief Conversion of a u32 or u64 color into 4 components floating color. (From GLM_GTX_color_cast extension) template <typename T> f64vec4 f64_abgr_cast(T c); //!< \brief Conversion of a u32 or u64 color into 4 components floating color. (From GLM_GTX_color_cast extension)
/// @} /// @}
}//namespace gtx
}//namespace glm }//namespace glm
#include "color_cast.inl" #include "color_cast.inl"

View File

@ -8,213 +8,212 @@
/////////////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////////////
namespace glm{ namespace glm{
namespace gtx{
template <typename T> template <typename T>
GLM_FUNC_QUALIFIER gtc::uint8 u8channel_cast(T a) GLM_FUNC_QUALIFIER uint8 u8channel_cast(T a)
{ {
return static_cast<gtc::uint8>(a * T(255)); return static_cast<uint8>(a * T(255));
} }
template <typename T> template <typename T>
GLM_FUNC_QUALIFIER gtc::uint16 u16channel_cast(T a) GLM_FUNC_QUALIFIER uint16 u16channel_cast(T a)
{ {
return static_cast<gtc::uint16>(a * T(65535)); return static_cast<uint16>(a * T(65535));
} }
template <typename T> template <typename T>
GLM_FUNC_QUALIFIER gtc::uint32 u32_rgbx_cast(const detail::tvec3<T>& c) GLM_FUNC_QUALIFIER uint32 u32_rgbx_cast(const detail::tvec3<T>& c)
{ {
gtc::uint32 result = 0; uint32 result = 0;
result += static_cast<gtc::uint32>(c.x * detail::tvec3<T>::value_type(255)) << 0; result += static_cast<uint32>(c.x * detail::tvec3<T>::value_type(255)) << 0;
result += static_cast<gtc::uint32>(c.y * detail::tvec3<T>::value_type(255)) << 8; result += static_cast<uint32>(c.y * detail::tvec3<T>::value_type(255)) << 8;
result += static_cast<gtc::uint32>(c.z * detail::tvec3<T>::value_type(255)) << 16; result += static_cast<uint32>(c.z * detail::tvec3<T>::value_type(255)) << 16;
return result; return result;
} }
template <typename T> template <typename T>
GLM_FUNC_QUALIFIER gtc::uint32 u32_xrgb_cast(const detail::tvec3<T>& c) GLM_FUNC_QUALIFIER uint32 u32_xrgb_cast(const detail::tvec3<T>& c)
{ {
gtc::uint32 result = 0; uint32 result = 0;
result += static_cast<gtc::uint32>(c.x * detail::tvec3<T>::value_type(255)) << 8; result += static_cast<uint32>(c.x * detail::tvec3<T>::value_type(255)) << 8;
result += static_cast<gtc::uint32>(c.y * detail::tvec3<T>::value_type(255)) << 16; result += static_cast<uint32>(c.y * detail::tvec3<T>::value_type(255)) << 16;
result += static_cast<gtc::uint32>(c.z * detail::tvec3<T>::value_type(255)) << 24; result += static_cast<uint32>(c.z * detail::tvec3<T>::value_type(255)) << 24;
return result; return result;
} }
template <typename T> template <typename T>
GLM_FUNC_QUALIFIER gtc::uint32 u32_bgrx_cast(const detail::tvec3<T>& c) GLM_FUNC_QUALIFIER uint32 u32_bgrx_cast(const detail::tvec3<T>& c)
{ {
gtc::uint32 result = 0; uint32 result = 0;
result += static_cast<gtc::uint32>(c.x * detail::tvec3<T>::value_type(255)) << 16; result += static_cast<uint32>(c.x * detail::tvec3<T>::value_type(255)) << 16;
result += static_cast<gtc::uint32>(c.y * detail::tvec3<T>::value_type(255)) << 8; result += static_cast<uint32>(c.y * detail::tvec3<T>::value_type(255)) << 8;
result += static_cast<gtc::uint32>(c.z * detail::tvec3<T>::value_type(255)) << 0; result += static_cast<uint32>(c.z * detail::tvec3<T>::value_type(255)) << 0;
return result; return result;
} }
template <typename T> template <typename T>
GLM_FUNC_QUALIFIER gtc::uint32 u32_xbgr_cast(const detail::tvec3<T>& c) GLM_FUNC_QUALIFIER uint32 u32_xbgr_cast(const detail::tvec3<T>& c)
{ {
gtc::uint32 result = 0; uint32 result = 0;
result += static_cast<gtc::uint32>(c.x * detail::tvec3<T>::value_type(255)) << 24; result += static_cast<uint32>(c.x * detail::tvec3<T>::value_type(255)) << 24;
result += static_cast<gtc::uint32>(c.y * detail::tvec3<T>::value_type(255)) << 16; result += static_cast<uint32>(c.y * detail::tvec3<T>::value_type(255)) << 16;
result += static_cast<gtc::uint32>(c.z * detail::tvec3<T>::value_type(255)) << 8; result += static_cast<uint32>(c.z * detail::tvec3<T>::value_type(255)) << 8;
result += static_cast<gtc::uint32>(c.w * detail::tvec3<T>::value_type(255)) << 0; result += static_cast<uint32>(c.w * detail::tvec3<T>::value_type(255)) << 0;
return result; return result;
} }
template <typename T> template <typename T>
GLM_FUNC_QUALIFIER gtc::uint32 u32_rgba_cast(const detail::tvec4<T>& c) GLM_FUNC_QUALIFIER uint32 u32_rgba_cast(const detail::tvec4<T>& c)
{ {
gtc::uint32 result = 0; uint32 result = 0;
result += static_cast<gtc::uint32>(c.x * detail::tvec4<T>::value_type(255)) << 0; result += static_cast<uint32>(c.x * detail::tvec4<T>::value_type(255)) << 0;
result += static_cast<gtc::uint32>(c.y * detail::tvec4<T>::value_type(255)) << 8; result += static_cast<uint32>(c.y * detail::tvec4<T>::value_type(255)) << 8;
result += static_cast<gtc::uint32>(c.z * detail::tvec4<T>::value_type(255)) << 16; result += static_cast<uint32>(c.z * detail::tvec4<T>::value_type(255)) << 16;
result += static_cast<gtc::uint32>(c.w * detail::tvec4<T>::value_type(255)) << 24; result += static_cast<uint32>(c.w * detail::tvec4<T>::value_type(255)) << 24;
return result; return result;
} }
template <typename T> template <typename T>
GLM_FUNC_QUALIFIER gtc::uint32 u32_argb_cast(const detail::tvec4<T>& c) GLM_FUNC_QUALIFIER uint32 u32_argb_cast(const detail::tvec4<T>& c)
{ {
gtc::uint32 result = 0; uint32 result = 0;
result += static_cast<gtc::uint32>(c.x * detail::tvec4<T>::value_type(255)) << 8; result += static_cast<uint32>(c.x * detail::tvec4<T>::value_type(255)) << 8;
result += static_cast<gtc::uint32>(c.y * detail::tvec4<T>::value_type(255)) << 16; result += static_cast<uint32>(c.y * detail::tvec4<T>::value_type(255)) << 16;
result += static_cast<gtc::uint32>(c.z * detail::tvec4<T>::value_type(255)) << 24; result += static_cast<uint32>(c.z * detail::tvec4<T>::value_type(255)) << 24;
result += static_cast<gtc::uint32>(c.w * detail::tvec4<T>::value_type(255)) << 0; result += static_cast<uint32>(c.w * detail::tvec4<T>::value_type(255)) << 0;
return result; return result;
} }
template <typename T> template <typename T>
GLM_FUNC_QUALIFIER gtc::uint32 u32_bgra_cast(const detail::tvec4<T>& c) GLM_FUNC_QUALIFIER uint32 u32_bgra_cast(const detail::tvec4<T>& c)
{ {
gtc::uint32 result = 0; uint32 result = 0;
result += static_cast<gtc::uint32>(c.x * detail::tvec4<T>::value_type(255)) << 16; result += static_cast<uint32>(c.x * detail::tvec4<T>::value_type(255)) << 16;
result += static_cast<gtc::uint32>(c.y * detail::tvec4<T>::value_type(255)) << 8; result += static_cast<uint32>(c.y * detail::tvec4<T>::value_type(255)) << 8;
result += static_cast<gtc::uint32>(c.z * detail::tvec4<T>::value_type(255)) << 0; result += static_cast<uint32>(c.z * detail::tvec4<T>::value_type(255)) << 0;
result += static_cast<gtc::uint32>(c.w * detail::tvec4<T>::value_type(255)) << 24; result += static_cast<uint32>(c.w * detail::tvec4<T>::value_type(255)) << 24;
return result; return result;
} }
template <typename T> template <typename T>
GLM_FUNC_QUALIFIER gtc::uint32 u32_abgr_cast(const detail::tvec4<T>& c) GLM_FUNC_QUALIFIER uint32 u32_abgr_cast(const detail::tvec4<T>& c)
{ {
gtc::uint32 result = 0; uint32 result = 0;
result += static_cast<gtc::uint32>(c.x * detail::tvec4<T>::value_type(255)) << 24; result += static_cast<uint32>(c.x * detail::tvec4<T>::value_type(255)) << 24;
result += static_cast<gtc::uint32>(c.y * detail::tvec4<T>::value_type(255)) << 16; result += static_cast<uint32>(c.y * detail::tvec4<T>::value_type(255)) << 16;
result += static_cast<gtc::uint32>(c.z * detail::tvec4<T>::value_type(255)) << 8; result += static_cast<uint32>(c.z * detail::tvec4<T>::value_type(255)) << 8;
result += static_cast<gtc::uint32>(c.w * detail::tvec4<T>::value_type(255)) << 0; result += static_cast<uint32>(c.w * detail::tvec4<T>::value_type(255)) << 0;
return result; return result;
} }
template <typename T> template <typename T>
GLM_FUNC_QUALIFIER gtc::uint64 u64_rgbx_cast(const detail::tvec3<T>& c) GLM_FUNC_QUALIFIER uint64 u64_rgbx_cast(const detail::tvec3<T>& c)
{ {
gtc::uint64 result = 0; uint64 result = 0;
result += static_cast<gtc::uint64>(c.x * detail::tvec3<T>::value_type(65535)) << 0; result += static_cast<uint64>(c.x * detail::tvec3<T>::value_type(65535)) << 0;
result += static_cast<gtc::uint64>(c.y * detail::tvec3<T>::value_type(65535)) << 16; result += static_cast<uint64>(c.y * detail::tvec3<T>::value_type(65535)) << 16;
result += static_cast<gtc::uint64>(c.z * detail::tvec3<T>::value_type(65535)) << 32; result += static_cast<uint64>(c.z * detail::tvec3<T>::value_type(65535)) << 32;
return result; return result;
} }
template <typename T> template <typename T>
GLM_FUNC_QUALIFIER gtc::uint64 u32_xrgb_cast(const detail::tvec3<T>& c) GLM_FUNC_QUALIFIER uint64 u32_xrgb_cast(const detail::tvec3<T>& c)
{ {
gtc::uint64 result = 0; uint64 result = 0;
result += static_cast<gtc::uint64>(c.x * detail::tvec3<T>::value_type(65535)) << 16; result += static_cast<uint64>(c.x * detail::tvec3<T>::value_type(65535)) << 16;
result += static_cast<gtc::uint64>(c.y * detail::tvec3<T>::value_type(65535)) << 32; result += static_cast<uint64>(c.y * detail::tvec3<T>::value_type(65535)) << 32;
result += static_cast<gtc::uint64>(c.z * detail::tvec3<T>::value_type(65535)) << 48; result += static_cast<uint64>(c.z * detail::tvec3<T>::value_type(65535)) << 48;
return result; return result;
} }
template <typename T> template <typename T>
GLM_FUNC_QUALIFIER gtc::uint64 u32_bgrx_cast(const detail::tvec3<T>& c) GLM_FUNC_QUALIFIER uint64 u32_bgrx_cast(const detail::tvec3<T>& c)
{ {
gtc::uint64 result = 0; uint64 result = 0;
result += static_cast<gtc::uint64>(c.x * detail::tvec3<T>::value_type(65535)) << 32; result += static_cast<uint64>(c.x * detail::tvec3<T>::value_type(65535)) << 32;
result += static_cast<gtc::uint64>(c.y * detail::tvec3<T>::value_type(65535)) << 16; result += static_cast<uint64>(c.y * detail::tvec3<T>::value_type(65535)) << 16;
result += static_cast<gtc::uint64>(c.z * detail::tvec3<T>::value_type(65535)) << 0; result += static_cast<uint64>(c.z * detail::tvec3<T>::value_type(65535)) << 0;
return result; return result;
} }
template <typename T> template <typename T>
GLM_FUNC_QUALIFIER gtc::uint64 u32_xbgr_cast(const detail::tvec3<T>& c) GLM_FUNC_QUALIFIER uint64 u32_xbgr_cast(const detail::tvec3<T>& c)
{ {
gtc::uint64 result = 0; uint64 result = 0;
result += static_cast<gtc::uint64>(c.x * detail::tvec3<T>::value_type(65535)) << 48; result += static_cast<uint64>(c.x * detail::tvec3<T>::value_type(65535)) << 48;
result += static_cast<gtc::uint64>(c.y * detail::tvec3<T>::value_type(65535)) << 32; result += static_cast<uint64>(c.y * detail::tvec3<T>::value_type(65535)) << 32;
result += static_cast<gtc::uint64>(c.z * detail::tvec3<T>::value_type(65535)) << 16; result += static_cast<uint64>(c.z * detail::tvec3<T>::value_type(65535)) << 16;
result += static_cast<gtc::uint64>(c.w * detail::tvec3<T>::value_type(65535)) << 0; result += static_cast<uint64>(c.w * detail::tvec3<T>::value_type(65535)) << 0;
return result; return result;
} }
template <typename T> template <typename T>
GLM_FUNC_QUALIFIER gtc::uint64 u64_rgba_cast(const detail::tvec4<T>& c) GLM_FUNC_QUALIFIER uint64 u64_rgba_cast(const detail::tvec4<T>& c)
{ {
gtc::uint64 result = 0; uint64 result = 0;
result += static_cast<gtc::uint64>(c.x * detail::tvec4<T>::value_type(65535)) << 0; result += static_cast<uint64>(c.x * detail::tvec4<T>::value_type(65535)) << 0;
result += static_cast<gtc::uint64>(c.y * detail::tvec4<T>::value_type(65535)) << 16; result += static_cast<uint64>(c.y * detail::tvec4<T>::value_type(65535)) << 16;
result += static_cast<gtc::uint64>(c.z * detail::tvec4<T>::value_type(65535)) << 32; result += static_cast<uint64>(c.z * detail::tvec4<T>::value_type(65535)) << 32;
result += static_cast<gtc::uint64>(c.w * detail::tvec4<T>::value_type(65535)) << 48; result += static_cast<uint64>(c.w * detail::tvec4<T>::value_type(65535)) << 48;
return result; return result;
} }
template <typename T> template <typename T>
GLM_FUNC_QUALIFIER gtc::uint64 u64_argb_cast(const detail::tvec4<T>& c) GLM_FUNC_QUALIFIER uint64 u64_argb_cast(const detail::tvec4<T>& c)
{ {
gtc::uint64 result = 0; uint64 result = 0;
result += static_cast<gtc::uint64>(c.x * detail::tvec4<T>::value_type(65535)) << 16; result += static_cast<uint64>(c.x * detail::tvec4<T>::value_type(65535)) << 16;
result += static_cast<gtc::uint64>(c.y * detail::tvec4<T>::value_type(65535)) << 32; result += static_cast<uint64>(c.y * detail::tvec4<T>::value_type(65535)) << 32;
result += static_cast<gtc::uint64>(c.z * detail::tvec4<T>::value_type(65535)) << 48; result += static_cast<uint64>(c.z * detail::tvec4<T>::value_type(65535)) << 48;
result += static_cast<gtc::uint64>(c.w * detail::tvec4<T>::value_type(65535)) << 0; result += static_cast<uint64>(c.w * detail::tvec4<T>::value_type(65535)) << 0;
return result; return result;
} }
template <typename T> template <typename T>
GLM_FUNC_QUALIFIER gtc::uint64 u64_bgra_cast(const detail::tvec4<T>& c) GLM_FUNC_QUALIFIER uint64 u64_bgra_cast(const detail::tvec4<T>& c)
{ {
gtc::uint64 result = 0; uint64 result = 0;
result += static_cast<gtc::uint64>(c.x * detail::tvec4<T>::value_type(65535)) << 32; result += static_cast<uint64>(c.x * detail::tvec4<T>::value_type(65535)) << 32;
result += static_cast<gtc::uint64>(c.y * detail::tvec4<T>::value_type(65535)) << 16; result += static_cast<uint64>(c.y * detail::tvec4<T>::value_type(65535)) << 16;
result += static_cast<gtc::uint64>(c.z * detail::tvec4<T>::value_type(65535)) << 0; result += static_cast<uint64>(c.z * detail::tvec4<T>::value_type(65535)) << 0;
result += static_cast<gtc::uint64>(c.w * detail::tvec4<T>::value_type(65535)) << 48; result += static_cast<uint64>(c.w * detail::tvec4<T>::value_type(65535)) << 48;
return result; return result;
} }
template <typename T> template <typename T>
GLM_FUNC_QUALIFIER gtc::uint64 u64_abgr_cast(const detail::tvec4<T>& c) GLM_FUNC_QUALIFIER uint64 u64_abgr_cast(const detail::tvec4<T>& c)
{ {
gtc::uint64 result = 0; uint64 result = 0;
result += static_cast<gtc::uint64>(c.x * detail::tvec4<T>::value_type(65535)) << 48; result += static_cast<uint64>(c.x * detail::tvec4<T>::value_type(65535)) << 48;
result += static_cast<gtc::uint64>(c.y * detail::tvec4<T>::value_type(65535)) << 32; result += static_cast<uint64>(c.y * detail::tvec4<T>::value_type(65535)) << 32;
result += static_cast<gtc::uint64>(c.z * detail::tvec4<T>::value_type(65535)) << 16; result += static_cast<uint64>(c.z * detail::tvec4<T>::value_type(65535)) << 16;
result += static_cast<gtc::uint64>(c.w * detail::tvec4<T>::value_type(65535)) << 0; result += static_cast<uint64>(c.w * detail::tvec4<T>::value_type(65535)) << 0;
return result; return result;
} }
template <> template <>
GLM_FUNC_QUALIFIER f16vec1 f16_channel_cast<gtc::uint32>(gtc::uint32 color) GLM_FUNC_QUALIFIER f16 f16_channel_cast<uint32>(uint32 color)
{ {
return gtc::f16(static_cast<float>(color >> 0) / static_cast<float>(255)); return f16(static_cast<float>(color >> 0) / static_cast<float>(255));
} }
template <> template <>
GLM_FUNC_QUALIFIER gtc::f16vec3 f16_rgbx_cast<gtc::uint32>(gtc::uint32 color) GLM_FUNC_QUALIFIER f16vec3 f16_rgbx_cast<uint32>(uint32 color)
{ {
gtc::f16vec3 result; f16vec3 result;
result.x = gtc::f16(static_cast<float>(color >> 0) / static_cast<float>(255)); result.x = f16(static_cast<float>(color >> 0) / static_cast<float>(255));
result.y = gtc::f16(static_cast<float>(color >> 8) / static_cast<float>(255)); result.y = f16(static_cast<float>(color >> 8) / static_cast<float>(255));
result.z = gtc::f16(static_cast<float>(color >> 16) / static_cast<float>(255)); result.z = f16(static_cast<float>(color >> 16) / static_cast<float>(255));
return result; return result;
} }
template <> template <>
GLM_FUNC_QUALIFIER gtc::f16vec3 f16_xrgb_cast<gtc::uint32>(gtc::uint32 color) GLM_FUNC_QUALIFIER f16vec3 f16_xrgb_cast<uint32>(uint32 color)
{ {
gtc::f16vec3 result; f16vec3 result;
result.x = gtc::f16(static_cast<float>(color >> 8) / static_cast<float>(255)); result.x = f16(static_cast<float>(color >> 8) / static_cast<float>(255));
result.y = gtc::f16(static_cast<float>(color >> 16) / static_cast<float>(255)); result.y = f16(static_cast<float>(color >> 16) / static_cast<float>(255));
result.z = gtc::f16(static_cast<float>(color >> 24) / static_cast<float>(255)); result.z = f16(static_cast<float>(color >> 24) / static_cast<float>(255));
return result; return result;
} }
@ -732,5 +731,4 @@ GLM_FUNC_QUALIFIER detail::tvec4<double> f64_abgr_cast<uint64>(uint64 color)
return result; return result;
} }
}//namespace gtx
}//namespace glm }//namespace glm

View File

@ -45,8 +45,7 @@
# pragma message("GLM: GLM_GTX_color_space extension included") # pragma message("GLM: GLM_GTX_color_space extension included")
#endif #endif
namespace glm{ namespace glm
namespace gtx
{ {
/// @addtogroup gtx_color_space /// @addtogroup gtx_color_space
/// @{ /// @{
@ -90,7 +89,6 @@ namespace gtx
detail::tvec3<valType> const & color); detail::tvec3<valType> const & color);
/// @} /// @}
}//namespace gtx
}//namespace glm }//namespace glm
#include "color_space.inl" #include "color_space.inl"

View File

@ -8,145 +8,143 @@
/////////////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////////////
namespace glm{ namespace glm{
namespace gtx
template <typename T>
GLM_FUNC_QUALIFIER detail::tvec3<T> rgbColor(const detail::tvec3<T>& hsvColor)
{ {
template <typename T> detail::tvec3<T> hsv = hsvColor;
GLM_FUNC_QUALIFIER detail::tvec3<T> rgbColor(const detail::tvec3<T>& hsvColor) detail::tvec3<T> rgbColor;
{
detail::tvec3<T> hsv = hsvColor;
detail::tvec3<T> rgbColor;
if(hsv.y == T(0)) if(hsv.y == T(0))
// achromatic (grey) // achromatic (grey)
rgbColor = detail::tvec3<T>(hsv.z); rgbColor = detail::tvec3<T>(hsv.z);
else else
{ {
T sector = floor(hsv.x / T(60)); T sector = floor(hsv.x / T(60));
T frac = (hsv.x / T(60)) - sector; T frac = (hsv.x / T(60)) - sector;
// factorial part of h // factorial part of h
T o = hsv.z * (T(1) - hsv.y); T o = hsv.z * (T(1) - hsv.y);
T p = hsv.z * (T(1) - hsv.y * frac); T p = hsv.z * (T(1) - hsv.y * frac);
T q = hsv.z * (T(1) - hsv.y * (T(1) - frac)); T q = hsv.z * (T(1) - hsv.y * (T(1) - frac));
switch(int(sector)) switch(int(sector))
{ {
default: default:
case 0: case 0:
rgbColor.r = hsv.z; rgbColor.r = hsv.z;
rgbColor.g = q; rgbColor.g = q;
rgbColor.b = o; rgbColor.b = o;
break; break;
case 1: case 1:
rgbColor.r = p; rgbColor.r = p;
rgbColor.g = hsv.z; rgbColor.g = hsv.z;
rgbColor.b = o; rgbColor.b = o;
break; break;
case 2: case 2:
rgbColor.r = o; rgbColor.r = o;
rgbColor.g = hsv.z; rgbColor.g = hsv.z;
rgbColor.b = q; rgbColor.b = q;
break; break;
case 3: case 3:
rgbColor.r = o; rgbColor.r = o;
rgbColor.g = p; rgbColor.g = p;
rgbColor.b = hsv.z; rgbColor.b = hsv.z;
break; break;
case 4: case 4:
rgbColor.r = q; rgbColor.r = q;
rgbColor.g = o; rgbColor.g = o;
rgbColor.b = hsv.z; rgbColor.b = hsv.z;
break; break;
case 5: case 5:
rgbColor.r = hsv.z; rgbColor.r = hsv.z;
rgbColor.g = o; rgbColor.g = o;
rgbColor.b = p; rgbColor.b = p;
break; break;
} }
} }
return rgbColor; return rgbColor;
} }
template <typename T> template <typename T>
GLM_FUNC_QUALIFIER detail::tvec3<T> hsvColor(const detail::tvec3<T>& rgbColor) GLM_FUNC_QUALIFIER detail::tvec3<T> hsvColor(const detail::tvec3<T>& rgbColor)
{ {
detail::tvec3<T> hsv = rgbColor; detail::tvec3<T> hsv = rgbColor;
float Min = min(min(rgbColor.r, rgbColor.g), rgbColor.b); float Min = min(min(rgbColor.r, rgbColor.g), rgbColor.b);
float Max = max(max(rgbColor.r, rgbColor.g), rgbColor.b); float Max = max(max(rgbColor.r, rgbColor.g), rgbColor.b);
float Delta = Max - Min; float Delta = Max - Min;
hsv.z = Max; hsv.z = Max;
if(Max != T(0)) if(Max != T(0))
{ {
hsv.y = Delta / hsv.z; hsv.y = Delta / hsv.z;
T h = T(0); T h = T(0);
if(rgbColor.r == Max) if(rgbColor.r == Max)
// between yellow & magenta // between yellow & magenta
h = T(0) + T(60) * (rgbColor.g - rgbColor.b) / Delta; h = T(0) + T(60) * (rgbColor.g - rgbColor.b) / Delta;
else if(rgbColor.g == Max) else if(rgbColor.g == Max)
// between cyan & yellow // between cyan & yellow
h = T(120) + T(60) * (rgbColor.b - rgbColor.r) / Delta; h = T(120) + T(60) * (rgbColor.b - rgbColor.r) / Delta;
else else
// between magenta & cyan // between magenta & cyan
h = T(240) + T(60) * (rgbColor.r - rgbColor.g) / Delta; h = T(240) + T(60) * (rgbColor.r - rgbColor.g) / Delta;
if(h < T(0)) if(h < T(0))
hsv.x = h + T(360); hsv.x = h + T(360);
else else
hsv.x = h; hsv.x = h;
} }
else else
{
// If r = g = b = 0 then s = 0, h is undefined
hsv.y = T(0);
hsv.x = T(0);
}
return hsv;
}
template <typename T>
GLM_FUNC_QUALIFIER detail::tmat4x4<T> saturation(const T s)
{ {
detail::tvec3<T> rgbw = detail::tvec3<T>(T(0.2126), T(0.7152), T(0.0722)); // If r = g = b = 0 then s = 0, h is undefined
hsv.y = T(0);
T col0 = (T(1) - s) * rgbw.r; hsv.x = T(0);
T col1 = (T(1) - s) * rgbw.g;
T col2 = (T(1) - s) * rgbw.b;
detail::tmat4x4<T> result(T(1));
result[0][0] = col0 + s;
result[0][1] = col0;
result[0][2] = col0;
result[1][0] = col1;
result[1][1] = col1 + s;
result[1][2] = col1;
result[2][0] = col2;
result[2][1] = col2;
result[2][2] = col2 + s;
return result;
} }
template <typename T> return hsv;
GLM_FUNC_QUALIFIER detail::tvec3<T> saturation(const T s, const detail::tvec3<T>& color) }
{
return detail::tvec3<T>(saturation(s) * detail::tvec4<T>(color, T(0)));
}
template <typename T> template <typename T>
GLM_FUNC_QUALIFIER detail::tvec4<T> saturation(const T s, const detail::tvec4<T>& color) GLM_FUNC_QUALIFIER detail::tmat4x4<T> saturation(const T s)
{ {
return saturation(s) * color; detail::tvec3<T> rgbw = detail::tvec3<T>(T(0.2126), T(0.7152), T(0.0722));
}
template <typename T> T col0 = (T(1) - s) * rgbw.r;
GLM_FUNC_QUALIFIER T luminosity(const detail::tvec3<T>& color) T col1 = (T(1) - s) * rgbw.g;
{ T col2 = (T(1) - s) * rgbw.b;
const detail::tvec3<T> tmp = detail::tvec3<T>(0.33, 0.59, 0.11);
return dot(color, tmp); detail::tmat4x4<T> result(T(1));
} result[0][0] = col0 + s;
result[0][1] = col0;
result[0][2] = col0;
result[1][0] = col1;
result[1][1] = col1 + s;
result[1][2] = col1;
result[2][0] = col2;
result[2][1] = col2;
result[2][2] = col2 + s;
return result;
}
template <typename T>
GLM_FUNC_QUALIFIER detail::tvec3<T> saturation(const T s, const detail::tvec3<T>& color)
{
return detail::tvec3<T>(saturation(s) * detail::tvec4<T>(color, T(0)));
}
template <typename T>
GLM_FUNC_QUALIFIER detail::tvec4<T> saturation(const T s, const detail::tvec4<T>& color)
{
return saturation(s) * color;
}
template <typename T>
GLM_FUNC_QUALIFIER T luminosity(const detail::tvec3<T>& color)
{
const detail::tvec3<T> tmp = detail::tvec3<T>(0.33, 0.59, 0.11);
return dot(color, tmp);
}
}//namespace gtx
}//namespace glm }//namespace glm

View File

@ -45,8 +45,7 @@
# pragma message("GLM: GLM_GTX_color_space_YCoCg extension included") # pragma message("GLM: GLM_GTX_color_space_YCoCg extension included")
#endif #endif
namespace glm{ namespace glm
namespace gtx
{ {
/// @addtogroup gtx_color_space_YCoCg /// @addtogroup gtx_color_space_YCoCg
/// @{ /// @{
@ -78,7 +77,6 @@ namespace gtx
detail::tvec3<valType> const & YCoCgColor); detail::tvec3<valType> const & YCoCgColor);
/// @} /// @}
}//namespace gtx
}//namespace glm }//namespace glm
#include "color_space_YCoCg.inl" #include "color_space_YCoCg.inl"

View File

@ -8,7 +8,6 @@
/////////////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////////////
namespace glm{ namespace glm{
namespace gtx{
template <typename valType> template <typename valType>
GLM_FUNC_QUALIFIER detail::tvec3<valType> rgb2YCoCg GLM_FUNC_QUALIFIER detail::tvec3<valType> rgb2YCoCg
@ -63,5 +62,4 @@ GLM_FUNC_QUALIFIER detail::tvec3<valType> YCoCgR2rgb
return result; return result;
} }
}//namespace gtx
}//namespace glm }//namespace glm

View File

@ -53,8 +53,7 @@
#include <cmath> #include <cmath>
#endif//GLM_COMPILER #endif//GLM_COMPILER
namespace glm{ namespace glm
namespace gtx
{ {
/// @addtogroup gtx_compatibility /// @addtogroup gtx_compatibility
/// @{ /// @{
@ -124,21 +123,21 @@ namespace gtx
typedef detail::tmat4x3<int> int4x3; //!< \brief integer matrix with 4 x 3 components. (From GLM_GTX_compatibility extension) typedef detail::tmat4x3<int> int4x3; //!< \brief integer matrix with 4 x 3 components. (From GLM_GTX_compatibility extension)
typedef detail::tmat4x4<int> int4x4; //!< \brief integer matrix with 4 x 4 components. (From GLM_GTX_compatibility extension) typedef detail::tmat4x4<int> int4x4; //!< \brief integer matrix with 4 x 4 components. (From GLM_GTX_compatibility extension)
typedef gtc::half half1; //!< \brief half-precision floating-point vector with 1 component. (From GLM_GTX_compatibility extension) typedef detail::thalf half1; //!< \brief half-precision floating-point vector with 1 component. (From GLM_GTX_compatibility extension)
typedef detail::tvec2<gtc::half> half2; //!< \brief half-precision floating-point vector with 2 components. (From GLM_GTX_compatibility extension) typedef detail::tvec2<detail::thalf> half2; //!< \brief half-precision floating-point vector with 2 components. (From GLM_GTX_compatibility extension)
typedef detail::tvec3<gtc::half> half3; //!< \brief half-precision floating-point vector with 2 components. (From GLM_GTX_compatibility extension) typedef detail::tvec3<detail::thalf> half3; //!< \brief half-precision floating-point vector with 2 components. (From GLM_GTX_compatibility extension)
typedef detail::tvec4<gtc::half> half4; //!< \brief half-precision floating-point vector with 2 components. (From GLM_GTX_compatibility extension) typedef detail::tvec4<detail::thalf> half4; //!< \brief half-precision floating-point vector with 2 components. (From GLM_GTX_compatibility extension)
typedef gtc::half half1x1; //!< \brief half-precision floating-point matrix with 1 component. (From GLM_GTX_compatibility extension) typedef detail::thalf half1x1; //!< \brief half-precision floating-point matrix with 1 component. (From GLM_GTX_compatibility extension)
typedef detail::tmat2x2<gtc::half> half2x2; //!< \brief half-precision floating-point matrix with 2 x 2 components. (From GLM_GTX_compatibility extension) typedef detail::tmat2x2<detail::thalf> half2x2; //!< \brief half-precision floating-point matrix with 2 x 2 components. (From GLM_GTX_compatibility extension)
typedef detail::tmat2x3<gtc::half> half2x3; //!< \brief half-precision floating-point matrix with 2 x 3 components. (From GLM_GTX_compatibility extension) typedef detail::tmat2x3<detail::thalf> half2x3; //!< \brief half-precision floating-point matrix with 2 x 3 components. (From GLM_GTX_compatibility extension)
typedef detail::tmat2x4<gtc::half> half2x4; //!< \brief half-precision floating-point matrix with 2 x 4 components. (From GLM_GTX_compatibility extension) typedef detail::tmat2x4<detail::thalf> half2x4; //!< \brief half-precision floating-point matrix with 2 x 4 components. (From GLM_GTX_compatibility extension)
typedef detail::tmat3x2<gtc::half> half3x2; //!< \brief half-precision floating-point matrix with 3 x 2 components. (From GLM_GTX_compatibility extension) typedef detail::tmat3x2<detail::thalf> half3x2; //!< \brief half-precision floating-point matrix with 3 x 2 components. (From GLM_GTX_compatibility extension)
typedef detail::tmat3x3<gtc::half> half3x3; //!< \brief half-precision floating-point matrix with 3 x 3 components. (From GLM_GTX_compatibility extension) typedef detail::tmat3x3<detail::thalf> half3x3; //!< \brief half-precision floating-point matrix with 3 x 3 components. (From GLM_GTX_compatibility extension)
typedef detail::tmat3x4<gtc::half> half3x4; //!< \brief half-precision floating-point matrix with 3 x 3 components. (From GLM_GTX_compatibility extension) typedef detail::tmat3x4<detail::thalf> half3x4; //!< \brief half-precision floating-point matrix with 3 x 3 components. (From GLM_GTX_compatibility extension)
typedef detail::tmat4x2<gtc::half> half4x2; //!< \brief half-precision floating-point matrix with 4 x 2 components. (From GLM_GTX_compatibility extension) typedef detail::tmat4x2<detail::thalf> half4x2; //!< \brief half-precision floating-point matrix with 4 x 2 components. (From GLM_GTX_compatibility extension)
typedef detail::tmat4x3<gtc::half> half4x3; //!< \brief half-precision floating-point matrix with 4 x 3 components. (From GLM_GTX_compatibility extension) typedef detail::tmat4x3<detail::thalf> half4x3; //!< \brief half-precision floating-point matrix with 4 x 3 components. (From GLM_GTX_compatibility extension)
typedef detail::tmat4x4<gtc::half> half4x4; //!< \brief half-precision floating-point matrix with 4 x 4 components. (From GLM_GTX_compatibility extension) typedef detail::tmat4x4<detail::thalf> half4x4; //!< \brief half-precision floating-point matrix with 4 x 4 components. (From GLM_GTX_compatibility extension)
typedef float float1; //!< \brief single-precision floating-point vector with 1 component. (From GLM_GTX_compatibility extension) typedef float float1; //!< \brief single-precision floating-point vector with 1 component. (From GLM_GTX_compatibility extension)
typedef detail::tvec2<float> float2; //!< \brief single-precision floating-point vector with 2 components. (From GLM_GTX_compatibility extension) typedef detail::tvec2<float> float2; //!< \brief single-precision floating-point vector with 2 components. (From GLM_GTX_compatibility extension)
@ -173,7 +172,6 @@ namespace gtx
typedef detail::tmat4x4<double> double4x4; //!< \brief double-precision floating-point matrix with 4 x 4 components. (From GLM_GTX_compatibility extension) typedef detail::tmat4x4<double> double4x4; //!< \brief double-precision floating-point matrix with 4 x 4 components. (From GLM_GTX_compatibility extension)
/// @} /// @}
}//namespace gtx
}//namespace glm }//namespace glm
#include "compatibility.inl" #include "compatibility.inl"

View File

@ -8,8 +8,6 @@
/////////////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////////////
namespace glm{ namespace glm{
namespace gtx{
namespace compatibility{
// isfinite // isfinite
template <typename genType> template <typename genType>
@ -136,6 +134,4 @@ GLM_FUNC_QUALIFIER detail::tvec4<bool> isnan(
isnan(x.w)); isnan(x.w));
} }
}//namespace compatibility
}//namespace gtx
}//namespace glm }//namespace glm

View File

@ -45,8 +45,7 @@
# pragma message("GLM: GLM_GTX_component_wise extension included") # pragma message("GLM: GLM_GTX_component_wise extension included")
#endif #endif
namespace glm{ namespace glm
namespace gtx
{ {
/// @addtogroup gtx_component_wise /// @addtogroup gtx_component_wise
/// @{ /// @{
@ -76,7 +75,6 @@ namespace gtx
genType const & v); genType const & v);
/// @} /// @}
}//namespace gtx
}//namespace glm }//namespace glm
#include "component_wise.inl" #include "component_wise.inl"

View File

@ -8,43 +8,41 @@
/////////////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////////////
namespace glm{ namespace glm{
namespace gtx
template <typename genType>
GLM_FUNC_QUALIFIER typename genType::value_type compAdd(genType const & v)
{ {
template <typename genType> typename genType::size_type result = typename genType::value_type(0);
GLM_FUNC_QUALIFIER typename genType::value_type compAdd(genType const & v) for(typename genType::size_type i = 0; i < genType::value_size(); ++i)
{ result += v[i];
typename genType::size_type result = typename genType::value_type(0); return result;
for(typename genType::size_type i = 0; i < genType::value_size(); ++i) }
result += v[i];
return result;
}
template <typename genType> template <typename genType>
GLM_FUNC_QUALIFIER typename genType::value_type compMul(genType const & v) GLM_FUNC_QUALIFIER typename genType::value_type compMul(genType const & v)
{ {
typename genType::value_type result = typename genType::value_type(1); typename genType::value_type result = typename genType::value_type(1);
for(typename genType::size_type i = 0; i < genType::value_size(); ++i) for(typename genType::size_type i = 0; i < genType::value_size(); ++i)
result *= v[i]; result *= v[i];
return result; return result;
} }
template <typename genType> template <typename genType>
GLM_FUNC_QUALIFIER typename genType::value_type compMin(genType const & v) GLM_FUNC_QUALIFIER typename genType::value_type compMin(genType const & v)
{ {
typename genType::value_type result = typename genType::value_type(v[0]); typename genType::value_type result = typename genType::value_type(v[0]);
for(typename genType::size_type i = 1; i < genType::value_size(); ++i) for(typename genType::size_type i = 1; i < genType::value_size(); ++i)
result = min(result, v[i]); result = min(result, v[i]);
return result; return result;
} }
template <typename genType> template <typename genType>
GLM_FUNC_QUALIFIER typename genType::value_type compMax(genType const & v) GLM_FUNC_QUALIFIER typename genType::value_type compMax(genType const & v)
{ {
typename genType::value_type result = typename genType::value_type(v[0]); typename genType::value_type result = typename genType::value_type(v[0]);
for(typename genType::size_type i = 1; i < genType::value_size(); ++i) for(typename genType::size_type i = 1; i < genType::value_size(); ++i)
result = max(result, v[i]); result = max(result, v[i]);
return result; return result;
} }
}//namespace gtx
}//namespace glm }//namespace glm

View File

@ -49,8 +49,7 @@
# pragma message("GLM: GLM_GTX_epsilon extension included") # pragma message("GLM: GLM_GTX_epsilon extension included")
#endif #endif
namespace glm{ namespace glm
namespace gtx
{ {
/// @addtogroup gtx_epsilon /// @addtogroup gtx_epsilon
/// @{ /// @{
@ -72,7 +71,6 @@ namespace gtx
genTypeU const & epsilon); genTypeU const & epsilon);
/// @} /// @}
}//namespace gtx
}//namespace glm }//namespace glm
#include "epsilon.inl" #include "epsilon.inl"

View File

@ -8,7 +8,6 @@
/////////////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////////////
namespace glm{ namespace glm{
namespace gtx{
template <typename genType> template <typename genType>
GLM_FUNC_QUALIFIER bool equalEpsilon GLM_FUNC_QUALIFIER bool equalEpsilon
@ -228,5 +227,4 @@ GLM_FUNC_QUALIFIER detail::tvec4<bool> notEqualEpsilon
abs(x.w - y.w) >= epsilon.w); abs(x.w - y.w) >= epsilon.w);
} }
}//namespace gtx
}//namespace glm }//namespace glm

View File

@ -50,8 +50,7 @@
# pragma message("GLM: GLM_GTX_euler_angles extension included") # pragma message("GLM: GLM_GTX_euler_angles extension included")
#endif #endif
namespace glm{ namespace glm
namespace gtx
{ {
/// @addtogroup gtx_euler_angles /// @addtogroup gtx_euler_angles
/// @{ /// @{
@ -153,7 +152,6 @@ namespace gtx
detail::tmat4x4<T> orientate4(detail::tvec3<T> const & angles); detail::tmat4x4<T> orientate4(detail::tvec3<T> const & angles);
/// @} /// @}
}//namespace gtx
}//namespace glm }//namespace glm
#include "euler_angles.inl" #include "euler_angles.inl"

View File

@ -8,7 +8,6 @@
/////////////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////////////
namespace glm{ namespace glm{
namespace gtx{
template <typename valType> template <typename valType>
GLM_FUNC_QUALIFIER detail::tmat4x4<valType> eulerAngleX GLM_FUNC_QUALIFIER detail::tmat4x4<valType> eulerAngleX
@ -243,5 +242,4 @@ GLM_FUNC_QUALIFIER detail::tmat4x4<valType> orientate4
return yawPitchRoll(angles.z, angles.x, angles.y); return yawPitchRoll(angles.z, angles.x, angles.y);
} }
}//namespace gtx
}//namespace glm }//namespace glm

View File

@ -45,8 +45,7 @@
# pragma message("GLM: GLM_GTX_extend extension included") # pragma message("GLM: GLM_GTX_extend extension included")
#endif #endif
namespace glm{ namespace glm
namespace gtx
{ {
/// @addtogroup gtx_extend /// @addtogroup gtx_extend
/// @{ /// @{
@ -60,7 +59,6 @@ namespace gtx
typename genType::value_type const Length); typename genType::value_type const Length);
/// @} /// @}
}//namespace gtx
}//namespace glm }//namespace glm
#include "extend.inl" #include "extend.inl"

View File

@ -8,7 +8,6 @@
/////////////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////////////
namespace glm{ namespace glm{
namespace gtx{
template <typename genType> template <typename genType>
genType extend genType extend
@ -54,5 +53,4 @@ detail::tvec4<valType> extend
return Origin + (Source - Origin) * Distance; return Origin + (Source - Origin) * Distance;
} }
}//namespace gtx
}//namespace glm }//namespace glm

View File

@ -47,8 +47,7 @@
# pragma message("GLM: GLM_GTX_extented_min_max extension included") # pragma message("GLM: GLM_GTX_extented_min_max extension included")
#endif #endif
namespace glm{ namespace glm
namespace gtx
{ {
/// @addtogroup gtx_extented_min_max /// @addtogroup gtx_extented_min_max
/// @{ /// @{
@ -188,7 +187,6 @@ namespace gtx
C<T> const & w); C<T> const & w);
/// @} /// @}
}//namespace gtx
}//namespace glm }//namespace glm
#include "extented_min_max.inl" #include "extented_min_max.inl"

View File

@ -7,8 +7,7 @@
// File : gtx_extented_min_max.inl // File : gtx_extented_min_max.inl
/////////////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////////////
namespace glm{ namespace glm
namespace gtx
{ {
template <typename T> template <typename T>
GLM_FUNC_QUALIFIER T min( GLM_FUNC_QUALIFIER T min(
@ -176,5 +175,4 @@ namespace gtx
return glm::max(glm::max(x, y), glm::max(z, w)); return glm::max(glm::max(x, y), glm::max(z, w));
} }
}//namespace gtx
}//namespace glm }//namespace glm

View File

@ -47,8 +47,7 @@
# pragma message("GLM: GLM_GTX_fast_exponential extension included") # pragma message("GLM: GLM_GTX_fast_exponential extension included")
#endif #endif
namespace glm{ namespace glm
namespace gtx
{ {
/// @addtogroup gtx_fast_exponential /// @addtogroup gtx_fast_exponential
/// @{ /// @{
@ -93,7 +92,6 @@ namespace gtx
T fastLn(const T& x); T fastLn(const T& x);
/// @} /// @}
}//namespace gtx
}//namespace glm }//namespace glm
#include "fast_exponential.inl" #include "fast_exponential.inl"

View File

@ -8,285 +8,283 @@
/////////////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////////////
namespace glm{ namespace glm{
namespace gtx
// fastPow:
template <typename T>
GLM_FUNC_QUALIFIER T fastPow(const T x, const T y)
{ {
// fastPow: return exp(y * log(x));
template <typename T> }
GLM_FUNC_QUALIFIER T fastPow(const T x, const T y)
{
return exp(y * log(x));
}
template <typename T> template <typename T>
GLM_FUNC_QUALIFIER detail::tvec2<T> fastPow( GLM_FUNC_QUALIFIER detail::tvec2<T> fastPow(
const detail::tvec2<T>& x, const detail::tvec2<T>& x,
const detail::tvec2<T>& y) const detail::tvec2<T>& y)
{ {
return detail::tvec2<T>( return detail::tvec2<T>(
fastPow(x.x, y.x), fastPow(x.x, y.x),
fastPow(x.y, y.y)); fastPow(x.y, y.y));
} }
template <typename T> template <typename T>
GLM_FUNC_QUALIFIER detail::tvec3<T> fastPow( GLM_FUNC_QUALIFIER detail::tvec3<T> fastPow(
const detail::tvec3<T>& x, const detail::tvec3<T>& x,
const detail::tvec3<T>& y) const detail::tvec3<T>& y)
{ {
return detail::tvec3<T>( return detail::tvec3<T>(
fastPow(x.x, y.x), fastPow(x.x, y.x),
fastPow(x.y, y.y), fastPow(x.y, y.y),
fastPow(x.z, y.z)); fastPow(x.z, y.z));
} }
template <typename T> template <typename T>
GLM_FUNC_QUALIFIER detail::tvec4<T> fastPow( GLM_FUNC_QUALIFIER detail::tvec4<T> fastPow(
const detail::tvec4<T>& x, const detail::tvec4<T>& x,
const detail::tvec4<T>& y) const detail::tvec4<T>& y)
{ {
return detail::tvec4<T>( return detail::tvec4<T>(
fastPow(x.x, y.x), fastPow(x.x, y.x),
fastPow(x.y, y.y), fastPow(x.y, y.y),
fastPow(x.z, y.z), fastPow(x.z, y.z),
fastPow(x.w, y.w)); fastPow(x.w, y.w));
} }
template <typename T> template <typename T>
GLM_FUNC_QUALIFIER T fastPow(const T x, int y) GLM_FUNC_QUALIFIER T fastPow(const T x, int y)
{ {
T f = T(1); T f = T(1);
for(int i = 0; i < y; ++i) for(int i = 0; i < y; ++i)
f *= x; f *= x;
return f; return f;
} }
template <typename T> template <typename T>
GLM_FUNC_QUALIFIER detail::tvec2<T> fastPow( GLM_FUNC_QUALIFIER detail::tvec2<T> fastPow(
const detail::tvec2<T>& x, const detail::tvec2<T>& x,
const detail::tvec2<int>& y) const detail::tvec2<int>& y)
{ {
return detail::tvec2<T>( return detail::tvec2<T>(
fastPow(x.x, y.x), fastPow(x.x, y.x),
fastPow(x.y, y.y)); fastPow(x.y, y.y));
} }
template <typename T> template <typename T>
GLM_FUNC_QUALIFIER detail::tvec3<T> fastPow( GLM_FUNC_QUALIFIER detail::tvec3<T> fastPow(
const detail::tvec3<T>& x, const detail::tvec3<T>& x,
const detail::tvec3<int>& y) const detail::tvec3<int>& y)
{ {
return detail::tvec3<T>( return detail::tvec3<T>(
fastPow(x.x, y.x), fastPow(x.x, y.x),
fastPow(x.y, y.y), fastPow(x.y, y.y),
fastPow(x.z, y.z)); fastPow(x.z, y.z));
} }
template <typename T> template <typename T>
GLM_FUNC_QUALIFIER detail::tvec4<T> fastPow( GLM_FUNC_QUALIFIER detail::tvec4<T> fastPow(
const detail::tvec4<T>& x, const detail::tvec4<T>& x,
const detail::tvec4<int>& y) const detail::tvec4<int>& y)
{ {
return detail::tvec4<T>( return detail::tvec4<T>(
fastPow(x.x, y.x), fastPow(x.x, y.x),
fastPow(x.y, y.y), fastPow(x.y, y.y),
fastPow(x.z, y.z), fastPow(x.z, y.z),
fastPow(x.w, y.w)); fastPow(x.w, y.w));
} }
// fastExp // fastExp
// Note: This function provides accurate results only for value between -1 and 1, else avoid it. // Note: This function provides accurate results only for value between -1 and 1, else avoid it.
template <typename T> template <typename T>
GLM_FUNC_QUALIFIER T fastExp(const T x) GLM_FUNC_QUALIFIER T fastExp(const T x)
{ {
// This has a better looking and same performance in release mode than the following code. However, in debug mode it's slower. // This has a better looking and same performance in release mode than the following code. However, in debug mode it's slower.
// return 1.0f + x * (1.0f + x * 0.5f * (1.0f + x * 0.3333333333f * (1.0f + x * 0.25 * (1.0f + x * 0.2f)))); // return 1.0f + x * (1.0f + x * 0.5f * (1.0f + x * 0.3333333333f * (1.0f + x * 0.25 * (1.0f + x * 0.2f))));
T x2 = x * x; T x2 = x * x;
T x3 = x2 * x; T x3 = x2 * x;
T x4 = x3 * x; T x4 = x3 * x;
T x5 = x4 * x; T x5 = x4 * x;
return T(1) + x + (x2 * T(0.5)) + (x3 * T(0.1666666667)) + (x4 * T(0.041666667)) + (x5 * T(0.008333333333)); return T(1) + x + (x2 * T(0.5)) + (x3 * T(0.1666666667)) + (x4 * T(0.041666667)) + (x5 * T(0.008333333333));
} }
/* // Try to handle all values of float... but often shower than std::exp, glm::floor and the loop kill the performance /* // Try to handle all values of float... but often shower than std::exp, glm::floor and the loop kill the performance
GLM_FUNC_QUALIFIER float fastExp(float x) GLM_FUNC_QUALIFIER float fastExp(float x)
{ {
const float e = 2.718281828f; const float e = 2.718281828f;
const float IntegerPart = floor(x); const float IntegerPart = floor(x);
const float FloatPart = x - IntegerPart; const float FloatPart = x - IntegerPart;
float z = 1.f; float z = 1.f;
for(int i = 0; i < int(IntegerPart); ++i) for(int i = 0; i < int(IntegerPart); ++i)
z *= e; z *= e;
const float x2 = FloatPart * FloatPart; const float x2 = FloatPart * FloatPart;
const float x3 = x2 * FloatPart; const float x3 = x2 * FloatPart;
const float x4 = x3 * FloatPart; const float x4 = x3 * FloatPart;
const float x5 = x4 * FloatPart; const float x5 = x4 * FloatPart;
return z * (1.0f + FloatPart + (x2 * 0.5f) + (x3 * 0.1666666667f) + (x4 * 0.041666667f) + (x5 * 0.008333333333f)); return z * (1.0f + FloatPart + (x2 * 0.5f) + (x3 * 0.1666666667f) + (x4 * 0.041666667f) + (x5 * 0.008333333333f));
} }
// Increase accuracy on number bigger that 1 and smaller than -1 but it's not enough for high and negative numbers // Increase accuracy on number bigger that 1 and smaller than -1 but it's not enough for high and negative numbers
GLM_FUNC_QUALIFIER float fastExp(float x) GLM_FUNC_QUALIFIER float fastExp(float x)
{ {
// This has a better looking and same performance in release mode than the following code. However, in debug mode it's slower. // This has a better looking and same performance in release mode than the following code. However, in debug mode it's slower.
// return 1.0f + x * (1.0f + x * 0.5f * (1.0f + x * 0.3333333333f * (1.0f + x * 0.25 * (1.0f + x * 0.2f)))); // return 1.0f + x * (1.0f + x * 0.5f * (1.0f + x * 0.3333333333f * (1.0f + x * 0.25 * (1.0f + x * 0.2f))));
float x2 = x * x; float x2 = x * x;
float x3 = x2 * x; float x3 = x2 * x;
float x4 = x3 * x; float x4 = x3 * x;
float x5 = x4 * x; float x5 = x4 * x;
float x6 = x5 * x; float x6 = x5 * x;
float x7 = x6 * x; float x7 = x6 * x;
float x8 = x7 * x; float x8 = x7 * x;
return 1.0f + x + (x2 * 0.5f) + (x3 * 0.1666666667f) + (x4 * 0.041666667f) + (x5 * 0.008333333333f)+ (x6 * 0.00138888888888f) + (x7 * 0.000198412698f) + (x8 * 0.0000248015873f);; return 1.0f + x + (x2 * 0.5f) + (x3 * 0.1666666667f) + (x4 * 0.041666667f) + (x5 * 0.008333333333f)+ (x6 * 0.00138888888888f) + (x7 * 0.000198412698f) + (x8 * 0.0000248015873f);;
} }
*/ */
template <typename T> template <typename T>
GLM_FUNC_QUALIFIER detail::tvec2<T> fastExp( GLM_FUNC_QUALIFIER detail::tvec2<T> fastExp(
const detail::tvec2<T>& x) const detail::tvec2<T>& x)
{ {
return detail::tvec2<T>( return detail::tvec2<T>(
fastExp(x.x), fastExp(x.x),
fastExp(x.y)); fastExp(x.y));
} }
template <typename T> template <typename T>
GLM_FUNC_QUALIFIER detail::tvec3<T> fastExp( GLM_FUNC_QUALIFIER detail::tvec3<T> fastExp(
const detail::tvec3<T>& x) const detail::tvec3<T>& x)
{ {
return detail::tvec3<T>( return detail::tvec3<T>(
fastExp(x.x), fastExp(x.x),
fastExp(x.y), fastExp(x.y),
fastExp(x.z)); fastExp(x.z));
} }
template <typename T> template <typename T>
GLM_FUNC_QUALIFIER detail::tvec4<T> fastExp( GLM_FUNC_QUALIFIER detail::tvec4<T> fastExp(
const detail::tvec4<T>& x) const detail::tvec4<T>& x)
{ {
return detail::tvec4<T>( return detail::tvec4<T>(
fastExp(x.x), fastExp(x.x),
fastExp(x.y), fastExp(x.y),
fastExp(x.z), fastExp(x.z),
fastExp(x.w)); fastExp(x.w));
} }
// fastLog // fastLog
template <typename T> template <typename T>
GLM_FUNC_QUALIFIER T fastLog(const T x) GLM_FUNC_QUALIFIER T fastLog(const T x)
{ {
return std::log(x); return std::log(x);
} }
/* Slower than the VC7.1 function... /* Slower than the VC7.1 function...
GLM_FUNC_QUALIFIER float fastLog(float x) GLM_FUNC_QUALIFIER float fastLog(float x)
{ {
float y1 = (x - 1.0f) / (x + 1.0f); float y1 = (x - 1.0f) / (x + 1.0f);
float y2 = y1 * y1; float y2 = y1 * y1;
return 2.0f * y1 * (1.0f + y2 * (0.3333333333f + y2 * (0.2f + y2 * 0.1428571429f))); return 2.0f * y1 * (1.0f + y2 * (0.3333333333f + y2 * (0.2f + y2 * 0.1428571429f)));
} }
*/ */
template <typename T> template <typename T>
GLM_FUNC_QUALIFIER detail::tvec2<T> fastLog( GLM_FUNC_QUALIFIER detail::tvec2<T> fastLog(
const detail::tvec2<T>& x) const detail::tvec2<T>& x)
{ {
return detail::tvec2<T>( return detail::tvec2<T>(
fastLog(x.x), fastLog(x.x),
fastLog(x.y)); fastLog(x.y));
} }
template <typename T> template <typename T>
GLM_FUNC_QUALIFIER detail::tvec3<T> fastLog( GLM_FUNC_QUALIFIER detail::tvec3<T> fastLog(
const detail::tvec3<T>& x) const detail::tvec3<T>& x)
{ {
return detail::tvec3<T>( return detail::tvec3<T>(
fastLog(x.x), fastLog(x.x),
fastLog(x.y), fastLog(x.y),
fastLog(x.z)); fastLog(x.z));
} }
template <typename T> template <typename T>
GLM_FUNC_QUALIFIER detail::tvec4<T> fastLog( GLM_FUNC_QUALIFIER detail::tvec4<T> fastLog(
const detail::tvec4<T>& x) const detail::tvec4<T>& x)
{ {
return detail::tvec4<T>( return detail::tvec4<T>(
fastLog(x.x), fastLog(x.x),
fastLog(x.y), fastLog(x.y),
fastLog(x.z), fastLog(x.z),
fastLog(x.w)); fastLog(x.w));
} }
//fastExp2, ln2 = 0.69314718055994530941723212145818f //fastExp2, ln2 = 0.69314718055994530941723212145818f
template <typename T> template <typename T>
GLM_FUNC_QUALIFIER T fastExp2(const T x) GLM_FUNC_QUALIFIER T fastExp2(const T x)
{ {
return fastExp(0.69314718055994530941723212145818f * x); return fastExp(0.69314718055994530941723212145818f * x);
} }
template <typename T> template <typename T>
GLM_FUNC_QUALIFIER detail::tvec2<T> fastExp2( GLM_FUNC_QUALIFIER detail::tvec2<T> fastExp2(
const detail::tvec2<T>& x) const detail::tvec2<T>& x)
{ {
return detail::tvec2<T>( return detail::tvec2<T>(
fastExp2(x.x), fastExp2(x.x),
fastExp2(x.y)); fastExp2(x.y));
} }
template <typename T> template <typename T>
GLM_FUNC_QUALIFIER detail::tvec3<T> fastExp2( GLM_FUNC_QUALIFIER detail::tvec3<T> fastExp2(
const detail::tvec3<T>& x) const detail::tvec3<T>& x)
{ {
return detail::tvec3<T>( return detail::tvec3<T>(
fastExp2(x.x), fastExp2(x.x),
fastExp2(x.y), fastExp2(x.y),
fastExp2(x.z)); fastExp2(x.z));
} }
template <typename T> template <typename T>
GLM_FUNC_QUALIFIER detail::tvec4<T> fastExp2( GLM_FUNC_QUALIFIER detail::tvec4<T> fastExp2(
const detail::tvec4<T>& x) const detail::tvec4<T>& x)
{ {
return detail::tvec4<T>( return detail::tvec4<T>(
fastExp2(x.x), fastExp2(x.x),
fastExp2(x.y), fastExp2(x.y),
fastExp2(x.z), fastExp2(x.z),
fastExp2(x.w)); fastExp2(x.w));
} }
// fastLog2, ln2 = 0.69314718055994530941723212145818f // fastLog2, ln2 = 0.69314718055994530941723212145818f
template <typename T> template <typename T>
GLM_FUNC_QUALIFIER T fastLog2(const T x) GLM_FUNC_QUALIFIER T fastLog2(const T x)
{ {
return fastLog(x) / 0.69314718055994530941723212145818f; return fastLog(x) / 0.69314718055994530941723212145818f;
} }
template <typename T> template <typename T>
GLM_FUNC_QUALIFIER detail::tvec2<T> fastLog2( GLM_FUNC_QUALIFIER detail::tvec2<T> fastLog2(
const detail::tvec2<T>& x) const detail::tvec2<T>& x)
{ {
return detail::tvec2<T>( return detail::tvec2<T>(
fastLog2(x.x), fastLog2(x.x),
fastLog2(x.y)); fastLog2(x.y));
} }
template <typename T> template <typename T>
GLM_FUNC_QUALIFIER detail::tvec3<T> fastLog2( GLM_FUNC_QUALIFIER detail::tvec3<T> fastLog2(
const detail::tvec3<T>& x) const detail::tvec3<T>& x)
{ {
return detail::tvec3<T>( return detail::tvec3<T>(
fastLog2(x.x), fastLog2(x.x),
fastLog2(x.y), fastLog2(x.y),
fastLog2(x.z)); fastLog2(x.z));
} }
template <typename T> template <typename T>
GLM_FUNC_QUALIFIER detail::tvec4<T> fastLog2( GLM_FUNC_QUALIFIER detail::tvec4<T> fastLog2(
const detail::tvec4<T>& x) const detail::tvec4<T>& x)
{ {
return detail::tvec4<T>( return detail::tvec4<T>(
fastLog2(x.x), fastLog2(x.x),
fastLog2(x.y), fastLog2(x.y),
fastLog2(x.z), fastLog2(x.z),
fastLog2(x.w)); fastLog2(x.w));
} }
}//namespace gtx
}//namespace glm }//namespace glm

View File

@ -47,8 +47,7 @@
# pragma message("GLM: GLM_GTX_fast_square_root extension included") # pragma message("GLM: GLM_GTX_fast_square_root extension included")
#endif #endif
namespace glm{ namespace glm
namespace gtx
{ {
/// @addtogroup gtx_fast_square_root /// @addtogroup gtx_fast_square_root
/// @{ /// @{
@ -79,7 +78,6 @@ namespace gtx
genType fastNormalize(genType const & x); genType fastNormalize(genType const & x);
/// @} /// @}
}// namespace gtx
}// namespace glm }// namespace glm
#include "fast_square_root.inl" #include "fast_square_root.inl"

View File

@ -8,7 +8,6 @@
/////////////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////////////
namespace glm{ namespace glm{
namespace gtx{
// fastSqrt // fastSqrt
template <typename genType> template <typename genType>
@ -231,5 +230,4 @@ GLM_FUNC_QUALIFIER detail::tvec4<valType> fastNormalize
return x * fastInverseSqrt(sqr); return x * fastInverseSqrt(sqr);
} }
}//namespace gtx
}//namespace glm }//namespace glm

View File

@ -45,8 +45,7 @@
# pragma message("GLM: GLM_GTX_fast_trigonometry extension included") # pragma message("GLM: GLM_GTX_fast_trigonometry extension included")
#endif #endif
namespace glm{ namespace glm
namespace gtx
{ {
/// @addtogroup gtx_fast_trigonometry /// @addtogroup gtx_fast_trigonometry
/// @{ /// @{
@ -94,7 +93,6 @@ namespace gtx
T fastAtan(const T& angle); T fastAtan(const T& angle);
/// @} /// @}
}//namespace gtx
}//namespace glm }//namespace glm
#include "fast_trigonometry.inl" #include "fast_trigonometry.inl"

View File

@ -8,263 +8,261 @@
/////////////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////////////
namespace glm{ namespace glm{
namespace gtx
// sin
template <typename T>
GLM_FUNC_QUALIFIER T fastSin(const T x)
{ {
// sin return x - ((x * x * x) / T(6)) + ((x * x * x * x * x) / T(120)) - ((x * x * x * x * x * x * x) / T(5040));
template <typename T> }
GLM_FUNC_QUALIFIER T fastSin(const T x)
{
return x - ((x * x * x) / T(6)) + ((x * x * x * x * x) / T(120)) - ((x * x * x * x * x * x * x) / T(5040));
}
template <typename T> template <typename T>
GLM_FUNC_QUALIFIER detail::tvec2<T> fastSin( GLM_FUNC_QUALIFIER detail::tvec2<T> fastSin(
const detail::tvec2<T>& x) const detail::tvec2<T>& x)
{ {
return detail::tvec2<T>( return detail::tvec2<T>(
fastSin(x.x), fastSin(x.x),
fastSin(x.y)); fastSin(x.y));
} }
template <typename T> template <typename T>
GLM_FUNC_QUALIFIER detail::tvec3<T> fastSin( GLM_FUNC_QUALIFIER detail::tvec3<T> fastSin(
const detail::tvec3<T>& x) const detail::tvec3<T>& x)
{ {
return detail::tvec3<T>( return detail::tvec3<T>(
fastSin(x.x), fastSin(x.x),
fastSin(x.y), fastSin(x.y),
fastSin(x.z)); fastSin(x.z));
} }
template <typename T> template <typename T>
GLM_FUNC_QUALIFIER detail::tvec4<T> fastSin( GLM_FUNC_QUALIFIER detail::tvec4<T> fastSin(
const detail::tvec4<T>& x) const detail::tvec4<T>& x)
{ {
return detail::tvec4<T>( return detail::tvec4<T>(
fastSin(x.x), fastSin(x.x),
fastSin(x.y), fastSin(x.y),
fastSin(x.z), fastSin(x.z),
fastSin(x.w)); fastSin(x.w));
} }
// cos // cos
template <typename T> template <typename T>
GLM_FUNC_QUALIFIER T fastCos(const T x) GLM_FUNC_QUALIFIER T fastCos(const T x)
{ {
return T(1) - (x * x * T(0.5)) + (x * x * x * x * T(0.041666666666)) - (x * x * x * x * x * x * T(0.00138888888888)); return T(1) - (x * x * T(0.5)) + (x * x * x * x * T(0.041666666666)) - (x * x * x * x * x * x * T(0.00138888888888));
} }
template <typename T> template <typename T>
GLM_FUNC_QUALIFIER detail::tvec2<T> fastCos( GLM_FUNC_QUALIFIER detail::tvec2<T> fastCos(
const detail::tvec2<T>& x) const detail::tvec2<T>& x)
{ {
return detail::tvec2<T>( return detail::tvec2<T>(
fastCos(x.x), fastCos(x.x),
fastCos(x.y)); fastCos(x.y));
} }
template <typename T> template <typename T>
GLM_FUNC_QUALIFIER detail::tvec3<T> fastCos( GLM_FUNC_QUALIFIER detail::tvec3<T> fastCos(
const detail::tvec3<T>& x) const detail::tvec3<T>& x)
{ {
return detail::tvec3<T>( return detail::tvec3<T>(
fastCos(x.x), fastCos(x.x),
fastCos(x.y), fastCos(x.y),
fastCos(x.z)); fastCos(x.z));
} }
template <typename T> template <typename T>
GLM_FUNC_QUALIFIER detail::tvec4<T> fastCos( GLM_FUNC_QUALIFIER detail::tvec4<T> fastCos(
const detail::tvec4<T>& x) const detail::tvec4<T>& x)
{ {
return detail::tvec4<T>( return detail::tvec4<T>(
fastCos(x.x), fastCos(x.x),
fastCos(x.y), fastCos(x.y),
fastCos(x.z), fastCos(x.z),
fastCos(x.w)); fastCos(x.w));
} }
// tan // tan
template <typename T> template <typename T>
GLM_FUNC_QUALIFIER T fastTan(const T x) GLM_FUNC_QUALIFIER T fastTan(const T x)
{ {
return x + (x * x * x * T(0.3333333333)) + (x * x * x * x * x * T(0.1333333333333)) + (x * x * x * x * x * x * x * T(0.0539682539)); return x + (x * x * x * T(0.3333333333)) + (x * x * x * x * x * T(0.1333333333333)) + (x * x * x * x * x * x * x * T(0.0539682539));
} }
template <typename T> template <typename T>
GLM_FUNC_QUALIFIER detail::tvec2<T> fastTan( GLM_FUNC_QUALIFIER detail::tvec2<T> fastTan(
const detail::tvec2<T>& x) const detail::tvec2<T>& x)
{ {
return detail::tvec2<T>( return detail::tvec2<T>(
fastTan(x.x), fastTan(x.x),
fastTan(x.y)); fastTan(x.y));
} }
template <typename T> template <typename T>
GLM_FUNC_QUALIFIER detail::tvec3<T> fastTan( GLM_FUNC_QUALIFIER detail::tvec3<T> fastTan(
const detail::tvec3<T>& x) const detail::tvec3<T>& x)
{ {
return detail::tvec3<T>( return detail::tvec3<T>(
fastTan(x.x), fastTan(x.x),
fastTan(x.y), fastTan(x.y),
fastTan(x.z)); fastTan(x.z));
} }
template <typename T> template <typename T>
GLM_FUNC_QUALIFIER detail::tvec4<T> fastTan( GLM_FUNC_QUALIFIER detail::tvec4<T> fastTan(
const detail::tvec4<T>& x) const detail::tvec4<T>& x)
{ {
return detail::tvec4<T>( return detail::tvec4<T>(
fastTan(x.x), fastTan(x.x),
fastTan(x.y), fastTan(x.y),
fastTan(x.z), fastTan(x.z),
fastTan(x.w)); fastTan(x.w));
} }
// asin // asin
template <typename T> template <typename T>
GLM_FUNC_QUALIFIER T fastAsin(const T x) GLM_FUNC_QUALIFIER T fastAsin(const T x)
{ {
return x + (x * x * x * T(0.166666667)) + (x * x * x * x * x * T(0.075)) + (x * x * x * x * x * x * x * T(0.0446428571)) + (x * x * x * x * x * x * x * x * x * T(0.0303819444));// + (x * x * x * x * x * x * x * x * x * x * x * T(0.022372159)); return x + (x * x * x * T(0.166666667)) + (x * x * x * x * x * T(0.075)) + (x * x * x * x * x * x * x * T(0.0446428571)) + (x * x * x * x * x * x * x * x * x * T(0.0303819444));// + (x * x * x * x * x * x * x * x * x * x * x * T(0.022372159));
} }
template <typename T> detail::tvec2<T> fastAsin( template <typename T> detail::tvec2<T> fastAsin(
const detail::tvec2<T>& x) const detail::tvec2<T>& x)
{ {
return detail::tvec2<T>( return detail::tvec2<T>(
fastAsin(x.x), fastAsin(x.x),
fastAsin(x.y)); fastAsin(x.y));
} }
template <typename T> detail::tvec3<T> fastAsin( template <typename T> detail::tvec3<T> fastAsin(
const detail::tvec3<T>& x) const detail::tvec3<T>& x)
{ {
return detail::tvec3<T>( return detail::tvec3<T>(
fastAsin(x.x), fastAsin(x.x),
fastAsin(x.y), fastAsin(x.y),
fastAsin(x.z)); fastAsin(x.z));
} }
template <typename T> detail::tvec4<T> fastAsin( template <typename T> detail::tvec4<T> fastAsin(
const detail::tvec4<T>& x) const detail::tvec4<T>& x)
{ {
return detail::tvec4<T>( return detail::tvec4<T>(
fastAsin(x.x), fastAsin(x.x),
fastAsin(x.y), fastAsin(x.y),
fastAsin(x.z), fastAsin(x.z),
fastAsin(x.w)); fastAsin(x.w));
} }
// acos // acos
template <typename T> template <typename T>
GLM_FUNC_QUALIFIER T fastAcos(const T x) GLM_FUNC_QUALIFIER T fastAcos(const T x)
{ {
return T(1.5707963267948966192313216916398) - fastAsin(x); //(PI / 2) return T(1.5707963267948966192313216916398) - fastAsin(x); //(PI / 2)
} }
template <typename T> detail::tvec2<T> fastAcos( template <typename T> detail::tvec2<T> fastAcos(
const detail::tvec2<T>& x) const detail::tvec2<T>& x)
{ {
return detail::tvec2<T>( return detail::tvec2<T>(
fastAcos(x.x), fastAcos(x.x),
fastAcos(x.y)); fastAcos(x.y));
} }
template <typename T> detail::tvec3<T> fastAcos( template <typename T> detail::tvec3<T> fastAcos(
const detail::tvec3<T>& x) const detail::tvec3<T>& x)
{ {
return detail::tvec3<T>( return detail::tvec3<T>(
fastAcos(x.x), fastAcos(x.x),
fastAcos(x.y), fastAcos(x.y),
fastAcos(x.z)); fastAcos(x.z));
} }
template <typename T> detail::tvec4<T> fastAcos( template <typename T> detail::tvec4<T> fastAcos(
const detail::tvec4<T>& x) const detail::tvec4<T>& x)
{ {
return detail::tvec4<T>( return detail::tvec4<T>(
fastAcos(x.x), fastAcos(x.x),
fastAcos(x.y), fastAcos(x.y),
fastAcos(x.z), fastAcos(x.z),
fastAcos(x.w)); fastAcos(x.w));
} }
// atan // atan
template <typename T> template <typename T>
GLM_FUNC_QUALIFIER T fastAtan(const T y, const T x) GLM_FUNC_QUALIFIER T fastAtan(const T y, const T x)
{ {
T sgn = sign(y) * sign(x); T sgn = sign(y) * sign(x);
return abs(fastAtan(y / x)) * sgn; return abs(fastAtan(y / x)) * sgn;
} }
template <typename T> template <typename T>
GLM_FUNC_QUALIFIER detail::tvec2<T> fastAtan( GLM_FUNC_QUALIFIER detail::tvec2<T> fastAtan(
const detail::tvec2<T>& y, const detail::tvec2<T>& y,
const detail::tvec2<T>& x) const detail::tvec2<T>& x)
{ {
return detail::tvec2<T>( return detail::tvec2<T>(
fastAtan(y.x, x.x), fastAtan(y.x, x.x),
fastAtan(y.y, x.y)); fastAtan(y.y, x.y));
} }
template <typename T> template <typename T>
GLM_FUNC_QUALIFIER detail::tvec3<T> fastAtan( GLM_FUNC_QUALIFIER detail::tvec3<T> fastAtan(
const detail::tvec3<T>& y, const detail::tvec3<T>& y,
const detail::tvec3<T>& x) const detail::tvec3<T>& x)
{ {
return detail::tvec3<T>( return detail::tvec3<T>(
fastAtan(y.x, x.x), fastAtan(y.x, x.x),
fastAtan(y.y, x.y), fastAtan(y.y, x.y),
fastAtan(y.z, x.z)); fastAtan(y.z, x.z));
} }
template <typename T> template <typename T>
GLM_FUNC_QUALIFIER detail::tvec4<T> fastAtan( GLM_FUNC_QUALIFIER detail::tvec4<T> fastAtan(
const detail::tvec4<T>& y, const detail::tvec4<T>& y,
const detail::tvec4<T>& x) const detail::tvec4<T>& x)
{ {
return detail::tvec4<T>( return detail::tvec4<T>(
fastAtan(y.x, x.x), fastAtan(y.x, x.x),
fastAtan(y.y, x.y), fastAtan(y.y, x.y),
fastAtan(y.z, x.z), fastAtan(y.z, x.z),
fastAtan(y.w, x.w)); fastAtan(y.w, x.w));
} }
template <typename T> template <typename T>
GLM_FUNC_QUALIFIER T fastAtan(const T x) GLM_FUNC_QUALIFIER T fastAtan(const T x)
{ {
return x - (x * x * x * T(0.333333333333)) + (x * x * x * x * x * T(0.2)) - (x * x * x * x * x * x * x * T(0.1428571429)) + (x * x * x * x * x * x * x * x * x * T(0.111111111111)) - (x * x * x * x * x * x * x * x * x * x * x * T(0.0909090909)); return x - (x * x * x * T(0.333333333333)) + (x * x * x * x * x * T(0.2)) - (x * x * x * x * x * x * x * T(0.1428571429)) + (x * x * x * x * x * x * x * x * x * T(0.111111111111)) - (x * x * x * x * x * x * x * x * x * x * x * T(0.0909090909));
} }
template <typename T> template <typename T>
GLM_FUNC_QUALIFIER detail::tvec2<T> fastAtan( GLM_FUNC_QUALIFIER detail::tvec2<T> fastAtan(
const detail::tvec2<T>& x) const detail::tvec2<T>& x)
{ {
return detail::tvec2<T>( return detail::tvec2<T>(
fastAtan(x.x), fastAtan(x.x),
fastAtan(x.y)); fastAtan(x.y));
} }
template <typename T> template <typename T>
GLM_FUNC_QUALIFIER detail::tvec3<T> fastAtan( GLM_FUNC_QUALIFIER detail::tvec3<T> fastAtan(
const detail::tvec3<T>& x) const detail::tvec3<T>& x)
{ {
return detail::tvec3<T>( return detail::tvec3<T>(
fastAtan(x.x), fastAtan(x.x),
fastAtan(x.y), fastAtan(x.y),
fastAtan(x.z)); fastAtan(x.z));
} }
template <typename T> template <typename T>
GLM_FUNC_QUALIFIER detail::tvec4<T> fastAtan( GLM_FUNC_QUALIFIER detail::tvec4<T> fastAtan(
const detail::tvec4<T>& x) const detail::tvec4<T>& x)
{ {
return detail::tvec4<T>( return detail::tvec4<T>(
fastAtan(x.x), fastAtan(x.x),
fastAtan(x.y), fastAtan(x.y),
fastAtan(x.z), fastAtan(x.z),
fastAtan(x.w)); fastAtan(x.w));
} }
}//namespace gtx
}//namespace glm }//namespace glm

View File

@ -46,8 +46,7 @@
# pragma message("GLM: GLM_GTX_gradient_paint extension included") # pragma message("GLM: GLM_GTX_gradient_paint extension included")
#endif #endif
namespace glm{ namespace glm
namespace gtx
{ {
/// @addtogroup gtx_gradient_paint /// @addtogroup gtx_gradient_paint
/// @{ /// @{
@ -70,7 +69,6 @@ namespace gtx
glm::detail::tvec2<valType> const & Position); glm::detail::tvec2<valType> const & Position);
/// @} /// @}
}// namespace gtx
}// namespace glm }// namespace glm
#include "gradient_paint.inl" #include "gradient_paint.inl"

View File

@ -8,35 +8,33 @@
/////////////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////////////
namespace glm{ namespace glm{
namespace gtx{
template <typename valType> template <typename valType>
valType radialGradient( valType radialGradient(
glm::detail::tvec2<valType> const & Center, glm::detail::tvec2<valType> const & Center,
valType const & Radius, valType const & Radius,
glm::detail::tvec2<valType> const & Focal, glm::detail::tvec2<valType> const & Focal,
glm::detail::tvec2<valType> const & Position) glm::detail::tvec2<valType> const & Position)
{ {
glm::detail::tvec2<valType> F = Focal - Center; glm::detail::tvec2<valType> F = Focal - Center;
glm::detail::tvec2<valType> D = Position - Focal; glm::detail::tvec2<valType> D = Position - Focal;
valType Radius2 = gtx::pow2(Radius); valType Radius2 = gtx::pow2(Radius);
valType Fx2 = gtx::pow2(F.x); valType Fx2 = gtx::pow2(F.x);
valType Fy2 = gtx::pow2(F.y); valType Fy2 = gtx::pow2(F.y);
valType Numerator = (D.x * F.x + D.y * F.y) + glm::sqrt(Radius2 * (gtx::pow2(D.x) + gtx::pow2(D.y)) - gtx::pow2(D.x * F.y - D.y * F.x)); valType Numerator = (D.x * F.x + D.y * F.y) + glm::sqrt(Radius2 * (gtx::pow2(D.x) + gtx::pow2(D.y)) - gtx::pow2(D.x * F.y - D.y * F.x));
valType Denominator = Radius2 - (Fx2 + Fy2); valType Denominator = Radius2 - (Fx2 + Fy2);
return Numerator / Denominator; return Numerator / Denominator;
} }
template <typename valType> template <typename valType>
valType linearGradient( valType linearGradient(
glm::detail::tvec2<valType> const & Point0, glm::detail::tvec2<valType> const & Point0,
glm::detail::tvec2<valType> const & Point1, glm::detail::tvec2<valType> const & Point1,
glm::detail::tvec2<valType> const & Position) glm::detail::tvec2<valType> const & Position)
{ {
glm::detail::tvec2<valType> Dist = Point1 - Point0; glm::detail::tvec2<valType> Dist = Point1 - Point0;
return (Dist.x * (Position.x - Point0.x) + Dist.y * (Position.y - Point0.y)) / glm::dot(Dist, Dist); return (Dist.x * (Position.x - Point0.x) + Dist.y * (Position.y - Point0.y)) / glm::dot(Dist, Dist);
} }
}//namespace gtx
}//namespace glm }//namespace glm

View File

@ -45,8 +45,7 @@
# pragma message("GLM: GLM_GTX_handed_coordinate_space extension included") # pragma message("GLM: GLM_GTX_handed_coordinate_space extension included")
#endif #endif
namespace glm{ namespace glm
namespace gtx
{ {
/// @addtogroup gtx_handed_coordinate_space /// @addtogroup gtx_handed_coordinate_space
/// @{ /// @{
@ -68,7 +67,6 @@ namespace gtx
detail::tvec3<T> const & normal); detail::tvec3<T> const & normal);
/// @} /// @}
}// namespace gtx
}// namespace glm }// namespace glm
#include "handed_coordinate_space.inl" #include "handed_coordinate_space.inl"

View File

@ -8,25 +8,23 @@
/////////////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////////////
namespace glm{ namespace glm{
namespace gtx
template <typename T>
GLM_FUNC_QUALIFIER bool rightHanded(
detail::tvec3<T> const & tangent,
detail::tvec3<T> const & binormal,
detail::tvec3<T> const & normal)
{ {
template <typename T> return dot(cross(normal, tangent), binormal) > T(0);
GLM_FUNC_QUALIFIER bool rightHanded( }
detail::tvec3<T> const & tangent,
detail::tvec3<T> const & binormal,
detail::tvec3<T> const & normal)
{
return dot(cross(normal, tangent), binormal) > T(0);
}
template <typename T> template <typename T>
GLM_FUNC_QUALIFIER bool leftHanded( GLM_FUNC_QUALIFIER bool leftHanded(
detail::tvec3<T> const & tangent, detail::tvec3<T> const & tangent,
detail::tvec3<T> const & binormal, detail::tvec3<T> const & binormal,
detail::tvec3<T> const & normal) detail::tvec3<T> const & normal)
{ {
return dot(cross(normal, tangent), binormal) < T(0); return dot(cross(normal, tangent), binormal) < T(0);
} }
}//namespace gtx
}//namespace glm }//namespace glm

View File

@ -46,8 +46,7 @@
# pragma message("GLM: GLM_GTX_inertia extension included") # pragma message("GLM: GLM_GTX_inertia extension included")
#endif #endif
namespace glm{ namespace glm
namespace gtx
{ {
/// @addtogroup gtx_inertia /// @addtogroup gtx_inertia
/// @{ /// @{
@ -109,7 +108,6 @@ namespace gtx
const T Radius); const T Radius);
/// @} /// @}
}// namespace gtx
}// namespace glm }// namespace glm
#include "inertia.inl" #include "inertia.inl"

View File

@ -8,94 +8,92 @@
/////////////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////////////
namespace glm{ namespace glm{
namespace gtx{
template <typename T> template <typename T>
GLM_FUNC_QUALIFIER detail::tmat3x3<T> boxInertia3( GLM_FUNC_QUALIFIER detail::tmat3x3<T> boxInertia3(
const T Mass, const T Mass,
const detail::tvec3<T>& Scale) const detail::tvec3<T>& Scale)
{ {
detail::tmat3x3<T> Result(T(1)); detail::tmat3x3<T> Result(T(1));
Result[0][0] = (Scale.y * Scale.y + Scale.z * Scale.z) * Mass / T(12); Result[0][0] = (Scale.y * Scale.y + Scale.z * Scale.z) * Mass / T(12);
Result[1][1] = (Scale.x * Scale.x + Scale.z * Scale.z) * Mass / T(12); Result[1][1] = (Scale.x * Scale.x + Scale.z * Scale.z) * Mass / T(12);
Result[2][2] = (Scale.x * Scale.x + Scale.y * Scale.y) * Mass / T(12); Result[2][2] = (Scale.x * Scale.x + Scale.y * Scale.y) * Mass / T(12);
return Result; return Result;
} }
template <typename T> template <typename T>
GLM_FUNC_QUALIFIER detail::tmat4x4<T> boxInertia4( GLM_FUNC_QUALIFIER detail::tmat4x4<T> boxInertia4(
const T Mass, const T Mass,
const detail::tvec3<T>& Scale) const detail::tvec3<T>& Scale)
{ {
detail::tmat4x4<T> Result(T(1)); detail::tmat4x4<T> Result(T(1));
Result[0][0] = (Scale.y * Scale.y + Scale.z * Scale.z) * Mass / T(12); Result[0][0] = (Scale.y * Scale.y + Scale.z * Scale.z) * Mass / T(12);
Result[1][1] = (Scale.x * Scale.x + Scale.z * Scale.z) * Mass / T(12); Result[1][1] = (Scale.x * Scale.x + Scale.z * Scale.z) * Mass / T(12);
Result[2][2] = (Scale.x * Scale.x + Scale.y * Scale.y) * Mass / T(12); Result[2][2] = (Scale.x * Scale.x + Scale.y * Scale.y) * Mass / T(12);
return Result; return Result;
} }
template <typename T> template <typename T>
GLM_FUNC_QUALIFIER detail::tmat3x3<T> diskInertia3( GLM_FUNC_QUALIFIER detail::tmat3x3<T> diskInertia3(
const T Mass, const T Mass,
const T Radius) const T Radius)
{ {
T a = Mass * Radius * Radius / T(2); T a = Mass * Radius * Radius / T(2);
detail::tmat3x3<T> Result(a); detail::tmat3x3<T> Result(a);
Result[2][2] *= T(2); Result[2][2] *= T(2);
return Result; return Result;
} }
template <typename T> template <typename T>
GLM_FUNC_QUALIFIER detail::tmat4x4<T> diskInertia4( GLM_FUNC_QUALIFIER detail::tmat4x4<T> diskInertia4(
const T Mass, const T Mass,
const T Radius) const T Radius)
{ {
T a = Mass * Radius * Radius / T(2); T a = Mass * Radius * Radius / T(2);
detail::tmat4x4<T> Result(a); detail::tmat4x4<T> Result(a);
Result[2][2] *= T(2); Result[2][2] *= T(2);
Result[3][3] = T(1); Result[3][3] = T(1);
return Result; return Result;
} }
template <typename T> template <typename T>
GLM_FUNC_QUALIFIER detail::tmat3x3<T> ballInertia3( GLM_FUNC_QUALIFIER detail::tmat3x3<T> ballInertia3(
const T Mass, const T Mass,
const T Radius) const T Radius)
{ {
T a = T(2) * Mass * Radius * Radius / T(5); T a = T(2) * Mass * Radius * Radius / T(5);
return detail::tmat3x3<T>(a); return detail::tmat3x3<T>(a);
} }
template <typename T> template <typename T>
GLM_FUNC_QUALIFIER detail::tmat4x4<T> ballInertia4( GLM_FUNC_QUALIFIER detail::tmat4x4<T> ballInertia4(
const T Mass, const T Mass,
const T Radius) const T Radius)
{ {
T a = T(2) * Mass * Radius * Radius / T(5); T a = T(2) * Mass * Radius * Radius / T(5);
detail::tmat4x4<T> Result(a); detail::tmat4x4<T> Result(a);
Result[3][3] = T(1); Result[3][3] = T(1);
return Result; return Result;
} }
template <typename T> template <typename T>
GLM_FUNC_QUALIFIER detail::tmat3x3<T> sphereInertia3( GLM_FUNC_QUALIFIER detail::tmat3x3<T> sphereInertia3(
const T Mass, const T Mass,
const T Radius) const T Radius)
{ {
T a = T(2) * Mass * Radius * Radius / T(3); T a = T(2) * Mass * Radius * Radius / T(3);
return detail::tmat3x3<T>(a); return detail::tmat3x3<T>(a);
} }
template <typename T> template <typename T>
GLM_FUNC_QUALIFIER detail::tmat4x4<T> sphereInertia4( GLM_FUNC_QUALIFIER detail::tmat4x4<T> sphereInertia4(
const T Mass, const T Mass,
const T Radius) const T Radius)
{ {
T a = T(2) * Mass * Radius * Radius / T(3); T a = T(2) * Mass * Radius * Radius / T(3);
detail::tmat4x4<T> Result(a); detail::tmat4x4<T> Result(a);
Result[3][3] = T(1); Result[3][3] = T(1);
return Result; return Result;
} }
}//namespace gtx
}//namespace glm }//namespace glm

View File

@ -47,8 +47,7 @@
# pragma message("GLM: GLM_GTX_int_10_10_10_2 extension included") # pragma message("GLM: GLM_GTX_int_10_10_10_2 extension included")
#endif #endif
namespace glm{ namespace glm
namespace gtx
{ {
/// @addtogroup gtx_int_10_10_10_2 /// @addtogroup gtx_int_10_10_10_2
/// @{ /// @{
@ -58,7 +57,6 @@ namespace gtx
dword uint10_10_10_2_cast(glm::vec4 const & v); dword uint10_10_10_2_cast(glm::vec4 const & v);
/// @} /// @}
}//namespace gtx
}//namespace glm }//namespace glm
#include "int_10_10_10_2.inl" #include "int_10_10_10_2.inl"

View File

@ -8,12 +8,10 @@
/////////////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////////////
namespace glm{ namespace glm{
namespace gtx{
GLM_FUNC_QUALIFIER dword uint10_10_10_2_cast(glm::vec4 const & v) GLM_FUNC_QUALIFIER dword uint10_10_10_2_cast(glm::vec4 const & v)
{ {
return dword(uint(v.x * 2047.f) << 0 | uint(v.y * 2047.f) << 10 | uint(v.z * 2047.f) << 20 | uint(v.w * 3.f) << 30); return dword(uint(v.x * 2047.f) << 0 | uint(v.y * 2047.f) << 10 | uint(v.z * 2047.f) << 20 | uint(v.w * 3.f) << 30);
} }
}//namespace gtx
}//namespace glm }//namespace glm

View File

@ -45,8 +45,7 @@
# pragma message("GLM: GLM_GTX_integer extension included") # pragma message("GLM: GLM_GTX_integer extension included")
#endif #endif
namespace glm{ namespace glm
namespace gtx
{ {
/// @addtogroup gtx_integer /// @addtogroup gtx_integer
/// @{ /// @{
@ -69,7 +68,6 @@ namespace gtx
genType factorial(genType const & x); genType factorial(genType const & x);
/// @} /// @}
}//namespace gtx
}//namespace glm }//namespace glm
#include "integer.inl" #include "integer.inl"

View File

@ -8,82 +8,80 @@
/////////////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////////////
namespace glm{ namespace glm{
namespace gtx{
// pow // pow
GLM_FUNC_QUALIFIER int pow(int x, int y) GLM_FUNC_QUALIFIER int pow(int x, int y)
{
if(y == 0)
return 1;
int result = x;
for(int i = 1; i < y; ++i)
result *= x;
return result;
}
// sqrt: From Christopher J. Musial, An integer square root, Graphics Gems, 1990, page 387
GLM_FUNC_QUALIFIER int sqrt(int x)
{
if(x <= 1) return x;
int NextTrial = x >> 1;
int CurrentAnswer;
do
{ {
if(y == 0) CurrentAnswer = NextTrial;
return 1; NextTrial = (NextTrial + x / NextTrial) >> 1;
int result = x; } while(NextTrial < CurrentAnswer);
for(int i = 1; i < y; ++i)
result *= x;
return result;
}
// sqrt: From Christopher J. Musial, An integer square root, Graphics Gems, 1990, page 387 return CurrentAnswer;
GLM_FUNC_QUALIFIER int sqrt(int x) }
{
if(x <= 1) return x;
int NextTrial = x >> 1; // mod
int CurrentAnswer; GLM_FUNC_QUALIFIER int mod(int x, int y)
{
return x - y * (x / y);
}
do // factorial (!12 max, integer only)
{ template <typename genType>
CurrentAnswer = NextTrial; GLM_FUNC_QUALIFIER genType factorial(genType const & x)
NextTrial = (NextTrial + x / NextTrial) >> 1; {
} while(NextTrial < CurrentAnswer); genType Temp = x;
genType Result;
for(Result = 1; Temp > 1; --Temp)
Result *= Temp;
return Result;
}
return CurrentAnswer; template <typename valType>
} GLM_FUNC_QUALIFIER detail::tvec2<valType> factorial(
detail::tvec2<valType> const & x)
{
return detail::tvec2<valType>(
factorial(x.x),
factorial(x.y));
}
// mod template <typename valType>
GLM_FUNC_QUALIFIER int mod(int x, int y) GLM_FUNC_QUALIFIER detail::tvec3<valType> factorial(
{ detail::tvec3<valType> const & x)
return x - y * (x / y); {
} return detail::tvec3<valType>(
factorial(x.x),
factorial(x.y),
factorial(x.z));
}
// factorial (!12 max, integer only) template <typename valType>
template <typename genType> GLM_FUNC_QUALIFIER detail::tvec4<valType> factorial(
GLM_FUNC_QUALIFIER genType factorial(genType const & x) detail::tvec4<valType> const & x)
{ {
genType Temp = x; return detail::tvec4<valType>(
genType Result; factorial(x.x),
for(Result = 1; Temp > 1; --Temp) factorial(x.y),
Result *= Temp; factorial(x.z),
return Result; factorial(x.w));
} }
template <typename valType>
GLM_FUNC_QUALIFIER detail::tvec2<valType> factorial(
detail::tvec2<valType> const & x)
{
return detail::tvec2<valType>(
factorial(x.x),
factorial(x.y));
}
template <typename valType>
GLM_FUNC_QUALIFIER detail::tvec3<valType> factorial(
detail::tvec3<valType> const & x)
{
return detail::tvec3<valType>(
factorial(x.x),
factorial(x.y),
factorial(x.z));
}
template <typename valType>
GLM_FUNC_QUALIFIER detail::tvec4<valType> factorial(
detail::tvec4<valType> const & x)
{
return detail::tvec4<valType>(
factorial(x.x),
factorial(x.y),
factorial(x.z),
factorial(x.w));
}
}//namespace gtx
}//namespace glm }//namespace glm

View File

@ -47,8 +47,7 @@
# pragma message("GLM: GLM_GTX_closest_point extension included") # pragma message("GLM: GLM_GTX_closest_point extension included")
#endif #endif
namespace glm{ namespace glm
namespace gtx
{ {
/// @addtogroup gtx_intersect /// @addtogroup gtx_intersect
/// @{ /// @{
@ -86,7 +85,6 @@ namespace gtx
genType & position, genType & normal); genType & position, genType & normal);
/// @} /// @}
}//namespace gtx
}//namespace glm }//namespace glm
#include "intersect.inl" #include "intersect.inl"

View File

@ -11,7 +11,6 @@
#include <limits> #include <limits>
namespace glm{ namespace glm{
namespace gtx{
template <typename genType> template <typename genType>
GLM_FUNC_QUALIFIER bool intersectRayTriangle GLM_FUNC_QUALIFIER bool intersectRayTriangle
@ -195,5 +194,4 @@ GLM_FUNC_QUALIFIER bool intersectLineSphere
return false; return false;
} }
}//namespace gtx
}//namespace glm }//namespace glm

View File

@ -45,8 +45,7 @@
# pragma message("GLM: GLM_GTX_log_base extension included") # pragma message("GLM: GLM_GTX_log_base extension included")
#endif #endif
namespace glm{ namespace glm
namespace gtx
{ {
/// @addtogroup gtx_log_base /// @addtogroup gtx_log_base
/// @{ /// @{
@ -59,7 +58,6 @@ namespace gtx
genType const & base); genType const & base);
/// @} /// @}
}//namespace gtx
}//namespace glm }//namespace glm
#include "log_base.inl" #include "log_base.inl"

View File

@ -8,7 +8,6 @@
/////////////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////////////
namespace glm{ namespace glm{
namespace gtx{
template <typename genType> template <typename genType>
GLM_FUNC_QUALIFIER genType log( GLM_FUNC_QUALIFIER genType log(
@ -86,5 +85,4 @@ GLM_FUNC_QUALIFIER detail::tvec4<valType> log(
log(v.w, base.w)); log(v.w, base.w));
} }
}//namespace gtx
}//namespace glm }//namespace glm

View File

@ -46,8 +46,7 @@
# pragma message("GLM: GLM_GTX_matrix_cross_product extension included") # pragma message("GLM: GLM_GTX_matrix_cross_product extension included")
#endif #endif
namespace glm{ namespace glm
namespace gtx
{ {
/// @addtogroup gtx_matrix_cross_product /// @addtogroup gtx_matrix_cross_product
/// @{ /// @{
@ -65,7 +64,6 @@ namespace gtx
detail::tvec3<T> const & x); detail::tvec3<T> const & x);
/// @} /// @}
}//namespace gtx
}//namespace glm }//namespace glm
#include "matrix_cross_product.inl" #include "matrix_cross_product.inl"

View File

@ -8,7 +8,6 @@
/////////////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////////////
namespace glm{ namespace glm{
namespace gtx{
template <typename T> template <typename T>
GLM_FUNC_QUALIFIER detail::tmat3x3<T> matrixCross3( GLM_FUNC_QUALIFIER detail::tmat3x3<T> matrixCross3(
@ -38,5 +37,4 @@ GLM_FUNC_QUALIFIER detail::tmat4x4<T> matrixCross4(
return Result; return Result;
} }
}//namespace gtx
}//namespace glm }//namespace glm

View File

@ -45,8 +45,7 @@
# pragma message("GLM: GLM_GTX_matrix_interpolation extension included") # pragma message("GLM: GLM_GTX_matrix_interpolation extension included")
#endif #endif
namespace glm{ namespace glm
namespace gtx
{ {
/// @addtogroup gtx_matrix_interpolation /// @addtogroup gtx_matrix_interpolation
/// @{ /// @{
@ -76,7 +75,6 @@ namespace gtx
T const delta); T const delta);
/// @} /// @}
}//namespace gtx
}//namespace glm }//namespace glm
#include "matrix_interpolation.inl" #include "matrix_interpolation.inl"

View File

@ -8,108 +8,106 @@
/////////////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////////////
namespace glm{ namespace glm{
namespace gtx{
template <typename T> template <typename T>
GLM_FUNC_QUALIFIER void axisAngle( GLM_FUNC_QUALIFIER void axisAngle(
detail::tmat4x4<T> const & mat, detail::tmat4x4<T> const & mat,
detail::tvec3<T> & axis, detail::tvec3<T> & axis,
T & angle) T & angle)
{ {
T epsilon = (T)0.01; T epsilon = (T)0.01;
T epsilon2 = (T)0.1; T epsilon2 = (T)0.1;
if ((fabs(mat[1][0] - mat[0][1]) < epsilon) && (fabs(mat[2][0] - mat[0][2]) < epsilon) && (fabs(mat[2][1] - mat[1][2]) < epsilon)) { if ((fabs(mat[1][0] - mat[0][1]) < epsilon) && (fabs(mat[2][0] - mat[0][2]) < epsilon) && (fabs(mat[2][1] - mat[1][2]) < epsilon)) {
if ((fabs(mat[1][0] + mat[0][1]) < epsilon2) && (fabs(mat[2][0] + mat[0][2]) < epsilon2) && (fabs(mat[2][1] + mat[1][2]) < epsilon2) && (fabs(mat[0][0] + mat[1][1] + mat[2][2] - (T)3.0) < epsilon2)) { if ((fabs(mat[1][0] + mat[0][1]) < epsilon2) && (fabs(mat[2][0] + mat[0][2]) < epsilon2) && (fabs(mat[2][1] + mat[1][2]) < epsilon2) && (fabs(mat[0][0] + mat[1][1] + mat[2][2] - (T)3.0) < epsilon2)) {
angle = (T)0.0; angle = (T)0.0;
axis.x = (T)1.0; axis.x = (T)1.0;
axis.y = (T)0.0; axis.y = (T)0.0;
axis.z = (T)0.0; axis.z = (T)0.0;
return;
}
angle = M_1_PI;
T xx = (mat[0][0] + (T)1.0) / (T)2.0;
T yy = (mat[1][1] + (T)1.0) / (T)2.0;
T zz = (mat[2][2] + (T)1.0) / (T)2.0;
T xy = (mat[1][0] + mat[0][1]) / (T)4.0;
T xz = (mat[2][0] + mat[0][2]) / (T)4.0;
T yz = (mat[2][1] + mat[1][2]) / (T)4.0;
if ((xx > yy) && (xx > zz)) {
if (xx < epsilon) {
axis.x = (T)0.0;
axis.y = (T)0.7071;
axis.z = (T)0.7071;
} else {
axis.x = sqrt(xx);
axis.y = xy / axis.x;
axis.z = xz / axis.x;
}
} else if (yy > zz) {
if (yy < epsilon) {
axis.x = (T)0.7071;
axis.y = (T)0.0;
axis.z = (T)0.7071;
} else {
axis.y = sqrt(yy);
axis.x = xy / axis.y;
axis.z = yz / axis.y;
}
} else {
if (zz < epsilon) {
axis.x = (T)0.7071;
axis.y = (T)0.7071;
axis.z = (T)0.0;
} else {
axis.z = sqrt(zz);
axis.x = xz / axis.z;
axis.y = yz / axis.z;
}
}
return; return;
} }
T s = sqrt((mat[2][1] - mat[1][2]) * (mat[2][1] - mat[1][2]) + (mat[2][0] - mat[0][2]) * (mat[2][0] - mat[0][2]) + (mat[1][0] - mat[0][1]) * (mat[1][0] - mat[0][1])); angle = M_1_PI;
if (glm::abs(s) < T(0.001)) T xx = (mat[0][0] + (T)1.0) / (T)2.0;
s = (T)1.0; T yy = (mat[1][1] + (T)1.0) / (T)2.0;
angle = acos((mat[0][0] + mat[1][1] + mat[2][2] - (T)1.0) / (T)2.0); T zz = (mat[2][2] + (T)1.0) / (T)2.0;
axis.x = (mat[1][2] - mat[2][1]) / s; T xy = (mat[1][0] + mat[0][1]) / (T)4.0;
axis.y = (mat[2][0] - mat[0][2]) / s; T xz = (mat[2][0] + mat[0][2]) / (T)4.0;
axis.z = (mat[0][1] - mat[1][0]) / s; T yz = (mat[2][1] + mat[1][2]) / (T)4.0;
if ((xx > yy) && (xx > zz)) {
if (xx < epsilon) {
axis.x = (T)0.0;
axis.y = (T)0.7071;
axis.z = (T)0.7071;
} else {
axis.x = sqrt(xx);
axis.y = xy / axis.x;
axis.z = xz / axis.x;
}
} else if (yy > zz) {
if (yy < epsilon) {
axis.x = (T)0.7071;
axis.y = (T)0.0;
axis.z = (T)0.7071;
} else {
axis.y = sqrt(yy);
axis.x = xy / axis.y;
axis.z = yz / axis.y;
}
} else {
if (zz < epsilon) {
axis.x = (T)0.7071;
axis.y = (T)0.7071;
axis.z = (T)0.0;
} else {
axis.z = sqrt(zz);
axis.x = xz / axis.z;
axis.y = yz / axis.z;
}
}
return;
} }
T s = sqrt((mat[2][1] - mat[1][2]) * (mat[2][1] - mat[1][2]) + (mat[2][0] - mat[0][2]) * (mat[2][0] - mat[0][2]) + (mat[1][0] - mat[0][1]) * (mat[1][0] - mat[0][1]));
if (glm::abs(s) < T(0.001))
s = (T)1.0;
angle = acos((mat[0][0] + mat[1][1] + mat[2][2] - (T)1.0) / (T)2.0);
axis.x = (mat[1][2] - mat[2][1]) / s;
axis.y = (mat[2][0] - mat[0][2]) / s;
axis.z = (mat[0][1] - mat[1][0]) / s;
}
template <typename T> template <typename T>
GLM_FUNC_QUALIFIER detail::tmat4x4<T> axisAngleMatrix( GLM_FUNC_QUALIFIER detail::tmat4x4<T> axisAngleMatrix(
detail::tvec3<T> const & axis, detail::tvec3<T> const & axis,
T const angle) T const angle)
{ {
T c = cos(angle); T c = cos(angle);
T s = sin(angle); T s = sin(angle);
T t = T(1) - c; T t = T(1) - c;
detail::tvec3<T> n = normalize(axis); detail::tvec3<T> n = normalize(axis);
return detail::tmat4x4<T>( return detail::tmat4x4<T>(
t * n.x * n.x + c, t * n.x * n.y + n.z * s, t * n.x * n.z - n.y * s, T(0), t * n.x * n.x + c, t * n.x * n.y + n.z * s, t * n.x * n.z - n.y * s, T(0),
t * n.x * n.y - n.z * s, t * n.y * n.y + c, t * n.y * n.z + n.x * s, T(0), t * n.x * n.y - n.z * s, t * n.y * n.y + c, t * n.y * n.z + n.x * s, T(0),
t * n.x * n.z + n.y * s, t * n.y * n.z - n.x * s, t * n.z * n.z + c, T(0), t * n.x * n.z + n.y * s, t * n.y * n.z - n.x * s, t * n.z * n.z + c, T(0),
T(0), T(0), T(0), T(1) T(0), T(0), T(0), T(1)
); );
} }
template <typename T> template <typename T>
GLM_FUNC_QUALIFIER detail::tmat4x4<T> interpolate( GLM_FUNC_QUALIFIER detail::tmat4x4<T> interpolate(
detail::tmat4x4<T> const & m1, detail::tmat4x4<T> const & m1,
detail::tmat4x4<T> const & m2, detail::tmat4x4<T> const & m2,
T const delta) T const delta)
{ {
detail::tmat4x4<T> dltRotation = m2 * transpose(m1); detail::tmat4x4<T> dltRotation = m2 * transpose(m1);
detail::tvec3<T> dltAxis; detail::tvec3<T> dltAxis;
T dltAngle; T dltAngle;
axisAngle(dltRotation, dltAxis, dltAngle); axisAngle(dltRotation, dltAxis, dltAngle);
detail::tmat4x4<T> out = axisAngleMatrix(dltAxis, dltAngle * delta) * rotationMatrix(m1); detail::tmat4x4<T> out = axisAngleMatrix(dltAxis, dltAngle * delta) * rotationMatrix(m1);
out[3][0] = m1[3][0] + delta * (m2[3][0] - m1[3][0]); out[3][0] = m1[3][0] + delta * (m2[3][0] - m1[3][0]);
out[3][1] = m1[3][1] + delta * (m2[3][1] - m1[3][1]); out[3][1] = m1[3][1] + delta * (m2[3][1] - m1[3][1]);
out[3][2] = m1[3][2] + delta * (m2[3][2] - m1[3][2]); out[3][2] = m1[3][2] + delta * (m2[3][2] - m1[3][2]);
return out; return out;
} }
}//namespace gtx
}//namespace glm }//namespace glm

View File

@ -46,10 +46,9 @@
# pragma message("GLM: GLM_GTX_matrix_major_storage extension included") # pragma message("GLM: GLM_GTX_matrix_major_storage extension included")
#endif #endif
namespace glm{ namespace glm
namespace gtx
{ {
/// \addtogroup gtx_matrix_major_storage /// @addtogroup gtx_matrix_major_storage
/// @{ /// @{
//! Build a row major matrix from row vectors. //! Build a row major matrix from row vectors.
@ -137,7 +136,6 @@ namespace gtx
const detail::tmat4x4<T>& m); const detail::tmat4x4<T>& m);
/// @} /// @}
}//namespace gtx
}//namespace glm }//namespace glm
#include "matrix_major_storage.inl" #include "matrix_major_storage.inl"

View File

@ -8,167 +8,165 @@
/////////////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////////////
namespace glm{ namespace glm{
namespace gtx{
template <typename T> template <typename T>
GLM_FUNC_QUALIFIER detail::tmat2x2<T> rowMajor2( GLM_FUNC_QUALIFIER detail::tmat2x2<T> rowMajor2(
const detail::tvec2<T>& v1, const detail::tvec2<T>& v1,
const detail::tvec2<T>& v2) const detail::tvec2<T>& v2)
{ {
detail::tmat2x2<T> Result; detail::tmat2x2<T> Result;
Result[0][0] = v1.x; Result[0][0] = v1.x;
Result[1][0] = v1.y; Result[1][0] = v1.y;
Result[0][1] = v2.x; Result[0][1] = v2.x;
Result[1][1] = v2.y; Result[1][1] = v2.y;
return Result; return Result;
} }
template <typename T> template <typename T>
GLM_FUNC_QUALIFIER detail::tmat2x2<T> rowMajor2( GLM_FUNC_QUALIFIER detail::tmat2x2<T> rowMajor2(
const detail::tmat2x2<T>& m) const detail::tmat2x2<T>& m)
{ {
detail::tmat2x2<T> Result; detail::tmat2x2<T> Result;
Result[0][0] = m[0][0]; Result[0][0] = m[0][0];
Result[0][1] = m[1][0]; Result[0][1] = m[1][0];
Result[1][0] = m[0][1]; Result[1][0] = m[0][1];
Result[1][1] = m[1][1]; Result[1][1] = m[1][1];
return Result; return Result;
} }
template <typename T> template <typename T>
GLM_FUNC_QUALIFIER detail::tmat3x3<T> rowMajor3( GLM_FUNC_QUALIFIER detail::tmat3x3<T> rowMajor3(
const detail::tvec3<T>& v1, const detail::tvec3<T>& v1,
const detail::tvec3<T>& v2, const detail::tvec3<T>& v2,
const detail::tvec3<T>& v3) const detail::tvec3<T>& v3)
{ {
detail::tmat3x3<T> Result; detail::tmat3x3<T> Result;
Result[0][0] = v1.x; Result[0][0] = v1.x;
Result[1][0] = v1.y; Result[1][0] = v1.y;
Result[2][0] = v1.z; Result[2][0] = v1.z;
Result[0][1] = v2.x; Result[0][1] = v2.x;
Result[1][1] = v2.y; Result[1][1] = v2.y;
Result[2][1] = v2.z; Result[2][1] = v2.z;
Result[0][2] = v3.x; Result[0][2] = v3.x;
Result[1][2] = v3.y; Result[1][2] = v3.y;
Result[2][2] = v3.z; Result[2][2] = v3.z;
return Result; return Result;
} }
template <typename T> template <typename T>
GLM_FUNC_QUALIFIER detail::tmat3x3<T> rowMajor3( GLM_FUNC_QUALIFIER detail::tmat3x3<T> rowMajor3(
const detail::tmat3x3<T>& m) const detail::tmat3x3<T>& m)
{ {
detail::tmat3x3<T> Result; detail::tmat3x3<T> Result;
Result[0][0] = m[0][0]; Result[0][0] = m[0][0];
Result[0][1] = m[1][0]; Result[0][1] = m[1][0];
Result[0][2] = m[2][0]; Result[0][2] = m[2][0];
Result[1][0] = m[0][1]; Result[1][0] = m[0][1];
Result[1][1] = m[1][1]; Result[1][1] = m[1][1];
Result[1][2] = m[2][1]; Result[1][2] = m[2][1];
Result[2][0] = m[0][2]; Result[2][0] = m[0][2];
Result[2][1] = m[1][2]; Result[2][1] = m[1][2];
Result[2][2] = m[2][2]; Result[2][2] = m[2][2];
return Result; return Result;
} }
template <typename T> template <typename T>
GLM_FUNC_QUALIFIER detail::tmat4x4<T> rowMajor4( GLM_FUNC_QUALIFIER detail::tmat4x4<T> rowMajor4(
const detail::tvec4<T>& v1, const detail::tvec4<T>& v1,
const detail::tvec4<T>& v2, const detail::tvec4<T>& v2,
const detail::tvec4<T>& v3, const detail::tvec4<T>& v3,
const detail::tvec4<T>& v4) const detail::tvec4<T>& v4)
{ {
detail::tmat4x4<T> Result; detail::tmat4x4<T> Result;
Result[0][0] = v1.x; Result[0][0] = v1.x;
Result[1][0] = v1.y; Result[1][0] = v1.y;
Result[2][0] = v1.z; Result[2][0] = v1.z;
Result[3][0] = v1.w; Result[3][0] = v1.w;
Result[0][1] = v2.x; Result[0][1] = v2.x;
Result[1][1] = v2.y; Result[1][1] = v2.y;
Result[2][1] = v2.z; Result[2][1] = v2.z;
Result[3][1] = v2.w; Result[3][1] = v2.w;
Result[0][2] = v3.x; Result[0][2] = v3.x;
Result[1][2] = v3.y; Result[1][2] = v3.y;
Result[2][2] = v3.z; Result[2][2] = v3.z;
Result[3][2] = v3.w; Result[3][2] = v3.w;
Result[0][3] = v4.x; Result[0][3] = v4.x;
Result[1][3] = v4.y; Result[1][3] = v4.y;
Result[2][3] = v4.z; Result[2][3] = v4.z;
Result[3][3] = v4.w; Result[3][3] = v4.w;
return Result; return Result;
} }
template <typename T> template <typename T>
GLM_FUNC_QUALIFIER detail::tmat4x4<T> rowMajor4( GLM_FUNC_QUALIFIER detail::tmat4x4<T> rowMajor4(
const detail::tmat4x4<T>& m) const detail::tmat4x4<T>& m)
{ {
detail::tmat4x4<T> Result; detail::tmat4x4<T> Result;
Result[0][0] = m[0][0]; Result[0][0] = m[0][0];
Result[0][1] = m[1][0]; Result[0][1] = m[1][0];
Result[0][2] = m[2][0]; Result[0][2] = m[2][0];
Result[0][3] = m[3][0]; Result[0][3] = m[3][0];
Result[1][0] = m[0][1]; Result[1][0] = m[0][1];
Result[1][1] = m[1][1]; Result[1][1] = m[1][1];
Result[1][2] = m[2][1]; Result[1][2] = m[2][1];
Result[1][3] = m[3][1]; Result[1][3] = m[3][1];
Result[2][0] = m[0][2]; Result[2][0] = m[0][2];
Result[2][1] = m[1][2]; Result[2][1] = m[1][2];
Result[2][2] = m[2][2]; Result[2][2] = m[2][2];
Result[2][3] = m[3][2]; Result[2][3] = m[3][2];
Result[3][0] = m[0][3]; Result[3][0] = m[0][3];
Result[3][1] = m[1][3]; Result[3][1] = m[1][3];
Result[3][2] = m[2][3]; Result[3][2] = m[2][3];
Result[3][3] = m[3][3]; Result[3][3] = m[3][3];
return Result; return Result;
} }
template <typename T> template <typename T>
GLM_FUNC_QUALIFIER detail::tmat2x2<T> colMajor2( GLM_FUNC_QUALIFIER detail::tmat2x2<T> colMajor2(
const detail::tvec2<T>& v1, const detail::tvec2<T>& v1,
const detail::tvec2<T>& v2) const detail::tvec2<T>& v2)
{ {
return detail::tmat2x2<T>(v1, v2); return detail::tmat2x2<T>(v1, v2);
} }
template <typename T> template <typename T>
GLM_FUNC_QUALIFIER detail::tmat2x2<T> colMajor2( GLM_FUNC_QUALIFIER detail::tmat2x2<T> colMajor2(
const detail::tmat2x2<T>& m) const detail::tmat2x2<T>& m)
{ {
return detail::tmat2x2<T>(m); return detail::tmat2x2<T>(m);
} }
template <typename T> template <typename T>
GLM_FUNC_QUALIFIER detail::tmat3x3<T> colMajor3( GLM_FUNC_QUALIFIER detail::tmat3x3<T> colMajor3(
const detail::tvec3<T>& v1, const detail::tvec3<T>& v1,
const detail::tvec3<T>& v2, const detail::tvec3<T>& v2,
const detail::tvec3<T>& v3) const detail::tvec3<T>& v3)
{ {
return detail::tmat3x3<T>(v1, v2, v3); return detail::tmat3x3<T>(v1, v2, v3);
} }
template <typename T> template <typename T>
GLM_FUNC_QUALIFIER detail::tmat3x3<T> colMajor3( GLM_FUNC_QUALIFIER detail::tmat3x3<T> colMajor3(
const detail::tmat3x3<T>& m) const detail::tmat3x3<T>& m)
{ {
return detail::tmat3x3<T>(m); return detail::tmat3x3<T>(m);
} }
template <typename T> template <typename T>
GLM_FUNC_QUALIFIER detail::tmat4x4<T> colMajor4( GLM_FUNC_QUALIFIER detail::tmat4x4<T> colMajor4(
const detail::tvec4<T>& v1, const detail::tvec4<T>& v1,
const detail::tvec4<T>& v2, const detail::tvec4<T>& v2,
const detail::tvec4<T>& v3, const detail::tvec4<T>& v3,
const detail::tvec4<T>& v4) const detail::tvec4<T>& v4)
{ {
return detail::tmat4x4<T>(v1, v2, v3, v4); return detail::tmat4x4<T>(v1, v2, v3, v4);
} }
template <typename T> template <typename T>
GLM_FUNC_QUALIFIER detail::tmat4x4<T> colMajor4( GLM_FUNC_QUALIFIER detail::tmat4x4<T> colMajor4(
const detail::tmat4x4<T>& m) const detail::tmat4x4<T>& m)
{ {
return detail::tmat4x4<T>(m); return detail::tmat4x4<T>(m);
} }
}//namespace gtx
}//namespace glm }//namespace glm

View File

@ -45,10 +45,9 @@
# pragma message("GLM: GLM_GTX_matrix_operation extension included") # pragma message("GLM: GLM_GTX_matrix_operation extension included")
#endif #endif
namespace glm{ namespace glm
namespace gtx
{ {
/// \addtogroup gtx_matrix_operation /// @addtogroup gtx_matrix_operation
/// @{ /// @{
//! Build a diagonal matrix. //! Build a diagonal matrix.
@ -106,7 +105,6 @@ namespace gtx
detail::tvec4<valType> const & v); detail::tvec4<valType> const & v);
/// @} /// @}
}//namespace gtx
}//namespace glm }//namespace glm
#include "matrix_operation.inl" #include "matrix_operation.inl"

View File

@ -8,120 +8,118 @@
/////////////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////////////
namespace glm{ namespace glm{
namespace gtx{
template <typename valType> template <typename valType>
GLM_FUNC_QUALIFIER detail::tmat2x2<valType> diagonal2x2 GLM_FUNC_QUALIFIER detail::tmat2x2<valType> diagonal2x2
( (
detail::tvec2<valType> const & v detail::tvec2<valType> const & v
) )
{ {
detail::tmat2x2<valType> Result(valType(1)); detail::tmat2x2<valType> Result(valType(1));
Result[0][0] = v[0]; Result[0][0] = v[0];
Result[1][1] = v[1]; Result[1][1] = v[1];
return Result; return Result;
} }
template <typename valType> template <typename valType>
GLM_FUNC_QUALIFIER detail::tmat2x3<valType> diagonal2x3 GLM_FUNC_QUALIFIER detail::tmat2x3<valType> diagonal2x3
( (
detail::tvec2<valType> const & v detail::tvec2<valType> const & v
) )
{ {
detail::tmat2x3<valType> Result(valType(1)); detail::tmat2x3<valType> Result(valType(1));
Result[0][0] = v[0]; Result[0][0] = v[0];
Result[1][1] = v[1]; Result[1][1] = v[1];
return Result; return Result;
} }
template <typename valType> template <typename valType>
GLM_FUNC_QUALIFIER detail::tmat2x4<valType> diagonal2x4 GLM_FUNC_QUALIFIER detail::tmat2x4<valType> diagonal2x4
( (
detail::tvec2<valType> const & v detail::tvec2<valType> const & v
) )
{ {
detail::tmat2x4<valType> Result(valType(1)); detail::tmat2x4<valType> Result(valType(1));
Result[0][0] = v[0]; Result[0][0] = v[0];
Result[1][1] = v[1]; Result[1][1] = v[1];
return Result; return Result;
} }
template <typename valType> template <typename valType>
GLM_FUNC_QUALIFIER detail::tmat3x2<valType> diagonal3x2 GLM_FUNC_QUALIFIER detail::tmat3x2<valType> diagonal3x2
( (
detail::tvec2<valType> const & v detail::tvec2<valType> const & v
) )
{ {
detail::tmat3x2<valType> Result(valType(1)); detail::tmat3x2<valType> Result(valType(1));
Result[0][0] = v[0]; Result[0][0] = v[0];
Result[1][1] = v[1]; Result[1][1] = v[1];
return Result; return Result;
} }
template <typename valType> template <typename valType>
GLM_FUNC_QUALIFIER detail::tmat3x3<valType> diagonal3x3 GLM_FUNC_QUALIFIER detail::tmat3x3<valType> diagonal3x3
( (
detail::tvec3<valType> const & v detail::tvec3<valType> const & v
) )
{ {
detail::tmat3x3<valType> Result(valType(1)); detail::tmat3x3<valType> Result(valType(1));
Result[0][0] = v[0]; Result[0][0] = v[0];
Result[1][1] = v[1]; Result[1][1] = v[1];
Result[2][2] = v[2]; Result[2][2] = v[2];
return Result; return Result;
} }
template <typename valType> template <typename valType>
GLM_FUNC_QUALIFIER detail::tmat3x4<valType> diagonal3x4 GLM_FUNC_QUALIFIER detail::tmat3x4<valType> diagonal3x4
( (
detail::tvec3<valType> const & v detail::tvec3<valType> const & v
) )
{ {
detail::tmat3x4<valType> Result(valType(1)); detail::tmat3x4<valType> Result(valType(1));
Result[0][0] = v[0]; Result[0][0] = v[0];
Result[1][1] = v[1]; Result[1][1] = v[1];
Result[2][2] = v[2]; Result[2][2] = v[2];
return Result; return Result;
} }
template <typename valType> template <typename valType>
GLM_FUNC_QUALIFIER detail::tmat4x4<valType> diagonal4x4 GLM_FUNC_QUALIFIER detail::tmat4x4<valType> diagonal4x4
( (
detail::tvec4<valType> const & v detail::tvec4<valType> const & v
) )
{ {
detail::tmat4x4<valType> Result(valType(1)); detail::tmat4x4<valType> Result(valType(1));
Result[0][0] = v[0]; Result[0][0] = v[0];
Result[1][1] = v[1]; Result[1][1] = v[1];
Result[2][2] = v[2]; Result[2][2] = v[2];
Result[3][3] = v[3]; Result[3][3] = v[3];
return Result; return Result;
} }
template <typename valType> template <typename valType>
GLM_FUNC_QUALIFIER detail::tmat4x3<valType> diagonal4x3 GLM_FUNC_QUALIFIER detail::tmat4x3<valType> diagonal4x3
( (
detail::tvec3<valType> const & v detail::tvec3<valType> const & v
) )
{ {
detail::tmat4x3<valType> Result(valType(1)); detail::tmat4x3<valType> Result(valType(1));
Result[0][0] = v[0]; Result[0][0] = v[0];
Result[1][1] = v[1]; Result[1][1] = v[1];
Result[2][2] = v[2]; Result[2][2] = v[2];
return Result; return Result;
} }
template <typename valType> template <typename valType>
GLM_FUNC_QUALIFIER detail::tmat4x2<valType> diagonal4x2 GLM_FUNC_QUALIFIER detail::tmat4x2<valType> diagonal4x2
( (
detail::tvec2<valType> const & v detail::tvec2<valType> const & v
) )
{ {
detail::tmat4x2<valType> Result(valType(1)); detail::tmat4x2<valType> Result(valType(1));
Result[0][0] = v[0]; Result[0][0] = v[0];
Result[1][1] = v[1]; Result[1][1] = v[1];
return Result; return Result;
} }
}//namespace gtx
}//namespace glm }//namespace glm

View File

@ -46,8 +46,7 @@
# pragma message("GLM: GLM_GTX_matrix_query extension included") # pragma message("GLM: GLM_GTX_matrix_query extension included")
#endif #endif
namespace glm{ namespace glm
namespace gtx
{ {
/// @addtogroup gtx_matrix_query /// @addtogroup gtx_matrix_query
/// @{ /// @{
@ -109,7 +108,6 @@ namespace gtx
const typename genType::value_type epsilon = std::numeric_limits<typename genType::value_type>::epsilon()); const typename genType::value_type epsilon = std::numeric_limits<typename genType::value_type>::epsilon());
/// @} /// @}
}//namespace gtx
}//namespace glm }//namespace glm
#include "matrix_query.inl" #include "matrix_query.inl"

View File

@ -11,132 +11,130 @@
/////////////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////////////
namespace glm{ namespace glm{
namespace gtx
template<typename T>
GLM_FUNC_QUALIFIER bool isNull(
const detail::tmat2x2<T>& m,
const T epsilon)
{ {
template<typename T> bool result = true;
GLM_FUNC_QUALIFIER bool isNull( for(int i = 0; result && i < 2 ; ++i)
const detail::tmat2x2<T>& m, result = isNull(m[i], epsilon);
const T epsilon) return result;
{ }
bool result = true;
for(int i = 0; result && i < 2 ; ++i)
result = isNull(m[i], epsilon);
return result;
}
template<typename T> template<typename T>
GLM_FUNC_QUALIFIER bool isNull( GLM_FUNC_QUALIFIER bool isNull(
const detail::tmat3x3<T>& m, const detail::tmat3x3<T>& m,
const T epsilon) const T epsilon)
{ {
bool result = true; bool result = true;
for(int i = 0; result && i < 3 ; ++i) for(int i = 0; result && i < 3 ; ++i)
result = isNull(m[i], epsilon); result = isNull(m[i], epsilon);
return result; return result;
} }
template<typename T> template<typename T>
GLM_FUNC_QUALIFIER bool isNull( GLM_FUNC_QUALIFIER bool isNull(
const detail::tmat4x4<T>& m, const detail::tmat4x4<T>& m,
const T epsilon) const T epsilon)
{ {
bool result = true; bool result = true;
for(int i = 0; result && i < 4 ; ++i) for(int i = 0; result && i < 4 ; ++i)
result = isNull(m[i], epsilon); result = isNull(m[i], epsilon);
return result; return result;
} }
template<typename genType> template<typename genType>
GLM_FUNC_QUALIFIER bool isIdentity( GLM_FUNC_QUALIFIER bool isIdentity(
const genType& m, const genType& m,
const typename genType::value_type epsilon) const typename genType::value_type epsilon)
{
bool result = true;
for(typename genType::value_type i = typename genType::value_type(0); result && i < genType::col_size(); ++i)
{ {
bool result = true; for(typename genType::value_type j = typename genType::value_type(0); result && j < i ; ++j)
for(typename genType::value_type i = typename genType::value_type(0); result && i < genType::col_size(); ++i) result = abs(m[i][j]) <= epsilon;
{
for(typename genType::value_type j = typename genType::value_type(0); result && j < i ; ++j)
result = abs(m[i][j]) <= epsilon;
if(result)
result = abs(m[i][i] - typename genType::value_type(1)) <= epsilon;
for(typename genType::value_type j = i + typename genType::value_type(1); result && j < genType::row_size(); ++j)
result = abs(m[i][j]) <= epsilon;
}
return result;
}
template<typename T>
GLM_FUNC_QUALIFIER bool isNormalized(
const detail::tmat2x2<T>& m,
const T epsilon)
{
bool result = true;
for(int i = 0; result && i < 2; ++i)
result = isNormalized(m[i], epsilon);
for(int i = 0; result && i < 2; ++i)
{
detail::tvec2<T> v;
for(int j = 0; j < 2; ++j)
v[j] = m[j][i];
result = isNormalized(v, epsilon);
}
return result;
}
template<typename T>
GLM_FUNC_QUALIFIER bool isNormalized(
const detail::tmat3x3<T>& m,
const T epsilon)
{
bool result = true;
for(int i = 0; result && i < 3; ++i)
result = isNormalized(m[i], epsilon);
for(int i = 0; result && i < 3; ++i)
{
detail::tvec3<T> v;
for(int j = 0; j < 3; ++j)
v[j] = m[j][i];
result = isNormalized(v, epsilon);
}
return result;
}
template<typename T>
GLM_FUNC_QUALIFIER bool isNormalized(
const detail::tmat4x4<T>& m,
const T epsilon)
{
bool result = true;
for(int i = 0; result && i < 4; ++i)
result = isNormalized(m[i], epsilon);
for(int i = 0; result && i < 4; ++i)
{
detail::tvec4<T> v;
for(int j = 0; j < 4; ++j)
v[j] = m[j][i];
result = isNormalized(v, epsilon);
}
return result;
}
template<typename genType>
GLM_FUNC_QUALIFIER bool isOrthogonal(
const genType& m,
const typename genType::value_type epsilon)
{
bool result = true;
for(int i = 0; result && i < genType::col_size() - 1; ++i)
for(int j= i + 1; result && j < genType::col_size(); ++j)
result = areOrthogonal(m[i], m[j], epsilon);
if(result) if(result)
{ result = abs(m[i][i] - typename genType::value_type(1)) <= epsilon;
genType tmp = transpose(m); for(typename genType::value_type j = i + typename genType::value_type(1); result && j < genType::row_size(); ++j)
for(int i = 0; result && i < genType::col_size() - 1 ; ++i) result = abs(m[i][j]) <= epsilon;
for(int j = i + 1; result && j < genType::col_size(); ++j)
result = areOrthogonal(tmp[i], tmp[j], epsilon);
}
return result;
} }
return result;
}
template<typename T>
GLM_FUNC_QUALIFIER bool isNormalized(
const detail::tmat2x2<T>& m,
const T epsilon)
{
bool result = true;
for(int i = 0; result && i < 2; ++i)
result = isNormalized(m[i], epsilon);
for(int i = 0; result && i < 2; ++i)
{
detail::tvec2<T> v;
for(int j = 0; j < 2; ++j)
v[j] = m[j][i];
result = isNormalized(v, epsilon);
}
return result;
}
template<typename T>
GLM_FUNC_QUALIFIER bool isNormalized(
const detail::tmat3x3<T>& m,
const T epsilon)
{
bool result = true;
for(int i = 0; result && i < 3; ++i)
result = isNormalized(m[i], epsilon);
for(int i = 0; result && i < 3; ++i)
{
detail::tvec3<T> v;
for(int j = 0; j < 3; ++j)
v[j] = m[j][i];
result = isNormalized(v, epsilon);
}
return result;
}
template<typename T>
GLM_FUNC_QUALIFIER bool isNormalized(
const detail::tmat4x4<T>& m,
const T epsilon)
{
bool result = true;
for(int i = 0; result && i < 4; ++i)
result = isNormalized(m[i], epsilon);
for(int i = 0; result && i < 4; ++i)
{
detail::tvec4<T> v;
for(int j = 0; j < 4; ++j)
v[j] = m[j][i];
result = isNormalized(v, epsilon);
}
return result;
}
template<typename genType>
GLM_FUNC_QUALIFIER bool isOrthogonal(
const genType& m,
const typename genType::value_type epsilon)
{
bool result = true;
for(int i = 0; result && i < genType::col_size() - 1; ++i)
for(int j= i + 1; result && j < genType::col_size(); ++j)
result = areOrthogonal(m[i], m[j], epsilon);
if(result)
{
genType tmp = transpose(m);
for(int i = 0; result && i < genType::col_size() - 1 ; ++i)
for(int j = i + 1; result && j < genType::col_size(); ++j)
result = areOrthogonal(tmp[i], tmp[j], epsilon);
}
return result;
}
}//namespace gtx
}//namespace glm }//namespace glm

View File

@ -45,8 +45,7 @@
# pragma message("GLM: GLM_GTX_mixed_product extension included") # pragma message("GLM: GLM_GTX_mixed_product extension included")
#endif #endif
namespace glm{ namespace glm
namespace gtx
{ {
/// @addtogroup gtx_mixed_product /// @addtogroup gtx_mixed_product
/// @{ /// @{
@ -59,7 +58,6 @@ namespace gtx
detail::tvec3<valType> const & v3); detail::tvec3<valType> const & v3);
/// @} /// @}
}// namespace gtx
}// namespace glm }// namespace glm
#include "mixed_product.inl" #include "mixed_product.inl"

View File

@ -8,7 +8,6 @@
/////////////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////////////
namespace glm{ namespace glm{
namespace gtx{
template <typename valType> template <typename valType>
GLM_FUNC_QUALIFIER valType mixedProduct( GLM_FUNC_QUALIFIER valType mixedProduct(
@ -19,14 +18,4 @@ GLM_FUNC_QUALIFIER valType mixedProduct(
return dot(cross(v1, v2), v3); return dot(cross(v1, v2), v3);
} }
}//namespace gtx
}//namespace glm }//namespace glm

View File

@ -46,8 +46,7 @@
# pragma message("GLM: GLM_GTX_multiple extension included") # pragma message("GLM: GLM_GTX_multiple extension included")
#endif #endif
namespace glm{ namespace glm
namespace gtx
{ {
/// @addtogroup gtx_multiple /// @addtogroup gtx_multiple
/// @{ /// @{
@ -67,7 +66,6 @@ namespace gtx
genType const & Multiple); genType const & Multiple);
/// @} /// @}
}//namespace gtx
}//namespace glm }//namespace glm
#include "multiple.inl" #include "multiple.inl"

View File

@ -11,179 +11,177 @@
/////////////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////////////
namespace glm{ namespace glm{
namespace gtx
//////////////////////
// higherMultiple
template <typename genType>
GLM_FUNC_QUALIFIER genType higherMultiple
(
genType const & Source,
genType const & Multiple
)
{ {
////////////////////// genType Tmp = Source % Multiple;
// higherMultiple return Tmp ? Source + Multiple - Tmp : Source;
}
template <typename genType> template <>
GLM_FUNC_QUALIFIER genType higherMultiple GLM_FUNC_QUALIFIER detail::thalf higherMultiple
( (
genType const & Source, detail::thalf const & Source,
genType const & Multiple detail::thalf const & Multiple
) )
{ {
genType Tmp = Source % Multiple; int Tmp = int(float(Source)) % int(float(Multiple));
return Tmp ? Source + Multiple - Tmp : Source; return Tmp ? Source + Multiple - detail::thalf(float(Tmp)) : Source;
} }
template <> template <>
GLM_FUNC_QUALIFIER detail::thalf higherMultiple GLM_FUNC_QUALIFIER float higherMultiple
( (
detail::thalf const & Source, float const & Source,
detail::thalf const & Multiple float const & Multiple
) )
{ {
int Tmp = int(float(Source)) % int(float(Multiple)); int Tmp = int(Source) % int(Multiple);
return Tmp ? Source + Multiple - detail::thalf(float(Tmp)) : Source; return Tmp ? Source + Multiple - float(Tmp) : Source;
} }
template <> template <>
GLM_FUNC_QUALIFIER float higherMultiple GLM_FUNC_QUALIFIER double higherMultiple
( (
float const & Source, double const & Source,
float const & Multiple double const & Multiple
) )
{ {
int Tmp = int(Source) % int(Multiple); long Tmp = long(Source) % long(Multiple);
return Tmp ? Source + Multiple - float(Tmp) : Source; return Tmp ? Source + Multiple - double(Tmp) : Source;
} }
template <> template <typename T>
GLM_FUNC_QUALIFIER double higherMultiple GLM_FUNC_QUALIFIER detail::tvec2<T> higherMultiple
( (
double const & Source, detail::tvec2<T> const & Source,
double const & Multiple detail::tvec2<T> const & Multiple
) )
{ {
long Tmp = long(Source) % long(Multiple); detail::tvec2<T> Result;
return Tmp ? Source + Multiple - double(Tmp) : Source; for(typename detail::tvec2<T>::size_type i = 0; i < detail::tvec2<T>::value_size(); ++i)
} Result[i] = higherMultiple(Source[i], Multiple[i]);
return Result;
}
template <typename T> template <typename T>
GLM_FUNC_QUALIFIER detail::tvec2<T> higherMultiple GLM_FUNC_QUALIFIER detail::tvec3<T> higherMultiple
( (
detail::tvec2<T> const & Source, detail::tvec3<T> const & Source,
detail::tvec2<T> const & Multiple detail::tvec3<T> const & Multiple
) )
{ {
detail::tvec2<T> Result; detail::tvec3<T> Result;
for(typename detail::tvec2<T>::size_type i = 0; i < detail::tvec2<T>::value_size(); ++i) for(typename detail::tvec3<T>::size_type i = 0; i < detail::tvec3<T>::value_size(); ++i)
Result[i] = higherMultiple(Source[i], Multiple[i]); Result[i] = higherMultiple(Source[i], Multiple[i]);
return Result; return Result;
} }
template <typename T> template <typename T>
GLM_FUNC_QUALIFIER detail::tvec3<T> higherMultiple GLM_FUNC_QUALIFIER detail::tvec4<T> higherMultiple
( (
detail::tvec3<T> const & Source, detail::tvec4<T> const & Source,
detail::tvec3<T> const & Multiple detail::tvec4<T> const & Multiple
) )
{ {
detail::tvec3<T> Result; detail::tvec4<T> Result;
for(typename detail::tvec3<T>::size_type i = 0; i < detail::tvec3<T>::value_size(); ++i) for(typename detail::tvec4<T>::size_type i = 0; i < detail::tvec4<T>::value_size(); ++i)
Result[i] = higherMultiple(Source[i], Multiple[i]); Result[i] = higherMultiple(Source[i], Multiple[i]);
return Result; return Result;
} }
template <typename T> //////////////////////
GLM_FUNC_QUALIFIER detail::tvec4<T> higherMultiple // lowerMultiple
(
detail::tvec4<T> const & Source,
detail::tvec4<T> const & Multiple
)
{
detail::tvec4<T> Result;
for(typename detail::tvec4<T>::size_type i = 0; i < detail::tvec4<T>::value_size(); ++i)
Result[i] = higherMultiple(Source[i], Multiple[i]);
return Result;
}
////////////////////// template <typename genType>
// lowerMultiple GLM_FUNC_QUALIFIER genType lowerMultiple
(
genType const & Source,
genType const & Multiple
)
{
genType Tmp = Source % Multiple;
return Tmp ? Source - Tmp : Source;
}
template <typename genType> template <>
GLM_FUNC_QUALIFIER genType lowerMultiple GLM_FUNC_QUALIFIER detail::thalf lowerMultiple
( (
genType const & Source, detail::thalf const & Source,
genType const & Multiple detail::thalf const & Multiple
) )
{ {
genType Tmp = Source % Multiple; int Tmp = int(float(Source)) % int(float(Multiple));
return Tmp ? Source - Tmp : Source; return Tmp ? Source - detail::thalf(float(Tmp)) : Source;
} }
template <> template <>
GLM_FUNC_QUALIFIER detail::thalf lowerMultiple GLM_FUNC_QUALIFIER float lowerMultiple
( (
detail::thalf const & Source, float const & Source,
detail::thalf const & Multiple float const & Multiple
) )
{ {
int Tmp = int(float(Source)) % int(float(Multiple)); int Tmp = int(Source) % int(Multiple);
return Tmp ? Source - detail::thalf(float(Tmp)) : Source; return Tmp ? Source - float(Tmp) : Source;
} }
template <> template <>
GLM_FUNC_QUALIFIER float lowerMultiple GLM_FUNC_QUALIFIER double lowerMultiple
( (
float const & Source, double const & Source,
float const & Multiple double const & Multiple
) )
{ {
int Tmp = int(Source) % int(Multiple); long Tmp = long(Source) % long(Multiple);
return Tmp ? Source - float(Tmp) : Source; return Tmp ? Source - double(Tmp) : Source;
} }
template <> template <typename T>
GLM_FUNC_QUALIFIER double lowerMultiple GLM_FUNC_QUALIFIER detail::tvec2<T> lowerMultiple
( (
double const & Source, detail::tvec2<T> const & Source,
double const & Multiple detail::tvec2<T> const & Multiple
) )
{ {
long Tmp = long(Source) % long(Multiple); detail::tvec2<T> Result;
return Tmp ? Source - double(Tmp) : Source; for(typename detail::tvec2<T>::size_type i = 0; i < detail::tvec2<T>::value_size(); ++i)
} Result[i] = lowerMultiple(Source[i], Multiple[i]);
return Result;
}
template <typename T> template <typename T>
GLM_FUNC_QUALIFIER detail::tvec2<T> lowerMultiple GLM_FUNC_QUALIFIER detail::tvec3<T> lowerMultiple
( (
detail::tvec2<T> const & Source, detail::tvec3<T> const & Source,
detail::tvec2<T> const & Multiple detail::tvec3<T> const & Multiple
) )
{ {
detail::tvec2<T> Result; detail::tvec3<T> Result;
for(typename detail::tvec2<T>::size_type i = 0; i < detail::tvec2<T>::value_size(); ++i) for(typename detail::tvec3<T>::size_type i = 0; i < detail::tvec3<T>::value_size(); ++i)
Result[i] = lowerMultiple(Source[i], Multiple[i]); Result[i] = lowerMultiple(Source[i], Multiple[i]);
return Result; return Result;
} }
template <typename T> template <typename T>
GLM_FUNC_QUALIFIER detail::tvec3<T> lowerMultiple GLM_FUNC_QUALIFIER detail::tvec4<T> lowerMultiple
( (
detail::tvec3<T> const & Source, detail::tvec4<T> const & Source,
detail::tvec3<T> const & Multiple detail::tvec4<T> const & Multiple
) )
{ {
detail::tvec3<T> Result; detail::tvec4<T> Result;
for(typename detail::tvec3<T>::size_type i = 0; i < detail::tvec3<T>::value_size(); ++i) for(typename detail::tvec4<T>::size_type i = 0; i < detail::tvec4<T>::value_size(); ++i)
Result[i] = lowerMultiple(Source[i], Multiple[i]); Result[i] = lowerMultiple(Source[i], Multiple[i]);
return Result; return Result;
} }
template <typename T>
GLM_FUNC_QUALIFIER detail::tvec4<T> lowerMultiple
(
detail::tvec4<T> const & Source,
detail::tvec4<T> const & Multiple
)
{
detail::tvec4<T> Result;
for(typename detail::tvec4<T>::size_type i = 0; i < detail::tvec4<T>::value_size(); ++i)
Result[i] = lowerMultiple(Source[i], Multiple[i]);
return Result;
}
}//namespace gtx
}//namespace glm }//namespace glm

View File

@ -49,8 +49,7 @@
# pragma message("GLM: GLM_GTX_noise extension included") # pragma message("GLM: GLM_GTX_noise extension included")
#endif #endif
namespace glm{ namespace glm
namespace gtx
{ {
/// @addtogroup gtx_noise /// @addtogroup gtx_noise
/// @{ /// @{
@ -75,7 +74,6 @@ namespace gtx
vecType<T> const & p); vecType<T> const & p);
/// @} /// @}
}//namespace gtx
}//namespace glm }//namespace glm
#include "noise.inl" #include "noise.inl"

File diff suppressed because it is too large Load Diff

View File

@ -49,8 +49,7 @@
# pragma message("GLM: GLM_GTX_norm extension included") # pragma message("GLM: GLM_GTX_norm extension included")
#endif #endif
namespace glm{ namespace glm
namespace gtx
{ {
/// @addtogroup gtx_norm /// @addtogroup gtx_norm
/// @{ /// @{
@ -155,7 +154,6 @@ namespace gtx
unsigned int Depth); unsigned int Depth);
/// @} /// @}
}//namespace gtx
}//namespace glm }//namespace glm
#include "norm.inl" #include "norm.inl"

View File

@ -8,121 +8,119 @@
/////////////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////////////
namespace glm{ namespace glm{
namespace gtx
template <typename T>
GLM_FUNC_QUALIFIER T length2(
const T x)
{ {
template <typename T> return x * x;
GLM_FUNC_QUALIFIER T length2( }
const T x)
{
return x * x;
}
template <typename T> template <typename T>
GLM_FUNC_QUALIFIER T length2( GLM_FUNC_QUALIFIER T length2(
const detail::tvec2<T>& x) const detail::tvec2<T>& x)
{ {
return dot(x, x); return dot(x, x);
} }
template <typename T> template <typename T>
GLM_FUNC_QUALIFIER T length2( GLM_FUNC_QUALIFIER T length2(
const detail::tvec3<T>& x) const detail::tvec3<T>& x)
{ {
return dot(x, x); return dot(x, x);
} }
template <typename T> template <typename T>
GLM_FUNC_QUALIFIER T length2( GLM_FUNC_QUALIFIER T length2(
const detail::tvec4<T>& x) const detail::tvec4<T>& x)
{ {
return dot(x, x); return dot(x, x);
} }
template <typename T> template <typename T>
GLM_FUNC_QUALIFIER T length2( GLM_FUNC_QUALIFIER T length2(
const detail::tquat<T>& q) const detail::tquat<T>& q)
{ {
return q.x * q.x + q.y * q.y + q.z * q.z + q.w * q.w; return q.x * q.x + q.y * q.y + q.z * q.z + q.w * q.w;
} }
template <typename T> template <typename T>
T distance2( T distance2(
const T p0, const T p0,
const T p1) const T p1)
{ {
return length2(p1 - p0); return length2(p1 - p0);
} }
template <typename T> template <typename T>
T distance2( T distance2(
const detail::tvec2<T>& p0, const detail::tvec2<T>& p0,
const detail::tvec2<T>& p1) const detail::tvec2<T>& p1)
{ {
return length2(p1 - p0); return length2(p1 - p0);
} }
template <typename T> template <typename T>
T distance2( T distance2(
const detail::tvec3<T>& p0, const detail::tvec3<T>& p0,
const detail::tvec3<T>& p1) const detail::tvec3<T>& p1)
{ {
return length2(p1 - p0); return length2(p1 - p0);
} }
template <typename T> template <typename T>
T distance2( T distance2(
const detail::tvec4<T>& p0, const detail::tvec4<T>& p0,
const detail::tvec4<T>& p1) const detail::tvec4<T>& p1)
{ {
return length2(p1 - p0); return length2(p1 - p0);
} }
template <typename T> template <typename T>
GLM_FUNC_QUALIFIER T l1Norm( GLM_FUNC_QUALIFIER T l1Norm(
const detail::tvec3<T>& a, const detail::tvec3<T>& a,
const detail::tvec3<T>& b) const detail::tvec3<T>& b)
{ {
return abs(b.x - a.x) + abs(b.y - a.y) + abs(b.z - a.z); return abs(b.x - a.x) + abs(b.y - a.y) + abs(b.z - a.z);
} }
template <typename T> template <typename T>
GLM_FUNC_QUALIFIER T l1Norm( GLM_FUNC_QUALIFIER T l1Norm(
const detail::tvec3<T>& v) const detail::tvec3<T>& v)
{ {
return abs(v.x) + abs(v.y) + abs(v.z); return abs(v.x) + abs(v.y) + abs(v.z);
} }
template <typename T> template <typename T>
GLM_FUNC_QUALIFIER T l2Norm( GLM_FUNC_QUALIFIER T l2Norm(
const detail::tvec3<T>& a, const detail::tvec3<T>& a,
const detail::tvec3<T>& b) const detail::tvec3<T>& b)
{ {
return length(b - a); return length(b - a);
} }
template <typename T> template <typename T>
GLM_FUNC_QUALIFIER T l2Norm( GLM_FUNC_QUALIFIER T l2Norm(
const detail::tvec3<T>& v) const detail::tvec3<T>& v)
{ {
return length(v); return length(v);
} }
template <typename T> template <typename T>
GLM_FUNC_QUALIFIER T lxNorm( GLM_FUNC_QUALIFIER T lxNorm(
const detail::tvec3<T>& x, const detail::tvec3<T>& x,
const detail::tvec3<T>& y, const detail::tvec3<T>& y,
unsigned int Depth) unsigned int Depth)
{ {
return pow(pow(y.x - x.x, T(Depth)) + pow(y.y - x.y, T(Depth)) + pow(y.z - x.z, T(Depth)), T(1) / T(Depth)); return pow(pow(y.x - x.x, T(Depth)) + pow(y.y - x.y, T(Depth)) + pow(y.z - x.z, T(Depth)), T(1) / T(Depth));
} }
template <typename T> template <typename T>
GLM_FUNC_QUALIFIER T lxNorm( GLM_FUNC_QUALIFIER T lxNorm(
const detail::tvec3<T>& v, const detail::tvec3<T>& v,
unsigned int Depth) unsigned int Depth)
{ {
return pow(pow(v.x, T(Depth)) + pow(v.y, T(Depth)) + pow(v.z, T(Depth)), T(1) / T(Depth)); return pow(pow(v.x, T(Depth)) + pow(v.y, T(Depth)) + pow(v.z, T(Depth)), T(1) / T(Depth));
} }
}//namespace gtx
}//namespace glm }//namespace glm

View File

@ -46,8 +46,7 @@
# pragma message("GLM: GLM_GTX_normal extension included") # pragma message("GLM: GLM_GTX_normal extension included")
#endif #endif
namespace glm{ namespace glm
namespace gtx
{ {
/// @addtogroup gtx_normal /// @addtogroup gtx_normal
/// @{ /// @{
@ -61,7 +60,6 @@ namespace gtx
detail::tvec3<T> const & p3); detail::tvec3<T> const & p3);
/// @} /// @}
}//namespace gtx
}//namespace glm }//namespace glm
#include "normal.inl" #include "normal.inl"

View File

@ -8,7 +8,6 @@
/////////////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////////////
namespace glm{ namespace glm{
namespace gtx{
template <typename T> template <typename T>
GLM_FUNC_QUALIFIER detail::tvec3<T> triangleNormal GLM_FUNC_QUALIFIER detail::tvec3<T> triangleNormal
@ -21,5 +20,4 @@ GLM_FUNC_QUALIFIER detail::tvec3<T> triangleNormal
return normalize(cross(p1 - p2, p1 - p3)); return normalize(cross(p1 - p2, p1 - p3));
} }
}//namespace gtx
}//namespace glm }//namespace glm

View File

@ -47,8 +47,7 @@
# pragma message("GLM: GLM_GTX_normalize_dot extension included") # pragma message("GLM: GLM_GTX_normalize_dot extension included")
#endif #endif
namespace glm{ namespace glm
namespace gtx
{ {
/// @addtogroup gtx_normalize_dot /// @addtogroup gtx_normalize_dot
/// @{ /// @{
@ -70,7 +69,6 @@ namespace gtx
genType const & y); genType const & y);
/// @} /// @}
}//namespace gtx
}//namespace glm }//namespace glm
#include "normalize_dot.inl" #include "normalize_dot.inl"

View File

@ -8,7 +8,6 @@
////////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////////
namespace glm{ namespace glm{
namespace gtx{
template <typename genType> template <typename genType>
GLM_FUNC_QUALIFIER genType normalizeDot GLM_FUNC_QUALIFIER genType normalizeDot
@ -71,7 +70,7 @@ GLM_FUNC_QUALIFIER genType fastNormalizeDot
{ {
return return
glm::dot(x, y) * glm::dot(x, y) *
glm::gtx::fastInverseSqrt(glm::dot(x, x) * fastInverseSqrt(glm::dot(x, x) *
glm::dot(y, y)); glm::dot(y, y));
} }
@ -84,7 +83,7 @@ GLM_FUNC_QUALIFIER valType fastNormalizeDot
{ {
return return
glm::dot(x, y) * glm::dot(x, y) *
glm::gtx::fastInverseSqrt(glm::dot(x, x) * fastInverseSqrt(glm::dot(x, x) *
glm::dot(y, y)); glm::dot(y, y));
} }
@ -97,7 +96,7 @@ GLM_FUNC_QUALIFIER valType fastNormalizeDot
{ {
return return
glm::dot(x, y) * glm::dot(x, y) *
glm::gtx::fastInverseSqrt(glm::dot(x, x) * fastInverseSqrt(glm::dot(x, x) *
glm::dot(y, y)); glm::dot(y, y));
} }
@ -110,9 +109,8 @@ GLM_FUNC_QUALIFIER valType fastNormalizeDot
{ {
return return
glm::dot(x, y) * glm::dot(x, y) *
glm::gtx::fastInverseSqrt(glm::dot(x, x) * fastInverseSqrt(glm::dot(x, x) *
glm::dot(y, y)); glm::dot(y, y));
} }
}//namespace gtx
}//namespace glm }//namespace glm

View File

@ -8,54 +8,52 @@
/////////////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////////////
namespace glm{ namespace glm{
namespace gtx{
template <typename genType> template <typename genType>
GLM_FUNC_QUALIFIER genType pow2(const genType& x) GLM_FUNC_QUALIFIER genType pow2(const genType& x)
{ {
return x * x; return x * x;
} }
template <typename genType> template <typename genType>
GLM_FUNC_QUALIFIER genType pow3(const genType& x) GLM_FUNC_QUALIFIER genType pow3(const genType& x)
{ {
return x * x * x; return x * x * x;
} }
template <typename genType> template <typename genType>
GLM_FUNC_QUALIFIER genType pow4(const genType& x) GLM_FUNC_QUALIFIER genType pow4(const genType& x)
{ {
return x * x * x * x; return x * x * x * x;
} }
GLM_FUNC_QUALIFIER bool powOfTwo(int x) GLM_FUNC_QUALIFIER bool powOfTwo(int x)
{ {
return !(x & (x - 1)); return !(x & (x - 1));
} }
GLM_FUNC_QUALIFIER detail::tvec2<bool> powOfTwo(const detail::tvec2<int>& x) GLM_FUNC_QUALIFIER detail::tvec2<bool> powOfTwo(const detail::tvec2<int>& x)
{ {
return detail::tvec2<bool>( return detail::tvec2<bool>(
powOfTwo(x.x), powOfTwo(x.x),
powOfTwo(x.y)); powOfTwo(x.y));
} }
GLM_FUNC_QUALIFIER detail::tvec3<bool> powOfTwo(const detail::tvec3<int>& x) GLM_FUNC_QUALIFIER detail::tvec3<bool> powOfTwo(const detail::tvec3<int>& x)
{ {
return detail::tvec3<bool>( return detail::tvec3<bool>(
powOfTwo(x.x), powOfTwo(x.x),
powOfTwo(x.y), powOfTwo(x.y),
powOfTwo(x.z)); powOfTwo(x.z));
} }
GLM_FUNC_QUALIFIER detail::tvec4<bool> powOfTwo(const detail::tvec4<int>& x) GLM_FUNC_QUALIFIER detail::tvec4<bool> powOfTwo(const detail::tvec4<int>& x)
{ {
return detail::tvec4<bool>( return detail::tvec4<bool>(
powOfTwo(x.x), powOfTwo(x.x),
powOfTwo(x.y), powOfTwo(x.y),
powOfTwo(x.z), powOfTwo(x.z),
powOfTwo(x.w)); powOfTwo(x.w));
} }
}//namespace gtx
}//namespace glm }//namespace glm

Some files were not shown because too many files have changed in this diff Show More