diff --git a/doc/pages.doxy b/doc/pages.doxy index 54d03a04..997f4f3f 100644 --- a/doc/pages.doxy +++ b/doc/pages.doxy @@ -311,11 +311,11 @@ void foo()
glRotate[fd]
-
\link glm::gtc::rotate glm::rotate \endlink
+
\link glm::rotate glm::rotate \endlink
glScale[fd]
-
\link glm::gtc::scale glm::scale \endlink
+
\link glm::scale glm::scale \endlink
glTranslate[fd]
-
\link glm::gtc::translate glm::translate \endlink
+
\link glm::translate glm::translate \endlink
glLoadIdentity
The default constructor of all matrix types creates an identity matrix.
glMultMatrix[fd]
@@ -325,24 +325,24 @@ void foo()
glMultTransposeMatrix
Combine the last two.
glFrustum
-
\link glm::gtc::frustum glm::frustum \endlink
+
\link glm::frustum glm::frustum \endlink
glOrtho
-
\link glm::gtc::ortho glm::ortho \endlink
+
\link glm::ortho glm::ortho \endlink
gluLookAt
-
\link glm::gtc::lookAt glm::lookAt \endlink
+
\link glm::lookAt glm::lookAt \endlink
\section deprecated_glu GLU function replacements
gluOrtho2D
-
\link glm::gtc::ortho glm::ortho \endlink
+
\link glm::ortho glm::ortho \endlink
gluPerspective
-
\link glm::gtc::perspective glm::perspective \endlink
+
\link glm::perspective glm::perspective \endlink
gluProject
-
\link glm::gtc::project glm::project \endlink
+
\link glm::project glm::project \endlink
gluUnProject
-
\link glm::gtc::unProject glm::unProject \endlink
+
\link glm::unProject glm::unProject \endlink
**/ diff --git a/glm/core/func_common.hpp b/glm/core/func_common.hpp index 6127d284..8a1de5ad 100644 --- a/glm/core/func_common.hpp +++ b/glm/core/func_common.hpp @@ -31,8 +31,7 @@ #include "_fixes.hpp" -namespace glm{ -namespace core +namespace glm { /// @addtogroup core_funcs /// @{ @@ -367,7 +366,6 @@ namespace core genType ldexp(genType const & x, genIType const & exp); /// @} -}//namespace core }//namespace glm #include "func_common.inl" diff --git a/glm/core/func_common.inl b/glm/core/func_common.inl index bf6871c3..facb3ce6 100644 --- a/glm/core/func_common.inl +++ b/glm/core/func_common.inl @@ -38,8 +38,6 @@ namespace detail }; }//namespace detail -namespace core -{ // abs template GLM_FUNC_QUALIFIER genFIType abs( @@ -728,7 +726,7 @@ namespace core //if(x >= maxVal) return maxVal; //if(x <= minVal) return minVal; //return x; - return glm::max(glm::min(x, maxVal), minVal); + return max(min(x, maxVal), minVal); } template @@ -1566,5 +1564,4 @@ namespace core return std::frexp(x, exp); } -}//namespace core }//namespace glm diff --git a/glm/core/func_exponential.hpp b/glm/core/func_exponential.hpp index 5d50d93d..a182ca33 100644 --- a/glm/core/func_exponential.hpp +++ b/glm/core/func_exponential.hpp @@ -29,10 +29,9 @@ #ifndef glm_core_func_exponential #define glm_core_func_exponential -namespace glm{ -namespace core +namespace glm { - /// \addtogroup core_funcs + /// @addtogroup core_funcs /// @{ //! Returns x raised to the y power. @@ -88,7 +87,6 @@ namespace core genType inversesqrt(genType const & x); /// @} -}//namespace core }//namespace glm #include "func_exponential.inl" diff --git a/glm/core/func_exponential.inl b/glm/core/func_exponential.inl index 3c950b20..272149b7 100644 --- a/glm/core/func_exponential.inl +++ b/glm/core/func_exponential.inl @@ -7,8 +7,7 @@ // File : glm/core/func_exponential.inl /////////////////////////////////////////////////////////////////////////////////////////////////// -namespace glm{ -namespace core +namespace glm { // pow template @@ -349,5 +348,4 @@ namespace core inversesqrt(x.w)); } -}//namespace core }//namespace glm diff --git a/glm/core/func_geometric.hpp b/glm/core/func_geometric.hpp index 5bd192f0..849bbe15 100644 --- a/glm/core/func_geometric.hpp +++ b/glm/core/func_geometric.hpp @@ -29,8 +29,7 @@ #ifndef glm_core_func_geometric #define glm_core_func_geometric -namespace glm{ -namespace core +namespace glm { /// \addtogroup core_funcs /// @{ @@ -111,7 +110,6 @@ namespace core typename genType::value_type const & eta); /// @} -}//namespace core }//namespace glm #include "func_geometric.inl" diff --git a/glm/core/func_geometric.inl b/glm/core/func_geometric.inl index 3963da96..35b25711 100644 --- a/glm/core/func_geometric.inl +++ b/glm/core/func_geometric.inl @@ -7,8 +7,7 @@ // File : glm/core/func_geometric.inl /////////////////////////////////////////////////////////////////////////////////////////////////// -namespace glm{ -namespace core +namespace glm { // length template @@ -281,5 +280,4 @@ namespace core return eta * I - (eta * dotValue + sqrt(k)) * N; } -}//namespace core }//namespace glm diff --git a/glm/core/func_integer.hpp b/glm/core/func_integer.hpp index b6d80079..a856c781 100644 --- a/glm/core/func_integer.hpp +++ b/glm/core/func_integer.hpp @@ -29,10 +29,9 @@ #ifndef glm_core_func_integer #define glm_core_func_integer -namespace glm{ -namespace core +namespace glm { - /// \addtogroup core_funcs + /// @addtogroup core_funcs /// @{ //! Adds 32-bit unsigned integer x and y, returning the sum @@ -159,7 +158,6 @@ namespace core typename C::signed_type findMSB(C const & Value); /// @} -}//namespace core }//namespace glm #include "func_integer.inl" diff --git a/glm/core/func_integer.inl b/glm/core/func_integer.inl index 980d898a..17b48d8f 100644 --- a/glm/core/func_integer.inl +++ b/glm/core/func_integer.inl @@ -7,581 +7,578 @@ // File : glm/core/func_integer.inl /////////////////////////////////////////////////////////////////////////////////////////////////// -namespace glm{ -namespace core +namespace glm { - // uaddCarry - template - GLM_FUNC_QUALIFIER genUType uaddCarry - ( - genUType const & x, - genUType const & y, - genUType & Carry - ) + // uaddCarry + template + GLM_FUNC_QUALIFIER genUType uaddCarry + ( + genUType const & x, + genUType const & y, + genUType & Carry + ) + { + detail::highp_uint_t Value64 = detail::highp_uint_t(x) + detail::highp_uint_t(y); + genUType Result = genUType(Value64 % (detail::highp_uint_t(1) << detail::highp_uint_t(32))); + Carry = (Value64 % (detail::highp_uint_t(1) << detail::highp_uint_t(32))) > 1 ? 1 : 0; + return Result; + } + + template + GLM_FUNC_QUALIFIER detail::tvec2 uaddCarry + ( + detail::tvec2 const & x, + detail::tvec2 const & y, + detail::tvec2 & Carry + ) + { + return detail::tvec2( + uaddCarry(x[0], y[0], Carry[0]), + uaddCarry(x[1], y[1], Carry[1])); + } + + template + GLM_FUNC_QUALIFIER detail::tvec3 uaddCarry + ( + detail::tvec3 const & x, + detail::tvec3 const & y, + detail::tvec3 & Carry + ) + { + return detail::tvec3( + uaddCarry(x[0], y[0], Carry[0]), + uaddCarry(x[1], y[1], Carry[1]), + uaddCarry(x[2], y[2], Carry[2])); + } + + template + GLM_FUNC_QUALIFIER detail::tvec4 uaddCarry + ( + detail::tvec4 const & x, + detail::tvec4 const & y, + detail::tvec4 & Carry + ) + { + return detail::tvec4( + uaddCarry(x[0], y[0], Carry[0]), + uaddCarry(x[1], y[1], Carry[1]), + uaddCarry(x[2], y[2], Carry[2]), + uaddCarry(x[3], y[3], Carry[3])); + } + + // usubBorrow + template + GLM_FUNC_QUALIFIER genUType usubBorrow + ( + genUType const & x, + genUType const & y, + genUType & Borrow + ) + { + Borrow = x >= y ? 0 : 1; + if(x > y) + return genUType(detail::highp_int_t(x) - detail::highp_int_t(y)); + else + return genUType(detail::highp_int_t(1) << detail::highp_int_t(32) + detail::highp_int_t(x) - detail::highp_int_t(y)); + } + + template + GLM_FUNC_QUALIFIER detail::tvec2 usubBorrow + ( + detail::tvec2 const & x, + detail::tvec2 const & y, + detail::tvec2 & Borrow + ) + { + return detail::tvec2( + usubBorrow(x[0], y[0], Borrow[0]), + usubBorrow(x[1], y[1], Borrow[1])); + } + + template + GLM_FUNC_QUALIFIER detail::tvec3 usubBorrow + ( + detail::tvec3 const & x, + detail::tvec3 const & y, + detail::tvec3 & Borrow + ) + { + return detail::tvec3( + usubBorrow(x[0], y[0], Borrow[0]), + usubBorrow(x[1], y[1], Borrow[1]), + usubBorrow(x[2], y[2], Borrow[2])); + } + + template + GLM_FUNC_QUALIFIER detail::tvec4 usubBorrow + ( + detail::tvec4 const & x, + detail::tvec4 const & y, + detail::tvec4 & Borrow + ) + { + return detail::tvec4( + usubBorrow(x[0], y[0], Borrow[0]), + usubBorrow(x[1], y[1], Borrow[1]), + usubBorrow(x[2], y[2], Borrow[2]), + usubBorrow(x[3], y[3], Borrow[3])); + } + + // umulExtended + template + GLM_FUNC_QUALIFIER void umulExtended + ( + genUType const & x, + genUType const & y, + genUType & msb, + genUType & lsb + ) + { + detail::highp_uint_t ValueX64 = x; + detail::highp_uint_t ValueY64 = y; + detail::highp_uint_t Value64 = ValueX64 * ValueY64; + msb = *(genUType*)&genUType(Value64 & ((detail::highp_uint_t(1) << detail::highp_uint_t(32)) - detail::highp_uint_t(1))); + lsb = *(genUType*)&genUType(Value64 >> detail::highp_uint_t(32)); + } + + template + GLM_FUNC_QUALIFIER detail::tvec2 umulExtended + ( + detail::tvec2 const & x, + detail::tvec2 const & y, + detail::tvec2 & msb, + detail::tvec2 & lsb + ) + { + return detail::tvec2( + umulExtended(x[0], y[0], msb, lsb), + umulExtended(x[1], y[1], msb, lsb)); + } + + template + GLM_FUNC_QUALIFIER detail::tvec3 umulExtended + ( + detail::tvec3 const & x, + detail::tvec3 const & y, + detail::tvec3 & msb, + detail::tvec3 & lsb + ) + { + return detail::tvec3( + umulExtended(x[0], y[0], msb, lsb), + umulExtended(x[1], y[1], msb, lsb), + umulExtended(x[2], y[2], msb, lsb)); + } + + template + GLM_FUNC_QUALIFIER detail::tvec4 umulExtended + ( + detail::tvec4 const & x, + detail::tvec4 const & y, + detail::tvec4 & msb, + detail::tvec4 & lsb + ) + { + return detail::tvec4( + umulExtended(x[0], y[0], msb, lsb), + umulExtended(x[1], y[1], msb, lsb), + umulExtended(x[2], y[2], msb, lsb), + umulExtended(x[3], y[3], msb, lsb)); + } + + // imulExtended + template + GLM_FUNC_QUALIFIER void imulExtended + ( + genIType const & x, + genIType const & y, + genIType & msb, + genIType & lsb + ) + { + detail::highp_int_t ValueX64 = x; + detail::highp_int_t ValueY64 = y; + detail::highp_int_t Value64 = ValueX64 * ValueY64; + msb = *(genIType*)&genIType(Value64 & ((detail::highp_uint_t(1) << detail::highp_uint_t(32)) - detail::highp_uint_t(1))); + lsb = *(genIType*)&genIType(Value64 >> detail::highp_uint_t(32)); + } + + template + GLM_FUNC_QUALIFIER detail::tvec2 imulExtended + ( + detail::tvec2 const & x, + detail::tvec2 const & y, + detail::tvec2 & msb, + detail::tvec2 & lsb + ) + { + return detail::tvec2( + imulExtended(x[0], y[0], msb, lsb), + imulExtended(x[1], y[1], msb, lsb)); + } + + template + GLM_FUNC_QUALIFIER detail::tvec3 imulExtended + ( + detail::tvec3 const & x, + detail::tvec3 const & y, + detail::tvec3 & msb, + detail::tvec3 & lsb + ) + { + return detail::tvec3( + imulExtended(x[0], y[0], msb, lsb), + imulExtended(x[1], y[1], msb, lsb), + imulExtended(x[2], y[2], msb, lsb)); + } + + template + GLM_FUNC_QUALIFIER detail::tvec4 imulExtended + ( + detail::tvec4 const & x, + detail::tvec4 const & y, + detail::tvec4 & msb, + detail::tvec4 & lsb + ) + { + return detail::tvec4( + imulExtended(x[0], y[0], msb, lsb), + imulExtended(x[1], y[1], msb, lsb), + imulExtended(x[2], y[2], msb, lsb), + imulExtended(x[3], y[3], msb, lsb)); + } + + // bitfieldExtract + template + GLM_FUNC_QUALIFIER genIUType bitfieldExtract + ( + genIUType const & Value, + int const & Offset, + int const & Bits + ) + { + int GenSize = int(sizeof(genIUType)) << int(3); + + assert(Offset + Bits <= GenSize); + + genIUType ShiftLeft = Bits ? Value << (GenSize - (Bits + Offset)) : genIUType(0); + genIUType ShiftBack = ShiftLeft >> genIUType(GenSize - Bits); + + return ShiftBack; + } + + template + GLM_FUNC_QUALIFIER detail::tvec2 bitfieldExtract + ( + detail::tvec2 const & Value, + int const & Offset, + int const & Bits + ) + { + return detail::tvec2( + bitfieldExtract(Value[0]), + bitfieldExtract(Value[1])); + } + + template + GLM_FUNC_QUALIFIER detail::tvec3 bitfieldExtract + ( + detail::tvec3 const & Value, + int const & Offset, + int const & Bits + ) + { + return detail::tvec3( + bitfieldExtract(Value[0]), + bitfieldExtract(Value[1]), + bitfieldExtract(Value[2])); + } + + template + GLM_FUNC_QUALIFIER detail::tvec4 bitfieldExtract + ( + detail::tvec4 const & Value, + int const & Offset, + int const & Bits + ) + { + return detail::tvec4( + bitfieldExtract(Value[0]), + bitfieldExtract(Value[1]), + bitfieldExtract(Value[2]), + bitfieldExtract(Value[3])); + } + + // bitfieldInsert + template + GLM_FUNC_QUALIFIER genIUType bitfieldInsert + ( + genIUType const & Base, + genIUType const & Insert, + int const & Offset, + int const & Bits + ) + { + GLM_STATIC_ASSERT(std::numeric_limits::is_integer, "'bitfieldInsert' only accept integer values"); + assert(Offset + Bits <= sizeof(genIUType)); + + if(Bits == 0) + return Base; + + genIUType Mask = 0; + for(int Bit = Offset; Bit < Offset + Bits; ++Bit) + Mask |= (1 << Bit); + + return (Base & ~Mask) | (Insert & Mask); + } + + template + GLM_FUNC_QUALIFIER detail::tvec2 bitfieldInsert + ( + detail::tvec2 const & Base, + detail::tvec2 const & Insert, + int const & Offset, + int const & Bits + ) + { + return detail::tvec2( + bitfieldInsert(Base[0], Insert[0], Offset, Bits), + bitfieldInsert(Base[1], Insert[1], Offset, Bits)); + } + + template + GLM_FUNC_QUALIFIER detail::tvec3 bitfieldInsert + ( + detail::tvec3 const & Base, + detail::tvec3 const & Insert, + int const & Offset, + int const & Bits + ) + { + return detail::tvec3( + bitfieldInsert(Base[0], Insert[0], Offset, Bits), + bitfieldInsert(Base[1], Insert[1], Offset, Bits), + bitfieldInsert(Base[2], Insert[2], Offset, Bits)); + } + + template + GLM_FUNC_QUALIFIER detail::tvec4 bitfieldInsert + ( + detail::tvec4 const & Base, + detail::tvec4 const & Insert, + int const & Offset, + int const & Bits + ) + { + return detail::tvec4( + bitfieldInsert(Base[0], Insert[0], Offset, Bits), + bitfieldInsert(Base[1], Insert[1], Offset, Bits), + bitfieldInsert(Base[2], Insert[2], Offset, Bits), + bitfieldInsert(Base[3], Insert[3], Offset, Bits)); + } + + // bitfieldReverse + template + GLM_FUNC_QUALIFIER genIUType bitfieldReverse(genIUType const & Value) + { + GLM_STATIC_ASSERT(std::numeric_limits::is_integer, "'bitfieldReverse' only accept integer values"); + + genIUType Out = 0; + std::size_t BitSize = sizeof(genIUType) * 8; + for(std::size_t i = 0; i < BitSize; ++i) + if(Value & (genIUType(1) << i)) + Out |= genIUType(1) << (BitSize - 1 - i); + return Out; + } + + template + GLM_FUNC_QUALIFIER detail::tvec2 bitfieldReverse + ( + detail::tvec2 const & value + ) + { + return detail::tvec2( + bitfieldReverse(value[0]), + bitfieldReverse(value[1])); + } + + template + GLM_FUNC_QUALIFIER detail::tvec3 bitfieldReverse + ( + detail::tvec3 const & value + ) + { + return detail::tvec3( + bitfieldReverse(value[0]), + bitfieldReverse(value[1]), + bitfieldReverse(value[2])); + } + + template + GLM_FUNC_QUALIFIER detail::tvec4 bitfieldReverse + ( + detail::tvec4 const & value + ) + { + return detail::tvec4( + bitfieldReverse(value[0]), + bitfieldReverse(value[1]), + bitfieldReverse(value[2]), + bitfieldReverse(value[3])); + } + + // bitCount + template + GLM_FUNC_QUALIFIER int bitCount(genIUType const & Value) + { + GLM_STATIC_ASSERT(std::numeric_limits::is_integer, "'bitCount' only accept integer values"); + + int Count = 0; + for(std::size_t i = 0; i < sizeof(genIUType) * std::size_t(8); ++i) { - detail::highp_uint_t Value64 = detail::highp_uint_t(x) + detail::highp_uint_t(y); - genUType Result = genUType(Value64 % (detail::highp_uint_t(1) << detail::highp_uint_t(32))); - Carry = (Value64 % (detail::highp_uint_t(1) << detail::highp_uint_t(32))) > 1 ? 1 : 0; - return Result; + if(Value & (1 << i)) + ++Count; } + return Count; + } - template - GLM_FUNC_QUALIFIER detail::tvec2 uaddCarry - ( - detail::tvec2 const & x, - detail::tvec2 const & y, - detail::tvec2 & Carry - ) - { - return detail::tvec2( - uaddCarry(x[0], y[0], Carry[0]), - uaddCarry(x[1], y[1], Carry[1])); - } + template + GLM_FUNC_QUALIFIER detail::tvec2 bitCount + ( + detail::tvec2 const & value + ) + { + return detail::tvec2( + bitCount(value[0]), + bitCount(value[1])); + } - template - GLM_FUNC_QUALIFIER detail::tvec3 uaddCarry - ( - detail::tvec3 const & x, - detail::tvec3 const & y, - detail::tvec3 & Carry - ) - { - return detail::tvec3( - uaddCarry(x[0], y[0], Carry[0]), - uaddCarry(x[1], y[1], Carry[1]), - uaddCarry(x[2], y[2], Carry[2])); - } + template + GLM_FUNC_QUALIFIER detail::tvec3 bitCount + ( + detail::tvec3 const & value + ) + { + return detail::tvec3( + bitCount(value[0]), + bitCount(value[1]), + bitCount(value[2])); + } - template - GLM_FUNC_QUALIFIER detail::tvec4 uaddCarry - ( - detail::tvec4 const & x, - detail::tvec4 const & y, - detail::tvec4 & Carry - ) - { - return detail::tvec4( - uaddCarry(x[0], y[0], Carry[0]), - uaddCarry(x[1], y[1], Carry[1]), - uaddCarry(x[2], y[2], Carry[2]), - uaddCarry(x[3], y[3], Carry[3])); - } + template + GLM_FUNC_QUALIFIER detail::tvec4 bitCount + ( + detail::tvec4 const & value + ) + { + return detail::tvec4( + bitCount(value[0]), + bitCount(value[1]), + bitCount(value[2]), + bitCount(value[3])); + } - // usubBorrow - template - GLM_FUNC_QUALIFIER genUType usubBorrow - ( - genUType const & x, - genUType const & y, - genUType & Borrow - ) - { - Borrow = x >= y ? 0 : 1; - if(x > y) - return genUType(detail::highp_int_t(x) - detail::highp_int_t(y)); - else - return genUType(detail::highp_int_t(1) << detail::highp_int_t(32) + detail::highp_int_t(x) - detail::highp_int_t(y)); - } + // findLSB + template + GLM_FUNC_QUALIFIER int findLSB + ( + genIUType const & Value + ) + { + GLM_STATIC_ASSERT(std::numeric_limits::is_integer, "'findLSB' only accept integer values"); + if(Value == 0) + return -1; - template - GLM_FUNC_QUALIFIER detail::tvec2 usubBorrow - ( - detail::tvec2 const & x, - detail::tvec2 const & y, - detail::tvec2 & Borrow - ) - { - return detail::tvec2( - usubBorrow(x[0], y[0], Borrow[0]), - usubBorrow(x[1], y[1], Borrow[1])); - } + genIUType Bit; + for(Bit = genIUType(0); !(Value & (1 << Bit)); ++Bit){} + return Bit; + } - template - GLM_FUNC_QUALIFIER detail::tvec3 usubBorrow - ( - detail::tvec3 const & x, - detail::tvec3 const & y, - detail::tvec3 & Borrow - ) - { - return detail::tvec3( - usubBorrow(x[0], y[0], Borrow[0]), - usubBorrow(x[1], y[1], Borrow[1]), - usubBorrow(x[2], y[2], Borrow[2])); - } + template + GLM_FUNC_QUALIFIER detail::tvec2 findLSB + ( + detail::tvec2 const & value + ) + { + return detail::tvec2( + findLSB(value[0]), + findLSB(value[1])); + } - template - GLM_FUNC_QUALIFIER detail::tvec4 usubBorrow - ( - detail::tvec4 const & x, - detail::tvec4 const & y, - detail::tvec4 & Borrow - ) - { - return detail::tvec4( - usubBorrow(x[0], y[0], Borrow[0]), - usubBorrow(x[1], y[1], Borrow[1]), - usubBorrow(x[2], y[2], Borrow[2]), - usubBorrow(x[3], y[3], Borrow[3])); - } + template + GLM_FUNC_QUALIFIER detail::tvec3 findLSB + ( + detail::tvec3 const & value + ) + { + return detail::tvec3( + findLSB(value[0]), + findLSB(value[1]), + findLSB(value[2])); + } - // umulExtended - template - GLM_FUNC_QUALIFIER void umulExtended - ( - genUType const & x, - genUType const & y, - genUType & msb, - genUType & lsb - ) - { - detail::highp_uint_t ValueX64 = x; - detail::highp_uint_t ValueY64 = y; - detail::highp_uint_t Value64 = ValueX64 * ValueY64; - msb = *(genUType*)&genUType(Value64 & ((detail::highp_uint_t(1) << detail::highp_uint_t(32)) - detail::highp_uint_t(1))); - lsb = *(genUType*)&genUType(Value64 >> detail::highp_uint_t(32)); - } + template + GLM_FUNC_QUALIFIER detail::tvec4 findLSB + ( + detail::tvec4 const & value + ) + { + return detail::tvec4( + findLSB(value[0]), + findLSB(value[1]), + findLSB(value[2]), + findLSB(value[3])); + } - template - GLM_FUNC_QUALIFIER detail::tvec2 umulExtended - ( - detail::tvec2 const & x, - detail::tvec2 const & y, - detail::tvec2 & msb, - detail::tvec2 & lsb - ) - { - return detail::tvec2( - umulExtended(x[0], y[0], msb, lsb), - umulExtended(x[1], y[1], msb, lsb)); - } + // findMSB + template + GLM_FUNC_QUALIFIER int findMSB + ( + genIUType const & Value + ) + { + GLM_STATIC_ASSERT(std::numeric_limits::is_integer, "'findMSB' only accept integer values"); + if(Value == 0) + return -1; - template - GLM_FUNC_QUALIFIER detail::tvec3 umulExtended - ( - detail::tvec3 const & x, - detail::tvec3 const & y, - detail::tvec3 & msb, - detail::tvec3 & lsb - ) - { - return detail::tvec3( - umulExtended(x[0], y[0], msb, lsb), - umulExtended(x[1], y[1], msb, lsb), - umulExtended(x[2], y[2], msb, lsb)); - } + genIUType bit = genIUType(-1); + for(genIUType tmp = Value; tmp; tmp >>= 1, ++bit){} + return bit; + } - template - GLM_FUNC_QUALIFIER detail::tvec4 umulExtended - ( - detail::tvec4 const & x, - detail::tvec4 const & y, - detail::tvec4 & msb, - detail::tvec4 & lsb - ) - { - return detail::tvec4( - umulExtended(x[0], y[0], msb, lsb), - umulExtended(x[1], y[1], msb, lsb), - umulExtended(x[2], y[2], msb, lsb), - umulExtended(x[3], y[3], msb, lsb)); - } + template + GLM_FUNC_QUALIFIER detail::tvec2 findMSB + ( + detail::tvec2 const & value + ) + { + return detail::tvec2( + findMSB(value[0]), + findMSB(value[1])); + } - // imulExtended - template - GLM_FUNC_QUALIFIER void imulExtended - ( - genIType const & x, - genIType const & y, - genIType & msb, - genIType & lsb - ) - { - detail::highp_int_t ValueX64 = x; - detail::highp_int_t ValueY64 = y; - detail::highp_int_t Value64 = ValueX64 * ValueY64; - msb = *(genIType*)&genIType(Value64 & ((detail::highp_uint_t(1) << detail::highp_uint_t(32)) - detail::highp_uint_t(1))); - lsb = *(genIType*)&genIType(Value64 >> detail::highp_uint_t(32)); - } + template + GLM_FUNC_QUALIFIER detail::tvec3 findMSB + ( + detail::tvec3 const & value + ) + { + return detail::tvec3( + findMSB(value[0]), + findMSB(value[1]), + findMSB(value[2])); + } - template - GLM_FUNC_QUALIFIER detail::tvec2 imulExtended - ( - detail::tvec2 const & x, - detail::tvec2 const & y, - detail::tvec2 & msb, - detail::tvec2 & lsb - ) - { - return detail::tvec2( - imulExtended(x[0], y[0], msb, lsb), - imulExtended(x[1], y[1], msb, lsb)); - } - - template - GLM_FUNC_QUALIFIER detail::tvec3 imulExtended - ( - detail::tvec3 const & x, - detail::tvec3 const & y, - detail::tvec3 & msb, - detail::tvec3 & lsb - ) - { - return detail::tvec3( - imulExtended(x[0], y[0], msb, lsb), - imulExtended(x[1], y[1], msb, lsb), - imulExtended(x[2], y[2], msb, lsb)); - } - - template - GLM_FUNC_QUALIFIER detail::tvec4 imulExtended - ( - detail::tvec4 const & x, - detail::tvec4 const & y, - detail::tvec4 & msb, - detail::tvec4 & lsb - ) - { - return detail::tvec4( - imulExtended(x[0], y[0], msb, lsb), - imulExtended(x[1], y[1], msb, lsb), - imulExtended(x[2], y[2], msb, lsb), - imulExtended(x[3], y[3], msb, lsb)); - } - - // bitfieldExtract - template - GLM_FUNC_QUALIFIER genIUType bitfieldExtract - ( - genIUType const & Value, - int const & Offset, - int const & Bits - ) - { - int GenSize = int(sizeof(genIUType)) << int(3); - - assert(Offset + Bits <= GenSize); - - genIUType ShiftLeft = Bits ? Value << (GenSize - (Bits + Offset)) : genIUType(0); - genIUType ShiftBack = ShiftLeft >> genIUType(GenSize - Bits); - - return ShiftBack; - } - - template - GLM_FUNC_QUALIFIER detail::tvec2 bitfieldExtract - ( - detail::tvec2 const & Value, - int const & Offset, - int const & Bits - ) - { - return detail::tvec2( - bitfieldExtract(Value[0]), - bitfieldExtract(Value[1])); - } - - template - GLM_FUNC_QUALIFIER detail::tvec3 bitfieldExtract - ( - detail::tvec3 const & Value, - int const & Offset, - int const & Bits - ) - { - return detail::tvec3( - bitfieldExtract(Value[0]), - bitfieldExtract(Value[1]), - bitfieldExtract(Value[2])); - } - - template - GLM_FUNC_QUALIFIER detail::tvec4 bitfieldExtract - ( - detail::tvec4 const & Value, - int const & Offset, - int const & Bits - ) - { - return detail::tvec4( - bitfieldExtract(Value[0]), - bitfieldExtract(Value[1]), - bitfieldExtract(Value[2]), - bitfieldExtract(Value[3])); - } - - // bitfieldInsert - template - GLM_FUNC_QUALIFIER genIUType bitfieldInsert - ( - genIUType const & Base, - genIUType const & Insert, - int const & Offset, - int const & Bits - ) - { - GLM_STATIC_ASSERT(std::numeric_limits::is_integer, "'bitfieldInsert' only accept integer values"); - assert(Offset + Bits <= sizeof(genIUType)); - - if(Bits == 0) - return Base; - - genIUType Mask = 0; - for(int Bit = Offset; Bit < Offset + Bits; ++Bit) - Mask |= (1 << Bit); - - return (Base & ~Mask) | (Insert & Mask); - } - - template - GLM_FUNC_QUALIFIER detail::tvec2 bitfieldInsert - ( - detail::tvec2 const & Base, - detail::tvec2 const & Insert, - int const & Offset, - int const & Bits - ) - { - return detail::tvec2( - bitfieldInsert(Base[0], Insert[0], Offset, Bits), - bitfieldInsert(Base[1], Insert[1], Offset, Bits)); - } - - template - GLM_FUNC_QUALIFIER detail::tvec3 bitfieldInsert - ( - detail::tvec3 const & Base, - detail::tvec3 const & Insert, - int const & Offset, - int const & Bits - ) - { - return detail::tvec3( - bitfieldInsert(Base[0], Insert[0], Offset, Bits), - bitfieldInsert(Base[1], Insert[1], Offset, Bits), - bitfieldInsert(Base[2], Insert[2], Offset, Bits)); - } - - template - GLM_FUNC_QUALIFIER detail::tvec4 bitfieldInsert - ( - detail::tvec4 const & Base, - detail::tvec4 const & Insert, - int const & Offset, - int const & Bits - ) - { - return detail::tvec4( - bitfieldInsert(Base[0], Insert[0], Offset, Bits), - bitfieldInsert(Base[1], Insert[1], Offset, Bits), - bitfieldInsert(Base[2], Insert[2], Offset, Bits), - bitfieldInsert(Base[3], Insert[3], Offset, Bits)); - } - - // bitfieldReverse - template - GLM_FUNC_QUALIFIER genIUType bitfieldReverse(genIUType const & Value) - { - GLM_STATIC_ASSERT(std::numeric_limits::is_integer, "'bitfieldReverse' only accept integer values"); - - genIUType Out = 0; - std::size_t BitSize = sizeof(genIUType) * 8; - for(std::size_t i = 0; i < BitSize; ++i) - if(Value & (genIUType(1) << i)) - Out |= genIUType(1) << (BitSize - 1 - i); - return Out; - } - - template - GLM_FUNC_QUALIFIER detail::tvec2 bitfieldReverse - ( - detail::tvec2 const & value - ) - { - return detail::tvec2( - bitfieldReverse(value[0]), - bitfieldReverse(value[1])); - } - - template - GLM_FUNC_QUALIFIER detail::tvec3 bitfieldReverse - ( - detail::tvec3 const & value - ) - { - return detail::tvec3( - bitfieldReverse(value[0]), - bitfieldReverse(value[1]), - bitfieldReverse(value[2])); - } - - template - GLM_FUNC_QUALIFIER detail::tvec4 bitfieldReverse - ( - detail::tvec4 const & value - ) - { - return detail::tvec4( - bitfieldReverse(value[0]), - bitfieldReverse(value[1]), - bitfieldReverse(value[2]), - bitfieldReverse(value[3])); - } - - // bitCount - template - GLM_FUNC_QUALIFIER int bitCount(genIUType const & Value) - { - GLM_STATIC_ASSERT(std::numeric_limits::is_integer, "'bitCount' only accept integer values"); - - int Count = 0; - for(std::size_t i = 0; i < sizeof(genIUType) * std::size_t(8); ++i) - { - if(Value & (1 << i)) - ++Count; - } - return Count; - } - - template - GLM_FUNC_QUALIFIER detail::tvec2 bitCount - ( - detail::tvec2 const & value - ) - { - return detail::tvec2( - bitCount(value[0]), - bitCount(value[1])); - } - - template - GLM_FUNC_QUALIFIER detail::tvec3 bitCount - ( - detail::tvec3 const & value - ) - { - return detail::tvec3( - bitCount(value[0]), - bitCount(value[1]), - bitCount(value[2])); - } - - template - GLM_FUNC_QUALIFIER detail::tvec4 bitCount - ( - detail::tvec4 const & value - ) - { - return detail::tvec4( - bitCount(value[0]), - bitCount(value[1]), - bitCount(value[2]), - bitCount(value[3])); - } - - // findLSB - template - GLM_FUNC_QUALIFIER int findLSB - ( - genIUType const & Value - ) - { - GLM_STATIC_ASSERT(std::numeric_limits::is_integer, "'findLSB' only accept integer values"); - if(Value == 0) - return -1; - - genIUType Bit; - for(Bit = genIUType(0); !(Value & (1 << Bit)); ++Bit){} - return Bit; - } - - template - GLM_FUNC_QUALIFIER detail::tvec2 findLSB - ( - detail::tvec2 const & value - ) - { - return detail::tvec2( - findLSB(value[0]), - findLSB(value[1])); - } - - template - GLM_FUNC_QUALIFIER detail::tvec3 findLSB - ( - detail::tvec3 const & value - ) - { - return detail::tvec3( - findLSB(value[0]), - findLSB(value[1]), - findLSB(value[2])); - } - - template - GLM_FUNC_QUALIFIER detail::tvec4 findLSB - ( - detail::tvec4 const & value - ) - { - return detail::tvec4( - findLSB(value[0]), - findLSB(value[1]), - findLSB(value[2]), - findLSB(value[3])); - } - - // findMSB - template - GLM_FUNC_QUALIFIER int findMSB - ( - genIUType const & Value - ) - { - GLM_STATIC_ASSERT(std::numeric_limits::is_integer, "'findMSB' only accept integer values"); - if(Value == 0) - return -1; - - genIUType bit = genIUType(-1); - for(genIUType tmp = Value; tmp; tmp >>= 1, ++bit){} - return bit; - } - - template - GLM_FUNC_QUALIFIER detail::tvec2 findMSB - ( - detail::tvec2 const & value - ) - { - return detail::tvec2( - findMSB(value[0]), - findMSB(value[1])); - } - - template - GLM_FUNC_QUALIFIER detail::tvec3 findMSB - ( - detail::tvec3 const & value - ) - { - return detail::tvec3( - findMSB(value[0]), - findMSB(value[1]), - findMSB(value[2])); - } - - template - GLM_FUNC_QUALIFIER detail::tvec4 findMSB - ( - detail::tvec4 const & value - ) - { - return detail::tvec4( - findMSB(value[0]), - findMSB(value[1]), - findMSB(value[2]), - findMSB(value[3])); - } - -}//namespace core + template + GLM_FUNC_QUALIFIER detail::tvec4 findMSB + ( + detail::tvec4 const & value + ) + { + return detail::tvec4( + findMSB(value[0]), + findMSB(value[1]), + findMSB(value[2]), + findMSB(value[3])); + } }//namespace glm diff --git a/glm/core/func_matrix.hpp b/glm/core/func_matrix.hpp index fc475287..29757507 100644 --- a/glm/core/func_matrix.hpp +++ b/glm/core/func_matrix.hpp @@ -10,10 +10,9 @@ #ifndef glm_core_func_matrix #define glm_core_func_matrix -namespace glm{ -namespace core +namespace glm { - /// \addtogroup core_funcs + /// @addtogroup core_funcs /// @{ //! Multiply matrix x by matrix y component-wise, i.e., @@ -94,7 +93,6 @@ namespace core detail::tmat4x4 const & m); /// @} -}//namespace core }//namespace glm #include "func_matrix.inl" diff --git a/glm/core/func_matrix.inl b/glm/core/func_matrix.inl index e78d9faa..ec520329 100644 --- a/glm/core/func_matrix.inl +++ b/glm/core/func_matrix.inl @@ -7,33 +7,32 @@ // File : glm/core/func_matrix.inl /////////////////////////////////////////////////////////////////////////////////////////////////// -namespace glm{ -namespace core +namespace glm { - // matrixCompMult - template - GLM_FUNC_QUALIFIER matType matrixCompMult + // matrixCompMult + template + GLM_FUNC_QUALIFIER matType matrixCompMult ( matType const & x, matType const & y ) - { + { GLM_STATIC_ASSERT(detail::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) result[i] = x[i] * y[i]; - return result; - } + return result; + } // outerProduct - template - GLM_FUNC_QUALIFIER detail::tmat2x2 outerProduct + template + GLM_FUNC_QUALIFIER detail::tmat2x2 outerProduct ( detail::tvec2 const & c, detail::tvec2 const & r ) - { + { GLM_STATIC_ASSERT(detail::type::is_float, "'outerProduct' only accept floating-point inputs"); detail::tmat2x2 m(detail::tmat2x2::null); @@ -41,40 +40,40 @@ namespace core m[0][1] = c[1] * r[0]; m[1][0] = c[0] * r[1]; m[1][1] = c[1] * r[1]; - return m; - } + return m; + } - template - GLM_FUNC_QUALIFIER detail::tmat3x3 outerProduct + template + GLM_FUNC_QUALIFIER detail::tmat3x3 outerProduct ( detail::tvec3 const & c, detail::tvec3 const & r ) - { + { GLM_STATIC_ASSERT(detail::type::is_float, "'outerProduct' only accept floating-point inputs"); detail::tmat3x3 m(detail::tmat3x3::null); for(typename detail::tmat3x3::size_type i = 0; i < detail::tmat3x3::col_size(); ++i) m[i] = c * r[i]; - return m; - } + return m; + } - template - GLM_FUNC_QUALIFIER detail::tmat4x4 outerProduct + template + GLM_FUNC_QUALIFIER detail::tmat4x4 outerProduct ( detail::tvec4 const & c, detail::tvec4 const & r ) - { + { GLM_STATIC_ASSERT(detail::type::is_float, "'outerProduct' only accept floating-point inputs"); detail::tmat4x4 m(detail::tmat4x4::null); for(typename detail::tmat4x4::size_type i = 0; i < detail::tmat4x4::col_size(); ++i) m[i] = c * r[i]; - return m; - } + return m; + } - template + template GLM_FUNC_QUALIFIER detail::tmat2x3 outerProduct ( detail::tvec3 const & c, @@ -93,7 +92,7 @@ namespace core return m; } - template + template GLM_FUNC_QUALIFIER detail::tmat3x2 outerProduct ( detail::tvec2 const & c, @@ -204,113 +203,113 @@ namespace core return m; } - template - GLM_FUNC_QUALIFIER detail::tmat2x2 transpose + template + GLM_FUNC_QUALIFIER detail::tmat2x2 transpose ( detail::tmat2x2 const & m ) - { + { GLM_STATIC_ASSERT(detail::type::is_float, "'transpose' only accept floating-point inputs"); - detail::tmat2x2 result(detail::tmat2x2::null); - result[0][0] = m[0][0]; - result[0][1] = m[1][0]; - result[1][0] = m[0][1]; - result[1][1] = m[1][1]; - return result; - } + detail::tmat2x2 result(detail::tmat2x2::null); + result[0][0] = m[0][0]; + result[0][1] = m[1][0]; + result[1][0] = m[0][1]; + result[1][1] = m[1][1]; + return result; + } - template - GLM_FUNC_QUALIFIER detail::tmat3x3 transpose + template + GLM_FUNC_QUALIFIER detail::tmat3x3 transpose ( detail::tmat3x3 const & m ) - { + { GLM_STATIC_ASSERT(detail::type::is_float, "'transpose' only accept floating-point inputs"); - detail::tmat3x3 result(detail::tmat3x3::null); - result[0][0] = m[0][0]; - result[0][1] = m[1][0]; - result[0][2] = m[2][0]; + detail::tmat3x3 result(detail::tmat3x3::null); + result[0][0] = m[0][0]; + result[0][1] = m[1][0]; + result[0][2] = m[2][0]; - result[1][0] = m[0][1]; - result[1][1] = m[1][1]; - result[1][2] = m[2][1]; + result[1][0] = m[0][1]; + result[1][1] = m[1][1]; + result[1][2] = m[2][1]; - result[2][0] = m[0][2]; - result[2][1] = m[1][2]; - result[2][2] = m[2][2]; - return result; - } + result[2][0] = m[0][2]; + result[2][1] = m[1][2]; + result[2][2] = m[2][2]; + return result; + } - template - GLM_FUNC_QUALIFIER detail::tmat4x4 transpose + template + GLM_FUNC_QUALIFIER detail::tmat4x4 transpose ( detail::tmat4x4 const & m ) - { + { GLM_STATIC_ASSERT(detail::type::is_float, "'transpose' only accept floating-point inputs"); - detail::tmat4x4 result(detail::tmat4x4::null); - result[0][0] = m[0][0]; - result[0][1] = m[1][0]; - result[0][2] = m[2][0]; - result[0][3] = m[3][0]; + detail::tmat4x4 result(detail::tmat4x4::null); + result[0][0] = m[0][0]; + result[0][1] = m[1][0]; + result[0][2] = m[2][0]; + result[0][3] = m[3][0]; - result[1][0] = m[0][1]; - result[1][1] = m[1][1]; - result[1][2] = m[2][1]; - result[1][3] = m[3][1]; + result[1][0] = m[0][1]; + result[1][1] = m[1][1]; + result[1][2] = m[2][1]; + result[1][3] = m[3][1]; - result[2][0] = m[0][2]; - result[2][1] = m[1][2]; - result[2][2] = m[2][2]; - result[2][3] = m[3][2]; + result[2][0] = m[0][2]; + result[2][1] = m[1][2]; + result[2][2] = m[2][2]; + result[2][3] = m[3][2]; - result[3][0] = m[0][3]; - result[3][1] = m[1][3]; - result[3][2] = m[2][3]; - result[3][3] = m[3][3]; - return result; - } + result[3][0] = m[0][3]; + result[3][1] = m[1][3]; + result[3][2] = m[2][3]; + result[3][3] = m[3][3]; + return result; + } - template - GLM_FUNC_QUALIFIER detail::tmat2x3 transpose + template + GLM_FUNC_QUALIFIER detail::tmat2x3 transpose ( detail::tmat3x2 const & m ) - { + { GLM_STATIC_ASSERT(detail::type::is_float, "'transpose' only accept floating-point inputs"); - detail::tmat2x3 result(detail::tmat2x3::null); - result[0][0] = m[0][0]; - result[0][1] = m[1][0]; + detail::tmat2x3 result(detail::tmat2x3::null); + result[0][0] = m[0][0]; + result[0][1] = m[1][0]; result[0][2] = m[2][0]; - result[1][0] = m[0][1]; - result[1][1] = m[1][1]; + result[1][0] = m[0][1]; + result[1][1] = m[1][1]; result[1][2] = m[2][1]; - return result; - } + return result; + } - template - GLM_FUNC_QUALIFIER detail::tmat3x2 transpose + template + GLM_FUNC_QUALIFIER detail::tmat3x2 transpose ( detail::tmat2x3 const & m ) - { + { GLM_STATIC_ASSERT(detail::type::is_float, "'transpose' only accept floating-point inputs"); - detail::tmat3x2 result(detail::tmat3x2::null); - result[0][0] = m[0][0]; - result[0][1] = m[1][0]; - result[1][0] = m[0][1]; - result[1][1] = m[1][1]; - result[2][0] = m[0][2]; - result[2][1] = m[1][2]; - return result; - } + detail::tmat3x2 result(detail::tmat3x2::null); + result[0][0] = m[0][0]; + result[0][1] = m[1][0]; + result[1][0] = m[0][1]; + result[1][1] = m[1][1]; + result[2][0] = m[0][2]; + result[2][1] = m[1][2]; + return result; + } - template + template GLM_FUNC_QUALIFIER detail::tmat2x4 transpose ( detail::tmat4x2 const & m @@ -319,18 +318,18 @@ namespace core GLM_STATIC_ASSERT(detail::type::is_float, "'transpose' only accept floating-point inputs"); detail::tmat2x4 result(detail::tmat2x4::null); - result[0][0] = m[0][0]; - result[0][1] = m[1][0]; + result[0][0] = m[0][0]; + result[0][1] = m[1][0]; result[0][2] = m[2][0]; result[0][3] = m[3][0]; - result[1][0] = m[0][1]; - result[1][1] = m[1][1]; + result[1][0] = m[0][1]; + result[1][1] = m[1][1]; result[1][2] = m[2][1]; result[1][3] = m[3][1]; return result; } - template + template GLM_FUNC_QUALIFIER detail::tmat4x2 transpose ( detail::tmat2x4 const & m @@ -338,19 +337,19 @@ namespace core { GLM_STATIC_ASSERT(detail::type::is_float, "'transpose' only accept floating-point inputs"); - detail::tmat4x2 result(detail::tmat4x2::null); - result[0][0] = m[0][0]; - result[0][1] = m[1][0]; - result[1][0] = m[0][1]; - result[1][1] = m[1][1]; - result[2][0] = m[0][2]; - result[2][1] = m[1][2]; - result[3][0] = m[0][3]; - result[3][1] = m[1][3]; - return result; + detail::tmat4x2 result(detail::tmat4x2::null); + result[0][0] = m[0][0]; + result[0][1] = m[1][0]; + result[1][0] = m[0][1]; + result[1][1] = m[1][1]; + result[2][0] = m[0][2]; + result[2][1] = m[1][2]; + result[3][0] = m[0][3]; + result[3][1] = m[1][3]; + return result; } - template + template GLM_FUNC_QUALIFIER detail::tmat3x4 transpose ( detail::tmat4x3 const & m @@ -359,22 +358,22 @@ namespace core GLM_STATIC_ASSERT(detail::type::is_float, "'transpose' only accept floating-point inputs"); detail::tmat3x4 result(detail::tmat3x4::null); - result[0][0] = m[0][0]; - result[0][1] = m[1][0]; + result[0][0] = m[0][0]; + result[0][1] = m[1][0]; result[0][2] = m[2][0]; result[0][3] = m[3][0]; - result[1][0] = m[0][1]; - result[1][1] = m[1][1]; + result[1][0] = m[0][1]; + result[1][1] = m[1][1]; result[1][2] = m[2][1]; result[1][3] = m[3][1]; - result[2][0] = m[0][2]; - result[2][1] = m[1][2]; + result[2][0] = m[0][2]; + result[2][1] = m[1][2]; result[2][2] = m[2][2]; result[2][3] = m[3][2]; return result; } - template + template GLM_FUNC_QUALIFIER detail::tmat4x3 transpose ( detail::tmat3x4 const & m @@ -382,20 +381,20 @@ namespace core { GLM_STATIC_ASSERT(detail::type::is_float, "'transpose' only accept floating-point inputs"); - detail::tmat4x3 result(detail::tmat4x3::null); - result[0][0] = m[0][0]; - result[0][1] = m[1][0]; + detail::tmat4x3 result(detail::tmat4x3::null); + result[0][0] = m[0][0]; + result[0][1] = m[1][0]; result[0][2] = m[2][0]; - result[1][0] = m[0][1]; - result[1][1] = m[1][1]; + result[1][0] = m[0][1]; + result[1][1] = m[1][1]; result[1][2] = m[2][1]; - result[2][0] = m[0][2]; - result[2][1] = m[1][2]; + result[2][0] = m[0][2]; + result[2][1] = m[1][2]; result[2][2] = m[2][2]; - result[3][0] = m[0][3]; - result[3][1] = m[1][3]; + result[3][0] = m[0][3]; + result[3][1] = m[1][3]; result[3][2] = m[2][3]; - return result; + return result; } template @@ -445,9 +444,9 @@ namespace core - (m[1][0] * SubFactor02 - m[1][1] * SubFactor04 + m[1][2] * SubFactor05)); return m[0][0] * DetCof[0] - + m[0][1] * DetCof[1] - + m[0][2] * DetCof[2] - + m[0][3] * DetCof[3]; + + m[0][1] * DetCof[1] + + m[0][2] * DetCof[2] + + m[0][3] * DetCof[3]; } template @@ -561,6 +560,4 @@ namespace core return Inverse; } - -}//namespace core }//namespace glm diff --git a/glm/core/func_noise.hpp b/glm/core/func_noise.hpp index 35a1e572..c7d0cfbe 100644 --- a/glm/core/func_noise.hpp +++ b/glm/core/func_noise.hpp @@ -10,10 +10,9 @@ #ifndef glm_core_func_noise #define glm_core_func_noise -namespace glm{ -namespace core +namespace glm { - /// \addtogroup core_funcs + /// @addtogroup core_funcs /// @{ //! Returns a 1D noise value based on the input value x. @@ -45,7 +44,6 @@ namespace core detail::tvec4 noise4(genType const & x); /// @} -}//namespace core }//namespace glm #include "func_noise.inl" diff --git a/glm/core/func_packing.hpp b/glm/core/func_packing.hpp index 23388bbf..e99b1094 100644 --- a/glm/core/func_packing.hpp +++ b/glm/core/func_packing.hpp @@ -10,11 +10,10 @@ #ifndef glm_core_func_packing #define glm_core_func_packing -namespace glm{ -namespace core +namespace glm { - /// \addtogroup core_funcs - ///@{ + /// @addtogroup core_funcs + /// @{ //! 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. @@ -114,7 +113,6 @@ namespace core detail::tvec2 unpackDouble2x32(double const & v); /// @} -}//namespace core }//namespace glm #include "func_packing.inl" diff --git a/glm/core/func_packing.inl b/glm/core/func_packing.inl index cc5a5776..905d13c3 100644 --- a/glm/core/func_packing.inl +++ b/glm/core/func_packing.inl @@ -8,77 +8,75 @@ /////////////////////////////////////////////////////////////////////////////////////////////////// namespace glm{ -namespace core + +GLM_FUNC_QUALIFIER detail::uint32 packUnorm2x16(detail::tvec2 const & v) { - GLM_FUNC_QUALIFIER detail::uint32 packUnorm2x16(detail::tvec2 const & v) - { - detail::uint16 A((detail::uint16)round(clamp(v.x, 0.0f, 1.0f) * 65535.0f)); - detail::uint16 B((detail::uint16)round(clamp(v.y, 0.0f, 1.0f) * 65535.0f)); - return detail::uint32((B << 16) | A); - } + detail::uint16 A((detail::uint16)round(clamp(v.x, 0.0f, 1.0f) * 65535.0f)); + detail::uint16 B((detail::uint16)round(clamp(v.y, 0.0f, 1.0f) * 65535.0f)); + return detail::uint32((B << 16) | A); +} - GLM_FUNC_QUALIFIER detail::uint32 packUnorm4x8(detail::tvec4 const & v) - { - detail::uint8 A((detail::uint8)round(clamp(v.x, 0.0f, 1.0f) * 255.0f)); - detail::uint8 B((detail::uint8)round(clamp(v.y, 0.0f, 1.0f) * 255.0f)); - detail::uint8 C((detail::uint8)round(clamp(v.z, 0.0f, 1.0f) * 255.0f)); - detail::uint8 D((detail::uint8)round(clamp(v.w, 0.0f, 1.0f) * 255.0f)); - return detail::uint32((D << 24) | (C << 16) | (B << 8) | A); - } +GLM_FUNC_QUALIFIER detail::uint32 packUnorm4x8(detail::tvec4 const & v) +{ + detail::uint8 A((detail::uint8)round(clamp(v.x, 0.0f, 1.0f) * 255.0f)); + detail::uint8 B((detail::uint8)round(clamp(v.y, 0.0f, 1.0f) * 255.0f)); + detail::uint8 C((detail::uint8)round(clamp(v.z, 0.0f, 1.0f) * 255.0f)); + detail::uint8 D((detail::uint8)round(clamp(v.w, 0.0f, 1.0f) * 255.0f)); + return detail::uint32((D << 24) | (C << 16) | (B << 8) | A); +} - GLM_FUNC_QUALIFIER detail::uint32 packSnorm4x8(detail::tvec4 const & v) - { - 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 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)); - return detail::uint32((D << 24) | (C << 16) | (B << 8) | A); - } +GLM_FUNC_QUALIFIER detail::uint32 packSnorm4x8(detail::tvec4 const & v) +{ + 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 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)); + return detail::uint32((D << 24) | (C << 16) | (B << 8) | A); +} - GLM_FUNC_QUALIFIER detail::tvec2 unpackUnorm2x16(detail::uint32 const & p) - { - detail::uint16 A(detail::uint16(p >> 0)); - detail::uint16 B(detail::uint16(p >> 16)); - return detail::tvec2( - A * 1.0f / 65535.0f, - B * 1.0f / 65535.0f); - } +GLM_FUNC_QUALIFIER detail::tvec2 unpackUnorm2x16(detail::uint32 const & p) +{ + detail::uint16 A(detail::uint16(p >> 0)); + detail::uint16 B(detail::uint16(p >> 16)); + return detail::tvec2( + A * 1.0f / 65535.0f, + B * 1.0f / 65535.0f); +} - GLM_FUNC_QUALIFIER detail::tvec4 unpackUnorm4x8(detail::uint32 const & p) - { - detail::uint8 A(detail::uint8(p >> 0)); - detail::uint8 B(detail::uint8(p >> 8)); - detail::uint8 C(detail::uint8(p >> 16)); - detail::uint8 D(detail::uint8(p >> 24)); - return detail::tvec4( - A * 1.0f / 255.0f, - B * 1.0f / 255.0f, - C * 1.0f / 255.0f, - D * 1.0f / 255.0f); - } +GLM_FUNC_QUALIFIER detail::tvec4 unpackUnorm4x8(detail::uint32 const & p) +{ + detail::uint8 A(detail::uint8(p >> 0)); + detail::uint8 B(detail::uint8(p >> 8)); + detail::uint8 C(detail::uint8(p >> 16)); + detail::uint8 D(detail::uint8(p >> 24)); + return detail::tvec4( + A * 1.0f / 255.0f, + B * 1.0f / 255.0f, + C * 1.0f / 255.0f, + D * 1.0f / 255.0f); +} - GLM_FUNC_QUALIFIER detail::tvec4 unpackSnorm4x8(detail::uint32 const & p) - { - detail::uint8 A(detail::uint8(p >> 0)); - detail::uint8 B(detail::uint8(p >> 8)); - detail::uint8 C(detail::uint8(p >> 16)); - detail::uint8 D(detail::uint8(p >> 24)); - return clamp(detail::tvec4( - A * 1.0f / 127.0f, - B * 1.0f / 127.0f, - C * 1.0f / 127.0f, - D * 1.0f / 127.0f), -1.0f, 1.0f); - } +GLM_FUNC_QUALIFIER detail::tvec4 unpackSnorm4x8(detail::uint32 const & p) +{ + detail::uint8 A(detail::uint8(p >> 0)); + detail::uint8 B(detail::uint8(p >> 8)); + detail::uint8 C(detail::uint8(p >> 16)); + detail::uint8 D(detail::uint8(p >> 24)); + return clamp(detail::tvec4( + A * 1.0f / 127.0f, + B * 1.0f / 127.0f, + C * 1.0f / 127.0f, + D * 1.0f / 127.0f), -1.0f, 1.0f); +} - GLM_FUNC_QUALIFIER double packDouble2x32(detail::tvec2 const & v) - { - return *(double*)&v; - } +GLM_FUNC_QUALIFIER double packDouble2x32(detail::tvec2 const & v) +{ + return *(double*)&v; +} - GLM_FUNC_QUALIFIER detail::tvec2 unpackDouble2x32(double const & v) - { - return *(detail::tvec2*)&v; - } +GLM_FUNC_QUALIFIER detail::tvec2 unpackDouble2x32(double const & v) +{ + return *(detail::tvec2*)&v; +} -}//namespace core }//namespace glm diff --git a/glm/core/func_trigonometric.hpp b/glm/core/func_trigonometric.hpp index 62dec8c0..ef941d54 100644 --- a/glm/core/func_trigonometric.hpp +++ b/glm/core/func_trigonometric.hpp @@ -10,10 +10,9 @@ #ifndef glm_core_func_trigonometric #define glm_core_func_trigonometric -namespace glm{ -namespace core +namespace glm { - /// \addtogroup core_funcs + /// @addtogroup core_funcs /// @{ //! Converts degrees to radians and returns the result. @@ -135,7 +134,6 @@ namespace core genType atanh(genType const & x); /// @} -}//namespace core }//namespace glm #include "func_trigonometric.inl" diff --git a/glm/core/func_trigonometric.inl b/glm/core/func_trigonometric.inl index d0db73a1..eeafc8ef 100644 --- a/glm/core/func_trigonometric.inl +++ b/glm/core/func_trigonometric.inl @@ -8,733 +8,731 @@ /////////////////////////////////////////////////////////////////////////////////////////////////// namespace glm{ -namespace core + +// radians +template +GLM_FUNC_QUALIFIER genType radians +( + genType const & degrees +) { - // radians - template - GLM_FUNC_QUALIFIER genType radians - ( - genType const & degrees - ) - { - GLM_STATIC_ASSERT(detail::type::is_float, "'radians' only accept floating-point input"); + GLM_STATIC_ASSERT(detail::type::is_float, "'radians' only accept floating-point input"); - const genType pi = genType(3.1415926535897932384626433832795); - return degrees * (pi / genType(180)); - } + const genType pi = genType(3.1415926535897932384626433832795); + return degrees * (pi / genType(180)); +} - template - GLM_FUNC_QUALIFIER detail::tvec2 radians - ( - detail::tvec2 const & degrees - ) - { - return detail::tvec2( - radians(degrees.x), - radians(degrees.y)); - } +template +GLM_FUNC_QUALIFIER detail::tvec2 radians +( + detail::tvec2 const & degrees +) +{ + return detail::tvec2( + radians(degrees.x), + radians(degrees.y)); +} - template - GLM_FUNC_QUALIFIER detail::tvec3 radians - ( - detail::tvec3 const & degrees - ) - { - return detail::tvec3( - radians(degrees.x), - radians(degrees.y), - radians(degrees.z)); - } +template +GLM_FUNC_QUALIFIER detail::tvec3 radians +( + detail::tvec3 const & degrees +) +{ + return detail::tvec3( + radians(degrees.x), + radians(degrees.y), + radians(degrees.z)); +} - template - GLM_FUNC_QUALIFIER detail::tvec4 radians - ( - detail::tvec4 const & degrees - ) - { - return detail::tvec4( - radians(degrees.x), - radians(degrees.y), - radians(degrees.z), - radians(degrees.w)); - } +template +GLM_FUNC_QUALIFIER detail::tvec4 radians +( + detail::tvec4 const & degrees +) +{ + return detail::tvec4( + radians(degrees.x), + radians(degrees.y), + radians(degrees.z), + radians(degrees.w)); +} - // degrees - template - GLM_FUNC_QUALIFIER genType degrees - ( - genType const & radians - ) - { - GLM_STATIC_ASSERT(detail::type::is_float, "'degrees' only accept floating-point input"); +// degrees +template +GLM_FUNC_QUALIFIER genType degrees +( + genType const & radians +) +{ + GLM_STATIC_ASSERT(detail::type::is_float, "'degrees' only accept floating-point input"); - const genType pi = genType(3.1415926535897932384626433832795); - return radians * (genType(180) / pi); - } + const genType pi = genType(3.1415926535897932384626433832795); + return radians * (genType(180) / pi); +} - template - GLM_FUNC_QUALIFIER detail::tvec2 degrees - ( - detail::tvec2 const & radians - ) - { - return detail::tvec2( - degrees(radians.x), - degrees(radians.y)); - } +template +GLM_FUNC_QUALIFIER detail::tvec2 degrees +( + detail::tvec2 const & radians +) +{ + return detail::tvec2( + degrees(radians.x), + degrees(radians.y)); +} - template - GLM_FUNC_QUALIFIER detail::tvec3 degrees - ( - detail::tvec3 const & radians - ) - { - return detail::tvec3( - degrees(radians.x), - degrees(radians.y), - degrees(radians.z)); - } +template +GLM_FUNC_QUALIFIER detail::tvec3 degrees +( + detail::tvec3 const & radians +) +{ + return detail::tvec3( + degrees(radians.x), + degrees(radians.y), + degrees(radians.z)); +} - template - GLM_FUNC_QUALIFIER detail::tvec4 degrees - ( - detail::tvec4 const & radians - ) - { - return detail::tvec4( - degrees(radians.x), - degrees(radians.y), - degrees(radians.z), - degrees(radians.w)); - } +template +GLM_FUNC_QUALIFIER detail::tvec4 degrees +( + detail::tvec4 const & radians +) +{ + return detail::tvec4( + degrees(radians.x), + degrees(radians.y), + degrees(radians.z), + degrees(radians.w)); +} - // sin - template - GLM_FUNC_QUALIFIER genType sin - ( - genType const & angle - ) - { - GLM_STATIC_ASSERT(detail::type::is_float, "'sin' only accept floating-point input"); +// sin +template +GLM_FUNC_QUALIFIER genType sin +( + genType const & angle +) +{ + GLM_STATIC_ASSERT(detail::type::is_float, "'sin' only accept floating-point input"); - return ::std::sin(angle); - } + return ::std::sin(angle); +} - template - GLM_FUNC_QUALIFIER detail::tvec2 sin - ( - detail::tvec2 const & angle - ) - { - return detail::tvec2( - sin(angle.x), - sin(angle.y)); - } +template +GLM_FUNC_QUALIFIER detail::tvec2 sin +( + detail::tvec2 const & angle +) +{ + return detail::tvec2( + sin(angle.x), + sin(angle.y)); +} - template - GLM_FUNC_QUALIFIER detail::tvec3 sin - ( - detail::tvec3 const & angle - ) - { - return detail::tvec3( - sin(angle.x), - sin(angle.y), - sin(angle.z)); - } +template +GLM_FUNC_QUALIFIER detail::tvec3 sin +( + detail::tvec3 const & angle +) +{ + return detail::tvec3( + sin(angle.x), + sin(angle.y), + sin(angle.z)); +} - template - GLM_FUNC_QUALIFIER detail::tvec4 sin - ( - detail::tvec4 const & angle - ) - { - return detail::tvec4( - sin(angle.x), - sin(angle.y), - sin(angle.z), - sin(angle.w)); - } +template +GLM_FUNC_QUALIFIER detail::tvec4 sin +( + detail::tvec4 const & angle +) +{ + return detail::tvec4( + sin(angle.x), + sin(angle.y), + sin(angle.z), + sin(angle.w)); +} - // cos - template - GLM_FUNC_QUALIFIER genType cos(genType const & angle) - { - GLM_STATIC_ASSERT(detail::type::is_float, "'cos' only accept floating-point input"); +// cos +template +GLM_FUNC_QUALIFIER genType cos(genType const & angle) +{ + GLM_STATIC_ASSERT(detail::type::is_float, "'cos' only accept floating-point input"); - return ::std::cos(angle); - } + return ::std::cos(angle); +} - template - GLM_FUNC_QUALIFIER detail::tvec2 cos - ( - detail::tvec2 const & angle - ) - { - return detail::tvec2( - cos(angle.x), - cos(angle.y)); - } +template +GLM_FUNC_QUALIFIER detail::tvec2 cos +( + detail::tvec2 const & angle +) +{ + return detail::tvec2( + cos(angle.x), + cos(angle.y)); +} - template - GLM_FUNC_QUALIFIER detail::tvec3 cos - ( - detail::tvec3 const & angle - ) - { - return detail::tvec3( - cos(angle.x), - cos(angle.y), - cos(angle.z)); - } +template +GLM_FUNC_QUALIFIER detail::tvec3 cos +( + detail::tvec3 const & angle +) +{ + return detail::tvec3( + cos(angle.x), + cos(angle.y), + cos(angle.z)); +} - template - GLM_FUNC_QUALIFIER detail::tvec4 cos - ( - detail::tvec4 const & angle - ) - { - return detail::tvec4( - cos(angle.x), - cos(angle.y), - cos(angle.z), - cos(angle.w)); - } +template +GLM_FUNC_QUALIFIER detail::tvec4 cos +( + detail::tvec4 const & angle +) +{ + return detail::tvec4( + cos(angle.x), + cos(angle.y), + cos(angle.z), + cos(angle.w)); +} - // tan - template - GLM_FUNC_QUALIFIER genType tan - ( - genType const & angle - ) - { - GLM_STATIC_ASSERT(detail::type::is_float, "'tan' only accept floating-point input"); +// tan +template +GLM_FUNC_QUALIFIER genType tan +( + genType const & angle +) +{ + GLM_STATIC_ASSERT(detail::type::is_float, "'tan' only accept floating-point input"); - return ::std::tan(angle); - } + return ::std::tan(angle); +} - template - GLM_FUNC_QUALIFIER detail::tvec2 tan - ( - detail::tvec2 const & angle - ) - { - return detail::tvec2( - tan(angle.x), - tan(angle.y)); - } +template +GLM_FUNC_QUALIFIER detail::tvec2 tan +( + detail::tvec2 const & angle +) +{ + return detail::tvec2( + tan(angle.x), + tan(angle.y)); +} - template - GLM_FUNC_QUALIFIER detail::tvec3 tan - ( - detail::tvec3 const & angle - ) - { - return detail::tvec3( - tan(angle.x), - tan(angle.y), - tan(angle.z)); - } +template +GLM_FUNC_QUALIFIER detail::tvec3 tan +( + detail::tvec3 const & angle +) +{ + return detail::tvec3( + tan(angle.x), + tan(angle.y), + tan(angle.z)); +} - template - GLM_FUNC_QUALIFIER detail::tvec4 tan - ( - detail::tvec4 const & angle - ) - { - return detail::tvec4( - tan(angle.x), - tan(angle.y), - tan(angle.z), - tan(angle.w)); - } +template +GLM_FUNC_QUALIFIER detail::tvec4 tan +( + detail::tvec4 const & angle +) +{ + return detail::tvec4( + tan(angle.x), + tan(angle.y), + tan(angle.z), + tan(angle.w)); +} - // asin - template - GLM_FUNC_QUALIFIER genType asin - ( - genType const & x - ) - { - GLM_STATIC_ASSERT(detail::type::is_float, "'asin' only accept floating-point input"); +// asin +template +GLM_FUNC_QUALIFIER genType asin +( + genType const & x +) +{ + GLM_STATIC_ASSERT(detail::type::is_float, "'asin' only accept floating-point input"); - return ::std::asin(x); - } + return ::std::asin(x); +} - template - GLM_FUNC_QUALIFIER detail::tvec2 asin - ( - detail::tvec2 const & x - ) - { - return detail::tvec2( - asin(x.x), - asin(x.y)); - } +template +GLM_FUNC_QUALIFIER detail::tvec2 asin +( + detail::tvec2 const & x +) +{ + return detail::tvec2( + asin(x.x), + asin(x.y)); +} - template - GLM_FUNC_QUALIFIER detail::tvec3 asin - ( - detail::tvec3 const & x - ) - { - return detail::tvec3( - asin(x.x), - asin(x.y), - asin(x.z)); - } +template +GLM_FUNC_QUALIFIER detail::tvec3 asin +( + detail::tvec3 const & x +) +{ + return detail::tvec3( + asin(x.x), + asin(x.y), + asin(x.z)); +} - template - GLM_FUNC_QUALIFIER detail::tvec4 asin - ( - detail::tvec4 const & x - ) - { - return detail::tvec4( - asin(x.x), - asin(x.y), - asin(x.z), - asin(x.w)); - } +template +GLM_FUNC_QUALIFIER detail::tvec4 asin +( + detail::tvec4 const & x +) +{ + return detail::tvec4( + asin(x.x), + asin(x.y), + asin(x.z), + asin(x.w)); +} - // acos - template - GLM_FUNC_QUALIFIER genType acos - ( - genType const & x - ) - { - GLM_STATIC_ASSERT(detail::type::is_float, "'acos' only accept floating-point input"); +// acos +template +GLM_FUNC_QUALIFIER genType acos +( + genType const & x +) +{ + GLM_STATIC_ASSERT(detail::type::is_float, "'acos' only accept floating-point input"); - return ::std::acos(x); - } + return ::std::acos(x); +} - template - GLM_FUNC_QUALIFIER detail::tvec2 acos - ( - detail::tvec2 const & x - ) - { - return detail::tvec2( - acos(x.x), - acos(x.y)); - } +template +GLM_FUNC_QUALIFIER detail::tvec2 acos +( + detail::tvec2 const & x +) +{ + return detail::tvec2( + acos(x.x), + acos(x.y)); +} - template - GLM_FUNC_QUALIFIER detail::tvec3 acos - ( - detail::tvec3 const & x - ) - { - return detail::tvec3( - acos(x.x), - acos(x.y), - acos(x.z)); - } +template +GLM_FUNC_QUALIFIER detail::tvec3 acos +( + detail::tvec3 const & x +) +{ + return detail::tvec3( + acos(x.x), + acos(x.y), + acos(x.z)); +} - template - GLM_FUNC_QUALIFIER detail::tvec4 acos - ( - detail::tvec4 const & x - ) - { - return detail::tvec4( - acos(x.x), - acos(x.y), - acos(x.z), - acos(x.w)); - } +template +GLM_FUNC_QUALIFIER detail::tvec4 acos +( + detail::tvec4 const & x +) +{ + return detail::tvec4( + acos(x.x), + acos(x.y), + acos(x.z), + acos(x.w)); +} - // atan - template - GLM_FUNC_QUALIFIER genType atan - ( - genType const & y, - genType const & x - ) - { - GLM_STATIC_ASSERT(detail::type::is_float, "'atan' only accept floating-point input"); +// atan +template +GLM_FUNC_QUALIFIER genType atan +( + genType const & y, + genType const & x +) +{ + GLM_STATIC_ASSERT(detail::type::is_float, "'atan' only accept floating-point input"); - return ::std::atan2(y, x); - } + return ::std::atan2(y, x); +} - template - GLM_FUNC_QUALIFIER detail::tvec2 atan - ( - detail::tvec2 const & y, - detail::tvec2 const & x - ) - { - return detail::tvec2( - atan(y.x, x.x), - atan(y.y, x.y)); - } +template +GLM_FUNC_QUALIFIER detail::tvec2 atan +( + detail::tvec2 const & y, + detail::tvec2 const & x +) +{ + return detail::tvec2( + atan(y.x, x.x), + atan(y.y, x.y)); +} - template - GLM_FUNC_QUALIFIER detail::tvec3 atan - ( - detail::tvec3 const & y, - detail::tvec3 const & x - ) - { - return detail::tvec3( - atan(y.x, x.x), - atan(y.y, x.y), - atan(y.z, x.z)); - } +template +GLM_FUNC_QUALIFIER detail::tvec3 atan +( + detail::tvec3 const & y, + detail::tvec3 const & x +) +{ + return detail::tvec3( + atan(y.x, x.x), + atan(y.y, x.y), + atan(y.z, x.z)); +} - template - GLM_FUNC_QUALIFIER detail::tvec4 atan - ( - detail::tvec4 const & y, - detail::tvec4 const & x - ) - { - return detail::tvec4( - atan(y.x, x.x), - atan(y.y, x.y), - atan(y.z, x.z), - atan(y.w, x.w)); - } +template +GLM_FUNC_QUALIFIER detail::tvec4 atan +( + detail::tvec4 const & y, + detail::tvec4 const & x +) +{ + return detail::tvec4( + atan(y.x, x.x), + atan(y.y, x.y), + atan(y.z, x.z), + atan(y.w, x.w)); +} - template - GLM_FUNC_QUALIFIER genType atan - ( - genType const & x - ) - { - GLM_STATIC_ASSERT(detail::type::is_float, "'atan' only accept floating-point input"); +template +GLM_FUNC_QUALIFIER genType atan +( + genType const & x +) +{ + GLM_STATIC_ASSERT(detail::type::is_float, "'atan' only accept floating-point input"); - return ::std::atan(x); - } + return ::std::atan(x); +} - template - GLM_FUNC_QUALIFIER detail::tvec2 atan - ( - detail::tvec2 const & x - ) - { - return detail::tvec2( - atan(x.x), - atan(x.y)); - } +template +GLM_FUNC_QUALIFIER detail::tvec2 atan +( + detail::tvec2 const & x +) +{ + return detail::tvec2( + atan(x.x), + atan(x.y)); +} - template - GLM_FUNC_QUALIFIER detail::tvec3 atan - ( - detail::tvec3 const & x - ) - { - return detail::tvec3( - atan(x.x), - atan(x.y), - atan(x.z)); - } +template +GLM_FUNC_QUALIFIER detail::tvec3 atan +( + detail::tvec3 const & x +) +{ + return detail::tvec3( + atan(x.x), + atan(x.y), + atan(x.z)); +} - template - GLM_FUNC_QUALIFIER detail::tvec4 atan - ( - detail::tvec4 const & x - ) - { - return detail::tvec4( - atan(x.x), - atan(x.y), - atan(x.z), - atan(x.w)); - } +template +GLM_FUNC_QUALIFIER detail::tvec4 atan +( + detail::tvec4 const & x +) +{ + return detail::tvec4( + atan(x.x), + atan(x.y), + atan(x.z), + atan(x.w)); +} - // sinh - template - GLM_FUNC_QUALIFIER genType sinh - ( - genType const & angle - ) - { - GLM_STATIC_ASSERT(detail::type::is_float, "'sinh' only accept floating-point input"); +// sinh +template +GLM_FUNC_QUALIFIER genType sinh +( + genType const & angle +) +{ + GLM_STATIC_ASSERT(detail::type::is_float, "'sinh' only accept floating-point input"); - return std::sinh(angle); - } + return std::sinh(angle); +} - template - GLM_FUNC_QUALIFIER detail::tvec2 sinh - ( - detail::tvec2 const & angle - ) - { - return detail::tvec2( - sinh(angle.x), - sinh(angle.y)); - } +template +GLM_FUNC_QUALIFIER detail::tvec2 sinh +( + detail::tvec2 const & angle +) +{ + return detail::tvec2( + sinh(angle.x), + sinh(angle.y)); +} - template - GLM_FUNC_QUALIFIER detail::tvec3 sinh - ( - detail::tvec3 const & angle - ) - { - return detail::tvec3( - sinh(angle.x), - sinh(angle.y), - sinh(angle.z)); - } +template +GLM_FUNC_QUALIFIER detail::tvec3 sinh +( + detail::tvec3 const & angle +) +{ + return detail::tvec3( + sinh(angle.x), + sinh(angle.y), + sinh(angle.z)); +} - template - GLM_FUNC_QUALIFIER detail::tvec4 sinh - ( - detail::tvec4 const & angle - ) - { - return detail::tvec4( - sinh(angle.x), - sinh(angle.y), - sinh(angle.z), - sinh(angle.w)); - } +template +GLM_FUNC_QUALIFIER detail::tvec4 sinh +( + detail::tvec4 const & angle +) +{ + return detail::tvec4( + sinh(angle.x), + sinh(angle.y), + sinh(angle.z), + sinh(angle.w)); +} - // cosh - template - GLM_FUNC_QUALIFIER genType cosh - ( - genType const & angle - ) - { - GLM_STATIC_ASSERT(detail::type::is_float, "'cosh' only accept floating-point input"); +// cosh +template +GLM_FUNC_QUALIFIER genType cosh +( + genType const & angle +) +{ + GLM_STATIC_ASSERT(detail::type::is_float, "'cosh' only accept floating-point input"); - return std::cosh(angle); - } + return std::cosh(angle); +} - template - GLM_FUNC_QUALIFIER detail::tvec2 cosh - ( - detail::tvec2 const & angle - ) - { - return detail::tvec2( - cosh(angle.x), - cosh(angle.y)); - } +template +GLM_FUNC_QUALIFIER detail::tvec2 cosh +( + detail::tvec2 const & angle +) +{ + return detail::tvec2( + cosh(angle.x), + cosh(angle.y)); +} - template - GLM_FUNC_QUALIFIER detail::tvec3 cosh - ( - detail::tvec3 const & angle - ) - { - return detail::tvec3( - cosh(angle.x), - cosh(angle.y), - cosh(angle.z)); - } +template +GLM_FUNC_QUALIFIER detail::tvec3 cosh +( + detail::tvec3 const & angle +) +{ + return detail::tvec3( + cosh(angle.x), + cosh(angle.y), + cosh(angle.z)); +} - template - GLM_FUNC_QUALIFIER detail::tvec4 cosh - ( - detail::tvec4 const & angle - ) - { - return detail::tvec4( - cosh(angle.x), - cosh(angle.y), - cosh(angle.z), - cosh(angle.w)); - } +template +GLM_FUNC_QUALIFIER detail::tvec4 cosh +( + detail::tvec4 const & angle +) +{ + return detail::tvec4( + cosh(angle.x), + cosh(angle.y), + cosh(angle.z), + cosh(angle.w)); +} - // tanh - template - GLM_FUNC_QUALIFIER genType tanh - ( - genType const & angle - ) - { - GLM_STATIC_ASSERT(detail::type::is_float, "'tanh' only accept floating-point input"); +// tanh +template +GLM_FUNC_QUALIFIER genType tanh +( + genType const & angle +) +{ + GLM_STATIC_ASSERT(detail::type::is_float, "'tanh' only accept floating-point input"); - return std::tanh(angle); - } + return std::tanh(angle); +} - template - GLM_FUNC_QUALIFIER detail::tvec2 tanh - ( - detail::tvec2 const & angle - ) - { - return detail::tvec2( - tanh(angle.x), - tanh(angle.y)); - } +template +GLM_FUNC_QUALIFIER detail::tvec2 tanh +( + detail::tvec2 const & angle +) +{ + return detail::tvec2( + tanh(angle.x), + tanh(angle.y)); +} - template - GLM_FUNC_QUALIFIER detail::tvec3 tanh - ( - detail::tvec3 const & angle - ) - { - return detail::tvec3( - tanh(angle.x), - tanh(angle.y), - tanh(angle.z)); - } +template +GLM_FUNC_QUALIFIER detail::tvec3 tanh +( + detail::tvec3 const & angle +) +{ + return detail::tvec3( + tanh(angle.x), + tanh(angle.y), + tanh(angle.z)); +} - template - GLM_FUNC_QUALIFIER detail::tvec4 tanh - ( - detail::tvec4 const & angle - ) - { - return detail::tvec4( - tanh(angle.x), - tanh(angle.y), - tanh(angle.z), - tanh(angle.w)); - } +template +GLM_FUNC_QUALIFIER detail::tvec4 tanh +( + detail::tvec4 const & angle +) +{ + return detail::tvec4( + tanh(angle.x), + tanh(angle.y), + tanh(angle.z), + tanh(angle.w)); +} - // asinh - template - GLM_FUNC_QUALIFIER genType asinh - ( - genType const & x - ) - { - GLM_STATIC_ASSERT(detail::type::is_float, "'asinh' only accept floating-point input"); +// asinh +template +GLM_FUNC_QUALIFIER genType asinh +( + genType const & x +) +{ + GLM_STATIC_ASSERT(detail::type::is_float, "'asinh' only accept floating-point input"); - return (x < genType(0) ? genType(-1) : (x > genType(0) ? genType(1) : genType(0))) * log(abs(x) + sqrt(genType(1) + x * x)); - } + return (x < genType(0) ? genType(-1) : (x > genType(0) ? genType(1) : genType(0))) * log(abs(x) + sqrt(genType(1) + x * x)); +} - template - GLM_FUNC_QUALIFIER detail::tvec2 asinh - ( - detail::tvec2 const & x - ) - { - return detail::tvec2( - asinh(x.x), - asinh(x.y)); - } +template +GLM_FUNC_QUALIFIER detail::tvec2 asinh +( + detail::tvec2 const & x +) +{ + return detail::tvec2( + asinh(x.x), + asinh(x.y)); +} - template - GLM_FUNC_QUALIFIER detail::tvec3 asinh - ( - detail::tvec3 const & x - ) - { - return detail::tvec3( - asinh(x.x), - asinh(x.y), - asinh(x.z)); - } +template +GLM_FUNC_QUALIFIER detail::tvec3 asinh +( + detail::tvec3 const & x +) +{ + return detail::tvec3( + asinh(x.x), + asinh(x.y), + asinh(x.z)); +} - template - GLM_FUNC_QUALIFIER detail::tvec4 asinh - ( - detail::tvec4 const & x - ) - { - return detail::tvec4( - asinh(x.x), - asinh(x.y), - asinh(x.z), - asinh(x.w)); - } +template +GLM_FUNC_QUALIFIER detail::tvec4 asinh +( + detail::tvec4 const & x +) +{ + return detail::tvec4( + asinh(x.x), + asinh(x.y), + asinh(x.z), + asinh(x.w)); +} - // acosh - template - GLM_FUNC_QUALIFIER genType acosh - ( - genType const & x - ) - { - GLM_STATIC_ASSERT(detail::type::is_float, "'acosh' only accept floating-point input"); +// acosh +template +GLM_FUNC_QUALIFIER genType acosh +( + genType const & x +) +{ + GLM_STATIC_ASSERT(detail::type::is_float, "'acosh' only accept floating-point input"); - if(x < genType(1)) - return genType(0); - return log(x + sqrt(x * x - genType(1))); - } + if(x < genType(1)) + return genType(0); + return log(x + sqrt(x * x - genType(1))); +} - template - GLM_FUNC_QUALIFIER detail::tvec2 acosh - ( - detail::tvec2 const & x - ) - { - return detail::tvec2( - acosh(x.x), - acosh(x.y)); - } +template +GLM_FUNC_QUALIFIER detail::tvec2 acosh +( + detail::tvec2 const & x +) +{ + return detail::tvec2( + acosh(x.x), + acosh(x.y)); +} - template - GLM_FUNC_QUALIFIER detail::tvec3 acosh - ( - detail::tvec3 const & x - ) - { - return detail::tvec3( - acosh(x.x), - acosh(x.y), - acosh(x.z)); - } +template +GLM_FUNC_QUALIFIER detail::tvec3 acosh +( + detail::tvec3 const & x +) +{ + return detail::tvec3( + acosh(x.x), + acosh(x.y), + acosh(x.z)); +} - template - GLM_FUNC_QUALIFIER detail::tvec4 acosh - ( - detail::tvec4 const & x - ) - { - return detail::tvec4( - acosh(x.x), - acosh(x.y), - acosh(x.z), - acosh(x.w)); - } +template +GLM_FUNC_QUALIFIER detail::tvec4 acosh +( + detail::tvec4 const & x +) +{ + return detail::tvec4( + acosh(x.x), + acosh(x.y), + acosh(x.z), + acosh(x.w)); +} - // atanh - template - GLM_FUNC_QUALIFIER genType atanh - ( - genType const & x - ) - { - GLM_STATIC_ASSERT(detail::type::is_float, "'atanh' only accept floating-point input"); +// atanh +template +GLM_FUNC_QUALIFIER genType atanh +( + genType const & x +) +{ + GLM_STATIC_ASSERT(detail::type::is_float, "'atanh' only accept floating-point input"); - if(abs(x) >= genType(1)) - return 0; - return genType(0.5) * log((genType(1) + x) / (genType(1) - x)); - } + if(abs(x) >= genType(1)) + return 0; + return genType(0.5) * log((genType(1) + x) / (genType(1) - x)); +} - template - GLM_FUNC_QUALIFIER detail::tvec2 atanh - ( - detail::tvec2 const & x - ) - { - return detail::tvec2( - atanh(x.x), - atanh(x.y)); - } +template +GLM_FUNC_QUALIFIER detail::tvec2 atanh +( + detail::tvec2 const & x +) +{ + return detail::tvec2( + atanh(x.x), + atanh(x.y)); +} - template - GLM_FUNC_QUALIFIER detail::tvec3 atanh - ( - detail::tvec3 const & x - ) - { - return detail::tvec3( - atanh(x.x), - atanh(x.y), - atanh(x.z)); - } +template +GLM_FUNC_QUALIFIER detail::tvec3 atanh +( + detail::tvec3 const & x +) +{ + return detail::tvec3( + atanh(x.x), + atanh(x.y), + atanh(x.z)); +} - template - GLM_FUNC_QUALIFIER detail::tvec4 atanh - ( - detail::tvec4 const & x - ) - { - return detail::tvec4( - atanh(x.x), - atanh(x.y), - atanh(x.z), - atanh(x.w)); - } +template +GLM_FUNC_QUALIFIER detail::tvec4 atanh +( + detail::tvec4 const & x +) +{ + return detail::tvec4( + atanh(x.x), + atanh(x.y), + atanh(x.z), + atanh(x.w)); +} -}//namespace core }//namespace glm diff --git a/glm/core/func_vector_relational.hpp b/glm/core/func_vector_relational.hpp index 2889ae50..3ff64d29 100644 --- a/glm/core/func_vector_relational.hpp +++ b/glm/core/func_vector_relational.hpp @@ -12,10 +12,9 @@ #include "_detail.hpp" -namespace glm{ -namespace core +namespace glm { - /// \addtogroup core_funcs + /// @addtogroup core_funcs /// @{ //! Returns the component-wise comparison result of x < y. @@ -197,7 +196,6 @@ namespace core } /// @} -}//namespace core }//namespace glm #include "func_vector_relational.inl" diff --git a/glm/core/hint.hpp b/glm/core/hint.hpp index d7efd589..9f1fdeac 100644 --- a/glm/core/hint.hpp +++ b/glm/core/hint.hpp @@ -16,6 +16,6 @@ namespace glm class dont_care {}; class nicest {}; class fastest {}; -}; +}//namespace glm #endif//glm_core_type diff --git a/glm/glm.hpp b/glm/glm.hpp index fa45aace..deee1712 100644 --- a/glm/glm.hpp +++ b/glm/glm.hpp @@ -43,16 +43,6 @@ # pragma message("GLM: Core library included") #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/type.hpp" diff --git a/glm/gtc/half_float.hpp b/glm/gtc/half_float.hpp index 1a3a3107..5f3ebd7a 100644 --- a/glm/gtc/half_float.hpp +++ b/glm/gtc/half_float.hpp @@ -35,8 +35,8 @@ /// /////////////////////////////////////////////////////////////////////////////////// -#ifndef glm_gtc_half_float -#define glm_gtc_half_float +#ifndef GLM_GTC_half_float +#define GLM_GTC_half_float 90 // Dependency: #include "../glm.hpp" @@ -349,8 +349,6 @@ namespace detail } //namespace detail -namespace gtc -{ /// @addtogroup gtc_half_float /// @{ @@ -419,9 +417,8 @@ namespace gtc typedef detail::tmat4x4 hmat4x4; /// @} -}// namespace gtc }// namespace glm #include "half_float.inl" -#endif//glm_gtc_half_float +#endif//GLM_GTC_half_float diff --git a/glm/gtc/matrix_access.hpp b/glm/gtc/matrix_access.hpp index c7914211..63682738 100644 --- a/glm/gtc/matrix_access.hpp +++ b/glm/gtc/matrix_access.hpp @@ -34,8 +34,8 @@ /// need to be included to use these functionalities. /////////////////////////////////////////////////////////////////////////////////// -#ifndef glm_gtc_matrix_access -#define glm_gtc_matrix_access +#ifndef GLM_GTC_matrix_access +#define GLM_GTC_matrix_access 90 // Dependency: #include "../glm.hpp" @@ -44,9 +44,8 @@ # pragma message("GLM: GLM_GTC_matrix_access extension included") #endif -namespace glm{ -namespace gtc{ - +namespace glm +{ /// @addtogroup gtc_matrix_access /// @{ @@ -81,9 +80,8 @@ namespace gtc{ typename genType::col_type const & x); /// @} -}//namespace gtc }//namespace glm #include "matrix_access.inl" -#endif//glm_gtc_matrix_access +#endif//GLM_GTC_matrix_access diff --git a/glm/gtc/matrix_access.inl b/glm/gtc/matrix_access.inl index b2c7570a..476b79f6 100644 --- a/glm/gtc/matrix_access.inl +++ b/glm/gtc/matrix_access.inl @@ -8,50 +8,48 @@ /////////////////////////////////////////////////////////////////////////////////////////////////// namespace glm{ -namespace gtc + +template +GLM_FUNC_QUALIFIER genType row( + genType const & m, + int index, + typename genType::row_type const & x) { - template - GLM_FUNC_QUALIFIER genType row( - genType const & m, - int index, - typename genType::row_type const & x) - { - genType Result = m; - for(typename genType::size_type i = 0; i < genType::row_size(); ++i) - Result[i][index] = x[i]; - return Result; - } + genType Result = m; + for(typename genType::size_type i = 0; i < genType::row_size(); ++i) + Result[i][index] = x[i]; + return Result; +} - template - GLM_FUNC_QUALIFIER typename genType::row_type row( - genType const & m, - int index) - { - typename genType::row_type Result; - for(typename genType::size_type i = 0; i < genType::row_size(); ++i) - Result[i] = m[i][index]; - return Result; - } +template +GLM_FUNC_QUALIFIER typename genType::row_type row( + genType const & m, + int index) +{ + typename genType::row_type Result; + for(typename genType::size_type i = 0; i < genType::row_size(); ++i) + Result[i] = m[i][index]; + return Result; +} - template - GLM_FUNC_QUALIFIER genType column( - genType const & m, - int index, - typename genType::col_type const & x) - { - genType Result = m; - Result[index] = x; - return Result; - } +template +GLM_FUNC_QUALIFIER genType column( + genType const & m, + int index, + typename genType::col_type const & x) +{ + genType Result = m; + Result[index] = x; + return Result; +} - template - GLM_FUNC_QUALIFIER typename genType::col_type column( - genType const & m, - int index) - { - return m[index]; - } +template +GLM_FUNC_QUALIFIER typename genType::col_type column( + genType const & m, + int index) +{ + return m[index]; +} -}//namespace gtc }//namespace glm diff --git a/glm/gtc/matrix_integer.hpp b/glm/gtc/matrix_integer.hpp index 48246817..04b56174 100644 --- a/glm/gtc/matrix_integer.hpp +++ b/glm/gtc/matrix_integer.hpp @@ -34,8 +34,8 @@ /// need to be included to use these functionalities. /////////////////////////////////////////////////////////////////////////////////// -#ifndef glm_gtc_matrix_integer -#define glm_gtc_matrix_integer +#ifndef GLM_GTC_matrix_integer +#define GLM_GTC_matrix_integer 90 // Dependency: #include "../glm.hpp" @@ -44,10 +44,9 @@ # pragma message("GLM: GLM_GTC_matrix_integer extension included") #endif -namespace glm{ -namespace gtc{ - - /// \addtogroup gtc_matrix_integer +namespace glm +{ + /// @addtogroup gtc_matrix_integer /// @{ typedef detail::tmat2x2 highp_imat2; //!< \brief High-precision signed integer 2x2 matrix. (from GLM_GTC_matrix_integer extension) @@ -217,7 +216,6 @@ namespace gtc{ #endif//GLM_PRECISION /// @} -}//namespace gtc }//namespace glm -#endif//glm_gtc_matrix_integer +#endif//GLM_GTC_matrix_integer diff --git a/glm/gtc/matrix_inverse.hpp b/glm/gtc/matrix_inverse.hpp index b130284f..a1f2efb7 100644 --- a/glm/gtc/matrix_inverse.hpp +++ b/glm/gtc/matrix_inverse.hpp @@ -34,8 +34,8 @@ /// need to be included to use these functionalities. /////////////////////////////////////////////////////////////////////////////////// -#ifndef glm_gtc_matrix_inverse -#define glm_gtc_matrix_inverse +#ifndef GLM_GTC_matrix_inverse +#define GLM_GTC_matrix_inverse 90 // Dependency: #include "../glm.hpp" @@ -44,8 +44,7 @@ # pragma message("GLM: GLM_GTC_matrix_inverse extension included") #endif -namespace glm{ -namespace gtc +namespace glm { /// @addtogroup gtc_matrix_inverse /// @{ @@ -62,9 +61,8 @@ namespace gtc genType const & m); /// @} -}//namespace gtc }//namespace glm #include "matrix_inverse.inl" -#endif//glm_gtc_matrix_inverse +#endif//GLM_GTC_matrix_inverse diff --git a/glm/gtc/matrix_inverse.inl b/glm/gtc/matrix_inverse.inl index 6dc8e11b..1689601f 100644 --- a/glm/gtc/matrix_inverse.inl +++ b/glm/gtc/matrix_inverse.inl @@ -8,130 +8,128 @@ /////////////////////////////////////////////////////////////////////////////////////////////////// namespace glm{ -namespace gtc{ - template - GLM_FUNC_QUALIFIER detail::tmat3x3 affineInverse - ( - detail::tmat3x3 const & m - ) - { - detail::tmat3x3 Result(m); - Result[2] = detail::tvec3(0, 0, 1); - Result = transpose(Result); - detail::tvec3 Translation = Result * detail::tvec3(-detail::tvec2(m[2]), m[2][2]); - Result[2] = Translation; - return Result; - } +template +GLM_FUNC_QUALIFIER detail::tmat3x3 affineInverse +( + detail::tmat3x3 const & m +) +{ + detail::tmat3x3 Result(m); + Result[2] = detail::tvec3(0, 0, 1); + Result = transpose(Result); + detail::tvec3 Translation = Result * detail::tvec3(-detail::tvec2(m[2]), m[2][2]); + Result[2] = Translation; + return Result; +} - template - GLM_FUNC_QUALIFIER detail::tmat4x4 affineInverse - ( - detail::tmat4x4 const & m - ) - { - detail::tmat4x4 Result(m); - Result[3] = detail::tvec4(0, 0, 0, 1); - Result = transpose(Result); - detail::tvec4 Translation = Result * detail::tvec4(-detail::tvec3(m[3]), m[3][3]); - Result[3] = Translation; - return Result; - } +template +GLM_FUNC_QUALIFIER detail::tmat4x4 affineInverse +( + detail::tmat4x4 const & m +) +{ + detail::tmat4x4 Result(m); + Result[3] = detail::tvec4(0, 0, 0, 1); + Result = transpose(Result); + detail::tvec4 Translation = Result * detail::tvec4(-detail::tvec3(m[3]), m[3][3]); + Result[3] = Translation; + return Result; +} - template - GLM_FUNC_QUALIFIER detail::tmat2x2 inverseTranspose( - detail::tmat2x2 const & m) - { - valType Determinant = m[0][0] * m[1][1] - m[1][0] * m[0][1]; +template +GLM_FUNC_QUALIFIER detail::tmat2x2 inverseTranspose( + detail::tmat2x2 const & m) +{ + valType Determinant = m[0][0] * m[1][1] - m[1][0] * m[0][1]; - detail::tmat2x2 Inverse( - + m[1][1] / Determinant, - - m[0][1] / Determinant, - - m[1][0] / Determinant, - + m[0][0] / Determinant); + detail::tmat2x2 Inverse( + + m[1][1] / Determinant, + - m[0][1] / Determinant, + - m[1][0] / Determinant, + + m[0][0] / Determinant); - return Inverse; - } + return Inverse; +} - template - GLM_FUNC_QUALIFIER detail::tmat3x3 inverseTranspose( - detail::tmat3x3 const & m) - { - valType Determinant = - + m[0][0] * (m[1][1] * m[2][2] - m[1][2] * m[2][1]) - - m[0][1] * (m[1][0] * m[2][2] - m[1][2] * m[2][0]) - + m[0][2] * (m[1][0] * m[2][1] - m[1][1] * m[2][0]); +template +GLM_FUNC_QUALIFIER detail::tmat3x3 inverseTranspose( + detail::tmat3x3 const & m) +{ + valType Determinant = + + m[0][0] * (m[1][1] * m[2][2] - m[1][2] * m[2][1]) + - m[0][1] * (m[1][0] * m[2][2] - m[1][2] * m[2][0]) + + m[0][2] * (m[1][0] * m[2][1] - m[1][1] * m[2][0]); - detail::tmat3x3 Inverse; - Inverse[0][0] = + (m[1][1] * m[2][2] - m[2][1] * m[1][2]); - Inverse[0][1] = - (m[1][0] * m[2][2] - m[2][0] * m[1][2]); - Inverse[0][2] = + (m[1][0] * m[2][1] - m[2][0] * m[1][1]); - Inverse[1][0] = - (m[0][1] * m[2][2] - m[2][1] * m[0][2]); - Inverse[1][1] = + (m[0][0] * m[2][2] - m[2][0] * m[0][2]); - Inverse[1][2] = - (m[0][0] * m[2][1] - m[2][0] * m[0][1]); - Inverse[2][0] = + (m[0][1] * m[1][2] - m[1][1] * m[0][2]); - Inverse[2][1] = - (m[0][0] * m[1][2] - m[1][0] * m[0][2]); - Inverse[2][2] = + (m[0][0] * m[1][1] - m[1][0] * m[0][1]); - Inverse /= Determinant; + detail::tmat3x3 Inverse; + Inverse[0][0] = + (m[1][1] * m[2][2] - m[2][1] * m[1][2]); + Inverse[0][1] = - (m[1][0] * m[2][2] - m[2][0] * m[1][2]); + Inverse[0][2] = + (m[1][0] * m[2][1] - m[2][0] * m[1][1]); + Inverse[1][0] = - (m[0][1] * m[2][2] - m[2][1] * m[0][2]); + Inverse[1][1] = + (m[0][0] * m[2][2] - m[2][0] * m[0][2]); + Inverse[1][2] = - (m[0][0] * m[2][1] - m[2][0] * m[0][1]); + Inverse[2][0] = + (m[0][1] * m[1][2] - m[1][1] * m[0][2]); + Inverse[2][1] = - (m[0][0] * m[1][2] - m[1][0] * m[0][2]); + Inverse[2][2] = + (m[0][0] * m[1][1] - m[1][0] * m[0][1]); + Inverse /= Determinant; - return Inverse; - } + return Inverse; +} - template - GLM_FUNC_QUALIFIER detail::tmat4x4 inverseTranspose( - detail::tmat4x4 const & m) - { - valType SubFactor00 = m[2][2] * m[3][3] - m[3][2] * m[2][3]; - valType SubFactor01 = m[2][1] * m[3][3] - m[3][1] * m[2][3]; - valType SubFactor02 = m[2][1] * m[3][2] - m[3][1] * m[2][2]; - valType SubFactor03 = m[2][0] * m[3][3] - m[3][0] * m[2][3]; - valType SubFactor04 = m[2][0] * m[3][2] - m[3][0] * m[2][2]; - valType SubFactor05 = m[2][0] * m[3][1] - m[3][0] * m[2][1]; - valType SubFactor06 = m[1][2] * m[3][3] - m[3][2] * m[1][3]; - valType SubFactor07 = m[1][1] * m[3][3] - m[3][1] * m[1][3]; - valType SubFactor08 = m[1][1] * m[3][2] - m[3][1] * m[1][2]; - valType SubFactor09 = m[1][0] * m[3][3] - m[3][0] * m[1][3]; - valType SubFactor10 = m[1][0] * m[3][2] - m[3][0] * m[1][2]; - valType SubFactor11 = m[1][1] * m[3][3] - m[3][1] * m[1][3]; - valType SubFactor12 = m[1][0] * m[3][1] - m[3][0] * m[1][1]; - valType SubFactor13 = m[1][2] * m[2][3] - m[2][2] * m[1][3]; - valType SubFactor14 = m[1][1] * m[2][3] - m[2][1] * m[1][3]; - valType SubFactor15 = m[1][1] * m[2][2] - m[2][1] * m[1][2]; - valType SubFactor16 = m[1][0] * m[2][3] - m[2][0] * m[1][3]; - valType SubFactor17 = m[1][0] * m[2][2] - m[2][0] * m[1][2]; - valType SubFactor18 = m[1][0] * m[2][1] - m[2][0] * m[1][1]; +template +GLM_FUNC_QUALIFIER detail::tmat4x4 inverseTranspose( + detail::tmat4x4 const & m) +{ + valType SubFactor00 = m[2][2] * m[3][3] - m[3][2] * m[2][3]; + valType SubFactor01 = m[2][1] * m[3][3] - m[3][1] * m[2][3]; + valType SubFactor02 = m[2][1] * m[3][2] - m[3][1] * m[2][2]; + valType SubFactor03 = m[2][0] * m[3][3] - m[3][0] * m[2][3]; + valType SubFactor04 = m[2][0] * m[3][2] - m[3][0] * m[2][2]; + valType SubFactor05 = m[2][0] * m[3][1] - m[3][0] * m[2][1]; + valType SubFactor06 = m[1][2] * m[3][3] - m[3][2] * m[1][3]; + valType SubFactor07 = m[1][1] * m[3][3] - m[3][1] * m[1][3]; + valType SubFactor08 = m[1][1] * m[3][2] - m[3][1] * m[1][2]; + valType SubFactor09 = m[1][0] * m[3][3] - m[3][0] * m[1][3]; + valType SubFactor10 = m[1][0] * m[3][2] - m[3][0] * m[1][2]; + valType SubFactor11 = m[1][1] * m[3][3] - m[3][1] * m[1][3]; + valType SubFactor12 = m[1][0] * m[3][1] - m[3][0] * m[1][1]; + valType SubFactor13 = m[1][2] * m[2][3] - m[2][2] * m[1][3]; + valType SubFactor14 = m[1][1] * m[2][3] - m[2][1] * m[1][3]; + valType SubFactor15 = m[1][1] * m[2][2] - m[2][1] * m[1][2]; + valType SubFactor16 = m[1][0] * m[2][3] - m[2][0] * m[1][3]; + valType SubFactor17 = m[1][0] * m[2][2] - m[2][0] * m[1][2]; + valType SubFactor18 = m[1][0] * m[2][1] - m[2][0] * m[1][1]; - detail::tmat4x4 Inverse; - Inverse[0][0] = + (m[1][1] * SubFactor00 - m[1][2] * SubFactor01 + m[1][3] * SubFactor02); - Inverse[0][1] = - (m[1][0] * SubFactor00 - m[1][2] * SubFactor03 + m[1][3] * SubFactor04); - Inverse[0][2] = + (m[1][0] * SubFactor01 - m[1][1] * SubFactor03 + m[1][3] * SubFactor05); - Inverse[0][3] = - (m[1][0] * SubFactor02 - m[1][1] * SubFactor04 + m[1][2] * SubFactor05); + detail::tmat4x4 Inverse; + Inverse[0][0] = + (m[1][1] * SubFactor00 - m[1][2] * SubFactor01 + m[1][3] * SubFactor02); + Inverse[0][1] = - (m[1][0] * SubFactor00 - m[1][2] * SubFactor03 + m[1][3] * SubFactor04); + Inverse[0][2] = + (m[1][0] * SubFactor01 - m[1][1] * SubFactor03 + m[1][3] * SubFactor05); + Inverse[0][3] = - (m[1][0] * SubFactor02 - m[1][1] * SubFactor04 + m[1][2] * SubFactor05); - Inverse[1][0] = - (m[0][1] * SubFactor00 - m[0][2] * SubFactor01 + m[0][3] * SubFactor02); - Inverse[1][1] = + (m[0][0] * SubFactor00 - m[0][2] * SubFactor03 + m[0][3] * SubFactor04); - Inverse[1][2] = - (m[0][0] * SubFactor01 - m[0][1] * SubFactor03 + m[0][3] * SubFactor05); - Inverse[1][3] = + (m[0][0] * SubFactor02 - m[0][1] * SubFactor04 + m[0][2] * SubFactor05); + Inverse[1][0] = - (m[0][1] * SubFactor00 - m[0][2] * SubFactor01 + m[0][3] * SubFactor02); + Inverse[1][1] = + (m[0][0] * SubFactor00 - m[0][2] * SubFactor03 + m[0][3] * SubFactor04); + Inverse[1][2] = - (m[0][0] * SubFactor01 - m[0][1] * SubFactor03 + m[0][3] * SubFactor05); + Inverse[1][3] = + (m[0][0] * SubFactor02 - m[0][1] * SubFactor04 + m[0][2] * SubFactor05); - Inverse[2][0] = + (m[0][1] * SubFactor06 - m[0][2] * SubFactor07 + m[0][3] * SubFactor08); - Inverse[2][1] = - (m[0][0] * SubFactor06 - m[0][2] * SubFactor09 + m[0][3] * SubFactor10); - Inverse[2][2] = + (m[0][0] * SubFactor11 - m[0][1] * SubFactor09 + m[0][3] * SubFactor12); - Inverse[2][3] = - (m[0][0] * SubFactor08 - m[0][1] * SubFactor10 + m[0][2] * SubFactor12); + Inverse[2][0] = + (m[0][1] * SubFactor06 - m[0][2] * SubFactor07 + m[0][3] * SubFactor08); + Inverse[2][1] = - (m[0][0] * SubFactor06 - m[0][2] * SubFactor09 + m[0][3] * SubFactor10); + Inverse[2][2] = + (m[0][0] * SubFactor11 - m[0][1] * SubFactor09 + m[0][3] * SubFactor12); + Inverse[2][3] = - (m[0][0] * SubFactor08 - m[0][1] * SubFactor10 + m[0][2] * SubFactor12); - Inverse[3][0] = - (m[0][1] * SubFactor13 - m[0][2] * SubFactor14 + m[0][3] * SubFactor15); - Inverse[3][1] = + (m[0][0] * SubFactor13 - m[0][2] * SubFactor16 + m[0][3] * SubFactor17); - Inverse[3][2] = - (m[0][0] * SubFactor14 - m[0][1] * SubFactor16 + m[0][3] * SubFactor18); - Inverse[3][3] = + (m[0][0] * SubFactor15 - m[0][1] * SubFactor17 + m[0][2] * SubFactor18); + Inverse[3][0] = - (m[0][1] * SubFactor13 - m[0][2] * SubFactor14 + m[0][3] * SubFactor15); + Inverse[3][1] = + (m[0][0] * SubFactor13 - m[0][2] * SubFactor16 + m[0][3] * SubFactor17); + Inverse[3][2] = - (m[0][0] * SubFactor14 - m[0][1] * SubFactor16 + m[0][3] * SubFactor18); + Inverse[3][3] = + (m[0][0] * SubFactor15 - m[0][1] * SubFactor17 + m[0][2] * SubFactor18); - valType Determinant = - + m[0][0] * Inverse[0][0] - + m[0][1] * Inverse[0][1] - + m[0][2] * Inverse[0][2] - + m[0][3] * Inverse[0][3]; + valType Determinant = + + m[0][0] * Inverse[0][0] + + m[0][1] * Inverse[0][1] + + m[0][2] * Inverse[0][2] + + m[0][3] * Inverse[0][3]; - Inverse /= Determinant; + Inverse /= Determinant; - return Inverse; - } + return Inverse; +} -}//namespace gtc }//namespace glm diff --git a/glm/gtc/matrix_transform.hpp b/glm/gtc/matrix_transform.hpp index 8fc03b64..a9cb653e 100644 --- a/glm/gtc/matrix_transform.hpp +++ b/glm/gtc/matrix_transform.hpp @@ -43,8 +43,8 @@ /// need to be included to use these functionalities. /////////////////////////////////////////////////////////////////////////////////// -#ifndef glm_gtc_matrix_transform -#define glm_gtc_matrix_transform +#ifndef GLM_GTC_matrix_transform +#define GLM_GTC_matrix_transform 90 // Dependency: #include "../glm.hpp" @@ -53,8 +53,7 @@ # pragma message("GLM: GLM_GTC_matrix_transform extension included") #endif -namespace glm{ -namespace gtc +namespace glm { /// @addtogroup gtc_matrix_transform /// @{ @@ -62,9 +61,9 @@ namespace gtc /// Builds a translation 4 * 4 matrix created from a vector of 3 components. /// @see - gtc_matrix_transform /// @see - gtx_transform: - /// - @link glm::gtx::translate(T x, T y, T z) translate(T x, T y, T z) @endlink - /// - @link glm::gtx::translate(detail::tmat4x4 const & m, T x, T y, T z) translate(mat4x4 const & m, T x, T y, T z) @endlink - /// - @link glm::gtx::translate(detail::tvec3 const & v) translate(vec3 const & v) @endlink + /// - @link translate(T x, T y, T z) translate(T x, T y, T z) @endlink + /// - @link translate(detail::tmat4x4 const & m, T x, T y, T z) translate(mat4x4 const & m, T x, T y, T z) @endlink + /// - @link translate(detail::tvec3 const & v) translate(vec3 const & v) @endlink template detail::tmat4x4 translate( detail::tmat4x4 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. /// @see - gtc_matrix_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 glm::gtx::rotate(detail::tmat4x4 const & m, T angle, T x, T y, T z) rotate(mat4x4 const & m, T const & angle, T const & x, T const & y, T const & z) @endlink - /// - @link glm::gtx::rotate(T angle, detail::tvec3 const & v) rotate(T const & angle, vec3 const & v) @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 rotate(detail::tmat4x4 const & m, T angle, T x, T y, T z) rotate(mat4x4 const & m, T const & angle, T const & x, T const & y, T const & z) @endlink + /// - @link rotate(T angle, detail::tvec3 const & v) rotate(T const & angle, vec3 const & v) @endlink template detail::tmat4x4 rotate( detail::tmat4x4 const & m, @@ -85,9 +84,9 @@ namespace gtc /// Builds a scale 4 * 4 matrix created from 3 scalars. /// @see - gtc_matrix_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 glm::gtx::scale(detail::tmat4x4 const & m, T x, T y, T z) scale(mat4x4 const & m, T const & angle, T const & x, T const & y, T const & z) @endlink - /// - @link glm::gtx::scale(detail::tvec3 const & v) scale(vec3 const & v) @endlink + /// - @link scale(T x, T y, T z) scale(T const & x, T const & y, T const & z) @endlink + /// - @link scale(detail::tmat4x4 const & m, T x, T y, T z) scale(mat4x4 const & m, T const & angle, T const & x, T const & y, T const & z) @endlink + /// - @link scale(detail::tvec3 const & v) scale(vec3 const & v) @endlink template detail::tmat4x4 scale( detail::tmat4x4 const & m, @@ -95,7 +94,7 @@ namespace gtc /// Creates a matrix for an orthographic parallel viewing volume. /// @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 detail::tmat4x4 ortho( T const & left, @@ -107,7 +106,7 @@ namespace gtc /// Creates a matrix for projecting two-dimensional coordinates onto the screen. /// @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 detail::tmat4x4 ortho( T const & left, @@ -196,9 +195,8 @@ namespace gtc detail::tvec3 const & up); /// @} -}//namespace gtc }//namespace glm #include "matrix_transform.inl" -#endif//glm_gtc_matrix_transform +#endif//GLM_GTC_matrix_transform diff --git a/glm/gtc/matrix_transform.inl b/glm/gtc/matrix_transform.inl index 7d4ed21f..ea336484 100644 --- a/glm/gtc/matrix_transform.inl +++ b/glm/gtc/matrix_transform.inl @@ -8,389 +8,387 @@ /////////////////////////////////////////////////////////////////////////////////////////////////// namespace glm{ -namespace gtc{ - template - GLM_FUNC_QUALIFIER detail::tmat4x4 translate - ( - detail::tmat4x4 const & m, - detail::tvec3 const & v - ) - { - detail::tmat4x4 Result(m); - Result[3] = m[0] * v[0] + m[1] * v[1] + m[2] * v[2] + m[3]; - return Result; - } +template +GLM_FUNC_QUALIFIER detail::tmat4x4 translate +( + detail::tmat4x4 const & m, + detail::tvec3 const & v +) +{ + detail::tmat4x4 Result(m); + Result[3] = m[0] * v[0] + m[1] * v[1] + m[2] * v[2] + m[3]; + return Result; +} - template - GLM_FUNC_QUALIFIER detail::tmat4x4 rotate - ( - detail::tmat4x4 const & m, - T const & angle, - detail::tvec3 const & v - ) - { - T a = radians(angle); - T c = cos(a); - T s = sin(a); +template +GLM_FUNC_QUALIFIER detail::tmat4x4 rotate +( + detail::tmat4x4 const & m, + T const & angle, + detail::tvec3 const & v +) +{ + T a = radians(angle); + T c = cos(a); + T s = sin(a); - detail::tvec3 axis = normalize(v); + detail::tvec3 axis = normalize(v); - detail::tvec3 temp = (T(1) - c) * axis; + detail::tvec3 temp = (T(1) - c) * axis; - detail::tmat4x4 Rotate(detail::tmat4x4::null); - Rotate[0][0] = c + temp[0] * axis[0]; - Rotate[0][1] = 0 + temp[0] * axis[1] + s * axis[2]; - Rotate[0][2] = 0 + temp[0] * axis[2] - s * axis[1]; + detail::tmat4x4 Rotate(detail::tmat4x4::null); + Rotate[0][0] = c + temp[0] * axis[0]; + Rotate[0][1] = 0 + temp[0] * axis[1] + s * axis[2]; + Rotate[0][2] = 0 + temp[0] * axis[2] - s * axis[1]; - Rotate[1][0] = 0 + temp[1] * axis[0] - s * axis[2]; - Rotate[1][1] = c + temp[1] * axis[1]; - Rotate[1][2] = 0 + temp[1] * axis[2] + s * axis[0]; + Rotate[1][0] = 0 + temp[1] * axis[0] - s * axis[2]; + Rotate[1][1] = c + temp[1] * axis[1]; + Rotate[1][2] = 0 + temp[1] * axis[2] + s * axis[0]; - Rotate[2][0] = 0 + temp[2] * axis[0] + s * axis[1]; - Rotate[2][1] = 0 + temp[2] * axis[1] - s * axis[0]; - Rotate[2][2] = c + temp[2] * axis[2]; + Rotate[2][0] = 0 + temp[2] * axis[0] + s * axis[1]; + Rotate[2][1] = 0 + temp[2] * axis[1] - s * axis[0]; + Rotate[2][2] = c + temp[2] * axis[2]; - detail::tmat4x4 Result(detail::tmat4x4::null); - Result[0] = m[0] * Rotate[0][0] + m[1] * Rotate[0][1] + m[2] * Rotate[0][2]; - Result[1] = m[0] * Rotate[1][0] + m[1] * Rotate[1][1] + m[2] * Rotate[1][2]; - Result[2] = m[0] * Rotate[2][0] + m[1] * Rotate[2][1] + m[2] * Rotate[2][2]; - Result[3] = m[3]; - return Result; - } + detail::tmat4x4 Result(detail::tmat4x4::null); + Result[0] = m[0] * Rotate[0][0] + m[1] * Rotate[0][1] + m[2] * Rotate[0][2]; + Result[1] = m[0] * Rotate[1][0] + m[1] * Rotate[1][1] + m[2] * Rotate[1][2]; + Result[2] = m[0] * Rotate[2][0] + m[1] * Rotate[2][1] + m[2] * Rotate[2][2]; + Result[3] = m[3]; + return Result; +} - template - GLM_FUNC_QUALIFIER detail::tmat4x4 scale - ( - detail::tmat4x4 const & m, - detail::tvec3 const & v - ) - { - detail::tmat4x4 Result(detail::tmat4x4::null); - Result[0] = m[0] * v[0]; - Result[1] = m[1] * v[1]; - Result[2] = m[2] * v[2]; - Result[3] = m[3]; - return Result; - } +template +GLM_FUNC_QUALIFIER detail::tmat4x4 scale +( + detail::tmat4x4 const & m, + detail::tvec3 const & v +) +{ + detail::tmat4x4 Result(detail::tmat4x4::null); + Result[0] = m[0] * v[0]; + Result[1] = m[1] * v[1]; + Result[2] = m[2] * v[2]; + Result[3] = m[3]; + return Result; +} - template - GLM_FUNC_QUALIFIER detail::tmat4x4 translate_slow - ( - detail::tmat4x4 const & m, - detail::tvec3 const & v - ) - { - detail::tmat4x4 Result(T(1)); - Result[3] = detail::tvec4(v, T(1)); - return m * Result; +template +GLM_FUNC_QUALIFIER detail::tmat4x4 translate_slow +( + detail::tmat4x4 const & m, + detail::tvec3 const & v +) +{ + detail::tmat4x4 Result(T(1)); + Result[3] = detail::tvec4(v, T(1)); + return m * Result; - //detail::tmat4x4 Result(m); - Result[3] = m[0] * v[0] + m[1] * v[1] + m[2] * v[2] + m[3]; - //Result[3][0] = m[0][0] * v[0] + m[1][0] * v[1] + m[2][0] * v[2] + m[3][0]; - //Result[3][1] = m[0][1] * v[0] + m[1][1] * v[1] + m[2][1] * v[2] + m[3][1]; - //Result[3][2] = m[0][2] * v[0] + m[1][2] * v[1] + m[2][2] * v[2] + m[3][2]; - //Result[3][3] = m[0][3] * v[0] + m[1][3] * v[1] + m[2][3] * v[2] + m[3][3]; - //return Result; - } + //detail::tmat4x4 Result(m); + Result[3] = m[0] * v[0] + m[1] * v[1] + m[2] * v[2] + m[3]; + //Result[3][0] = m[0][0] * v[0] + m[1][0] * v[1] + m[2][0] * v[2] + m[3][0]; + //Result[3][1] = m[0][1] * v[0] + m[1][1] * v[1] + m[2][1] * v[2] + m[3][1]; + //Result[3][2] = m[0][2] * v[0] + m[1][2] * v[1] + m[2][2] * v[2] + m[3][2]; + //Result[3][3] = m[0][3] * v[0] + m[1][3] * v[1] + m[2][3] * v[2] + m[3][3]; + //return Result; +} - template - GLM_FUNC_QUALIFIER detail::tmat4x4 rotate_slow - ( - detail::tmat4x4 const & m, - T const & angle, - detail::tvec3 const & v - ) - { - T a = radians(angle); - T c = cos(a); - T s = sin(a); - detail::tmat4x4 Result; +template +GLM_FUNC_QUALIFIER detail::tmat4x4 rotate_slow +( + detail::tmat4x4 const & m, + T const & angle, + detail::tvec3 const & v +) +{ + T a = radians(angle); + T c = cos(a); + T s = sin(a); + detail::tmat4x4 Result; - detail::tvec3 axis = normalize(v); + detail::tvec3 axis = normalize(v); - Result[0][0] = c + (1 - c) * axis.x * axis.x; - Result[0][1] = (1 - c) * axis.x * axis.y + s * axis.z; - Result[0][2] = (1 - c) * axis.x * axis.z - s * axis.y; - Result[0][3] = 0; + Result[0][0] = c + (1 - c) * axis.x * axis.x; + Result[0][1] = (1 - c) * axis.x * axis.y + s * axis.z; + Result[0][2] = (1 - c) * axis.x * axis.z - s * axis.y; + Result[0][3] = 0; - Result[1][0] = (1 - c) * axis.y * axis.x - s * axis.z; - Result[1][1] = c + (1 - c) * axis.y * axis.y; - Result[1][2] = (1 - c) * axis.y * axis.z + s * axis.x; - Result[1][3] = 0; + Result[1][0] = (1 - c) * axis.y * axis.x - s * axis.z; + Result[1][1] = c + (1 - c) * axis.y * axis.y; + Result[1][2] = (1 - c) * axis.y * axis.z + s * axis.x; + Result[1][3] = 0; - Result[2][0] = (1 - c) * axis.z * axis.x + s * axis.y; - Result[2][1] = (1 - c) * axis.z * axis.y - s * axis.x; - Result[2][2] = c + (1 - c) * axis.z * axis.z; - Result[2][3] = 0; + Result[2][0] = (1 - c) * axis.z * axis.x + s * axis.y; + Result[2][1] = (1 - c) * axis.z * axis.y - s * axis.x; + Result[2][2] = c + (1 - c) * axis.z * axis.z; + Result[2][3] = 0; - Result[3] = detail::tvec4(0, 0, 0, 1); - return m * Result; - } + Result[3] = detail::tvec4(0, 0, 0, 1); + return m * Result; +} - template - GLM_FUNC_QUALIFIER detail::tmat4x4 scale_slow - ( - detail::tmat4x4 const & m, - detail::tvec3 const & v - ) - { - detail::tmat4x4 Result(T(1)); - Result[0][0] = v.x; - Result[1][1] = v.y; - Result[2][2] = v.z; - return m * Result; - } +template +GLM_FUNC_QUALIFIER detail::tmat4x4 scale_slow +( + detail::tmat4x4 const & m, + detail::tvec3 const & v +) +{ + detail::tmat4x4 Result(T(1)); + Result[0][0] = v.x; + Result[1][1] = v.y; + Result[2][2] = v.z; + return m * Result; +} - template - GLM_FUNC_QUALIFIER detail::tmat4x4 ortho - ( - valType const & left, - valType const & right, - valType const & bottom, - valType const & top, - valType const & zNear, - valType const & zFar - ) - { - detail::tmat4x4 Result(1); - Result[0][0] = valType(2) / (right - left); - Result[1][1] = valType(2) / (top - bottom); - Result[2][2] = - valType(2) / (zFar - zNear); - Result[3][0] = - (right + left) / (right - left); - Result[3][1] = - (top + bottom) / (top - bottom); - Result[3][2] = - (zFar + zNear) / (zFar - zNear); - return Result; - } +template +GLM_FUNC_QUALIFIER detail::tmat4x4 ortho +( + valType const & left, + valType const & right, + valType const & bottom, + valType const & top, + valType const & zNear, + valType const & zFar +) +{ + detail::tmat4x4 Result(1); + Result[0][0] = valType(2) / (right - left); + Result[1][1] = valType(2) / (top - bottom); + Result[2][2] = - valType(2) / (zFar - zNear); + Result[3][0] = - (right + left) / (right - left); + Result[3][1] = - (top + bottom) / (top - bottom); + Result[3][2] = - (zFar + zNear) / (zFar - zNear); + return Result; +} - template - GLM_FUNC_QUALIFIER detail::tmat4x4 ortho( - valType const & left, - valType const & right, - valType const & bottom, - valType const & top) - { - detail::tmat4x4 Result(1); - Result[0][0] = valType(2) / (right - left); - Result[1][1] = valType(2) / (top - bottom); - Result[2][2] = - valType(1); - Result[3][0] = - (right + left) / (right - left); - Result[3][1] = - (top + bottom) / (top - bottom); - return Result; - } +template +GLM_FUNC_QUALIFIER detail::tmat4x4 ortho( + valType const & left, + valType const & right, + valType const & bottom, + valType const & top) +{ + detail::tmat4x4 Result(1); + Result[0][0] = valType(2) / (right - left); + Result[1][1] = valType(2) / (top - bottom); + Result[2][2] = - valType(1); + Result[3][0] = - (right + left) / (right - left); + Result[3][1] = - (top + bottom) / (top - bottom); + return Result; +} - template - GLM_FUNC_QUALIFIER detail::tmat4x4 frustum - ( - valType const & left, - valType const & right, - valType const & bottom, - valType const & top, - valType const & nearVal, - valType const & farVal - ) - { - detail::tmat4x4 Result(0); - Result[0][0] = (valType(2) * nearVal) / (right - left); - Result[1][1] = (valType(2) * nearVal) / (top - bottom); - Result[2][0] = (right + left) / (right - left); - Result[2][1] = (top + bottom) / (top - bottom); - Result[2][2] = -(farVal + nearVal) / (farVal - nearVal); - Result[2][3] = valType(-1); - Result[3][2] = -(valType(2) * farVal * nearVal) / (farVal - nearVal); - return Result; - } +template +GLM_FUNC_QUALIFIER detail::tmat4x4 frustum +( + valType const & left, + valType const & right, + valType const & bottom, + valType const & top, + valType const & nearVal, + valType const & farVal +) +{ + detail::tmat4x4 Result(0); + Result[0][0] = (valType(2) * nearVal) / (right - left); + Result[1][1] = (valType(2) * nearVal) / (top - bottom); + Result[2][0] = (right + left) / (right - left); + Result[2][1] = (top + bottom) / (top - bottom); + Result[2][2] = -(farVal + nearVal) / (farVal - nearVal); + Result[2][3] = valType(-1); + Result[3][2] = -(valType(2) * farVal * nearVal) / (farVal - nearVal); + return Result; +} - template - GLM_FUNC_QUALIFIER detail::tmat4x4 perspective - ( - valType const & fovy, - valType const & aspect, - valType const & zNear, - valType const & zFar - ) - { - valType range = tan(radians(fovy / valType(2))) * zNear; - valType left = -range * aspect; - valType right = range * aspect; - valType bottom = -range; - valType top = range; +template +GLM_FUNC_QUALIFIER detail::tmat4x4 perspective +( + valType const & fovy, + valType const & aspect, + valType const & zNear, + valType const & zFar +) +{ + valType range = tan(radians(fovy / valType(2))) * zNear; + valType left = -range * aspect; + valType right = range * aspect; + valType bottom = -range; + valType top = range; - detail::tmat4x4 Result(valType(0)); - Result[0][0] = (valType(2) * zNear) / (right - left); - Result[1][1] = (valType(2) * zNear) / (top - bottom); - Result[2][2] = - (zFar + zNear) / (zFar - zNear); - Result[2][3] = - valType(1); - Result[3][2] = - (valType(2) * zFar * zNear) / (zFar - zNear); - return Result; - } + detail::tmat4x4 Result(valType(0)); + Result[0][0] = (valType(2) * zNear) / (right - left); + Result[1][1] = (valType(2) * zNear) / (top - bottom); + Result[2][2] = - (zFar + zNear) / (zFar - zNear); + Result[2][3] = - valType(1); + Result[3][2] = - (valType(2) * zFar * zNear) / (zFar - zNear); + return Result; +} - template - GLM_FUNC_QUALIFIER detail::tmat4x4 perspectiveFov - ( - valType const & fov, - valType const & width, - valType const & height, - valType const & zNear, - valType const & zFar - ) - { - valType rad = glm::radians(fov); - valType h = glm::cos(valType(0.5) * rad) / glm::sin(valType(0.5) * rad); - valType w = h * height / width; +template +GLM_FUNC_QUALIFIER detail::tmat4x4 perspectiveFov +( + valType const & fov, + valType const & width, + valType const & height, + valType const & zNear, + valType const & zFar +) +{ + valType rad = glm::radians(fov); + valType h = glm::cos(valType(0.5) * rad) / glm::sin(valType(0.5) * rad); + valType w = h * height / width; - detail::tmat4x4 Result(valType(0)); - Result[0][0] = w; - Result[1][1] = h; - Result[2][2] = (zFar + zNear) / (zFar - zNear); - Result[2][3] = valType(1); - Result[3][2] = -(valType(2) * zFar * zNear) / (zFar - zNear); - return Result; - } + detail::tmat4x4 Result(valType(0)); + Result[0][0] = w; + Result[1][1] = h; + Result[2][2] = (zFar + zNear) / (zFar - zNear); + Result[2][3] = valType(1); + Result[3][2] = -(valType(2) * zFar * zNear) / (zFar - zNear); + return Result; +} - template - GLM_FUNC_QUALIFIER detail::tmat4x4 infinitePerspective - ( - T fovy, - T aspect, - T zNear - ) - { - T range = tan(radians(fovy / T(2))) * zNear; - T left = -range * aspect; - T right = range * aspect; - T bottom = -range; - T top = range; +template +GLM_FUNC_QUALIFIER detail::tmat4x4 infinitePerspective +( + T fovy, + T aspect, + T zNear +) +{ + T range = tan(radians(fovy / T(2))) * zNear; + T left = -range * aspect; + T right = range * aspect; + T bottom = -range; + T top = range; - detail::tmat4x4 Result(T(0)); - Result[0][0] = (T(2) * zNear) / (right - left); - Result[1][1] = (T(2) * zNear) / (top - bottom); - Result[2][2] = - T(1); - Result[2][3] = - T(1); - Result[3][2] = - T(2) * zNear; - return Result; - } + detail::tmat4x4 Result(T(0)); + Result[0][0] = (T(2) * zNear) / (right - left); + Result[1][1] = (T(2) * zNear) / (top - bottom); + Result[2][2] = - T(1); + Result[2][3] = - T(1); + Result[3][2] = - T(2) * zNear; + return Result; +} - template - GLM_FUNC_QUALIFIER detail::tmat4x4 tweakedInfinitePerspective - ( - T fovy, - T aspect, - T zNear - ) - { - T range = tan(radians(fovy / T(2))) * zNear; - T left = -range * aspect; - T right = range * aspect; - T bottom = -range; - T top = range; +template +GLM_FUNC_QUALIFIER detail::tmat4x4 tweakedInfinitePerspective +( + T fovy, + T aspect, + T zNear +) +{ + T range = tan(radians(fovy / T(2))) * zNear; + T left = -range * aspect; + T right = range * aspect; + T bottom = -range; + T top = range; - detail::tmat4x4 Result(T(0)); - Result[0][0] = (T(2) * zNear) / (right - left); - Result[1][1] = (T(2) * zNear) / (top - bottom); - Result[2][2] = T(0.0001) - T(1); - Result[2][3] = T(-1); - Result[3][2] = - (T(0.0001) - T(2)) * zNear; - return Result; - } + detail::tmat4x4 Result(T(0)); + Result[0][0] = (T(2) * zNear) / (right - left); + Result[1][1] = (T(2) * zNear) / (top - bottom); + Result[2][2] = T(0.0001) - T(1); + Result[2][3] = T(-1); + Result[3][2] = - (T(0.0001) - T(2)) * zNear; + return Result; +} - template - GLM_FUNC_QUALIFIER detail::tvec3 project - ( - detail::tvec3 const & obj, - detail::tmat4x4 const & model, - detail::tmat4x4 const & proj, - detail::tvec4 const & viewport - ) - { - detail::tvec4 tmp = detail::tvec4(obj, T(1)); - tmp = model * tmp; - tmp = proj * tmp; +template +GLM_FUNC_QUALIFIER detail::tvec3 project +( + detail::tvec3 const & obj, + detail::tmat4x4 const & model, + detail::tmat4x4 const & proj, + detail::tvec4 const & viewport +) +{ + detail::tvec4 tmp = detail::tvec4(obj, T(1)); + tmp = model * tmp; + tmp = proj * tmp; - tmp /= tmp.w; - tmp = tmp * T(0.5) + T(0.5); - tmp[0] = tmp[0] * T(viewport[2]) + T(viewport[0]); - tmp[1] = tmp[1] * T(viewport[3]) + T(viewport[1]); + tmp /= tmp.w; + tmp = tmp * T(0.5) + T(0.5); + tmp[0] = tmp[0] * T(viewport[2]) + T(viewport[0]); + tmp[1] = tmp[1] * T(viewport[3]) + T(viewport[1]); - return detail::tvec3(tmp); - } + return detail::tvec3(tmp); +} - template - GLM_FUNC_QUALIFIER detail::tvec3 unProject - ( - detail::tvec3 const & win, - detail::tmat4x4 const & model, - detail::tmat4x4 const & proj, - detail::tvec4 const & viewport - ) - { - detail::tmat4x4 inverse = glm::inverse(proj * model); +template +GLM_FUNC_QUALIFIER detail::tvec3 unProject +( + detail::tvec3 const & win, + detail::tmat4x4 const & model, + detail::tmat4x4 const & proj, + detail::tvec4 const & viewport +) +{ + detail::tmat4x4 inverse = glm::inverse(proj * model); - detail::tvec4 tmp = detail::tvec4(win, T(1)); - tmp.x = (tmp.x - T(viewport[0])) / T(viewport[2]); - tmp.y = (tmp.y - T(viewport[1])) / T(viewport[3]); - tmp = tmp * T(2) - T(1); + detail::tvec4 tmp = detail::tvec4(win, T(1)); + tmp.x = (tmp.x - T(viewport[0])) / T(viewport[2]); + tmp.y = (tmp.y - T(viewport[1])) / T(viewport[3]); + tmp = tmp * T(2) - T(1); - detail::tvec4 obj = inverse * tmp; - obj /= obj.w; + detail::tvec4 obj = inverse * tmp; + obj /= obj.w; - return detail::tvec3(obj); - } + return detail::tvec3(obj); +} - template - detail::tmat4x4 pickMatrix - ( - detail::tvec2 const & center, - detail::tvec2 const & delta, - detail::tvec4 const & viewport - ) - { - assert(delta.x > T(0) && delta.y > T(0)); - detail::tmat4x4 Result(1.0f); +template +detail::tmat4x4 pickMatrix +( + detail::tvec2 const & center, + detail::tvec2 const & delta, + detail::tvec4 const & viewport +) +{ + assert(delta.x > T(0) && delta.y > T(0)); + detail::tmat4x4 Result(1.0f); - if(!(delta.x > T(0) && delta.y > T(0))) - return Result; // Error + if(!(delta.x > T(0) && delta.y > T(0))) + return Result; // Error - detail::tvec3 Temp( - (T(viewport[2]) - T(2) * (center.x - T(viewport[0]))) / delta.x, - (T(viewport[3]) - T(2) * (center.y - T(viewport[1]))) / delta.y, - T(0)); + detail::tvec3 Temp( + (T(viewport[2]) - T(2) * (center.x - T(viewport[0]))) / delta.x, + (T(viewport[3]) - T(2) * (center.y - T(viewport[1]))) / delta.y, + T(0)); - // Translate and scale the picked region to the entire window - Result = translate(Result, Temp); - return scale(Result, detail::tvec3(T(viewport[2]) / delta.x, T(viewport[3]) / delta.y, T(1))); - } + // Translate and scale the picked region to the entire window + Result = translate(Result, Temp); + return scale(Result, detail::tvec3(T(viewport[2]) / delta.x, T(viewport[3]) / delta.y, T(1))); +} - template - GLM_FUNC_QUALIFIER detail::tmat4x4 lookAt - ( - detail::tvec3 const & eye, - detail::tvec3 const & center, - detail::tvec3 const & up - ) - { - detail::tvec3 f = normalize(center - eye); - detail::tvec3 u = normalize(up); - detail::tvec3 s = normalize(cross(f, u)); - u = cross(s, f); +template +GLM_FUNC_QUALIFIER detail::tmat4x4 lookAt +( + detail::tvec3 const & eye, + detail::tvec3 const & center, + detail::tvec3 const & up +) +{ + detail::tvec3 f = normalize(center - eye); + detail::tvec3 u = normalize(up); + detail::tvec3 s = normalize(cross(f, u)); + u = cross(s, f); - detail::tmat4x4 Result(1); - Result[0][0] = s.x; - Result[1][0] = s.y; - Result[2][0] = s.z; - Result[0][1] = u.x; - Result[1][1] = u.y; - Result[2][1] = u.z; - Result[0][2] =-f.x; - Result[1][2] =-f.y; - Result[2][2] =-f.z; - /* Test this instead of translate3D - Result[3][0] =-dot(s, eye); - Result[3][1] =-dot(y, eye); - Result[3][2] = dot(f, eye); - */ - return gtc::translate(Result, -eye); - } + detail::tmat4x4 Result(1); + Result[0][0] = s.x; + Result[1][0] = s.y; + Result[2][0] = s.z; + Result[0][1] = u.x; + Result[1][1] = u.y; + Result[2][1] = u.z; + Result[0][2] =-f.x; + Result[1][2] =-f.y; + Result[2][2] =-f.z; +/* Test this instead of translate3D + Result[3][0] =-dot(s, eye); + Result[3][1] =-dot(y, eye); + Result[3][2] = dot(f, eye); +*/ + return translate(Result, -eye); +} -}//namespace gtc }//namespace glm diff --git a/glm/gtc/quaternion.hpp b/glm/gtc/quaternion.hpp index 577b01ef..7cefd1c2 100644 --- a/glm/gtc/quaternion.hpp +++ b/glm/gtc/quaternion.hpp @@ -39,8 +39,8 @@ /// need to be included to use these functionalities. /////////////////////////////////////////////////////////////////////////////////// -#ifndef glm_gtc_quaternion -#define glm_gtc_quaternion +#ifndef GLM_GTC_quaternion +#define GLM_GTC_quaternion 90 // Dependency: #include "../glm.hpp" @@ -73,7 +73,7 @@ namespace detail tquat(); explicit tquat( value_type const & s, - tvec3 const & v); + glm::detail::tvec3 const & v); explicit tquat( value_type const & w, value_type const & x, @@ -150,8 +150,6 @@ namespace detail } //namespace detail -namespace gtc{ - /// @addtogroup gtc_quaternion /// @{ @@ -255,9 +253,8 @@ namespace gtc{ typedef detail::tquat highp_quat; /// @} -} //namespace gtc } //namespace glm #include "quaternion.inl" -#endif//glm_gtc_quaternion +#endif//GLM_GTC_quaternion diff --git a/glm/gtc/quaternion.inl b/glm/gtc/quaternion.inl index e0383d2a..8cc005ee 100644 --- a/glm/gtc/quaternion.inl +++ b/glm/gtc/quaternion.inl @@ -211,7 +211,7 @@ namespace detail{ detail::tquat const & q ) { - return gtc::inverse(q) * v; + return inverse(q) * v; } template @@ -231,7 +231,7 @@ namespace detail{ detail::tquat const & q ) { - return gtc::inverse(q) * v; + return inverse(q) * v; } template @@ -291,8 +291,6 @@ namespace detail{ }//namespace detail -namespace gtc{ - //////////////////////////////////////////////////////// template GLM_FUNC_QUALIFIER T length @@ -447,7 +445,7 @@ namespace gtc{ detail::tquat const & q ) { - return gtc::conjugate(q) / gtc::dot(q, q); + return conjugate(q) / dot(q, q); } template @@ -473,7 +471,7 @@ namespace gtc{ typename detail::tquat::value_type AngleRad = radians(angle); typename detail::tquat::value_type fSin = sin(AngleRad * T(0.5)); - return gtc::cross(q, detail::tquat(cos(AngleRad * T(0.5)), Tmp.x * fSin, Tmp.y * fSin, Tmp.z * fSin)); + return cross(q, detail::tquat(cos(AngleRad * T(0.5)), Tmp.x * fSin, Tmp.y * fSin, Tmp.z * fSin)); } template @@ -578,5 +576,4 @@ namespace gtc{ return quat_cast(detail::tmat3x3(m4)); } -}//namespace gtc }//namespace glm diff --git a/glm/gtc/swizzle.hpp b/glm/gtc/swizzle.hpp index d7281784..18aa6925 100644 --- a/glm/gtc/swizzle.hpp +++ b/glm/gtc/swizzle.hpp @@ -35,8 +35,8 @@ /// need to be included to use these functionalities. /////////////////////////////////////////////////////////////////////////////////// -#ifndef glm_gtc_swizzle -#define glm_gtc_swizzle +#ifndef GLM_GTC_swizzle +#define GLM_GTC_swizzle 90 // Dependency: #include "../glm.hpp" @@ -46,8 +46,7 @@ # pragma message("GLM: GLM_GTC_swizzle extension included") #endif -namespace glm{ -namespace gtc +namespace glm { /// @addtogroup gtc_swizzle /// @{ @@ -369,9 +368,8 @@ namespace gtc static_swizzle4_ref(glm::u64, 4) /// @} -}//namespace gtc }//namespace glm #include "swizzle.inl" -#endif//glm_gtc_swizzle +#endif//GLM_GTC_swizzle diff --git a/glm/gtc/swizzle.inl b/glm/gtc/swizzle.inl index 6d783c23..94a62de4 100644 --- a/glm/gtc/swizzle.inl +++ b/glm/gtc/swizzle.inl @@ -11,7 +11,6 @@ /////////////////////////////////////////////////////////////////////////////////////////////////// namespace glm{ -namespace gtc{ template class vecType> GLM_FUNC_QUALIFIER T swizzle @@ -172,5 +171,4 @@ GLM_FUNC_QUALIFIER detail::tref4 swizzle } */ -}//namespace gtc }//namespace glm diff --git a/glm/gtc/type_precision.hpp b/glm/gtc/type_precision.hpp index 4cfea1dd..fd915c6b 100644 --- a/glm/gtc/type_precision.hpp +++ b/glm/gtc/type_precision.hpp @@ -40,8 +40,8 @@ /// need to be included to use these functionalities. /////////////////////////////////////////////////////////////////////////////////// -#ifndef glm_gtc_type_precision -#define glm_gtc_type_precision +#ifndef GLM_GTC_type_precision +#define GLM_GTC_type_precision 100 // Dependency: #include "../glm.hpp" @@ -52,9 +52,8 @@ # pragma message("GLM: GLM_GTC_type_precision extension included") #endif -namespace glm{ -namespace gtc{ - +namespace glm +{ /////////////////////////// // Signed int vector types @@ -229,9 +228,8 @@ namespace gtc{ typedef detail::tquat f64quat; //!< \brief Double-precision floating-point quaternion. (from GLM_GTC_type_precision extension) /// @} -}//namespace gtc }//namespace glm #include "type_precision.inl" -#endif//glm_gtc_type_precision +#endif//GLM_GTC_type_precision diff --git a/glm/gtc/type_ptr.hpp b/glm/gtc/type_ptr.hpp index 4b12a958..8e608aaf 100644 --- a/glm/gtc/type_ptr.hpp +++ b/glm/gtc/type_ptr.hpp @@ -56,8 +56,8 @@ /// need to be included to use these functionalities. /////////////////////////////////////////////////////////////////////////////////// -#ifndef glm_gtc_type_ptr -#define glm_gtc_type_ptr +#ifndef GLM_GTC_type_ptr +#define GLM_GTC_type_ptr 90 // Dependency: #include "../glm.hpp" @@ -69,8 +69,7 @@ # pragma message("GLM: GLM_GTC_type_ptr extension included") #endif -namespace glm{ -namespace gtc +namespace glm { /// @addtogroup gtc_type_ptr /// @{ @@ -502,10 +501,9 @@ namespace gtc } /// @} -}//namespace gtc }//namespace glm #include "type_ptr.inl" -#endif//glm_gtx_type_ptr +#endif//GLM_GTC_type_ptr diff --git a/glm/gtx/associated_min_max.hpp b/glm/gtx/associated_min_max.hpp index 71e1f319..4b68ff46 100644 --- a/glm/gtx/associated_min_max.hpp +++ b/glm/gtx/associated_min_max.hpp @@ -45,8 +45,7 @@ # pragma message("GLM: GLM_GTX_associated_min_max extension included") #endif -namespace glm{ -namespace gtx +namespace glm { /// @addtogroup gtx_associated_min_max /// @{ @@ -94,7 +93,6 @@ namespace gtx const genTypeT& w, const genTypeU& d); /// @} -} //namespace gtx } //namespace glm #include "associated_min_max.inl" diff --git a/glm/gtx/associated_min_max.inl b/glm/gtx/associated_min_max.inl index e1d2d6f7..e6684021 100644 --- a/glm/gtx/associated_min_max.inl +++ b/glm/gtx/associated_min_max.inl @@ -8,907 +8,905 @@ /////////////////////////////////////////////////////////////////////////////////////////////////// namespace glm{ -namespace gtx + +// Min comparison between 2 variables +template +GLM_FUNC_QUALIFIER U associatedMin(T x, U a, T y, U b) { - // Min comparison between 2 variables - template - GLM_FUNC_QUALIFIER U associatedMin(T x, U a, T y, U b) + return x < y ? a : b; +} + +template +GLM_FUNC_QUALIFIER detail::tvec2 associatedMin +( + const detail::tvec2& x, const detail::tvec2& a, + const detail::tvec2& y, const detail::tvec2& b +) +{ + detail::tvec2 Result; + //Result.x = x[0] < y[0] ? a[0] : b[0]; + //Result.y = x[1] < y[1] ? a[1] : b[1]; + for(typename detail::tvec2::size_type i = 0; i < detail::tvec2::value_size; ++i) + Result[i] = x[i] < y[i] ? a[i] : b[i]; + return Result; +} + +template +GLM_FUNC_QUALIFIER detail::tvec3 associatedMin +( + const detail::tvec3& x, const detail::tvec3& a, + const detail::tvec3& y, const detail::tvec3& b +) +{ + detail::tvec3 Result; + for(typename detail::tvec3::size_type i = 0; i < detail::tvec3::value_size; ++i) + Result[i] = x[i] < y[i] ? a[i] : b[i]; + return Result; +} + +template +GLM_FUNC_QUALIFIER detail::tvec4 associatedMin +( + const detail::tvec4& x, const detail::tvec4& a, + const detail::tvec4& y, const detail::tvec4& b +) +{ + detail::tvec4 Result; + for(typename detail::tvec4::size_type i = 0; i < detail::tvec4::value_size; ++i) + Result[i] = x[i] < y[i] ? a[i] : b[i]; + return Result; +} + +template +GLM_FUNC_QUALIFIER detail::tvec2 associatedMin +( + T x, const detail::tvec2& a, + T y, const detail::tvec2& b +) +{ + detail::tvec2 Result; + for(typename detail::tvec2::size_type i = 0; i < detail::tvec2::value_size; ++i) + Result[i] = x < y ? a[i] : b[i]; + return Result; +} + +template +GLM_FUNC_QUALIFIER detail::tvec3 associatedMin +( + T x, const detail::tvec3& a, + T y, const detail::tvec3& b +) +{ + detail::tvec3 Result; + for(typename detail::tvec3::size_type i = 0; i < detail::tvec3::value_size; ++i) + Result[i] = x < y ? a[i] : b[i]; + return Result; +} + +template +GLM_FUNC_QUALIFIER detail::tvec4 associatedMin +( + T x, const detail::tvec4& a, + T y, const detail::tvec4& b +) +{ + detail::tvec4 Result; + for(typename detail::tvec4::size_type i = 0; i < detail::tvec4::value_size; ++i) + Result[i] = x < y ? a[i] : b[i]; + return Result; +} + +template +GLM_FUNC_QUALIFIER detail::tvec2 associatedMin +( + const detail::tvec2& x, U a, + const detail::tvec2& y, U b +) +{ + detail::tvec2 Result; + for(typename detail::tvec2::size_type i = 0; i < detail::tvec2::value_size(); ++i) + Result[i] = x[i] < y[i] ? a : b; + return Result; +} + +template +GLM_FUNC_QUALIFIER detail::tvec3 associatedMin +( + const detail::tvec3& x, U a, + const detail::tvec3& y, U b +) +{ + detail::tvec3 Result; + for(typename detail::tvec3::size_type i = 0; i < detail::tvec3::value_size(); ++i) + Result[i] = x[i] < y[i] ? a : b; + return Result; +} + +template +GLM_FUNC_QUALIFIER detail::tvec4 associatedMin +( + const detail::tvec4& x, U a, + const detail::tvec4& y, U b +) +{ + detail::tvec4 Result; + for(typename detail::tvec4::size_type i = 0; i < detail::tvec4::value_size(); ++i) + Result[i] = x[i] < y[i] ? a : b; + return Result; +} + +// Min comparison between 3 variables +template +GLM_FUNC_QUALIFIER U associatedMin +( + T x, U a, + T y, U b, + T z, U c +) +{ + U Result = x < y ? (x < z ? a : c) : (y < z ? b : c); + return Result; +} + +template +GLM_FUNC_QUALIFIER detail::tvec2 associatedMin +( + const detail::tvec2& x, const detail::tvec2& a, + const detail::tvec2& y, const detail::tvec2& b, + const detail::tvec2& z, const detail::tvec2& c +) +{ + detail::tvec2 Result; + for(typename detail::tvec2::size_type i = 0; i < detail::tvec2::value_size; ++i) + Result[i] = x[i] < y[i] ? (x[i] < z[i] ? a[i] : c[i]) : (y[i] < z[i] ? b[i] : c[i]); + return Result; +} + +template +GLM_FUNC_QUALIFIER detail::tvec3 associatedMin +( + const detail::tvec3& x, const detail::tvec3& a, + const detail::tvec3& y, const detail::tvec3& b, + const detail::tvec3& z, const detail::tvec3& c +) +{ + detail::tvec3 Result; + for(typename detail::tvec3::size_type i = 0; i < detail::tvec3::value_size; ++i) + Result[i] = x[i] < y[i] ? (x[i] < z[i] ? a[i] : c[i]) : (y[i] < z[i] ? b[i] : c[i]); + return Result; +} + +template +GLM_FUNC_QUALIFIER detail::tvec4 associatedMin +( + const detail::tvec4& x, const detail::tvec4& a, + const detail::tvec4& y, const detail::tvec4& b, + const detail::tvec4& z, const detail::tvec4& c +) +{ + detail::tvec4 Result; + for(typename detail::tvec4::size_type i = 0; i < detail::tvec4::value_size; ++i) + Result[i] = x[i] < y[i] ? (x[i] < z[i] ? a[i] : c[i]) : (y[i] < z[i] ? b[i] : c[i]); + return Result; +} + +// Min comparison between 4 variables +template +GLM_FUNC_QUALIFIER U associatedMin +( + T x, U a, + T y, U b, + T z, U c, + T w, U d +) +{ + T Test1 = min(x, y); + T Test2 = min(z, w);; + U Result1 = x < y ? a : b; + U Result2 = z < w ? c : d; + U Result = Test1 < Test2 ? Result1 : Result2; + return Result; +} + +// Min comparison between 4 variables +template +GLM_FUNC_QUALIFIER detail::tvec2 associatedMin +( + const detail::tvec2& x, const detail::tvec2& a, + const detail::tvec2& y, const detail::tvec2& b, + const detail::tvec2& z, const detail::tvec2& c, + const detail::tvec2& w, const detail::tvec2& d +) +{ + detail::tvec2 Result; + for(typename detail::tvec2::size_type i = 0; i < detail::tvec2::value_size; ++i) { - return x < y ? a : b; + T Test1 = min(x[i], y[i]); + T Test2 = min(z[i], w[i]); + U Result1 = x[i] < y[i] ? a[i] : b[i]; + U Result2 = z[i] < w[i] ? c[i] : d[i]; + Result[i] = Test1 < Test2 ? Result1 : Result2; } + return Result; +} - template - GLM_FUNC_QUALIFIER detail::tvec2 associatedMin - ( - const detail::tvec2& x, const detail::tvec2& a, - const detail::tvec2& y, const detail::tvec2& b - ) +// Min comparison between 4 variables +template +GLM_FUNC_QUALIFIER detail::tvec3 associatedMin +( + const detail::tvec3& x, const detail::tvec3& a, + const detail::tvec3& y, const detail::tvec3& b, + const detail::tvec3& z, const detail::tvec3& c, + const detail::tvec3& w, const detail::tvec3& d +) +{ + detail::tvec3 Result; + for(typename detail::tvec3::size_type i = 0; i < detail::tvec3::value_size; ++i) { - detail::tvec2 Result; - //Result.x = x[0] < y[0] ? a[0] : b[0]; - //Result.y = x[1] < y[1] ? a[1] : b[1]; - for(typename detail::tvec2::size_type i = 0; i < detail::tvec2::value_size; ++i) - Result[i] = x[i] < y[i] ? a[i] : b[i]; - return Result; + T Test1 = min(x[i], y[i]); + T Test2 = min(z[i], w[i]); + U Result1 = x[i] < y[i] ? a[i] : b[i]; + U Result2 = z[i] < w[i] ? c[i] : d[i]; + Result[i] = Test1 < Test2 ? Result1 : Result2; } + return Result; +} - template - GLM_FUNC_QUALIFIER detail::tvec3 associatedMin - ( - const detail::tvec3& x, const detail::tvec3& a, - const detail::tvec3& y, const detail::tvec3& b - ) +// Min comparison between 4 variables +template +GLM_FUNC_QUALIFIER detail::tvec4 associatedMin +( + const detail::tvec4& x, const detail::tvec4& a, + const detail::tvec4& y, const detail::tvec4& b, + const detail::tvec4& z, const detail::tvec4& c, + const detail::tvec4& w, const detail::tvec4& d +) +{ + detail::tvec4 Result; + for(typename detail::tvec4::size_type i = 0; i < detail::tvec4::value_size; ++i) { - detail::tvec3 Result; - for(typename detail::tvec3::size_type i = 0; i < detail::tvec3::value_size; ++i) - Result[i] = x[i] < y[i] ? a[i] : b[i]; - return Result; + T Test1 = min(x[i], y[i]); + T Test2 = min(z[i], w[i]); + U Result1 = x[i] < y[i] ? a[i] : b[i]; + U Result2 = z[i] < w[i] ? c[i] : d[i]; + Result[i] = Test1 < Test2 ? Result1 : Result2; } + return Result; +} - template - GLM_FUNC_QUALIFIER detail::tvec4 associatedMin - ( - const detail::tvec4& x, const detail::tvec4& a, - const detail::tvec4& y, const detail::tvec4& b - ) +// Min comparison between 4 variables +template +GLM_FUNC_QUALIFIER detail::tvec2 associatedMin +( + T x, const detail::tvec2& a, + T y, const detail::tvec2& b, + T z, const detail::tvec2& c, + T w, const detail::tvec2& d +) +{ + T Test1 = min(x, y); + T Test2 = min(z, w); + + detail::tvec2 Result; + for(typename detail::tvec2::size_type i = 0; i < detail::tvec2::value_size; ++i) { - detail::tvec4 Result; - for(typename detail::tvec4::size_type i = 0; i < detail::tvec4::value_size; ++i) - Result[i] = x[i] < y[i] ? a[i] : b[i]; - return Result; + U Result1 = x < y ? a[i] : b[i]; + U Result2 = z < w ? c[i] : d[i]; + Result[i] = Test1 < Test2 ? Result1 : Result2; } + return Result; +} - template - GLM_FUNC_QUALIFIER detail::tvec2 associatedMin - ( - T x, const detail::tvec2& a, - T y, const detail::tvec2& b - ) +// Min comparison between 4 variables +template +GLM_FUNC_QUALIFIER detail::tvec3 associatedMin +( + T x, const detail::tvec3& a, + T y, const detail::tvec3& b, + T z, const detail::tvec3& c, + T w, const detail::tvec3& d +) +{ + T Test1 = min(x, y); + T Test2 = min(z, w); + + detail::tvec3 Result; + for(typename detail::tvec3::size_type i = 0; i < detail::tvec3::value_size; ++i) { - detail::tvec2 Result; - for(typename detail::tvec2::size_type i = 0; i < detail::tvec2::value_size; ++i) - Result[i] = x < y ? a[i] : b[i]; - return Result; + U Result1 = x < y ? a[i] : b[i]; + U Result2 = z < w ? c[i] : d[i]; + Result[i] = Test1 < Test2 ? Result1 : Result2; } + return Result; +} - template - GLM_FUNC_QUALIFIER detail::tvec3 associatedMin - ( - T x, const detail::tvec3& a, - T y, const detail::tvec3& b - ) +// Min comparison between 4 variables +template +GLM_FUNC_QUALIFIER detail::tvec4 associatedMin +( + T x, const detail::tvec4& a, + T y, const detail::tvec4& b, + T z, const detail::tvec4& c, + T w, const detail::tvec4& d +) +{ + T Test1 = min(x, y); + T Test2 = min(z, w); + + detail::tvec4 Result; + for(typename detail::tvec4::size_type i = 0; i < detail::tvec4::value_size; ++i) { - detail::tvec3 Result; - for(typename detail::tvec3::size_type i = 0; i < detail::tvec3::value_size; ++i) - Result[i] = x < y ? a[i] : b[i]; - return Result; + U Result1 = x < y ? a[i] : b[i]; + U Result2 = z < w ? c[i] : d[i]; + Result[i] = Test1 < Test2 ? Result1 : Result2; } + return Result; +} - template - GLM_FUNC_QUALIFIER detail::tvec4 associatedMin - ( - T x, const detail::tvec4& a, - T y, const detail::tvec4& b - ) +// Min comparison between 4 variables +template +GLM_FUNC_QUALIFIER detail::tvec2 associatedMin +( + const detail::tvec2& x, U a, + const detail::tvec2& y, U b, + const detail::tvec2& z, U c, + const detail::tvec2& w, U d +) +{ + detail::tvec2 Result; + for(typename detail::tvec2::size_type i = 0; i < detail::tvec2::value_size(); ++i) { - detail::tvec4 Result; - for(typename detail::tvec4::size_type i = 0; i < detail::tvec4::value_size; ++i) - Result[i] = x < y ? a[i] : b[i]; - return Result; + T Test1 = min(x[i], y[i]); + T Test2 = min(z[i], w[i]);; + U Result1 = x[i] < y[i] ? a : b; + U Result2 = z[i] < w[i] ? c : d; + Result[i] = Test1 < Test2 ? Result1 : Result2; } + return Result; +} - template - GLM_FUNC_QUALIFIER detail::tvec2 associatedMin - ( - const detail::tvec2& x, U a, - const detail::tvec2& y, U b - ) +// Min comparison between 4 variables +template +GLM_FUNC_QUALIFIER detail::tvec3 associatedMin +( + const detail::tvec3& x, U a, + const detail::tvec3& y, U b, + const detail::tvec3& z, U c, + const detail::tvec3& w, U d +) +{ + detail::tvec3 Result; + for(typename detail::tvec3::size_type i = 0; i < detail::tvec3::value_size(); ++i) { - detail::tvec2 Result; - for(typename detail::tvec2::size_type i = 0; i < detail::tvec2::value_size(); ++i) - Result[i] = x[i] < y[i] ? a : b; - return Result; + T Test1 = min(x[i], y[i]); + T Test2 = min(z[i], w[i]);; + U Result1 = x[i] < y[i] ? a : b; + U Result2 = z[i] < w[i] ? c : d; + Result[i] = Test1 < Test2 ? Result1 : Result2; } + return Result; +} - template - GLM_FUNC_QUALIFIER detail::tvec3 associatedMin - ( - const detail::tvec3& x, U a, - const detail::tvec3& y, U b - ) +// Min comparison between 4 variables +template +GLM_FUNC_QUALIFIER detail::tvec4 associatedMin +( + const detail::tvec4& x, U a, + const detail::tvec4& y, U b, + const detail::tvec4& z, U c, + const detail::tvec4& w, U d +) +{ + detail::tvec4 Result; + for(typename detail::tvec4::size_type i = 0; i < detail::tvec4::value_size(); ++i) { - detail::tvec3 Result; - for(typename detail::tvec3::size_type i = 0; i < detail::tvec3::value_size(); ++i) - Result[i] = x[i] < y[i] ? a : b; - return Result; + T Test1 = min(x[i], y[i]); + T Test2 = min(z[i], w[i]);; + U Result1 = x[i] < y[i] ? a : b; + U Result2 = z[i] < w[i] ? c : d; + Result[i] = Test1 < Test2 ? Result1 : Result2; } + return Result; +} - template - GLM_FUNC_QUALIFIER detail::tvec4 associatedMin - ( - const detail::tvec4& x, U a, - const detail::tvec4& y, U b - ) +// Max comparison between 2 variables +template +GLM_FUNC_QUALIFIER U associatedMax(T x, U a, T y, U b) +{ + return x > y ? a : b; +} + +// Max comparison between 2 variables +template +GLM_FUNC_QUALIFIER detail::tvec2 associatedMax +( + const detail::tvec2& x, const detail::tvec2& a, + const detail::tvec2& y, const detail::tvec2& b +) +{ + detail::tvec2 Result; + for(typename detail::tvec2::size_type i = 0; i < detail::tvec2::value_size; ++i) + Result[i] = x[i] > y[i] ? a[i] : b[i]; + return Result; +} + +// Max comparison between 2 variables +template +GLM_FUNC_QUALIFIER detail::tvec3 associatedMax +( + const detail::tvec3& x, const detail::tvec3& a, + const detail::tvec3& y, const detail::tvec3& b +) +{ + detail::tvec3 Result; + for(typename detail::tvec3::size_type i = 0; i < detail::tvec3::value_size; ++i) + Result[i] = x[i] > y[i] ? a[i] : b[i]; + return Result; +} + +// Max comparison between 2 variables +template +GLM_FUNC_QUALIFIER detail::tvec4 associatedMax +( + const detail::tvec4& x, const detail::tvec4& a, + const detail::tvec4& y, const detail::tvec4& b +) +{ + detail::tvec4 Result; + for(typename detail::tvec4::size_type i = 0; i < detail::tvec4::value_size; ++i) + Result[i] = x[i] > y[i] ? a[i] : b[i]; + return Result; +} + +// Max comparison between 2 variables +template +GLM_FUNC_QUALIFIER detail::tvec2 associatedMax +( + T x, const detail::tvec2& a, + T y, const detail::tvec2& b +) +{ + detail::tvec2 Result; + for(typename detail::tvec2::size_type i = 0; i < detail::tvec2::value_size; ++i) + Result[i] = x > y ? a[i] : b[i]; + return Result; +} + +// Max comparison between 2 variables +template +GLM_FUNC_QUALIFIER detail::tvec3 associatedMax +( + T x, const detail::tvec3& a, + T y, const detail::tvec3& b +) +{ + detail::tvec3 Result; + for(typename detail::tvec3::size_type i = 0; i < detail::tvec3::value_size; ++i) + Result[i] = x > y ? a[i] : b[i]; + return Result; +} + +// Max comparison between 2 variables +template +GLM_FUNC_QUALIFIER detail::tvec4 associatedMax +( + T x, const detail::tvec4& a, + T y, const detail::tvec4& b +) +{ + detail::tvec4 Result; + for(typename detail::tvec4::size_type i = 0; i < detail::tvec4::value_size; ++i) + Result[i] = x > y ? a[i] : b[i]; + return Result; +} + +// Max comparison between 2 variables +template +GLM_FUNC_QUALIFIER detail::tvec2 associatedMax +( + const detail::tvec2& x, U a, + const detail::tvec2& y, U b +) +{ + detail::tvec2 Result; + for(typename detail::tvec2::size_type i = 0; i < detail::tvec2::value_size(); ++i) + Result[i] = x[i] > y[i] ? a : b; + return Result; +} + +// Max comparison between 2 variables +template +GLM_FUNC_QUALIFIER detail::tvec3 associatedMax +( + const detail::tvec3& x, U a, + const detail::tvec3& y, U b +) +{ + detail::tvec3 Result; + for(typename detail::tvec3::size_type i = 0; i < detail::tvec3::value_size(); ++i) + Result[i] = x[i] > y[i] ? a : b; + return Result; +} + +// Max comparison between 2 variables +template +GLM_FUNC_QUALIFIER detail::tvec4 associatedMax +( + const detail::tvec4& x, U a, + const detail::tvec4& y, U b +) +{ + detail::tvec4 Result; + for(typename detail::tvec4::size_type i = 0; i < detail::tvec4::value_size(); ++i) + Result[i] = x[i] > y[i] ? a : b; + return Result; +} + +// Max comparison between 3 variables +template +GLM_FUNC_QUALIFIER U associatedMax +( + T x, U a, + T y, U b, + T z, U c +) +{ + U Result = x > y ? (x > z ? a : c) : (y > z ? b : c); + return Result; +} + +// Max comparison between 3 variables +template +GLM_FUNC_QUALIFIER detail::tvec2 associatedMax +( + const detail::tvec2& x, const detail::tvec2& a, + const detail::tvec2& y, const detail::tvec2& b, + const detail::tvec2& z, const detail::tvec2& c +) +{ + detail::tvec2 Result; + for(typename detail::tvec2::size_type i = 0; i < detail::tvec2::value_size; ++i) + Result[i] = x[i] > y[i] ? (x[i] > z[i] ? a[i] : c[i]) : (y[i] > z[i] ? b[i] : c[i]); + return Result; +} + +// Max comparison between 3 variables +template +GLM_FUNC_QUALIFIER detail::tvec3 associatedMax +( + const detail::tvec3& x, const detail::tvec3& a, + const detail::tvec3& y, const detail::tvec3& b, + const detail::tvec3& z, const detail::tvec3& c +) +{ + detail::tvec3 Result; + for(typename detail::tvec3::size_type i = 0; i < detail::tvec3::value_size; ++i) + Result[i] = x[i] > y[i] ? (x[i] > z[i] ? a[i] : c[i]) : (y[i] > z[i] ? b[i] : c[i]); + return Result; +} + +// Max comparison between 3 variables +template +GLM_FUNC_QUALIFIER detail::tvec4 associatedMax +( + const detail::tvec4& x, const detail::tvec4& a, + const detail::tvec4& y, const detail::tvec4& b, + const detail::tvec4& z, const detail::tvec4& c +) +{ + detail::tvec4 Result; + for(typename detail::tvec4::size_type i = 0; i < detail::tvec4::value_size; ++i) + Result[i] = x[i] > y[i] ? (x[i] > z[i] ? a[i] : c[i]) : (y[i] > z[i] ? b[i] : c[i]); + return Result; +} + +// Max comparison between 3 variables +template +GLM_FUNC_QUALIFIER detail::tvec2 associatedMax +( + T x, const detail::tvec2& a, + T y, const detail::tvec2& b, + T z, const detail::tvec2& c +) +{ + detail::tvec2 Result; + for(typename detail::tvec2::size_type i = 0; i < detail::tvec2::value_size; ++i) + Result[i] = x > y ? (x > z ? a[i] : c[i]) : (y > z ? b[i] : c[i]); + return Result; +} + +// Max comparison between 3 variables +template +GLM_FUNC_QUALIFIER detail::tvec3 associatedMax +( + T x, const detail::tvec3& a, + T y, const detail::tvec3& b, + T z, const detail::tvec3& c +) +{ + detail::tvec3 Result; + for(typename detail::tvec3::size_type i = 0; i < detail::tvec3::value_size; ++i) + Result[i] = x > y ? (x > z ? a[i] : c[i]) : (y > z ? b[i] : c[i]); + return Result; +} + +// Max comparison between 3 variables +template +GLM_FUNC_QUALIFIER detail::tvec4 associatedMax +( + T x, const detail::tvec4& a, + T y, const detail::tvec4& b, + T z, const detail::tvec4& c +) +{ + detail::tvec4 Result; + for(typename detail::tvec4::size_type i = 0; i < detail::tvec4::value_size; ++i) + Result[i] = x > y ? (x > z ? a[i] : c[i]) : (y > z ? b[i] : c[i]); + return Result; +} + +// Max comparison between 3 variables +template +GLM_FUNC_QUALIFIER detail::tvec2 associatedMax +( + const detail::tvec2& x, U a, + const detail::tvec2& y, U b, + const detail::tvec2& z, U c +) +{ + detail::tvec2 Result; + for(typename detail::tvec2::size_type i = 0; i < detail::tvec2::value_size(); ++i) + Result[i] = x[i] > y[i] ? (x[i] > z[i] ? a : c) : (y[i] > z[i] ? b : c); + return Result; +} + +// Max comparison between 3 variables +template +GLM_FUNC_QUALIFIER detail::tvec3 associatedMax +( + const detail::tvec3& x, U a, + const detail::tvec3& y, U b, + const detail::tvec3& z, U c +) +{ + detail::tvec3 Result; + for(typename detail::tvec3::size_type i = 0; i < detail::tvec3::value_size(); ++i) + Result[i] = x[i] > y[i] ? (x[i] > z[i] ? a : c) : (y[i] > z[i] ? b : c); + return Result; +} + +// Max comparison between 3 variables +template +GLM_FUNC_QUALIFIER detail::tvec4 associatedMax +( + const detail::tvec4& x, U a, + const detail::tvec4& y, U b, + const detail::tvec4& z, U c +) +{ + detail::tvec4 Result; + for(typename detail::tvec4::size_type i = 0; i < detail::tvec4::value_size(); ++i) + Result[i] = x[i] > y[i] ? (x[i] > z[i] ? a : c) : (y[i] > z[i] ? b : c); + return Result; +} + +// Max comparison between 4 variables +template +GLM_FUNC_QUALIFIER U associatedMax +( + T x, U a, + T y, U b, + T z, U c, + T w, U d +) +{ + T Test1 = max(x, y); + T Test2 = max(z, w);; + U Result1 = x > y ? a : b; + U Result2 = z > w ? c : d; + U Result = Test1 > Test2 ? Result1 : Result2; + return Result; +} + +// Max comparison between 4 variables +template +GLM_FUNC_QUALIFIER detail::tvec2 associatedMax +( + const detail::tvec2& x, const detail::tvec2& a, + const detail::tvec2& y, const detail::tvec2& b, + const detail::tvec2& z, const detail::tvec2& c, + const detail::tvec2& w, const detail::tvec2& d +) +{ + detail::tvec2 Result; + for(typename detail::tvec2::size_type i = 0; i < detail::tvec2::value_size; ++i) { - detail::tvec4 Result; - for(typename detail::tvec4::size_type i = 0; i < detail::tvec4::value_size(); ++i) - Result[i] = x[i] < y[i] ? a : b; - return Result; + T Test1 = max(x[i], y[i]); + T Test2 = max(z[i], w[i]); + U Result1 = x[i] > y[i] ? a[i] : b[i]; + U Result2 = z[i] > w[i] ? c[i] : d[i]; + Result[i] = Test1 > Test2 ? Result1 : Result2; } + return Result; +} - // Min comparison between 3 variables - template - GLM_FUNC_QUALIFIER U associatedMin - ( - T x, U a, - T y, U b, - T z, U c - ) +// Max comparison between 4 variables +template +GLM_FUNC_QUALIFIER detail::tvec3 associatedMax +( + const detail::tvec3& x, const detail::tvec3& a, + const detail::tvec3& y, const detail::tvec3& b, + const detail::tvec3& z, const detail::tvec3& c, + const detail::tvec3& w, const detail::tvec3& d +) +{ + detail::tvec3 Result; + for(typename detail::tvec3::size_type i = 0; i < detail::tvec3::value_size; ++i) { - U Result = x < y ? (x < z ? a : c) : (y < z ? b : c); - return Result; + T Test1 = max(x[i], y[i]); + T Test2 = max(z[i], w[i]); + U Result1 = x[i] > y[i] ? a[i] : b[i]; + U Result2 = z[i] > w[i] ? c[i] : d[i]; + Result[i] = Test1 > Test2 ? Result1 : Result2; } + return Result; +} - template - GLM_FUNC_QUALIFIER detail::tvec2 associatedMin - ( - const detail::tvec2& x, const detail::tvec2& a, - const detail::tvec2& y, const detail::tvec2& b, - const detail::tvec2& z, const detail::tvec2& c - ) +// Max comparison between 4 variables +template +GLM_FUNC_QUALIFIER detail::tvec4 associatedMax +( + const detail::tvec4& x, const detail::tvec4& a, + const detail::tvec4& y, const detail::tvec4& b, + const detail::tvec4& z, const detail::tvec4& c, + const detail::tvec4& w, const detail::tvec4& d +) +{ + detail::tvec4 Result; + for(typename detail::tvec4::size_type i = 0; i < detail::tvec4::value_size; ++i) { - detail::tvec2 Result; - for(typename detail::tvec2::size_type i = 0; i < detail::tvec2::value_size; ++i) - Result[i] = x[i] < y[i] ? (x[i] < z[i] ? a[i] : c[i]) : (y[i] < z[i] ? b[i] : c[i]); - return Result; + T Test1 = max(x[i], y[i]); + T Test2 = max(z[i], w[i]); + U Result1 = x[i] > y[i] ? a[i] : b[i]; + U Result2 = z[i] > w[i] ? c[i] : d[i]; + Result[i] = Test1 > Test2 ? Result1 : Result2; } + return Result; +} - template - GLM_FUNC_QUALIFIER detail::tvec3 associatedMin - ( - const detail::tvec3& x, const detail::tvec3& a, - const detail::tvec3& y, const detail::tvec3& b, - const detail::tvec3& z, const detail::tvec3& c - ) +// Max comparison between 4 variables +template +GLM_FUNC_QUALIFIER detail::tvec2 associatedMax +( + T x, const detail::tvec2& a, + T y, const detail::tvec2& b, + T z, const detail::tvec2& c, + T w, const detail::tvec2& d +) +{ + T Test1 = max(x, y); + T Test2 = max(z, w); + + detail::tvec2 Result; + for(typename detail::tvec2::size_type i = 0; i < detail::tvec2::value_size; ++i) { - detail::tvec3 Result; - for(typename detail::tvec3::size_type i = 0; i < detail::tvec3::value_size; ++i) - Result[i] = x[i] < y[i] ? (x[i] < z[i] ? a[i] : c[i]) : (y[i] < z[i] ? b[i] : c[i]); - return Result; + U Result1 = x > y ? a[i] : b[i]; + U Result2 = z > w ? c[i] : d[i]; + Result[i] = Test1 > Test2 ? Result1 : Result2; } + return Result; +} - template - GLM_FUNC_QUALIFIER detail::tvec4 associatedMin - ( - const detail::tvec4& x, const detail::tvec4& a, - const detail::tvec4& y, const detail::tvec4& b, - const detail::tvec4& z, const detail::tvec4& c - ) +// Max comparison between 4 variables +template +GLM_FUNC_QUALIFIER detail::tvec3 associatedMax +( + T x, const detail::tvec3& a, + T y, const detail::tvec3& b, + T z, const detail::tvec3& c, + T w, const detail::tvec3& d +) +{ + T Test1 = max(x, y); + T Test2 = max(z, w); + + detail::tvec3 Result; + for(typename detail::tvec3::size_type i = 0; i < detail::tvec3::value_size; ++i) { - detail::tvec4 Result; - for(typename detail::tvec4::size_type i = 0; i < detail::tvec4::value_size; ++i) - Result[i] = x[i] < y[i] ? (x[i] < z[i] ? a[i] : c[i]) : (y[i] < z[i] ? b[i] : c[i]); - return Result; + U Result1 = x > y ? a[i] : b[i]; + U Result2 = z > w ? c[i] : d[i]; + Result[i] = Test1 > Test2 ? Result1 : Result2; } + return Result; +} - // Min comparison between 4 variables - template - GLM_FUNC_QUALIFIER U associatedMin - ( - T x, U a, - T y, U b, - T z, U c, - T w, U d - ) +// Max comparison between 4 variables +template +GLM_FUNC_QUALIFIER detail::tvec4 associatedMax +( + T x, const detail::tvec4& a, + T y, const detail::tvec4& b, + T z, const detail::tvec4& c, + T w, const detail::tvec4& d +) +{ + T Test1 = max(x, y); + T Test2 = max(z, w); + + detail::tvec4 Result; + for(typename detail::tvec4::size_type i = 0; i < detail::tvec4::value_size; ++i) { - T Test1 = min(x, y); - T Test2 = min(z, w);; - U Result1 = x < y ? a : b; - U Result2 = z < w ? c : d; - U Result = Test1 < Test2 ? Result1 : Result2; - return Result; + U Result1 = x > y ? a[i] : b[i]; + U Result2 = z > w ? c[i] : d[i]; + Result[i] = Test1 > Test2 ? Result1 : Result2; } + return Result; +} - // Min comparison between 4 variables - template - GLM_FUNC_QUALIFIER detail::tvec2 associatedMin - ( - const detail::tvec2& x, const detail::tvec2& a, - const detail::tvec2& y, const detail::tvec2& b, - const detail::tvec2& z, const detail::tvec2& c, - const detail::tvec2& w, const detail::tvec2& d - ) +// Max comparison between 4 variables +template +GLM_FUNC_QUALIFIER detail::tvec2 associatedMax +( + const detail::tvec2& x, U a, + const detail::tvec2& y, U b, + const detail::tvec2& z, U c, + const detail::tvec2& w, U d +) +{ + detail::tvec2 Result; + for(typename detail::tvec2::size_type i = 0; i < detail::tvec2::value_size(); ++i) { - detail::tvec2 Result; - for(typename detail::tvec2::size_type i = 0; i < detail::tvec2::value_size; ++i) - { - T Test1 = min(x[i], y[i]); - T Test2 = min(z[i], w[i]); - U Result1 = x[i] < y[i] ? a[i] : b[i]; - U Result2 = z[i] < w[i] ? c[i] : d[i]; - Result[i] = Test1 < Test2 ? Result1 : Result2; - } - return Result; + T Test1 = max(x[i], y[i]); + T Test2 = max(z[i], w[i]);; + U Result1 = x[i] > y[i] ? a : b; + U Result2 = z[i] > w[i] ? c : d; + Result[i] = Test1 > Test2 ? Result1 : Result2; } + return Result; +} - // Min comparison between 4 variables - template - GLM_FUNC_QUALIFIER detail::tvec3 associatedMin - ( - const detail::tvec3& x, const detail::tvec3& a, - const detail::tvec3& y, const detail::tvec3& b, - const detail::tvec3& z, const detail::tvec3& c, - const detail::tvec3& w, const detail::tvec3& d - ) +// Max comparison between 4 variables +template +GLM_FUNC_QUALIFIER detail::tvec3 associatedMax +( + const detail::tvec3& x, U a, + const detail::tvec3& y, U b, + const detail::tvec3& z, U c, + const detail::tvec3& w, U d +) +{ + detail::tvec3 Result; + for(typename detail::tvec3::size_type i = 0; i < detail::tvec3::value_size(); ++i) { - detail::tvec3 Result; - for(typename detail::tvec3::size_type i = 0; i < detail::tvec3::value_size; ++i) - { - T Test1 = min(x[i], y[i]); - T Test2 = min(z[i], w[i]); - U Result1 = x[i] < y[i] ? a[i] : b[i]; - U Result2 = z[i] < w[i] ? c[i] : d[i]; - Result[i] = Test1 < Test2 ? Result1 : Result2; - } - return Result; + T Test1 = max(x[i], y[i]); + T Test2 = max(z[i], w[i]);; + U Result1 = x[i] > y[i] ? a : b; + U Result2 = z[i] > w[i] ? c : d; + Result[i] = Test1 > Test2 ? Result1 : Result2; } + return Result; +} - // Min comparison between 4 variables - template - GLM_FUNC_QUALIFIER detail::tvec4 associatedMin - ( - const detail::tvec4& x, const detail::tvec4& a, - const detail::tvec4& y, const detail::tvec4& b, - const detail::tvec4& z, const detail::tvec4& c, - const detail::tvec4& w, const detail::tvec4& d - ) +// Max comparison between 4 variables +template +GLM_FUNC_QUALIFIER detail::tvec4 associatedMax +( + const detail::tvec4& x, U a, + const detail::tvec4& y, U b, + const detail::tvec4& z, U c, + const detail::tvec4& w, U d +) +{ + detail::tvec4 Result; + for(typename detail::tvec4::size_type i = 0; i < detail::tvec4::value_size(); ++i) { - detail::tvec4 Result; - for(typename detail::tvec4::size_type i = 0; i < detail::tvec4::value_size; ++i) - { - T Test1 = min(x[i], y[i]); - T Test2 = min(z[i], w[i]); - U Result1 = x[i] < y[i] ? a[i] : b[i]; - U Result2 = z[i] < w[i] ? c[i] : d[i]; - Result[i] = Test1 < Test2 ? Result1 : Result2; - } - return Result; + T Test1 = max(x[i], y[i]); + T Test2 = max(z[i], w[i]);; + U Result1 = x[i] > y[i] ? a : b; + U Result2 = z[i] > w[i] ? c : d; + Result[i] = Test1 > Test2 ? Result1 : Result2; } + return Result; +} - // Min comparison between 4 variables - template - GLM_FUNC_QUALIFIER detail::tvec2 associatedMin - ( - T x, const detail::tvec2& a, - T y, const detail::tvec2& b, - T z, const detail::tvec2& c, - T w, const detail::tvec2& d - ) - { - T Test1 = min(x, y); - T Test2 = min(z, w); - - detail::tvec2 Result; - for(typename detail::tvec2::size_type i = 0; i < detail::tvec2::value_size; ++i) - { - U Result1 = x < y ? a[i] : b[i]; - U Result2 = z < w ? c[i] : d[i]; - Result[i] = Test1 < Test2 ? Result1 : Result2; - } - return Result; - } - - // Min comparison between 4 variables - template - GLM_FUNC_QUALIFIER detail::tvec3 associatedMin - ( - T x, const detail::tvec3& a, - T y, const detail::tvec3& b, - T z, const detail::tvec3& c, - T w, const detail::tvec3& d - ) - { - T Test1 = min(x, y); - T Test2 = min(z, w); - - detail::tvec3 Result; - for(typename detail::tvec3::size_type i = 0; i < detail::tvec3::value_size; ++i) - { - U Result1 = x < y ? a[i] : b[i]; - U Result2 = z < w ? c[i] : d[i]; - Result[i] = Test1 < Test2 ? Result1 : Result2; - } - return Result; - } - - // Min comparison between 4 variables - template - GLM_FUNC_QUALIFIER detail::tvec4 associatedMin - ( - T x, const detail::tvec4& a, - T y, const detail::tvec4& b, - T z, const detail::tvec4& c, - T w, const detail::tvec4& d - ) - { - T Test1 = min(x, y); - T Test2 = min(z, w); - - detail::tvec4 Result; - for(typename detail::tvec4::size_type i = 0; i < detail::tvec4::value_size; ++i) - { - U Result1 = x < y ? a[i] : b[i]; - U Result2 = z < w ? c[i] : d[i]; - Result[i] = Test1 < Test2 ? Result1 : Result2; - } - return Result; - } - - // Min comparison between 4 variables - template - GLM_FUNC_QUALIFIER detail::tvec2 associatedMin - ( - const detail::tvec2& x, U a, - const detail::tvec2& y, U b, - const detail::tvec2& z, U c, - const detail::tvec2& w, U d - ) - { - detail::tvec2 Result; - for(typename detail::tvec2::size_type i = 0; i < detail::tvec2::value_size(); ++i) - { - T Test1 = min(x[i], y[i]); - T Test2 = min(z[i], w[i]);; - U Result1 = x[i] < y[i] ? a : b; - U Result2 = z[i] < w[i] ? c : d; - Result[i] = Test1 < Test2 ? Result1 : Result2; - } - return Result; - } - - // Min comparison between 4 variables - template - GLM_FUNC_QUALIFIER detail::tvec3 associatedMin - ( - const detail::tvec3& x, U a, - const detail::tvec3& y, U b, - const detail::tvec3& z, U c, - const detail::tvec3& w, U d - ) - { - detail::tvec3 Result; - for(typename detail::tvec3::size_type i = 0; i < detail::tvec3::value_size(); ++i) - { - T Test1 = min(x[i], y[i]); - T Test2 = min(z[i], w[i]);; - U Result1 = x[i] < y[i] ? a : b; - U Result2 = z[i] < w[i] ? c : d; - Result[i] = Test1 < Test2 ? Result1 : Result2; - } - return Result; - } - - // Min comparison between 4 variables - template - GLM_FUNC_QUALIFIER detail::tvec4 associatedMin - ( - const detail::tvec4& x, U a, - const detail::tvec4& y, U b, - const detail::tvec4& z, U c, - const detail::tvec4& w, U d - ) - { - detail::tvec4 Result; - for(typename detail::tvec4::size_type i = 0; i < detail::tvec4::value_size(); ++i) - { - T Test1 = min(x[i], y[i]); - T Test2 = min(z[i], w[i]);; - U Result1 = x[i] < y[i] ? a : b; - U Result2 = z[i] < w[i] ? c : d; - Result[i] = Test1 < Test2 ? Result1 : Result2; - } - return Result; - } - - // Max comparison between 2 variables - template - GLM_FUNC_QUALIFIER U associatedMax(T x, U a, T y, U b) - { - return x > y ? a : b; - } - - // Max comparison between 2 variables - template - GLM_FUNC_QUALIFIER detail::tvec2 associatedMax - ( - const detail::tvec2& x, const detail::tvec2& a, - const detail::tvec2& y, const detail::tvec2& b - ) - { - detail::tvec2 Result; - for(typename detail::tvec2::size_type i = 0; i < detail::tvec2::value_size; ++i) - Result[i] = x[i] > y[i] ? a[i] : b[i]; - return Result; - } - - // Max comparison between 2 variables - template - GLM_FUNC_QUALIFIER detail::tvec3 associatedMax - ( - const detail::tvec3& x, const detail::tvec3& a, - const detail::tvec3& y, const detail::tvec3& b - ) - { - detail::tvec3 Result; - for(typename detail::tvec3::size_type i = 0; i < detail::tvec3::value_size; ++i) - Result[i] = x[i] > y[i] ? a[i] : b[i]; - return Result; - } - - // Max comparison between 2 variables - template - GLM_FUNC_QUALIFIER detail::tvec4 associatedMax - ( - const detail::tvec4& x, const detail::tvec4& a, - const detail::tvec4& y, const detail::tvec4& b - ) - { - detail::tvec4 Result; - for(typename detail::tvec4::size_type i = 0; i < detail::tvec4::value_size; ++i) - Result[i] = x[i] > y[i] ? a[i] : b[i]; - return Result; - } - - // Max comparison between 2 variables - template - GLM_FUNC_QUALIFIER detail::tvec2 associatedMax - ( - T x, const detail::tvec2& a, - T y, const detail::tvec2& b - ) - { - detail::tvec2 Result; - for(typename detail::tvec2::size_type i = 0; i < detail::tvec2::value_size; ++i) - Result[i] = x > y ? a[i] : b[i]; - return Result; - } - - // Max comparison between 2 variables - template - GLM_FUNC_QUALIFIER detail::tvec3 associatedMax - ( - T x, const detail::tvec3& a, - T y, const detail::tvec3& b - ) - { - detail::tvec3 Result; - for(typename detail::tvec3::size_type i = 0; i < detail::tvec3::value_size; ++i) - Result[i] = x > y ? a[i] : b[i]; - return Result; - } - - // Max comparison between 2 variables - template - GLM_FUNC_QUALIFIER detail::tvec4 associatedMax - ( - T x, const detail::tvec4& a, - T y, const detail::tvec4& b - ) - { - detail::tvec4 Result; - for(typename detail::tvec4::size_type i = 0; i < detail::tvec4::value_size; ++i) - Result[i] = x > y ? a[i] : b[i]; - return Result; - } - - // Max comparison between 2 variables - template - GLM_FUNC_QUALIFIER detail::tvec2 associatedMax - ( - const detail::tvec2& x, U a, - const detail::tvec2& y, U b - ) - { - detail::tvec2 Result; - for(typename detail::tvec2::size_type i = 0; i < detail::tvec2::value_size(); ++i) - Result[i] = x[i] > y[i] ? a : b; - return Result; - } - - // Max comparison between 2 variables - template - GLM_FUNC_QUALIFIER detail::tvec3 associatedMax - ( - const detail::tvec3& x, U a, - const detail::tvec3& y, U b - ) - { - detail::tvec3 Result; - for(typename detail::tvec3::size_type i = 0; i < detail::tvec3::value_size(); ++i) - Result[i] = x[i] > y[i] ? a : b; - return Result; - } - - // Max comparison between 2 variables - template - GLM_FUNC_QUALIFIER detail::tvec4 associatedMax - ( - const detail::tvec4& x, U a, - const detail::tvec4& y, U b - ) - { - detail::tvec4 Result; - for(typename detail::tvec4::size_type i = 0; i < detail::tvec4::value_size(); ++i) - Result[i] = x[i] > y[i] ? a : b; - return Result; - } - - // Max comparison between 3 variables - template - GLM_FUNC_QUALIFIER U associatedMax - ( - T x, U a, - T y, U b, - T z, U c - ) - { - U Result = x > y ? (x > z ? a : c) : (y > z ? b : c); - return Result; - } - - // Max comparison between 3 variables - template - GLM_FUNC_QUALIFIER detail::tvec2 associatedMax - ( - const detail::tvec2& x, const detail::tvec2& a, - const detail::tvec2& y, const detail::tvec2& b, - const detail::tvec2& z, const detail::tvec2& c - ) - { - detail::tvec2 Result; - for(typename detail::tvec2::size_type i = 0; i < detail::tvec2::value_size; ++i) - Result[i] = x[i] > y[i] ? (x[i] > z[i] ? a[i] : c[i]) : (y[i] > z[i] ? b[i] : c[i]); - return Result; - } - - // Max comparison between 3 variables - template - GLM_FUNC_QUALIFIER detail::tvec3 associatedMax - ( - const detail::tvec3& x, const detail::tvec3& a, - const detail::tvec3& y, const detail::tvec3& b, - const detail::tvec3& z, const detail::tvec3& c - ) - { - detail::tvec3 Result; - for(typename detail::tvec3::size_type i = 0; i < detail::tvec3::value_size; ++i) - Result[i] = x[i] > y[i] ? (x[i] > z[i] ? a[i] : c[i]) : (y[i] > z[i] ? b[i] : c[i]); - return Result; - } - - // Max comparison between 3 variables - template - GLM_FUNC_QUALIFIER detail::tvec4 associatedMax - ( - const detail::tvec4& x, const detail::tvec4& a, - const detail::tvec4& y, const detail::tvec4& b, - const detail::tvec4& z, const detail::tvec4& c - ) - { - detail::tvec4 Result; - for(typename detail::tvec4::size_type i = 0; i < detail::tvec4::value_size; ++i) - Result[i] = x[i] > y[i] ? (x[i] > z[i] ? a[i] : c[i]) : (y[i] > z[i] ? b[i] : c[i]); - return Result; - } - - // Max comparison between 3 variables - template - GLM_FUNC_QUALIFIER detail::tvec2 associatedMax - ( - T x, const detail::tvec2& a, - T y, const detail::tvec2& b, - T z, const detail::tvec2& c - ) - { - detail::tvec2 Result; - for(typename detail::tvec2::size_type i = 0; i < detail::tvec2::value_size; ++i) - Result[i] = x > y ? (x > z ? a[i] : c[i]) : (y > z ? b[i] : c[i]); - return Result; - } - - // Max comparison between 3 variables - template - GLM_FUNC_QUALIFIER detail::tvec3 associatedMax - ( - T x, const detail::tvec3& a, - T y, const detail::tvec3& b, - T z, const detail::tvec3& c - ) - { - detail::tvec3 Result; - for(typename detail::tvec3::size_type i = 0; i < detail::tvec3::value_size; ++i) - Result[i] = x > y ? (x > z ? a[i] : c[i]) : (y > z ? b[i] : c[i]); - return Result; - } - - // Max comparison between 3 variables - template - GLM_FUNC_QUALIFIER detail::tvec4 associatedMax - ( - T x, const detail::tvec4& a, - T y, const detail::tvec4& b, - T z, const detail::tvec4& c - ) - { - detail::tvec4 Result; - for(typename detail::tvec4::size_type i = 0; i < detail::tvec4::value_size; ++i) - Result[i] = x > y ? (x > z ? a[i] : c[i]) : (y > z ? b[i] : c[i]); - return Result; - } - - // Max comparison between 3 variables - template - GLM_FUNC_QUALIFIER detail::tvec2 associatedMax - ( - const detail::tvec2& x, U a, - const detail::tvec2& y, U b, - const detail::tvec2& z, U c - ) - { - detail::tvec2 Result; - for(typename detail::tvec2::size_type i = 0; i < detail::tvec2::value_size(); ++i) - Result[i] = x[i] > y[i] ? (x[i] > z[i] ? a : c) : (y[i] > z[i] ? b : c); - return Result; - } - - // Max comparison between 3 variables - template - GLM_FUNC_QUALIFIER detail::tvec3 associatedMax - ( - const detail::tvec3& x, U a, - const detail::tvec3& y, U b, - const detail::tvec3& z, U c - ) - { - detail::tvec3 Result; - for(typename detail::tvec3::size_type i = 0; i < detail::tvec3::value_size(); ++i) - Result[i] = x[i] > y[i] ? (x[i] > z[i] ? a : c) : (y[i] > z[i] ? b : c); - return Result; - } - - // Max comparison between 3 variables - template - GLM_FUNC_QUALIFIER detail::tvec4 associatedMax - ( - const detail::tvec4& x, U a, - const detail::tvec4& y, U b, - const detail::tvec4& z, U c - ) - { - detail::tvec4 Result; - for(typename detail::tvec4::size_type i = 0; i < detail::tvec4::value_size(); ++i) - Result[i] = x[i] > y[i] ? (x[i] > z[i] ? a : c) : (y[i] > z[i] ? b : c); - return Result; - } - - // Max comparison between 4 variables - template - GLM_FUNC_QUALIFIER U associatedMax - ( - T x, U a, - T y, U b, - T z, U c, - T w, U d - ) - { - T Test1 = max(x, y); - T Test2 = max(z, w);; - U Result1 = x > y ? a : b; - U Result2 = z > w ? c : d; - U Result = Test1 > Test2 ? Result1 : Result2; - return Result; - } - - // Max comparison between 4 variables - template - GLM_FUNC_QUALIFIER detail::tvec2 associatedMax - ( - const detail::tvec2& x, const detail::tvec2& a, - const detail::tvec2& y, const detail::tvec2& b, - const detail::tvec2& z, const detail::tvec2& c, - const detail::tvec2& w, const detail::tvec2& d - ) - { - detail::tvec2 Result; - for(typename detail::tvec2::size_type i = 0; i < detail::tvec2::value_size; ++i) - { - T Test1 = max(x[i], y[i]); - T Test2 = max(z[i], w[i]); - U Result1 = x[i] > y[i] ? a[i] : b[i]; - U Result2 = z[i] > w[i] ? c[i] : d[i]; - Result[i] = Test1 > Test2 ? Result1 : Result2; - } - return Result; - } - - // Max comparison between 4 variables - template - GLM_FUNC_QUALIFIER detail::tvec3 associatedMax - ( - const detail::tvec3& x, const detail::tvec3& a, - const detail::tvec3& y, const detail::tvec3& b, - const detail::tvec3& z, const detail::tvec3& c, - const detail::tvec3& w, const detail::tvec3& d - ) - { - detail::tvec3 Result; - for(typename detail::tvec3::size_type i = 0; i < detail::tvec3::value_size; ++i) - { - T Test1 = max(x[i], y[i]); - T Test2 = max(z[i], w[i]); - U Result1 = x[i] > y[i] ? a[i] : b[i]; - U Result2 = z[i] > w[i] ? c[i] : d[i]; - Result[i] = Test1 > Test2 ? Result1 : Result2; - } - return Result; - } - - // Max comparison between 4 variables - template - GLM_FUNC_QUALIFIER detail::tvec4 associatedMax - ( - const detail::tvec4& x, const detail::tvec4& a, - const detail::tvec4& y, const detail::tvec4& b, - const detail::tvec4& z, const detail::tvec4& c, - const detail::tvec4& w, const detail::tvec4& d - ) - { - detail::tvec4 Result; - for(typename detail::tvec4::size_type i = 0; i < detail::tvec4::value_size; ++i) - { - T Test1 = max(x[i], y[i]); - T Test2 = max(z[i], w[i]); - U Result1 = x[i] > y[i] ? a[i] : b[i]; - U Result2 = z[i] > w[i] ? c[i] : d[i]; - Result[i] = Test1 > Test2 ? Result1 : Result2; - } - return Result; - } - - // Max comparison between 4 variables - template - GLM_FUNC_QUALIFIER detail::tvec2 associatedMax - ( - T x, const detail::tvec2& a, - T y, const detail::tvec2& b, - T z, const detail::tvec2& c, - T w, const detail::tvec2& d - ) - { - T Test1 = max(x, y); - T Test2 = max(z, w); - - detail::tvec2 Result; - for(typename detail::tvec2::size_type i = 0; i < detail::tvec2::value_size; ++i) - { - U Result1 = x > y ? a[i] : b[i]; - U Result2 = z > w ? c[i] : d[i]; - Result[i] = Test1 > Test2 ? Result1 : Result2; - } - return Result; - } - - // Max comparison between 4 variables - template - GLM_FUNC_QUALIFIER detail::tvec3 associatedMax - ( - T x, const detail::tvec3& a, - T y, const detail::tvec3& b, - T z, const detail::tvec3& c, - T w, const detail::tvec3& d - ) - { - T Test1 = max(x, y); - T Test2 = max(z, w); - - detail::tvec3 Result; - for(typename detail::tvec3::size_type i = 0; i < detail::tvec3::value_size; ++i) - { - U Result1 = x > y ? a[i] : b[i]; - U Result2 = z > w ? c[i] : d[i]; - Result[i] = Test1 > Test2 ? Result1 : Result2; - } - return Result; - } - - // Max comparison between 4 variables - template - GLM_FUNC_QUALIFIER detail::tvec4 associatedMax - ( - T x, const detail::tvec4& a, - T y, const detail::tvec4& b, - T z, const detail::tvec4& c, - T w, const detail::tvec4& d - ) - { - T Test1 = max(x, y); - T Test2 = max(z, w); - - detail::tvec4 Result; - for(typename detail::tvec4::size_type i = 0; i < detail::tvec4::value_size; ++i) - { - U Result1 = x > y ? a[i] : b[i]; - U Result2 = z > w ? c[i] : d[i]; - Result[i] = Test1 > Test2 ? Result1 : Result2; - } - return Result; - } - - // Max comparison between 4 variables - template - GLM_FUNC_QUALIFIER detail::tvec2 associatedMax - ( - const detail::tvec2& x, U a, - const detail::tvec2& y, U b, - const detail::tvec2& z, U c, - const detail::tvec2& w, U d - ) - { - detail::tvec2 Result; - for(typename detail::tvec2::size_type i = 0; i < detail::tvec2::value_size(); ++i) - { - T Test1 = max(x[i], y[i]); - T Test2 = max(z[i], w[i]);; - U Result1 = x[i] > y[i] ? a : b; - U Result2 = z[i] > w[i] ? c : d; - Result[i] = Test1 > Test2 ? Result1 : Result2; - } - return Result; - } - - // Max comparison between 4 variables - template - GLM_FUNC_QUALIFIER detail::tvec3 associatedMax - ( - const detail::tvec3& x, U a, - const detail::tvec3& y, U b, - const detail::tvec3& z, U c, - const detail::tvec3& w, U d - ) - { - detail::tvec3 Result; - for(typename detail::tvec3::size_type i = 0; i < detail::tvec3::value_size(); ++i) - { - T Test1 = max(x[i], y[i]); - T Test2 = max(z[i], w[i]);; - U Result1 = x[i] > y[i] ? a : b; - U Result2 = z[i] > w[i] ? c : d; - Result[i] = Test1 > Test2 ? Result1 : Result2; - } - return Result; - } - - // Max comparison between 4 variables - template - GLM_FUNC_QUALIFIER detail::tvec4 associatedMax - ( - const detail::tvec4& x, U a, - const detail::tvec4& y, U b, - const detail::tvec4& z, U c, - const detail::tvec4& w, U d - ) - { - detail::tvec4 Result; - for(typename detail::tvec4::size_type i = 0; i < detail::tvec4::value_size(); ++i) - { - T Test1 = max(x[i], y[i]); - T Test2 = max(z[i], w[i]);; - U Result1 = x[i] > y[i] ? a : b; - U Result2 = z[i] > w[i] ? c : d; - Result[i] = Test1 > Test2 ? Result1 : Result2; - } - return Result; - } - -}//namespace gtx }//namespace glm diff --git a/glm/gtx/bit.hpp b/glm/gtx/bit.hpp index 0887a4aa..6f161bcb 100644 --- a/glm/gtx/bit.hpp +++ b/glm/gtx/bit.hpp @@ -47,8 +47,7 @@ # pragma message("GLM: GLM_GTX_bit extension included") #endif -namespace glm{ -namespace gtx +namespace glm { /// @addtogroup gtx_bit /// @{ @@ -134,7 +133,6 @@ namespace gtx int const & ToBit); /// @} -}// namespace gtx }// namespace glm #include "bit.inl" diff --git a/glm/gtx/bit.inl b/glm/gtx/bit.inl index fa8b0cc7..c136d501 100644 --- a/glm/gtx/bit.inl +++ b/glm/gtx/bit.inl @@ -10,7 +10,6 @@ #include "../core/_detail.hpp" namespace glm{ -namespace gtx{ template GLM_FUNC_QUALIFIER genIType mask @@ -61,13 +60,13 @@ GLM_FUNC_QUALIFIER detail::tvec4 mask template GLM_FUNC_QUALIFIER genIType extractField ( - gtc::half const & value, + half const & value, genIType const & first, genIType const & count ) { - assert(first + count < sizeof(gtc::half)); - return (value._data() << first) >> ((sizeof(gtc::half) << 3) - count); + assert(first + count < sizeof(half)); + return (value._data() << first) >> ((sizeof(half) << 3) - count); } template @@ -771,5 +770,4 @@ GLM_FUNC_QUALIFIER genIUType fillBitfieldWithZero return Result; } -}//namespace gtx }//namespace glm diff --git a/glm/gtx/closest_point.hpp b/glm/gtx/closest_point.hpp index fbacd5c3..fc92d8c5 100644 --- a/glm/gtx/closest_point.hpp +++ b/glm/gtx/closest_point.hpp @@ -45,8 +45,7 @@ # pragma message("GLM: GLM_GTX_closest_point extension included") #endif -namespace glm{ -namespace gtx +namespace glm { /// @addtogroup gtx_closest_point /// @{ @@ -60,7 +59,6 @@ namespace gtx detail::tvec3 const & b); /// @} -}// namespace gtx }// namespace glm #include "closest_point.inl" diff --git a/glm/gtx/closest_point.inl b/glm/gtx/closest_point.inl index 783281f0..5d19d7cc 100644 --- a/glm/gtx/closest_point.inl +++ b/glm/gtx/closest_point.inl @@ -11,7 +11,6 @@ #define glm_gtx_closest_point namespace glm{ -namespace gtx{ template GLM_FUNC_QUALIFIER detail::tvec3 closestPointOnLine @@ -33,7 +32,6 @@ GLM_FUNC_QUALIFIER detail::tvec3 closestPointOnLine return a + LineDirection * Distance; } -}//namespace gtx }//namespace glm #endif//glm_gtx_closest_point diff --git a/glm/gtx/color_cast.hpp b/glm/gtx/color_cast.hpp index af8897e8..782000d5 100644 --- a/glm/gtx/color_cast.hpp +++ b/glm/gtx/color_cast.hpp @@ -47,78 +47,76 @@ # pragma message("GLM: GLM_GTX_color_cast extension included") #endif -namespace glm{ -namespace gtx +namespace glm { /// @addtogroup gtx_color_cast /// @{ //! Conversion of a floating value into a 8bit unsigned int value. //! From GLM_GTX_color_cast extension. - template gtc::uint8 u8channel_cast(valType a); + template uint8 u8channel_cast(valType a); //! Conversion of a floating value into a 16bit unsigned int value. //! From GLM_GTX_color_cast extension. - template gtc::uint16 u16channel_cast(valType a); + template uint16 u16channel_cast(valType a); - template gtc::uint32 u32_rgbx_cast(const detail::tvec3& c); //!< \brief Conversion of a 3 components color into an 32bit unsigned int value. (From GLM_GTX_color_cast extension) - template gtc::uint32 u32_xrgb_cast(const detail::tvec3& c); //!< \brief Conversion of a 3 components color into an 32bit unsigned int value. (From GLM_GTX_color_cast extension) - template gtc::uint32 u32_bgrx_cast(const detail::tvec3& c); //!< \brief Conversion of a 3 components color into an 32bit unsigned int value. (From GLM_GTX_color_cast extension) - template gtc::uint32 u32_xbgr_cast(const detail::tvec3& c); //!< \brief Conversion of a 3 components color into an 32bit unsigned int value. (From GLM_GTX_color_cast extension) + template uint32 u32_rgbx_cast(const detail::tvec3& c); //!< \brief Conversion of a 3 components color into an 32bit unsigned int value. (From GLM_GTX_color_cast extension) + template uint32 u32_xrgb_cast(const detail::tvec3& c); //!< \brief Conversion of a 3 components color into an 32bit unsigned int value. (From GLM_GTX_color_cast extension) + template uint32 u32_bgrx_cast(const detail::tvec3& c); //!< \brief Conversion of a 3 components color into an 32bit unsigned int value. (From GLM_GTX_color_cast extension) + template uint32 u32_xbgr_cast(const detail::tvec3& c); //!< \brief Conversion of a 3 components color into an 32bit unsigned int value. (From GLM_GTX_color_cast extension) - template gtc::uint32 u32_rgba_cast(const detail::tvec4& c); //!< \brief Conversion of a 4 components color into an 32bit unsigned int value. (From GLM_GTX_color_cast extension) - template gtc::uint32 u32_argb_cast(const detail::tvec4& c); //!< \brief Conversion of a 4 components color into an 32bit unsigned int value. (From GLM_GTX_color_cast extension) - template gtc::uint32 u32_bgra_cast(const detail::tvec4& c); //!< \brief Conversion of a 4 components color into an 32bit unsigned int value. (From GLM_GTX_color_cast extension) - template gtc::uint32 u32_abgr_cast(const detail::tvec4& c); //!< \brief Conversion of a 4 components color into an 32bit unsigned int value. (From GLM_GTX_color_cast extension) + template uint32 u32_rgba_cast(const detail::tvec4& c); //!< \brief Conversion of a 4 components color into an 32bit unsigned int value. (From GLM_GTX_color_cast extension) + template uint32 u32_argb_cast(const detail::tvec4& c); //!< \brief Conversion of a 4 components color into an 32bit unsigned int value. (From GLM_GTX_color_cast extension) + template uint32 u32_bgra_cast(const detail::tvec4& c); //!< \brief Conversion of a 4 components color into an 32bit unsigned int value. (From GLM_GTX_color_cast extension) + template uint32 u32_abgr_cast(const detail::tvec4& c); //!< \brief Conversion of a 4 components color into an 32bit unsigned int value. (From GLM_GTX_color_cast extension) - template gtc::uint64 u64_rgbx_cast(const detail::tvec3& c); //!< \brief Conversion of a 3 components color into an 64bit unsigned int value. (From GLM_GTX_color_cast extension) - template gtc::uint64 u64_xrgb_cast(const detail::tvec3& c); //!< \brief Conversion of a 3 components color into an 64bit unsigned int value. (From GLM_GTX_color_cast extension) - template gtc::uint64 u64_bgrx_cast(const detail::tvec3& c); //!< \brief Conversion of a 3 components color into an 64bit unsigned int value. (From GLM_GTX_color_cast extension) - template gtc::uint64 u64_xbgr_cast(const detail::tvec3& c); //!< \brief Conversion of a 3 components color into an 64bit unsigned int value. (From GLM_GTX_color_cast extension) + template uint64 u64_rgbx_cast(const detail::tvec3& c); //!< \brief Conversion of a 3 components color into an 64bit unsigned int value. (From GLM_GTX_color_cast extension) + template uint64 u64_xrgb_cast(const detail::tvec3& c); //!< \brief Conversion of a 3 components color into an 64bit unsigned int value. (From GLM_GTX_color_cast extension) + template uint64 u64_bgrx_cast(const detail::tvec3& c); //!< \brief Conversion of a 3 components color into an 64bit unsigned int value. (From GLM_GTX_color_cast extension) + template uint64 u64_xbgr_cast(const detail::tvec3& c); //!< \brief Conversion of a 3 components color into an 64bit unsigned int value. (From GLM_GTX_color_cast extension) - template gtc::uint64 u64_rgba_cast(const detail::tvec4& c); //!< \brief Conversion of a 4 components color into an 64bit unsigned int value. (From GLM_GTX_color_cast extension) - template gtc::uint64 u64_argb_cast(const detail::tvec4& c); //!< \brief Conversion of a 4 components color into an 64bit unsigned int value. (From GLM_GTX_color_cast extension) - template gtc::uint64 u64_bgra_cast(const detail::tvec4& c); //!< \brief Conversion of a 4 components color into an 64bit unsigned int value. (From GLM_GTX_color_cast extension) - template gtc::uint64 u64_abgr_cast(const detail::tvec4& c); //!< \brief Conversion of a 4 components color into an 64bit unsigned int value. (From GLM_GTX_color_cast extension) + template uint64 u64_rgba_cast(const detail::tvec4& c); //!< \brief Conversion of a 4 components color into an 64bit unsigned int value. (From GLM_GTX_color_cast extension) + template uint64 u64_argb_cast(const detail::tvec4& c); //!< \brief Conversion of a 4 components color into an 64bit unsigned int value. (From GLM_GTX_color_cast extension) + template uint64 u64_bgra_cast(const detail::tvec4& c); //!< \brief Conversion of a 4 components color into an 64bit unsigned int value. (From GLM_GTX_color_cast extension) + template uint64 u64_abgr_cast(const detail::tvec4& c); //!< \brief Conversion of a 4 components color into an 64bit unsigned int value. (From GLM_GTX_color_cast extension) - template 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 #include "color_cast.inl" diff --git a/glm/gtx/color_cast.inl b/glm/gtx/color_cast.inl index cda753d5..bad1f926 100644 --- a/glm/gtx/color_cast.inl +++ b/glm/gtx/color_cast.inl @@ -8,213 +8,212 @@ /////////////////////////////////////////////////////////////////////////////////////////////////// namespace glm{ -namespace gtx{ template -GLM_FUNC_QUALIFIER gtc::uint8 u8channel_cast(T a) +GLM_FUNC_QUALIFIER uint8 u8channel_cast(T a) { - return static_cast(a * T(255)); + return static_cast(a * T(255)); } template -GLM_FUNC_QUALIFIER gtc::uint16 u16channel_cast(T a) +GLM_FUNC_QUALIFIER uint16 u16channel_cast(T a) { - return static_cast(a * T(65535)); + return static_cast(a * T(65535)); } template -GLM_FUNC_QUALIFIER gtc::uint32 u32_rgbx_cast(const detail::tvec3& c) +GLM_FUNC_QUALIFIER uint32 u32_rgbx_cast(const detail::tvec3& c) { - gtc::uint32 result = 0; - result += static_cast(c.x * detail::tvec3::value_type(255)) << 0; - result += static_cast(c.y * detail::tvec3::value_type(255)) << 8; - result += static_cast(c.z * detail::tvec3::value_type(255)) << 16; + uint32 result = 0; + result += static_cast(c.x * detail::tvec3::value_type(255)) << 0; + result += static_cast(c.y * detail::tvec3::value_type(255)) << 8; + result += static_cast(c.z * detail::tvec3::value_type(255)) << 16; return result; } template -GLM_FUNC_QUALIFIER gtc::uint32 u32_xrgb_cast(const detail::tvec3& c) +GLM_FUNC_QUALIFIER uint32 u32_xrgb_cast(const detail::tvec3& c) { - gtc::uint32 result = 0; - result += static_cast(c.x * detail::tvec3::value_type(255)) << 8; - result += static_cast(c.y * detail::tvec3::value_type(255)) << 16; - result += static_cast(c.z * detail::tvec3::value_type(255)) << 24; + uint32 result = 0; + result += static_cast(c.x * detail::tvec3::value_type(255)) << 8; + result += static_cast(c.y * detail::tvec3::value_type(255)) << 16; + result += static_cast(c.z * detail::tvec3::value_type(255)) << 24; return result; } template -GLM_FUNC_QUALIFIER gtc::uint32 u32_bgrx_cast(const detail::tvec3& c) +GLM_FUNC_QUALIFIER uint32 u32_bgrx_cast(const detail::tvec3& c) { - gtc::uint32 result = 0; - result += static_cast(c.x * detail::tvec3::value_type(255)) << 16; - result += static_cast(c.y * detail::tvec3::value_type(255)) << 8; - result += static_cast(c.z * detail::tvec3::value_type(255)) << 0; + uint32 result = 0; + result += static_cast(c.x * detail::tvec3::value_type(255)) << 16; + result += static_cast(c.y * detail::tvec3::value_type(255)) << 8; + result += static_cast(c.z * detail::tvec3::value_type(255)) << 0; return result; } template -GLM_FUNC_QUALIFIER gtc::uint32 u32_xbgr_cast(const detail::tvec3& c) +GLM_FUNC_QUALIFIER uint32 u32_xbgr_cast(const detail::tvec3& c) { - gtc::uint32 result = 0; - result += static_cast(c.x * detail::tvec3::value_type(255)) << 24; - result += static_cast(c.y * detail::tvec3::value_type(255)) << 16; - result += static_cast(c.z * detail::tvec3::value_type(255)) << 8; - result += static_cast(c.w * detail::tvec3::value_type(255)) << 0; + uint32 result = 0; + result += static_cast(c.x * detail::tvec3::value_type(255)) << 24; + result += static_cast(c.y * detail::tvec3::value_type(255)) << 16; + result += static_cast(c.z * detail::tvec3::value_type(255)) << 8; + result += static_cast(c.w * detail::tvec3::value_type(255)) << 0; return result; } template -GLM_FUNC_QUALIFIER gtc::uint32 u32_rgba_cast(const detail::tvec4& c) +GLM_FUNC_QUALIFIER uint32 u32_rgba_cast(const detail::tvec4& c) { - gtc::uint32 result = 0; - result += static_cast(c.x * detail::tvec4::value_type(255)) << 0; - result += static_cast(c.y * detail::tvec4::value_type(255)) << 8; - result += static_cast(c.z * detail::tvec4::value_type(255)) << 16; - result += static_cast(c.w * detail::tvec4::value_type(255)) << 24; + uint32 result = 0; + result += static_cast(c.x * detail::tvec4::value_type(255)) << 0; + result += static_cast(c.y * detail::tvec4::value_type(255)) << 8; + result += static_cast(c.z * detail::tvec4::value_type(255)) << 16; + result += static_cast(c.w * detail::tvec4::value_type(255)) << 24; return result; } template -GLM_FUNC_QUALIFIER gtc::uint32 u32_argb_cast(const detail::tvec4& c) +GLM_FUNC_QUALIFIER uint32 u32_argb_cast(const detail::tvec4& c) { - gtc::uint32 result = 0; - result += static_cast(c.x * detail::tvec4::value_type(255)) << 8; - result += static_cast(c.y * detail::tvec4::value_type(255)) << 16; - result += static_cast(c.z * detail::tvec4::value_type(255)) << 24; - result += static_cast(c.w * detail::tvec4::value_type(255)) << 0; + uint32 result = 0; + result += static_cast(c.x * detail::tvec4::value_type(255)) << 8; + result += static_cast(c.y * detail::tvec4::value_type(255)) << 16; + result += static_cast(c.z * detail::tvec4::value_type(255)) << 24; + result += static_cast(c.w * detail::tvec4::value_type(255)) << 0; return result; } template -GLM_FUNC_QUALIFIER gtc::uint32 u32_bgra_cast(const detail::tvec4& c) +GLM_FUNC_QUALIFIER uint32 u32_bgra_cast(const detail::tvec4& c) { - gtc::uint32 result = 0; - result += static_cast(c.x * detail::tvec4::value_type(255)) << 16; - result += static_cast(c.y * detail::tvec4::value_type(255)) << 8; - result += static_cast(c.z * detail::tvec4::value_type(255)) << 0; - result += static_cast(c.w * detail::tvec4::value_type(255)) << 24; + uint32 result = 0; + result += static_cast(c.x * detail::tvec4::value_type(255)) << 16; + result += static_cast(c.y * detail::tvec4::value_type(255)) << 8; + result += static_cast(c.z * detail::tvec4::value_type(255)) << 0; + result += static_cast(c.w * detail::tvec4::value_type(255)) << 24; return result; } template -GLM_FUNC_QUALIFIER gtc::uint32 u32_abgr_cast(const detail::tvec4& c) +GLM_FUNC_QUALIFIER uint32 u32_abgr_cast(const detail::tvec4& c) { - gtc::uint32 result = 0; - result += static_cast(c.x * detail::tvec4::value_type(255)) << 24; - result += static_cast(c.y * detail::tvec4::value_type(255)) << 16; - result += static_cast(c.z * detail::tvec4::value_type(255)) << 8; - result += static_cast(c.w * detail::tvec4::value_type(255)) << 0; + uint32 result = 0; + result += static_cast(c.x * detail::tvec4::value_type(255)) << 24; + result += static_cast(c.y * detail::tvec4::value_type(255)) << 16; + result += static_cast(c.z * detail::tvec4::value_type(255)) << 8; + result += static_cast(c.w * detail::tvec4::value_type(255)) << 0; return result; } template -GLM_FUNC_QUALIFIER gtc::uint64 u64_rgbx_cast(const detail::tvec3& c) +GLM_FUNC_QUALIFIER uint64 u64_rgbx_cast(const detail::tvec3& c) { - gtc::uint64 result = 0; - result += static_cast(c.x * detail::tvec3::value_type(65535)) << 0; - result += static_cast(c.y * detail::tvec3::value_type(65535)) << 16; - result += static_cast(c.z * detail::tvec3::value_type(65535)) << 32; + uint64 result = 0; + result += static_cast(c.x * detail::tvec3::value_type(65535)) << 0; + result += static_cast(c.y * detail::tvec3::value_type(65535)) << 16; + result += static_cast(c.z * detail::tvec3::value_type(65535)) << 32; return result; } template -GLM_FUNC_QUALIFIER gtc::uint64 u32_xrgb_cast(const detail::tvec3& c) +GLM_FUNC_QUALIFIER uint64 u32_xrgb_cast(const detail::tvec3& c) { - gtc::uint64 result = 0; - result += static_cast(c.x * detail::tvec3::value_type(65535)) << 16; - result += static_cast(c.y * detail::tvec3::value_type(65535)) << 32; - result += static_cast(c.z * detail::tvec3::value_type(65535)) << 48; + uint64 result = 0; + result += static_cast(c.x * detail::tvec3::value_type(65535)) << 16; + result += static_cast(c.y * detail::tvec3::value_type(65535)) << 32; + result += static_cast(c.z * detail::tvec3::value_type(65535)) << 48; return result; } template -GLM_FUNC_QUALIFIER gtc::uint64 u32_bgrx_cast(const detail::tvec3& c) +GLM_FUNC_QUALIFIER uint64 u32_bgrx_cast(const detail::tvec3& c) { - gtc::uint64 result = 0; - result += static_cast(c.x * detail::tvec3::value_type(65535)) << 32; - result += static_cast(c.y * detail::tvec3::value_type(65535)) << 16; - result += static_cast(c.z * detail::tvec3::value_type(65535)) << 0; + uint64 result = 0; + result += static_cast(c.x * detail::tvec3::value_type(65535)) << 32; + result += static_cast(c.y * detail::tvec3::value_type(65535)) << 16; + result += static_cast(c.z * detail::tvec3::value_type(65535)) << 0; return result; } template -GLM_FUNC_QUALIFIER gtc::uint64 u32_xbgr_cast(const detail::tvec3& c) +GLM_FUNC_QUALIFIER uint64 u32_xbgr_cast(const detail::tvec3& c) { - gtc::uint64 result = 0; - result += static_cast(c.x * detail::tvec3::value_type(65535)) << 48; - result += static_cast(c.y * detail::tvec3::value_type(65535)) << 32; - result += static_cast(c.z * detail::tvec3::value_type(65535)) << 16; - result += static_cast(c.w * detail::tvec3::value_type(65535)) << 0; + uint64 result = 0; + result += static_cast(c.x * detail::tvec3::value_type(65535)) << 48; + result += static_cast(c.y * detail::tvec3::value_type(65535)) << 32; + result += static_cast(c.z * detail::tvec3::value_type(65535)) << 16; + result += static_cast(c.w * detail::tvec3::value_type(65535)) << 0; return result; } template -GLM_FUNC_QUALIFIER gtc::uint64 u64_rgba_cast(const detail::tvec4& c) +GLM_FUNC_QUALIFIER uint64 u64_rgba_cast(const detail::tvec4& c) { - gtc::uint64 result = 0; - result += static_cast(c.x * detail::tvec4::value_type(65535)) << 0; - result += static_cast(c.y * detail::tvec4::value_type(65535)) << 16; - result += static_cast(c.z * detail::tvec4::value_type(65535)) << 32; - result += static_cast(c.w * detail::tvec4::value_type(65535)) << 48; + uint64 result = 0; + result += static_cast(c.x * detail::tvec4::value_type(65535)) << 0; + result += static_cast(c.y * detail::tvec4::value_type(65535)) << 16; + result += static_cast(c.z * detail::tvec4::value_type(65535)) << 32; + result += static_cast(c.w * detail::tvec4::value_type(65535)) << 48; return result; } template -GLM_FUNC_QUALIFIER gtc::uint64 u64_argb_cast(const detail::tvec4& c) +GLM_FUNC_QUALIFIER uint64 u64_argb_cast(const detail::tvec4& c) { - gtc::uint64 result = 0; - result += static_cast(c.x * detail::tvec4::value_type(65535)) << 16; - result += static_cast(c.y * detail::tvec4::value_type(65535)) << 32; - result += static_cast(c.z * detail::tvec4::value_type(65535)) << 48; - result += static_cast(c.w * detail::tvec4::value_type(65535)) << 0; + uint64 result = 0; + result += static_cast(c.x * detail::tvec4::value_type(65535)) << 16; + result += static_cast(c.y * detail::tvec4::value_type(65535)) << 32; + result += static_cast(c.z * detail::tvec4::value_type(65535)) << 48; + result += static_cast(c.w * detail::tvec4::value_type(65535)) << 0; return result; } template -GLM_FUNC_QUALIFIER gtc::uint64 u64_bgra_cast(const detail::tvec4& c) +GLM_FUNC_QUALIFIER uint64 u64_bgra_cast(const detail::tvec4& c) { - gtc::uint64 result = 0; - result += static_cast(c.x * detail::tvec4::value_type(65535)) << 32; - result += static_cast(c.y * detail::tvec4::value_type(65535)) << 16; - result += static_cast(c.z * detail::tvec4::value_type(65535)) << 0; - result += static_cast(c.w * detail::tvec4::value_type(65535)) << 48; + uint64 result = 0; + result += static_cast(c.x * detail::tvec4::value_type(65535)) << 32; + result += static_cast(c.y * detail::tvec4::value_type(65535)) << 16; + result += static_cast(c.z * detail::tvec4::value_type(65535)) << 0; + result += static_cast(c.w * detail::tvec4::value_type(65535)) << 48; return result; } template -GLM_FUNC_QUALIFIER gtc::uint64 u64_abgr_cast(const detail::tvec4& c) +GLM_FUNC_QUALIFIER uint64 u64_abgr_cast(const detail::tvec4& c) { - gtc::uint64 result = 0; - result += static_cast(c.x * detail::tvec4::value_type(65535)) << 48; - result += static_cast(c.y * detail::tvec4::value_type(65535)) << 32; - result += static_cast(c.z * detail::tvec4::value_type(65535)) << 16; - result += static_cast(c.w * detail::tvec4::value_type(65535)) << 0; + uint64 result = 0; + result += static_cast(c.x * detail::tvec4::value_type(65535)) << 48; + result += static_cast(c.y * detail::tvec4::value_type(65535)) << 32; + result += static_cast(c.z * detail::tvec4::value_type(65535)) << 16; + result += static_cast(c.w * detail::tvec4::value_type(65535)) << 0; return result; } template <> -GLM_FUNC_QUALIFIER f16vec1 f16_channel_cast(gtc::uint32 color) +GLM_FUNC_QUALIFIER f16 f16_channel_cast(uint32 color) { - return gtc::f16(static_cast(color >> 0) / static_cast(255)); + return f16(static_cast(color >> 0) / static_cast(255)); } template <> -GLM_FUNC_QUALIFIER gtc::f16vec3 f16_rgbx_cast(gtc::uint32 color) +GLM_FUNC_QUALIFIER f16vec3 f16_rgbx_cast(uint32 color) { - gtc::f16vec3 result; - result.x = gtc::f16(static_cast(color >> 0) / static_cast(255)); - result.y = gtc::f16(static_cast(color >> 8) / static_cast(255)); - result.z = gtc::f16(static_cast(color >> 16) / static_cast(255)); + f16vec3 result; + result.x = f16(static_cast(color >> 0) / static_cast(255)); + result.y = f16(static_cast(color >> 8) / static_cast(255)); + result.z = f16(static_cast(color >> 16) / static_cast(255)); return result; } template <> -GLM_FUNC_QUALIFIER gtc::f16vec3 f16_xrgb_cast(gtc::uint32 color) +GLM_FUNC_QUALIFIER f16vec3 f16_xrgb_cast(uint32 color) { - gtc::f16vec3 result; - result.x = gtc::f16(static_cast(color >> 8) / static_cast(255)); - result.y = gtc::f16(static_cast(color >> 16) / static_cast(255)); - result.z = gtc::f16(static_cast(color >> 24) / static_cast(255)); + f16vec3 result; + result.x = f16(static_cast(color >> 8) / static_cast(255)); + result.y = f16(static_cast(color >> 16) / static_cast(255)); + result.z = f16(static_cast(color >> 24) / static_cast(255)); return result; } @@ -732,5 +731,4 @@ GLM_FUNC_QUALIFIER detail::tvec4 f64_abgr_cast(uint64 color) return result; } -}//namespace gtx }//namespace glm diff --git a/glm/gtx/color_space.hpp b/glm/gtx/color_space.hpp index 6c8f05c5..ad904e02 100644 --- a/glm/gtx/color_space.hpp +++ b/glm/gtx/color_space.hpp @@ -45,8 +45,7 @@ # pragma message("GLM: GLM_GTX_color_space extension included") #endif -namespace glm{ -namespace gtx +namespace glm { /// @addtogroup gtx_color_space /// @{ @@ -90,7 +89,6 @@ namespace gtx detail::tvec3 const & color); /// @} -}//namespace gtx }//namespace glm #include "color_space.inl" diff --git a/glm/gtx/color_space.inl b/glm/gtx/color_space.inl index 8b7ac198..4a270d8b 100644 --- a/glm/gtx/color_space.inl +++ b/glm/gtx/color_space.inl @@ -8,145 +8,143 @@ /////////////////////////////////////////////////////////////////////////////////////////////////// namespace glm{ -namespace gtx + +template +GLM_FUNC_QUALIFIER detail::tvec3 rgbColor(const detail::tvec3& hsvColor) { - template - GLM_FUNC_QUALIFIER detail::tvec3 rgbColor(const detail::tvec3& hsvColor) - { - detail::tvec3 hsv = hsvColor; - detail::tvec3 rgbColor; + detail::tvec3 hsv = hsvColor; + detail::tvec3 rgbColor; - if(hsv.y == T(0)) - // achromatic (grey) - rgbColor = detail::tvec3(hsv.z); - else - { - T sector = floor(hsv.x / T(60)); - T frac = (hsv.x / T(60)) - sector; - // factorial part of h - T o = hsv.z * (T(1) - hsv.y); - T p = hsv.z * (T(1) - hsv.y * frac); - T q = hsv.z * (T(1) - hsv.y * (T(1) - frac)); + if(hsv.y == T(0)) + // achromatic (grey) + rgbColor = detail::tvec3(hsv.z); + else + { + T sector = floor(hsv.x / T(60)); + T frac = (hsv.x / T(60)) - sector; + // factorial part of h + T o = hsv.z * (T(1) - hsv.y); + T p = hsv.z * (T(1) - hsv.y * frac); + T q = hsv.z * (T(1) - hsv.y * (T(1) - frac)); - switch(int(sector)) - { - default: - case 0: - rgbColor.r = hsv.z; - rgbColor.g = q; - rgbColor.b = o; - break; - case 1: - rgbColor.r = p; - rgbColor.g = hsv.z; - rgbColor.b = o; - break; - case 2: - rgbColor.r = o; - rgbColor.g = hsv.z; - rgbColor.b = q; - break; - case 3: - rgbColor.r = o; - rgbColor.g = p; - rgbColor.b = hsv.z; - break; - case 4: - rgbColor.r = q; - rgbColor.g = o; - rgbColor.b = hsv.z; - break; - case 5: - rgbColor.r = hsv.z; - rgbColor.g = o; - rgbColor.b = p; - break; - } - } + switch(int(sector)) + { + default: + case 0: + rgbColor.r = hsv.z; + rgbColor.g = q; + rgbColor.b = o; + break; + case 1: + rgbColor.r = p; + rgbColor.g = hsv.z; + rgbColor.b = o; + break; + case 2: + rgbColor.r = o; + rgbColor.g = hsv.z; + rgbColor.b = q; + break; + case 3: + rgbColor.r = o; + rgbColor.g = p; + rgbColor.b = hsv.z; + break; + case 4: + rgbColor.r = q; + rgbColor.g = o; + rgbColor.b = hsv.z; + break; + case 5: + rgbColor.r = hsv.z; + rgbColor.g = o; + rgbColor.b = p; + break; + } + } - return rgbColor; - } + return rgbColor; +} - template - GLM_FUNC_QUALIFIER detail::tvec3 hsvColor(const detail::tvec3& rgbColor) - { - detail::tvec3 hsv = rgbColor; - float Min = min(min(rgbColor.r, rgbColor.g), rgbColor.b); - float Max = max(max(rgbColor.r, rgbColor.g), rgbColor.b); - float Delta = Max - Min; +template +GLM_FUNC_QUALIFIER detail::tvec3 hsvColor(const detail::tvec3& rgbColor) +{ + detail::tvec3 hsv = rgbColor; + float Min = min(min(rgbColor.r, rgbColor.g), rgbColor.b); + float Max = max(max(rgbColor.r, rgbColor.g), rgbColor.b); + float Delta = Max - Min; - hsv.z = Max; + hsv.z = Max; - if(Max != T(0)) - { - hsv.y = Delta / hsv.z; - T h = T(0); + if(Max != T(0)) + { + hsv.y = Delta / hsv.z; + T h = T(0); - if(rgbColor.r == Max) - // between yellow & magenta - h = T(0) + T(60) * (rgbColor.g - rgbColor.b) / Delta; - else if(rgbColor.g == Max) - // between cyan & yellow - h = T(120) + T(60) * (rgbColor.b - rgbColor.r) / Delta; - else - // between magenta & cyan - h = T(240) + T(60) * (rgbColor.r - rgbColor.g) / Delta; + if(rgbColor.r == Max) + // between yellow & magenta + h = T(0) + T(60) * (rgbColor.g - rgbColor.b) / Delta; + else if(rgbColor.g == Max) + // between cyan & yellow + h = T(120) + T(60) * (rgbColor.b - rgbColor.r) / Delta; + else + // between magenta & cyan + h = T(240) + T(60) * (rgbColor.r - rgbColor.g) / Delta; - if(h < T(0)) - hsv.x = h + T(360); - else - hsv.x = h; - } - else - { - // If r = g = b = 0 then s = 0, h is undefined - hsv.y = T(0); - hsv.x = T(0); - } - - return hsv; - } - - template - GLM_FUNC_QUALIFIER detail::tmat4x4 saturation(const T s) + if(h < T(0)) + hsv.x = h + T(360); + else + hsv.x = h; + } + else { - detail::tvec3 rgbw = detail::tvec3(T(0.2126), T(0.7152), T(0.0722)); - - T col0 = (T(1) - s) * rgbw.r; - T col1 = (T(1) - s) * rgbw.g; - T col2 = (T(1) - s) * rgbw.b; - - detail::tmat4x4 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; + // If r = g = b = 0 then s = 0, h is undefined + hsv.y = T(0); + hsv.x = T(0); } - template - GLM_FUNC_QUALIFIER detail::tvec3 saturation(const T s, const detail::tvec3& color) - { - return detail::tvec3(saturation(s) * detail::tvec4(color, T(0))); - } + return hsv; +} - template - GLM_FUNC_QUALIFIER detail::tvec4 saturation(const T s, const detail::tvec4& color) - { - return saturation(s) * color; - } +template +GLM_FUNC_QUALIFIER detail::tmat4x4 saturation(const T s) +{ + detail::tvec3 rgbw = detail::tvec3(T(0.2126), T(0.7152), T(0.0722)); - template - GLM_FUNC_QUALIFIER T luminosity(const detail::tvec3& color) - { - const detail::tvec3 tmp = detail::tvec3(0.33, 0.59, 0.11); - return dot(color, tmp); - } + T col0 = (T(1) - s) * rgbw.r; + T col1 = (T(1) - s) * rgbw.g; + T col2 = (T(1) - s) * rgbw.b; + + detail::tmat4x4 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 +GLM_FUNC_QUALIFIER detail::tvec3 saturation(const T s, const detail::tvec3& color) +{ + return detail::tvec3(saturation(s) * detail::tvec4(color, T(0))); +} + +template +GLM_FUNC_QUALIFIER detail::tvec4 saturation(const T s, const detail::tvec4& color) +{ + return saturation(s) * color; +} + +template +GLM_FUNC_QUALIFIER T luminosity(const detail::tvec3& color) +{ + const detail::tvec3 tmp = detail::tvec3(0.33, 0.59, 0.11); + return dot(color, tmp); +} -}//namespace gtx }//namespace glm diff --git a/glm/gtx/color_space_YCoCg.hpp b/glm/gtx/color_space_YCoCg.hpp index a3df0b22..dc94fced 100644 --- a/glm/gtx/color_space_YCoCg.hpp +++ b/glm/gtx/color_space_YCoCg.hpp @@ -45,8 +45,7 @@ # pragma message("GLM: GLM_GTX_color_space_YCoCg extension included") #endif -namespace glm{ -namespace gtx +namespace glm { /// @addtogroup gtx_color_space_YCoCg /// @{ @@ -78,7 +77,6 @@ namespace gtx detail::tvec3 const & YCoCgColor); /// @} -}//namespace gtx }//namespace glm #include "color_space_YCoCg.inl" diff --git a/glm/gtx/color_space_YCoCg.inl b/glm/gtx/color_space_YCoCg.inl index ce1b7cc3..5dc57fe5 100644 --- a/glm/gtx/color_space_YCoCg.inl +++ b/glm/gtx/color_space_YCoCg.inl @@ -8,7 +8,6 @@ /////////////////////////////////////////////////////////////////////////////////////////////////// namespace glm{ -namespace gtx{ template GLM_FUNC_QUALIFIER detail::tvec3 rgb2YCoCg @@ -63,5 +62,4 @@ GLM_FUNC_QUALIFIER detail::tvec3 YCoCgR2rgb return result; } -}//namespace gtx }//namespace glm diff --git a/glm/gtx/compatibility.hpp b/glm/gtx/compatibility.hpp index 1e1b86f1..9a22145a 100644 --- a/glm/gtx/compatibility.hpp +++ b/glm/gtx/compatibility.hpp @@ -53,8 +53,7 @@ #include #endif//GLM_COMPILER -namespace glm{ -namespace gtx +namespace glm { /// @addtogroup gtx_compatibility /// @{ @@ -124,21 +123,21 @@ namespace gtx typedef detail::tmat4x3 int4x3; //!< \brief integer matrix with 4 x 3 components. (From GLM_GTX_compatibility extension) typedef detail::tmat4x4 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::tvec2 half2; //!< \brief half-precision floating-point vector with 2 components. (From GLM_GTX_compatibility extension) - typedef detail::tvec3 half3; //!< \brief half-precision floating-point vector with 2 components. (From GLM_GTX_compatibility extension) - typedef detail::tvec4 half4; //!< \brief half-precision floating-point vector with 2 components. (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 half2; //!< \brief half-precision floating-point vector with 2 components. (From GLM_GTX_compatibility extension) + typedef detail::tvec3 half3; //!< \brief half-precision floating-point vector with 2 components. (From GLM_GTX_compatibility extension) + typedef detail::tvec4 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::tmat2x2 half2x2; //!< \brief half-precision floating-point matrix with 2 x 2 components. (From GLM_GTX_compatibility extension) - typedef detail::tmat2x3 half2x3; //!< \brief half-precision floating-point matrix with 2 x 3 components. (From GLM_GTX_compatibility extension) - typedef detail::tmat2x4 half2x4; //!< \brief half-precision floating-point matrix with 2 x 4 components. (From GLM_GTX_compatibility extension) - typedef detail::tmat3x2 half3x2; //!< \brief half-precision floating-point matrix with 3 x 2 components. (From GLM_GTX_compatibility extension) - typedef detail::tmat3x3 half3x3; //!< \brief half-precision floating-point matrix with 3 x 3 components. (From GLM_GTX_compatibility extension) - typedef detail::tmat3x4 half3x4; //!< \brief half-precision floating-point matrix with 3 x 3 components. (From GLM_GTX_compatibility extension) - typedef detail::tmat4x2 half4x2; //!< \brief half-precision floating-point matrix with 4 x 2 components. (From GLM_GTX_compatibility extension) - typedef detail::tmat4x3 half4x3; //!< \brief half-precision floating-point matrix with 4 x 3 components. (From GLM_GTX_compatibility extension) - typedef detail::tmat4x4 half4x4; //!< \brief half-precision floating-point matrix with 4 x 4 components. (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 half2x2; //!< \brief half-precision floating-point matrix with 2 x 2 components. (From GLM_GTX_compatibility extension) + typedef detail::tmat2x3 half2x3; //!< \brief half-precision floating-point matrix with 2 x 3 components. (From GLM_GTX_compatibility extension) + typedef detail::tmat2x4 half2x4; //!< \brief half-precision floating-point matrix with 2 x 4 components. (From GLM_GTX_compatibility extension) + typedef detail::tmat3x2 half3x2; //!< \brief half-precision floating-point matrix with 3 x 2 components. (From GLM_GTX_compatibility extension) + typedef detail::tmat3x3 half3x3; //!< \brief half-precision floating-point matrix with 3 x 3 components. (From GLM_GTX_compatibility extension) + typedef detail::tmat3x4 half3x4; //!< \brief half-precision floating-point matrix with 3 x 3 components. (From GLM_GTX_compatibility extension) + typedef detail::tmat4x2 half4x2; //!< \brief half-precision floating-point matrix with 4 x 2 components. (From GLM_GTX_compatibility extension) + typedef detail::tmat4x3 half4x3; //!< \brief half-precision floating-point matrix with 4 x 3 components. (From GLM_GTX_compatibility extension) + typedef detail::tmat4x4 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 detail::tvec2 float2; //!< \brief single-precision floating-point vector with 2 components. (From GLM_GTX_compatibility extension) @@ -173,7 +172,6 @@ namespace gtx typedef detail::tmat4x4 double4x4; //!< \brief double-precision floating-point matrix with 4 x 4 components. (From GLM_GTX_compatibility extension) /// @} -}//namespace gtx }//namespace glm #include "compatibility.inl" diff --git a/glm/gtx/compatibility.inl b/glm/gtx/compatibility.inl index 33b9cefe..8a8549a1 100644 --- a/glm/gtx/compatibility.inl +++ b/glm/gtx/compatibility.inl @@ -8,8 +8,6 @@ /////////////////////////////////////////////////////////////////////////////////////////////////// namespace glm{ -namespace gtx{ -namespace compatibility{ // isfinite template @@ -136,6 +134,4 @@ GLM_FUNC_QUALIFIER detail::tvec4 isnan( isnan(x.w)); } -}//namespace compatibility -}//namespace gtx }//namespace glm diff --git a/glm/gtx/component_wise.hpp b/glm/gtx/component_wise.hpp index ea6d53bd..661c6ca4 100644 --- a/glm/gtx/component_wise.hpp +++ b/glm/gtx/component_wise.hpp @@ -45,8 +45,7 @@ # pragma message("GLM: GLM_GTX_component_wise extension included") #endif -namespace glm{ -namespace gtx +namespace glm { /// @addtogroup gtx_component_wise /// @{ @@ -76,7 +75,6 @@ namespace gtx genType const & v); /// @} -}//namespace gtx }//namespace glm #include "component_wise.inl" diff --git a/glm/gtx/component_wise.inl b/glm/gtx/component_wise.inl index 277b902a..43ffe18b 100644 --- a/glm/gtx/component_wise.inl +++ b/glm/gtx/component_wise.inl @@ -8,43 +8,41 @@ /////////////////////////////////////////////////////////////////////////////////////////////////// namespace glm{ -namespace gtx + +template +GLM_FUNC_QUALIFIER typename genType::value_type compAdd(genType const & v) { - template - GLM_FUNC_QUALIFIER typename genType::value_type compAdd(genType const & v) - { - typename genType::size_type result = typename genType::value_type(0); - for(typename genType::size_type i = 0; i < genType::value_size(); ++i) - result += v[i]; - return result; - } + typename genType::size_type result = typename genType::value_type(0); + for(typename genType::size_type i = 0; i < genType::value_size(); ++i) + result += v[i]; + return result; +} - template - GLM_FUNC_QUALIFIER typename genType::value_type compMul(genType const & v) - { - typename genType::value_type result = typename genType::value_type(1); - for(typename genType::size_type i = 0; i < genType::value_size(); ++i) - result *= v[i]; - return result; - } +template +GLM_FUNC_QUALIFIER typename genType::value_type compMul(genType const & v) +{ + typename genType::value_type result = typename genType::value_type(1); + for(typename genType::size_type i = 0; i < genType::value_size(); ++i) + result *= v[i]; + return result; +} - template - GLM_FUNC_QUALIFIER typename genType::value_type compMin(genType const & v) - { - typename genType::value_type result = typename genType::value_type(v[0]); - for(typename genType::size_type i = 1; i < genType::value_size(); ++i) - result = min(result, v[i]); - return result; - } +template +GLM_FUNC_QUALIFIER typename genType::value_type compMin(genType const & v) +{ + typename genType::value_type result = typename genType::value_type(v[0]); + for(typename genType::size_type i = 1; i < genType::value_size(); ++i) + result = min(result, v[i]); + return result; +} - template - GLM_FUNC_QUALIFIER typename genType::value_type compMax(genType const & v) - { - typename genType::value_type result = typename genType::value_type(v[0]); - for(typename genType::size_type i = 1; i < genType::value_size(); ++i) - result = max(result, v[i]); - return result; - } +template +GLM_FUNC_QUALIFIER typename genType::value_type compMax(genType const & v) +{ + typename genType::value_type result = typename genType::value_type(v[0]); + for(typename genType::size_type i = 1; i < genType::value_size(); ++i) + result = max(result, v[i]); + return result; +} -}//namespace gtx }//namespace glm diff --git a/glm/gtx/epsilon.hpp b/glm/gtx/epsilon.hpp index 94081f66..d96c17c7 100644 --- a/glm/gtx/epsilon.hpp +++ b/glm/gtx/epsilon.hpp @@ -49,8 +49,7 @@ # pragma message("GLM: GLM_GTX_epsilon extension included") #endif -namespace glm{ -namespace gtx +namespace glm { /// @addtogroup gtx_epsilon /// @{ @@ -72,7 +71,6 @@ namespace gtx genTypeU const & epsilon); /// @} -}//namespace gtx }//namespace glm #include "epsilon.inl" diff --git a/glm/gtx/epsilon.inl b/glm/gtx/epsilon.inl index 02fca35d..bfb2d3b1 100644 --- a/glm/gtx/epsilon.inl +++ b/glm/gtx/epsilon.inl @@ -8,7 +8,6 @@ /////////////////////////////////////////////////////////////////////////////////////////////////// namespace glm{ -namespace gtx{ template GLM_FUNC_QUALIFIER bool equalEpsilon @@ -228,5 +227,4 @@ GLM_FUNC_QUALIFIER detail::tvec4 notEqualEpsilon abs(x.w - y.w) >= epsilon.w); } -}//namespace gtx }//namespace glm diff --git a/glm/gtx/euler_angles.hpp b/glm/gtx/euler_angles.hpp index 3436e2e2..73f0e2ad 100644 --- a/glm/gtx/euler_angles.hpp +++ b/glm/gtx/euler_angles.hpp @@ -50,8 +50,7 @@ # pragma message("GLM: GLM_GTX_euler_angles extension included") #endif -namespace glm{ -namespace gtx +namespace glm { /// @addtogroup gtx_euler_angles /// @{ @@ -153,7 +152,6 @@ namespace gtx detail::tmat4x4 orientate4(detail::tvec3 const & angles); /// @} -}//namespace gtx }//namespace glm #include "euler_angles.inl" diff --git a/glm/gtx/euler_angles.inl b/glm/gtx/euler_angles.inl index f9de6eed..22d70052 100644 --- a/glm/gtx/euler_angles.inl +++ b/glm/gtx/euler_angles.inl @@ -8,7 +8,6 @@ /////////////////////////////////////////////////////////////////////////////////////////////////// namespace glm{ -namespace gtx{ template GLM_FUNC_QUALIFIER detail::tmat4x4 eulerAngleX @@ -243,5 +242,4 @@ GLM_FUNC_QUALIFIER detail::tmat4x4 orientate4 return yawPitchRoll(angles.z, angles.x, angles.y); } -}//namespace gtx }//namespace glm diff --git a/glm/gtx/extend.hpp b/glm/gtx/extend.hpp index 8f57d00d..7a205107 100644 --- a/glm/gtx/extend.hpp +++ b/glm/gtx/extend.hpp @@ -45,8 +45,7 @@ # pragma message("GLM: GLM_GTX_extend extension included") #endif -namespace glm{ -namespace gtx +namespace glm { /// @addtogroup gtx_extend /// @{ @@ -60,7 +59,6 @@ namespace gtx typename genType::value_type const Length); /// @} -}//namespace gtx }//namespace glm #include "extend.inl" diff --git a/glm/gtx/extend.inl b/glm/gtx/extend.inl index b4c08d27..0e094fb2 100644 --- a/glm/gtx/extend.inl +++ b/glm/gtx/extend.inl @@ -8,7 +8,6 @@ /////////////////////////////////////////////////////////////////////////////////////////////////// namespace glm{ -namespace gtx{ template genType extend @@ -54,5 +53,4 @@ detail::tvec4 extend return Origin + (Source - Origin) * Distance; } -}//namespace gtx }//namespace glm diff --git a/glm/gtx/extented_min_max.hpp b/glm/gtx/extented_min_max.hpp index ab21b17c..8c125c84 100644 --- a/glm/gtx/extented_min_max.hpp +++ b/glm/gtx/extented_min_max.hpp @@ -47,8 +47,7 @@ # pragma message("GLM: GLM_GTX_extented_min_max extension included") #endif -namespace glm{ -namespace gtx +namespace glm { /// @addtogroup gtx_extented_min_max /// @{ @@ -188,7 +187,6 @@ namespace gtx C const & w); /// @} -}//namespace gtx }//namespace glm #include "extented_min_max.inl" diff --git a/glm/gtx/extented_min_max.inl b/glm/gtx/extented_min_max.inl index 59a4cd49..2c641851 100644 --- a/glm/gtx/extented_min_max.inl +++ b/glm/gtx/extented_min_max.inl @@ -7,8 +7,7 @@ // File : gtx_extented_min_max.inl /////////////////////////////////////////////////////////////////////////////////////////////////// -namespace glm{ -namespace gtx +namespace glm { template GLM_FUNC_QUALIFIER T min( @@ -176,5 +175,4 @@ namespace gtx return glm::max(glm::max(x, y), glm::max(z, w)); } -}//namespace gtx }//namespace glm diff --git a/glm/gtx/fast_exponential.hpp b/glm/gtx/fast_exponential.hpp index df20a4e5..af5c0abf 100644 --- a/glm/gtx/fast_exponential.hpp +++ b/glm/gtx/fast_exponential.hpp @@ -47,8 +47,7 @@ # pragma message("GLM: GLM_GTX_fast_exponential extension included") #endif -namespace glm{ -namespace gtx +namespace glm { /// @addtogroup gtx_fast_exponential /// @{ @@ -93,7 +92,6 @@ namespace gtx T fastLn(const T& x); /// @} -}//namespace gtx }//namespace glm #include "fast_exponential.inl" diff --git a/glm/gtx/fast_exponential.inl b/glm/gtx/fast_exponential.inl index 617b8c54..37d6cd5f 100644 --- a/glm/gtx/fast_exponential.inl +++ b/glm/gtx/fast_exponential.inl @@ -8,285 +8,283 @@ /////////////////////////////////////////////////////////////////////////////////////////////////// namespace glm{ -namespace gtx + +// fastPow: +template +GLM_FUNC_QUALIFIER T fastPow(const T x, const T y) { - // fastPow: - template - GLM_FUNC_QUALIFIER T fastPow(const T x, const T y) - { - return exp(y * log(x)); - } + return exp(y * log(x)); +} - template - GLM_FUNC_QUALIFIER detail::tvec2 fastPow( - const detail::tvec2& x, - const detail::tvec2& y) - { - return detail::tvec2( - fastPow(x.x, y.x), - fastPow(x.y, y.y)); - } +template +GLM_FUNC_QUALIFIER detail::tvec2 fastPow( + const detail::tvec2& x, + const detail::tvec2& y) +{ + return detail::tvec2( + fastPow(x.x, y.x), + fastPow(x.y, y.y)); +} - template - GLM_FUNC_QUALIFIER detail::tvec3 fastPow( - const detail::tvec3& x, - const detail::tvec3& y) - { - return detail::tvec3( - fastPow(x.x, y.x), - fastPow(x.y, y.y), - fastPow(x.z, y.z)); - } +template +GLM_FUNC_QUALIFIER detail::tvec3 fastPow( + const detail::tvec3& x, + const detail::tvec3& y) +{ + return detail::tvec3( + fastPow(x.x, y.x), + fastPow(x.y, y.y), + fastPow(x.z, y.z)); +} - template - GLM_FUNC_QUALIFIER detail::tvec4 fastPow( - const detail::tvec4& x, - const detail::tvec4& y) - { - return detail::tvec4( - fastPow(x.x, y.x), - fastPow(x.y, y.y), - fastPow(x.z, y.z), - fastPow(x.w, y.w)); - } +template +GLM_FUNC_QUALIFIER detail::tvec4 fastPow( + const detail::tvec4& x, + const detail::tvec4& y) +{ + return detail::tvec4( + fastPow(x.x, y.x), + fastPow(x.y, y.y), + fastPow(x.z, y.z), + fastPow(x.w, y.w)); +} - template - GLM_FUNC_QUALIFIER T fastPow(const T x, int y) - { - T f = T(1); - for(int i = 0; i < y; ++i) - f *= x; - return f; - } +template +GLM_FUNC_QUALIFIER T fastPow(const T x, int y) +{ + T f = T(1); + for(int i = 0; i < y; ++i) + f *= x; + return f; +} - template - GLM_FUNC_QUALIFIER detail::tvec2 fastPow( - const detail::tvec2& x, - const detail::tvec2& y) - { - return detail::tvec2( - fastPow(x.x, y.x), - fastPow(x.y, y.y)); - } +template +GLM_FUNC_QUALIFIER detail::tvec2 fastPow( + const detail::tvec2& x, + const detail::tvec2& y) +{ + return detail::tvec2( + fastPow(x.x, y.x), + fastPow(x.y, y.y)); +} - template - GLM_FUNC_QUALIFIER detail::tvec3 fastPow( - const detail::tvec3& x, - const detail::tvec3& y) - { - return detail::tvec3( - fastPow(x.x, y.x), - fastPow(x.y, y.y), - fastPow(x.z, y.z)); - } +template +GLM_FUNC_QUALIFIER detail::tvec3 fastPow( + const detail::tvec3& x, + const detail::tvec3& y) +{ + return detail::tvec3( + fastPow(x.x, y.x), + fastPow(x.y, y.y), + fastPow(x.z, y.z)); +} - template - GLM_FUNC_QUALIFIER detail::tvec4 fastPow( - const detail::tvec4& x, - const detail::tvec4& y) - { - return detail::tvec4( - fastPow(x.x, y.x), - fastPow(x.y, y.y), - fastPow(x.z, y.z), - fastPow(x.w, y.w)); - } +template +GLM_FUNC_QUALIFIER detail::tvec4 fastPow( + const detail::tvec4& x, + const detail::tvec4& y) +{ + return detail::tvec4( + fastPow(x.x, y.x), + fastPow(x.y, y.y), + fastPow(x.z, y.z), + fastPow(x.w, y.w)); +} - // fastExp - // Note: This function provides accurate results only for value between -1 and 1, else avoid it. - template - 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. - // 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 x3 = x2 * x; - T x4 = x3 * 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)); - } +// fastExp +// Note: This function provides accurate results only for value between -1 and 1, else avoid it. +template +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. + // 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 x3 = x2 * x; + T x4 = x3 * 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)); +} /* // 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) - { - const float e = 2.718281828f; - const float IntegerPart = floor(x); - const float FloatPart = x - IntegerPart; - float z = 1.f; +GLM_FUNC_QUALIFIER float fastExp(float x) +{ + const float e = 2.718281828f; + const float IntegerPart = floor(x); + const float FloatPart = x - IntegerPart; + float z = 1.f; - for(int i = 0; i < int(IntegerPart); ++i) - z *= e; + for(int i = 0; i < int(IntegerPart); ++i) + z *= e; - const float x2 = FloatPart * FloatPart; - const float x3 = x2 * FloatPart; - const float x4 = x3 * FloatPart; - const float x5 = x4 * FloatPart; - return z * (1.0f + FloatPart + (x2 * 0.5f) + (x3 * 0.1666666667f) + (x4 * 0.041666667f) + (x5 * 0.008333333333f)); - } + const float x2 = FloatPart * FloatPart; + const float x3 = x2 * FloatPart; + const float x4 = x3 * FloatPart; + const float x5 = x4 * FloatPart; + 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 - 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. - // 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 x3 = x2 * x; - float x4 = x3 * x; - float x5 = x4 * x; - float x6 = x5 * x; - float x7 = x6 * 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);; - } +// 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) +{ + // 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)))); + float x2 = x * x; + float x3 = x2 * x; + float x4 = x3 * x; + float x5 = x4 * x; + float x6 = x5 * x; + float x7 = x6 * 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);; +} */ - template - GLM_FUNC_QUALIFIER detail::tvec2 fastExp( - const detail::tvec2& x) - { - return detail::tvec2( - fastExp(x.x), - fastExp(x.y)); - } +template +GLM_FUNC_QUALIFIER detail::tvec2 fastExp( + const detail::tvec2& x) +{ + return detail::tvec2( + fastExp(x.x), + fastExp(x.y)); +} - template - GLM_FUNC_QUALIFIER detail::tvec3 fastExp( - const detail::tvec3& x) - { - return detail::tvec3( - fastExp(x.x), - fastExp(x.y), - fastExp(x.z)); - } +template +GLM_FUNC_QUALIFIER detail::tvec3 fastExp( + const detail::tvec3& x) +{ + return detail::tvec3( + fastExp(x.x), + fastExp(x.y), + fastExp(x.z)); +} - template - GLM_FUNC_QUALIFIER detail::tvec4 fastExp( - const detail::tvec4& x) - { - return detail::tvec4( - fastExp(x.x), - fastExp(x.y), - fastExp(x.z), - fastExp(x.w)); - } +template +GLM_FUNC_QUALIFIER detail::tvec4 fastExp( + const detail::tvec4& x) +{ + return detail::tvec4( + fastExp(x.x), + fastExp(x.y), + fastExp(x.z), + fastExp(x.w)); +} - // fastLog - template - GLM_FUNC_QUALIFIER T fastLog(const T x) - { - return std::log(x); - } +// fastLog +template +GLM_FUNC_QUALIFIER T fastLog(const T x) +{ + return std::log(x); +} - /* Slower than the VC7.1 function... - GLM_FUNC_QUALIFIER float fastLog(float x) - { - float y1 = (x - 1.0f) / (x + 1.0f); - float y2 = y1 * y1; - return 2.0f * y1 * (1.0f + y2 * (0.3333333333f + y2 * (0.2f + y2 * 0.1428571429f))); - } - */ +/* Slower than the VC7.1 function... +GLM_FUNC_QUALIFIER float fastLog(float x) +{ + float y1 = (x - 1.0f) / (x + 1.0f); + float y2 = y1 * y1; + return 2.0f * y1 * (1.0f + y2 * (0.3333333333f + y2 * (0.2f + y2 * 0.1428571429f))); +} +*/ - template - GLM_FUNC_QUALIFIER detail::tvec2 fastLog( - const detail::tvec2& x) - { - return detail::tvec2( - fastLog(x.x), - fastLog(x.y)); - } +template +GLM_FUNC_QUALIFIER detail::tvec2 fastLog( + const detail::tvec2& x) +{ + return detail::tvec2( + fastLog(x.x), + fastLog(x.y)); +} - template - GLM_FUNC_QUALIFIER detail::tvec3 fastLog( - const detail::tvec3& x) - { - return detail::tvec3( - fastLog(x.x), - fastLog(x.y), - fastLog(x.z)); - } +template +GLM_FUNC_QUALIFIER detail::tvec3 fastLog( + const detail::tvec3& x) +{ + return detail::tvec3( + fastLog(x.x), + fastLog(x.y), + fastLog(x.z)); +} - template - GLM_FUNC_QUALIFIER detail::tvec4 fastLog( - const detail::tvec4& x) - { - return detail::tvec4( - fastLog(x.x), - fastLog(x.y), - fastLog(x.z), - fastLog(x.w)); - } +template +GLM_FUNC_QUALIFIER detail::tvec4 fastLog( + const detail::tvec4& x) +{ + return detail::tvec4( + fastLog(x.x), + fastLog(x.y), + fastLog(x.z), + fastLog(x.w)); +} - //fastExp2, ln2 = 0.69314718055994530941723212145818f - template - GLM_FUNC_QUALIFIER T fastExp2(const T x) - { - return fastExp(0.69314718055994530941723212145818f * x); - } +//fastExp2, ln2 = 0.69314718055994530941723212145818f +template +GLM_FUNC_QUALIFIER T fastExp2(const T x) +{ + return fastExp(0.69314718055994530941723212145818f * x); +} - template - GLM_FUNC_QUALIFIER detail::tvec2 fastExp2( - const detail::tvec2& x) - { - return detail::tvec2( - fastExp2(x.x), - fastExp2(x.y)); - } +template +GLM_FUNC_QUALIFIER detail::tvec2 fastExp2( + const detail::tvec2& x) +{ + return detail::tvec2( + fastExp2(x.x), + fastExp2(x.y)); +} - template - GLM_FUNC_QUALIFIER detail::tvec3 fastExp2( - const detail::tvec3& x) - { - return detail::tvec3( - fastExp2(x.x), - fastExp2(x.y), - fastExp2(x.z)); - } +template +GLM_FUNC_QUALIFIER detail::tvec3 fastExp2( + const detail::tvec3& x) +{ + return detail::tvec3( + fastExp2(x.x), + fastExp2(x.y), + fastExp2(x.z)); +} - template - GLM_FUNC_QUALIFIER detail::tvec4 fastExp2( - const detail::tvec4& x) - { - return detail::tvec4( - fastExp2(x.x), - fastExp2(x.y), - fastExp2(x.z), - fastExp2(x.w)); - } +template +GLM_FUNC_QUALIFIER detail::tvec4 fastExp2( + const detail::tvec4& x) +{ + return detail::tvec4( + fastExp2(x.x), + fastExp2(x.y), + fastExp2(x.z), + fastExp2(x.w)); +} - // fastLog2, ln2 = 0.69314718055994530941723212145818f - template - GLM_FUNC_QUALIFIER T fastLog2(const T x) - { - return fastLog(x) / 0.69314718055994530941723212145818f; - } +// fastLog2, ln2 = 0.69314718055994530941723212145818f +template +GLM_FUNC_QUALIFIER T fastLog2(const T x) +{ + return fastLog(x) / 0.69314718055994530941723212145818f; +} - template - GLM_FUNC_QUALIFIER detail::tvec2 fastLog2( - const detail::tvec2& x) - { - return detail::tvec2( - fastLog2(x.x), - fastLog2(x.y)); - } +template +GLM_FUNC_QUALIFIER detail::tvec2 fastLog2( + const detail::tvec2& x) +{ + return detail::tvec2( + fastLog2(x.x), + fastLog2(x.y)); +} - template - GLM_FUNC_QUALIFIER detail::tvec3 fastLog2( - const detail::tvec3& x) - { - return detail::tvec3( - fastLog2(x.x), - fastLog2(x.y), - fastLog2(x.z)); - } +template +GLM_FUNC_QUALIFIER detail::tvec3 fastLog2( + const detail::tvec3& x) +{ + return detail::tvec3( + fastLog2(x.x), + fastLog2(x.y), + fastLog2(x.z)); +} - template - GLM_FUNC_QUALIFIER detail::tvec4 fastLog2( - const detail::tvec4& x) - { - return detail::tvec4( - fastLog2(x.x), - fastLog2(x.y), - fastLog2(x.z), - fastLog2(x.w)); - } +template +GLM_FUNC_QUALIFIER detail::tvec4 fastLog2( + const detail::tvec4& x) +{ + return detail::tvec4( + fastLog2(x.x), + fastLog2(x.y), + fastLog2(x.z), + fastLog2(x.w)); +} -}//namespace gtx }//namespace glm diff --git a/glm/gtx/fast_square_root.hpp b/glm/gtx/fast_square_root.hpp index 22f181f2..a5785e43 100644 --- a/glm/gtx/fast_square_root.hpp +++ b/glm/gtx/fast_square_root.hpp @@ -47,8 +47,7 @@ # pragma message("GLM: GLM_GTX_fast_square_root extension included") #endif -namespace glm{ -namespace gtx +namespace glm { /// @addtogroup gtx_fast_square_root /// @{ @@ -79,7 +78,6 @@ namespace gtx genType fastNormalize(genType const & x); /// @} -}// namespace gtx }// namespace glm #include "fast_square_root.inl" diff --git a/glm/gtx/fast_square_root.inl b/glm/gtx/fast_square_root.inl index b3c3e611..987fca1e 100644 --- a/glm/gtx/fast_square_root.inl +++ b/glm/gtx/fast_square_root.inl @@ -8,7 +8,6 @@ /////////////////////////////////////////////////////////////////////////////////////////////////// namespace glm{ -namespace gtx{ // fastSqrt template @@ -231,5 +230,4 @@ GLM_FUNC_QUALIFIER detail::tvec4 fastNormalize return x * fastInverseSqrt(sqr); } -}//namespace gtx }//namespace glm diff --git a/glm/gtx/fast_trigonometry.hpp b/glm/gtx/fast_trigonometry.hpp index c79d0e44..e6a202a0 100644 --- a/glm/gtx/fast_trigonometry.hpp +++ b/glm/gtx/fast_trigonometry.hpp @@ -45,8 +45,7 @@ # pragma message("GLM: GLM_GTX_fast_trigonometry extension included") #endif -namespace glm{ -namespace gtx +namespace glm { /// @addtogroup gtx_fast_trigonometry /// @{ @@ -94,7 +93,6 @@ namespace gtx T fastAtan(const T& angle); /// @} -}//namespace gtx }//namespace glm #include "fast_trigonometry.inl" diff --git a/glm/gtx/fast_trigonometry.inl b/glm/gtx/fast_trigonometry.inl index bd8ac1c2..65293909 100644 --- a/glm/gtx/fast_trigonometry.inl +++ b/glm/gtx/fast_trigonometry.inl @@ -8,263 +8,261 @@ /////////////////////////////////////////////////////////////////////////////////////////////////// namespace glm{ -namespace gtx + +// sin +template +GLM_FUNC_QUALIFIER T fastSin(const T x) { - // sin - template - 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)); - } + return x - ((x * x * x) / T(6)) + ((x * x * x * x * x) / T(120)) - ((x * x * x * x * x * x * x) / T(5040)); +} - template - GLM_FUNC_QUALIFIER detail::tvec2 fastSin( - const detail::tvec2& x) - { - return detail::tvec2( - fastSin(x.x), - fastSin(x.y)); - } +template +GLM_FUNC_QUALIFIER detail::tvec2 fastSin( + const detail::tvec2& x) +{ + return detail::tvec2( + fastSin(x.x), + fastSin(x.y)); +} - template - GLM_FUNC_QUALIFIER detail::tvec3 fastSin( - const detail::tvec3& x) - { - return detail::tvec3( - fastSin(x.x), - fastSin(x.y), - fastSin(x.z)); - } +template +GLM_FUNC_QUALIFIER detail::tvec3 fastSin( + const detail::tvec3& x) +{ + return detail::tvec3( + fastSin(x.x), + fastSin(x.y), + fastSin(x.z)); +} - template - GLM_FUNC_QUALIFIER detail::tvec4 fastSin( - const detail::tvec4& x) - { - return detail::tvec4( - fastSin(x.x), - fastSin(x.y), - fastSin(x.z), - fastSin(x.w)); - } +template +GLM_FUNC_QUALIFIER detail::tvec4 fastSin( + const detail::tvec4& x) +{ + return detail::tvec4( + fastSin(x.x), + fastSin(x.y), + fastSin(x.z), + fastSin(x.w)); +} - // cos - template - 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)); - } +// cos +template +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)); +} - template - GLM_FUNC_QUALIFIER detail::tvec2 fastCos( - const detail::tvec2& x) - { - return detail::tvec2( - fastCos(x.x), - fastCos(x.y)); - } +template +GLM_FUNC_QUALIFIER detail::tvec2 fastCos( + const detail::tvec2& x) +{ + return detail::tvec2( + fastCos(x.x), + fastCos(x.y)); +} - template - GLM_FUNC_QUALIFIER detail::tvec3 fastCos( - const detail::tvec3& x) - { - return detail::tvec3( - fastCos(x.x), - fastCos(x.y), - fastCos(x.z)); - } +template +GLM_FUNC_QUALIFIER detail::tvec3 fastCos( + const detail::tvec3& x) +{ + return detail::tvec3( + fastCos(x.x), + fastCos(x.y), + fastCos(x.z)); +} - template - GLM_FUNC_QUALIFIER detail::tvec4 fastCos( - const detail::tvec4& x) - { - return detail::tvec4( - fastCos(x.x), - fastCos(x.y), - fastCos(x.z), - fastCos(x.w)); - } +template +GLM_FUNC_QUALIFIER detail::tvec4 fastCos( + const detail::tvec4& x) +{ + return detail::tvec4( + fastCos(x.x), + fastCos(x.y), + fastCos(x.z), + fastCos(x.w)); +} - // tan - template - 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)); - } +// tan +template +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)); +} - template - GLM_FUNC_QUALIFIER detail::tvec2 fastTan( - const detail::tvec2& x) - { - return detail::tvec2( - fastTan(x.x), - fastTan(x.y)); - } +template +GLM_FUNC_QUALIFIER detail::tvec2 fastTan( + const detail::tvec2& x) +{ + return detail::tvec2( + fastTan(x.x), + fastTan(x.y)); +} - template - GLM_FUNC_QUALIFIER detail::tvec3 fastTan( - const detail::tvec3& x) - { - return detail::tvec3( - fastTan(x.x), - fastTan(x.y), - fastTan(x.z)); - } +template +GLM_FUNC_QUALIFIER detail::tvec3 fastTan( + const detail::tvec3& x) +{ + return detail::tvec3( + fastTan(x.x), + fastTan(x.y), + fastTan(x.z)); +} - template - GLM_FUNC_QUALIFIER detail::tvec4 fastTan( - const detail::tvec4& x) - { - return detail::tvec4( - fastTan(x.x), - fastTan(x.y), - fastTan(x.z), - fastTan(x.w)); - } +template +GLM_FUNC_QUALIFIER detail::tvec4 fastTan( + const detail::tvec4& x) +{ + return detail::tvec4( + fastTan(x.x), + fastTan(x.y), + fastTan(x.z), + fastTan(x.w)); +} - // asin - template - 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)); - } +// asin +template +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)); +} - template detail::tvec2 fastAsin( - const detail::tvec2& x) - { - return detail::tvec2( - fastAsin(x.x), - fastAsin(x.y)); - } +template detail::tvec2 fastAsin( + const detail::tvec2& x) +{ + return detail::tvec2( + fastAsin(x.x), + fastAsin(x.y)); +} - template detail::tvec3 fastAsin( - const detail::tvec3& x) - { - return detail::tvec3( - fastAsin(x.x), - fastAsin(x.y), - fastAsin(x.z)); - } +template detail::tvec3 fastAsin( + const detail::tvec3& x) +{ + return detail::tvec3( + fastAsin(x.x), + fastAsin(x.y), + fastAsin(x.z)); +} - template detail::tvec4 fastAsin( - const detail::tvec4& x) - { - return detail::tvec4( - fastAsin(x.x), - fastAsin(x.y), - fastAsin(x.z), - fastAsin(x.w)); - } +template detail::tvec4 fastAsin( + const detail::tvec4& x) +{ + return detail::tvec4( + fastAsin(x.x), + fastAsin(x.y), + fastAsin(x.z), + fastAsin(x.w)); +} - // acos - template - GLM_FUNC_QUALIFIER T fastAcos(const T x) - { - return T(1.5707963267948966192313216916398) - fastAsin(x); //(PI / 2) - } +// acos +template +GLM_FUNC_QUALIFIER T fastAcos(const T x) +{ + return T(1.5707963267948966192313216916398) - fastAsin(x); //(PI / 2) +} - template detail::tvec2 fastAcos( - const detail::tvec2& x) - { - return detail::tvec2( - fastAcos(x.x), - fastAcos(x.y)); - } +template detail::tvec2 fastAcos( + const detail::tvec2& x) +{ + return detail::tvec2( + fastAcos(x.x), + fastAcos(x.y)); +} - template detail::tvec3 fastAcos( - const detail::tvec3& x) - { - return detail::tvec3( - fastAcos(x.x), - fastAcos(x.y), - fastAcos(x.z)); - } +template detail::tvec3 fastAcos( + const detail::tvec3& x) +{ + return detail::tvec3( + fastAcos(x.x), + fastAcos(x.y), + fastAcos(x.z)); +} - template detail::tvec4 fastAcos( - const detail::tvec4& x) - { - return detail::tvec4( - fastAcos(x.x), - fastAcos(x.y), - fastAcos(x.z), - fastAcos(x.w)); - } +template detail::tvec4 fastAcos( + const detail::tvec4& x) +{ + return detail::tvec4( + fastAcos(x.x), + fastAcos(x.y), + fastAcos(x.z), + fastAcos(x.w)); +} - // atan - template - GLM_FUNC_QUALIFIER T fastAtan(const T y, const T x) - { - T sgn = sign(y) * sign(x); - return abs(fastAtan(y / x)) * sgn; - } +// atan +template +GLM_FUNC_QUALIFIER T fastAtan(const T y, const T x) +{ + T sgn = sign(y) * sign(x); + return abs(fastAtan(y / x)) * sgn; +} - template - GLM_FUNC_QUALIFIER detail::tvec2 fastAtan( - const detail::tvec2& y, - const detail::tvec2& x) - { - return detail::tvec2( - fastAtan(y.x, x.x), - fastAtan(y.y, x.y)); - } +template +GLM_FUNC_QUALIFIER detail::tvec2 fastAtan( + const detail::tvec2& y, + const detail::tvec2& x) +{ + return detail::tvec2( + fastAtan(y.x, x.x), + fastAtan(y.y, x.y)); +} - template - GLM_FUNC_QUALIFIER detail::tvec3 fastAtan( - const detail::tvec3& y, - const detail::tvec3& x) - { - return detail::tvec3( - fastAtan(y.x, x.x), - fastAtan(y.y, x.y), - fastAtan(y.z, x.z)); - } +template +GLM_FUNC_QUALIFIER detail::tvec3 fastAtan( + const detail::tvec3& y, + const detail::tvec3& x) +{ + return detail::tvec3( + fastAtan(y.x, x.x), + fastAtan(y.y, x.y), + fastAtan(y.z, x.z)); +} - template - GLM_FUNC_QUALIFIER detail::tvec4 fastAtan( - const detail::tvec4& y, - const detail::tvec4& x) - { - return detail::tvec4( - fastAtan(y.x, x.x), - fastAtan(y.y, x.y), - fastAtan(y.z, x.z), - fastAtan(y.w, x.w)); - } +template +GLM_FUNC_QUALIFIER detail::tvec4 fastAtan( + const detail::tvec4& y, + const detail::tvec4& x) +{ + return detail::tvec4( + fastAtan(y.x, x.x), + fastAtan(y.y, x.y), + fastAtan(y.z, x.z), + fastAtan(y.w, x.w)); +} - template - 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)); - } +template +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)); +} - template - GLM_FUNC_QUALIFIER detail::tvec2 fastAtan( - const detail::tvec2& x) - { - return detail::tvec2( - fastAtan(x.x), - fastAtan(x.y)); - } +template +GLM_FUNC_QUALIFIER detail::tvec2 fastAtan( + const detail::tvec2& x) +{ + return detail::tvec2( + fastAtan(x.x), + fastAtan(x.y)); +} - template - GLM_FUNC_QUALIFIER detail::tvec3 fastAtan( - const detail::tvec3& x) - { - return detail::tvec3( - fastAtan(x.x), - fastAtan(x.y), - fastAtan(x.z)); - } +template +GLM_FUNC_QUALIFIER detail::tvec3 fastAtan( + const detail::tvec3& x) +{ + return detail::tvec3( + fastAtan(x.x), + fastAtan(x.y), + fastAtan(x.z)); +} - template - GLM_FUNC_QUALIFIER detail::tvec4 fastAtan( - const detail::tvec4& x) - { - return detail::tvec4( - fastAtan(x.x), - fastAtan(x.y), - fastAtan(x.z), - fastAtan(x.w)); - } +template +GLM_FUNC_QUALIFIER detail::tvec4 fastAtan( + const detail::tvec4& x) +{ + return detail::tvec4( + fastAtan(x.x), + fastAtan(x.y), + fastAtan(x.z), + fastAtan(x.w)); +} -}//namespace gtx }//namespace glm diff --git a/glm/gtx/gradient_paint.hpp b/glm/gtx/gradient_paint.hpp index c925726b..1ddf1cbd 100644 --- a/glm/gtx/gradient_paint.hpp +++ b/glm/gtx/gradient_paint.hpp @@ -46,8 +46,7 @@ # pragma message("GLM: GLM_GTX_gradient_paint extension included") #endif -namespace glm{ -namespace gtx +namespace glm { /// @addtogroup gtx_gradient_paint /// @{ @@ -70,7 +69,6 @@ namespace gtx glm::detail::tvec2 const & Position); /// @} -}// namespace gtx }// namespace glm #include "gradient_paint.inl" diff --git a/glm/gtx/gradient_paint.inl b/glm/gtx/gradient_paint.inl index 8c72e69c..f6ea0718 100644 --- a/glm/gtx/gradient_paint.inl +++ b/glm/gtx/gradient_paint.inl @@ -8,35 +8,33 @@ /////////////////////////////////////////////////////////////////////////////////////////////////// namespace glm{ -namespace gtx{ - template - valType radialGradient( - glm::detail::tvec2 const & Center, - valType const & Radius, - glm::detail::tvec2 const & Focal, - glm::detail::tvec2 const & Position) - { - glm::detail::tvec2 F = Focal - Center; - glm::detail::tvec2 D = Position - Focal; - valType Radius2 = gtx::pow2(Radius); - valType Fx2 = gtx::pow2(F.x); - valType Fy2 = gtx::pow2(F.y); +template +valType radialGradient( + glm::detail::tvec2 const & Center, + valType const & Radius, + glm::detail::tvec2 const & Focal, + glm::detail::tvec2 const & Position) +{ + glm::detail::tvec2 F = Focal - Center; + glm::detail::tvec2 D = Position - Focal; + valType Radius2 = gtx::pow2(Radius); + valType Fx2 = gtx::pow2(F.x); + 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 Denominator = Radius2 - (Fx2 + Fy2); - return Numerator / Denominator; - } + 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); + return Numerator / Denominator; +} - template - valType linearGradient( - glm::detail::tvec2 const & Point0, - glm::detail::tvec2 const & Point1, - glm::detail::tvec2 const & Position) - { - glm::detail::tvec2 Dist = Point1 - Point0; - return (Dist.x * (Position.x - Point0.x) + Dist.y * (Position.y - Point0.y)) / glm::dot(Dist, Dist); - } +template +valType linearGradient( + glm::detail::tvec2 const & Point0, + glm::detail::tvec2 const & Point1, + glm::detail::tvec2 const & Position) +{ + glm::detail::tvec2 Dist = Point1 - Point0; + return (Dist.x * (Position.x - Point0.x) + Dist.y * (Position.y - Point0.y)) / glm::dot(Dist, Dist); +} -}//namespace gtx }//namespace glm diff --git a/glm/gtx/handed_coordinate_space.hpp b/glm/gtx/handed_coordinate_space.hpp index 42c67d1f..e46705aa 100644 --- a/glm/gtx/handed_coordinate_space.hpp +++ b/glm/gtx/handed_coordinate_space.hpp @@ -45,8 +45,7 @@ # pragma message("GLM: GLM_GTX_handed_coordinate_space extension included") #endif -namespace glm{ -namespace gtx +namespace glm { /// @addtogroup gtx_handed_coordinate_space /// @{ @@ -68,7 +67,6 @@ namespace gtx detail::tvec3 const & normal); /// @} -}// namespace gtx }// namespace glm #include "handed_coordinate_space.inl" diff --git a/glm/gtx/handed_coordinate_space.inl b/glm/gtx/handed_coordinate_space.inl index 6b6fcd0a..8e0dd597 100644 --- a/glm/gtx/handed_coordinate_space.inl +++ b/glm/gtx/handed_coordinate_space.inl @@ -8,25 +8,23 @@ /////////////////////////////////////////////////////////////////////////////////////////////////// namespace glm{ -namespace gtx + +template +GLM_FUNC_QUALIFIER bool rightHanded( + detail::tvec3 const & tangent, + detail::tvec3 const & binormal, + detail::tvec3 const & normal) { - template - GLM_FUNC_QUALIFIER bool rightHanded( - detail::tvec3 const & tangent, - detail::tvec3 const & binormal, - detail::tvec3 const & normal) - { - return dot(cross(normal, tangent), binormal) > T(0); - } + return dot(cross(normal, tangent), binormal) > T(0); +} - template - GLM_FUNC_QUALIFIER bool leftHanded( - detail::tvec3 const & tangent, - detail::tvec3 const & binormal, - detail::tvec3 const & normal) - { - return dot(cross(normal, tangent), binormal) < T(0); - } +template +GLM_FUNC_QUALIFIER bool leftHanded( + detail::tvec3 const & tangent, + detail::tvec3 const & binormal, + detail::tvec3 const & normal) +{ + return dot(cross(normal, tangent), binormal) < T(0); +} -}//namespace gtx }//namespace glm diff --git a/glm/gtx/inertia.hpp b/glm/gtx/inertia.hpp index a3bc6b97..2c193f6d 100644 --- a/glm/gtx/inertia.hpp +++ b/glm/gtx/inertia.hpp @@ -46,8 +46,7 @@ # pragma message("GLM: GLM_GTX_inertia extension included") #endif -namespace glm{ -namespace gtx +namespace glm { /// @addtogroup gtx_inertia /// @{ @@ -109,7 +108,6 @@ namespace gtx const T Radius); /// @} -}// namespace gtx }// namespace glm #include "inertia.inl" diff --git a/glm/gtx/inertia.inl b/glm/gtx/inertia.inl index b82cda7b..b82a40db 100644 --- a/glm/gtx/inertia.inl +++ b/glm/gtx/inertia.inl @@ -8,94 +8,92 @@ /////////////////////////////////////////////////////////////////////////////////////////////////// namespace glm{ -namespace gtx{ - template - GLM_FUNC_QUALIFIER detail::tmat3x3 boxInertia3( - const T Mass, - const detail::tvec3& Scale) - { - detail::tmat3x3 Result(T(1)); - 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[2][2] = (Scale.x * Scale.x + Scale.y * Scale.y) * Mass / T(12); - return Result; - } +template +GLM_FUNC_QUALIFIER detail::tmat3x3 boxInertia3( + const T Mass, + const detail::tvec3& Scale) +{ + detail::tmat3x3 Result(T(1)); + 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[2][2] = (Scale.x * Scale.x + Scale.y * Scale.y) * Mass / T(12); + return Result; +} - template - GLM_FUNC_QUALIFIER detail::tmat4x4 boxInertia4( - const T Mass, - const detail::tvec3& Scale) - { - detail::tmat4x4 Result(T(1)); - 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[2][2] = (Scale.x * Scale.x + Scale.y * Scale.y) * Mass / T(12); - return Result; - } +template +GLM_FUNC_QUALIFIER detail::tmat4x4 boxInertia4( + const T Mass, + const detail::tvec3& Scale) +{ + detail::tmat4x4 Result(T(1)); + 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[2][2] = (Scale.x * Scale.x + Scale.y * Scale.y) * Mass / T(12); + return Result; +} - template - GLM_FUNC_QUALIFIER detail::tmat3x3 diskInertia3( - const T Mass, - const T Radius) - { - T a = Mass * Radius * Radius / T(2); - detail::tmat3x3 Result(a); - Result[2][2] *= T(2); - return Result; - } +template +GLM_FUNC_QUALIFIER detail::tmat3x3 diskInertia3( + const T Mass, + const T Radius) +{ + T a = Mass * Radius * Radius / T(2); + detail::tmat3x3 Result(a); + Result[2][2] *= T(2); + return Result; +} - template - GLM_FUNC_QUALIFIER detail::tmat4x4 diskInertia4( - const T Mass, - const T Radius) - { - T a = Mass * Radius * Radius / T(2); - detail::tmat4x4 Result(a); - Result[2][2] *= T(2); - Result[3][3] = T(1); - return Result; - } +template +GLM_FUNC_QUALIFIER detail::tmat4x4 diskInertia4( + const T Mass, + const T Radius) +{ + T a = Mass * Radius * Radius / T(2); + detail::tmat4x4 Result(a); + Result[2][2] *= T(2); + Result[3][3] = T(1); + return Result; +} - template - GLM_FUNC_QUALIFIER detail::tmat3x3 ballInertia3( - const T Mass, - const T Radius) - { - T a = T(2) * Mass * Radius * Radius / T(5); - return detail::tmat3x3(a); - } +template +GLM_FUNC_QUALIFIER detail::tmat3x3 ballInertia3( + const T Mass, + const T Radius) +{ + T a = T(2) * Mass * Radius * Radius / T(5); + return detail::tmat3x3(a); +} - template - GLM_FUNC_QUALIFIER detail::tmat4x4 ballInertia4( - const T Mass, - const T Radius) - { - T a = T(2) * Mass * Radius * Radius / T(5); - detail::tmat4x4 Result(a); - Result[3][3] = T(1); - return Result; - } +template +GLM_FUNC_QUALIFIER detail::tmat4x4 ballInertia4( + const T Mass, + const T Radius) +{ + T a = T(2) * Mass * Radius * Radius / T(5); + detail::tmat4x4 Result(a); + Result[3][3] = T(1); + return Result; +} - template - GLM_FUNC_QUALIFIER detail::tmat3x3 sphereInertia3( - const T Mass, - const T Radius) - { - T a = T(2) * Mass * Radius * Radius / T(3); - return detail::tmat3x3(a); - } +template +GLM_FUNC_QUALIFIER detail::tmat3x3 sphereInertia3( + const T Mass, + const T Radius) +{ + T a = T(2) * Mass * Radius * Radius / T(3); + return detail::tmat3x3(a); +} - template - GLM_FUNC_QUALIFIER detail::tmat4x4 sphereInertia4( - const T Mass, - const T Radius) - { - T a = T(2) * Mass * Radius * Radius / T(3); - detail::tmat4x4 Result(a); - Result[3][3] = T(1); - return Result; - } +template +GLM_FUNC_QUALIFIER detail::tmat4x4 sphereInertia4( + const T Mass, + const T Radius) +{ + T a = T(2) * Mass * Radius * Radius / T(3); + detail::tmat4x4 Result(a); + Result[3][3] = T(1); + return Result; +} -}//namespace gtx }//namespace glm diff --git a/glm/gtx/int_10_10_10_2.hpp b/glm/gtx/int_10_10_10_2.hpp index db578525..c20ba56c 100644 --- a/glm/gtx/int_10_10_10_2.hpp +++ b/glm/gtx/int_10_10_10_2.hpp @@ -47,8 +47,7 @@ # pragma message("GLM: GLM_GTX_int_10_10_10_2 extension included") #endif -namespace glm{ -namespace gtx +namespace glm { /// @addtogroup gtx_int_10_10_10_2 /// @{ @@ -58,7 +57,6 @@ namespace gtx dword uint10_10_10_2_cast(glm::vec4 const & v); /// @} -}//namespace gtx }//namespace glm #include "int_10_10_10_2.inl" diff --git a/glm/gtx/int_10_10_10_2.inl b/glm/gtx/int_10_10_10_2.inl index 6dad9683..83e15bcb 100644 --- a/glm/gtx/int_10_10_10_2.inl +++ b/glm/gtx/int_10_10_10_2.inl @@ -8,12 +8,10 @@ /////////////////////////////////////////////////////////////////////////////////////////////////// namespace glm{ -namespace gtx{ 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); } -}//namespace gtx }//namespace glm diff --git a/glm/gtx/integer.hpp b/glm/gtx/integer.hpp index 765ca1c1..59d22944 100644 --- a/glm/gtx/integer.hpp +++ b/glm/gtx/integer.hpp @@ -45,8 +45,7 @@ # pragma message("GLM: GLM_GTX_integer extension included") #endif -namespace glm{ -namespace gtx +namespace glm { /// @addtogroup gtx_integer /// @{ @@ -69,7 +68,6 @@ namespace gtx genType factorial(genType const & x); /// @} -}//namespace gtx }//namespace glm #include "integer.inl" diff --git a/glm/gtx/integer.inl b/glm/gtx/integer.inl index 0c971125..b70868cb 100644 --- a/glm/gtx/integer.inl +++ b/glm/gtx/integer.inl @@ -8,82 +8,80 @@ /////////////////////////////////////////////////////////////////////////////////////////////////// namespace glm{ -namespace gtx{ - // pow - GLM_FUNC_QUALIFIER int pow(int x, int y) +// pow +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) - return 1; - int result = x; - for(int i = 1; i < y; ++i) - result *= x; - return result; - } + CurrentAnswer = NextTrial; + NextTrial = (NextTrial + x / NextTrial) >> 1; + } while(NextTrial < CurrentAnswer); - // 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; + return CurrentAnswer; +} - int NextTrial = x >> 1; - int CurrentAnswer; +// mod +GLM_FUNC_QUALIFIER int mod(int x, int y) +{ + return x - y * (x / y); +} - do - { - CurrentAnswer = NextTrial; - NextTrial = (NextTrial + x / NextTrial) >> 1; - } while(NextTrial < CurrentAnswer); +// factorial (!12 max, integer only) +template +GLM_FUNC_QUALIFIER genType factorial(genType const & x) +{ + genType Temp = x; + genType Result; + for(Result = 1; Temp > 1; --Temp) + Result *= Temp; + return Result; +} - return CurrentAnswer; - } +template +GLM_FUNC_QUALIFIER detail::tvec2 factorial( + detail::tvec2 const & x) +{ + return detail::tvec2( + factorial(x.x), + factorial(x.y)); +} - // mod - GLM_FUNC_QUALIFIER int mod(int x, int y) - { - return x - y * (x / y); - } +template +GLM_FUNC_QUALIFIER detail::tvec3 factorial( + detail::tvec3 const & x) +{ + return detail::tvec3( + factorial(x.x), + factorial(x.y), + factorial(x.z)); +} - // factorial (!12 max, integer only) - template - GLM_FUNC_QUALIFIER genType factorial(genType const & x) - { - genType Temp = x; - genType Result; - for(Result = 1; Temp > 1; --Temp) - Result *= Temp; - return Result; - } +template +GLM_FUNC_QUALIFIER detail::tvec4 factorial( + detail::tvec4 const & x) +{ + return detail::tvec4( + factorial(x.x), + factorial(x.y), + factorial(x.z), + factorial(x.w)); +} - template - GLM_FUNC_QUALIFIER detail::tvec2 factorial( - detail::tvec2 const & x) - { - return detail::tvec2( - factorial(x.x), - factorial(x.y)); - } - - template - GLM_FUNC_QUALIFIER detail::tvec3 factorial( - detail::tvec3 const & x) - { - return detail::tvec3( - factorial(x.x), - factorial(x.y), - factorial(x.z)); - } - - template - GLM_FUNC_QUALIFIER detail::tvec4 factorial( - detail::tvec4 const & x) - { - return detail::tvec4( - factorial(x.x), - factorial(x.y), - factorial(x.z), - factorial(x.w)); - } - -}//namespace gtx }//namespace glm diff --git a/glm/gtx/intersect.hpp b/glm/gtx/intersect.hpp index c7bd443f..a21d6626 100644 --- a/glm/gtx/intersect.hpp +++ b/glm/gtx/intersect.hpp @@ -47,8 +47,7 @@ # pragma message("GLM: GLM_GTX_closest_point extension included") #endif -namespace glm{ -namespace gtx +namespace glm { /// @addtogroup gtx_intersect /// @{ @@ -86,7 +85,6 @@ namespace gtx genType & position, genType & normal); /// @} -}//namespace gtx }//namespace glm #include "intersect.inl" diff --git a/glm/gtx/intersect.inl b/glm/gtx/intersect.inl index c28e96bc..d616a0a3 100644 --- a/glm/gtx/intersect.inl +++ b/glm/gtx/intersect.inl @@ -11,7 +11,6 @@ #include namespace glm{ -namespace gtx{ template GLM_FUNC_QUALIFIER bool intersectRayTriangle @@ -195,5 +194,4 @@ GLM_FUNC_QUALIFIER bool intersectLineSphere return false; } -}//namespace gtx }//namespace glm diff --git a/glm/gtx/log_base.hpp b/glm/gtx/log_base.hpp index 7df6029d..4ec48bfd 100644 --- a/glm/gtx/log_base.hpp +++ b/glm/gtx/log_base.hpp @@ -45,8 +45,7 @@ # pragma message("GLM: GLM_GTX_log_base extension included") #endif -namespace glm{ -namespace gtx +namespace glm { /// @addtogroup gtx_log_base /// @{ @@ -59,7 +58,6 @@ namespace gtx genType const & base); /// @} -}//namespace gtx }//namespace glm #include "log_base.inl" diff --git a/glm/gtx/log_base.inl b/glm/gtx/log_base.inl index 678ab2d8..0389dfcf 100644 --- a/glm/gtx/log_base.inl +++ b/glm/gtx/log_base.inl @@ -8,7 +8,6 @@ /////////////////////////////////////////////////////////////////////////////////////////////////// namespace glm{ -namespace gtx{ template GLM_FUNC_QUALIFIER genType log( @@ -86,5 +85,4 @@ GLM_FUNC_QUALIFIER detail::tvec4 log( log(v.w, base.w)); } -}//namespace gtx }//namespace glm diff --git a/glm/gtx/matrix_cross_product.hpp b/glm/gtx/matrix_cross_product.hpp index 379b6dd9..d357b35e 100644 --- a/glm/gtx/matrix_cross_product.hpp +++ b/glm/gtx/matrix_cross_product.hpp @@ -46,8 +46,7 @@ # pragma message("GLM: GLM_GTX_matrix_cross_product extension included") #endif -namespace glm{ -namespace gtx +namespace glm { /// @addtogroup gtx_matrix_cross_product /// @{ @@ -65,7 +64,6 @@ namespace gtx detail::tvec3 const & x); /// @} -}//namespace gtx }//namespace glm #include "matrix_cross_product.inl" diff --git a/glm/gtx/matrix_cross_product.inl b/glm/gtx/matrix_cross_product.inl index 9d24ee69..4132ba96 100644 --- a/glm/gtx/matrix_cross_product.inl +++ b/glm/gtx/matrix_cross_product.inl @@ -8,7 +8,6 @@ /////////////////////////////////////////////////////////////////////////////////////////////////// namespace glm{ -namespace gtx{ template GLM_FUNC_QUALIFIER detail::tmat3x3 matrixCross3( @@ -38,5 +37,4 @@ GLM_FUNC_QUALIFIER detail::tmat4x4 matrixCross4( return Result; } -}//namespace gtx }//namespace glm diff --git a/glm/gtx/matrix_interpolation.hpp b/glm/gtx/matrix_interpolation.hpp index 25c6438d..5d497dec 100644 --- a/glm/gtx/matrix_interpolation.hpp +++ b/glm/gtx/matrix_interpolation.hpp @@ -45,8 +45,7 @@ # pragma message("GLM: GLM_GTX_matrix_interpolation extension included") #endif -namespace glm{ -namespace gtx +namespace glm { /// @addtogroup gtx_matrix_interpolation /// @{ @@ -76,7 +75,6 @@ namespace gtx T const delta); /// @} -}//namespace gtx }//namespace glm #include "matrix_interpolation.inl" diff --git a/glm/gtx/matrix_interpolation.inl b/glm/gtx/matrix_interpolation.inl index bab33409..224f61cf 100644 --- a/glm/gtx/matrix_interpolation.inl +++ b/glm/gtx/matrix_interpolation.inl @@ -8,108 +8,106 @@ /////////////////////////////////////////////////////////////////////////////////////////////////// namespace glm{ -namespace gtx{ - template - GLM_FUNC_QUALIFIER void axisAngle( - detail::tmat4x4 const & mat, - detail::tvec3 & axis, - T & angle) - { - T epsilon = (T)0.01; - T epsilon2 = (T)0.1; +template +GLM_FUNC_QUALIFIER void axisAngle( + detail::tmat4x4 const & mat, + detail::tvec3 & axis, + T & angle) +{ + T epsilon = (T)0.01; + 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]) < 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; - axis.x = (T)1.0; - axis.y = (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; - } - } + 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)) { + angle = (T)0.0; + axis.x = (T)1.0; + axis.y = (T)0.0; + axis.z = (T)0.0; 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; + 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; } + 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 - GLM_FUNC_QUALIFIER detail::tmat4x4 axisAngleMatrix( - detail::tvec3 const & axis, - T const angle) - { - T c = cos(angle); - T s = sin(angle); - T t = T(1) - c; - detail::tvec3 n = normalize(axis); +template +GLM_FUNC_QUALIFIER detail::tmat4x4 axisAngleMatrix( + detail::tvec3 const & axis, + T const angle) +{ + T c = cos(angle); + T s = sin(angle); + T t = T(1) - c; + detail::tvec3 n = normalize(axis); - return detail::tmat4x4( - 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.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) - ); - } + return detail::tmat4x4( + 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.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) + ); +} - template - GLM_FUNC_QUALIFIER detail::tmat4x4 interpolate( - detail::tmat4x4 const & m1, - detail::tmat4x4 const & m2, - T const delta) - { - detail::tmat4x4 dltRotation = m2 * transpose(m1); - detail::tvec3 dltAxis; - T dltAngle; - axisAngle(dltRotation, dltAxis, dltAngle); - detail::tmat4x4 out = axisAngleMatrix(dltAxis, dltAngle * delta) * rotationMatrix(m1); - 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][2] = m1[3][2] + delta * (m2[3][2] - m1[3][2]); - return out; - } +template +GLM_FUNC_QUALIFIER detail::tmat4x4 interpolate( + detail::tmat4x4 const & m1, + detail::tmat4x4 const & m2, + T const delta) +{ + detail::tmat4x4 dltRotation = m2 * transpose(m1); + detail::tvec3 dltAxis; + T dltAngle; + axisAngle(dltRotation, dltAxis, dltAngle); + detail::tmat4x4 out = axisAngleMatrix(dltAxis, dltAngle * delta) * rotationMatrix(m1); + 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][2] = m1[3][2] + delta * (m2[3][2] - m1[3][2]); + return out; +} -}//namespace gtx }//namespace glm diff --git a/glm/gtx/matrix_major_storage.hpp b/glm/gtx/matrix_major_storage.hpp index 9c0b8967..06454aec 100644 --- a/glm/gtx/matrix_major_storage.hpp +++ b/glm/gtx/matrix_major_storage.hpp @@ -46,10 +46,9 @@ # pragma message("GLM: GLM_GTX_matrix_major_storage extension included") #endif -namespace glm{ -namespace gtx +namespace glm { - /// \addtogroup gtx_matrix_major_storage + /// @addtogroup gtx_matrix_major_storage /// @{ //! Build a row major matrix from row vectors. @@ -137,7 +136,6 @@ namespace gtx const detail::tmat4x4& m); /// @} -}//namespace gtx }//namespace glm #include "matrix_major_storage.inl" diff --git a/glm/gtx/matrix_major_storage.inl b/glm/gtx/matrix_major_storage.inl index 60ce6014..3a028de1 100644 --- a/glm/gtx/matrix_major_storage.inl +++ b/glm/gtx/matrix_major_storage.inl @@ -8,167 +8,165 @@ /////////////////////////////////////////////////////////////////////////////////////////////////// namespace glm{ -namespace gtx{ - template - GLM_FUNC_QUALIFIER detail::tmat2x2 rowMajor2( - const detail::tvec2& v1, - const detail::tvec2& v2) - { - detail::tmat2x2 Result; - Result[0][0] = v1.x; - Result[1][0] = v1.y; - Result[0][1] = v2.x; - Result[1][1] = v2.y; - return Result; - } +template +GLM_FUNC_QUALIFIER detail::tmat2x2 rowMajor2( + const detail::tvec2& v1, + const detail::tvec2& v2) +{ + detail::tmat2x2 Result; + Result[0][0] = v1.x; + Result[1][0] = v1.y; + Result[0][1] = v2.x; + Result[1][1] = v2.y; + return Result; +} - template - GLM_FUNC_QUALIFIER detail::tmat2x2 rowMajor2( - const detail::tmat2x2& m) - { - detail::tmat2x2 Result; - Result[0][0] = m[0][0]; - Result[0][1] = m[1][0]; - Result[1][0] = m[0][1]; - Result[1][1] = m[1][1]; - return Result; - } +template +GLM_FUNC_QUALIFIER detail::tmat2x2 rowMajor2( + const detail::tmat2x2& m) +{ + detail::tmat2x2 Result; + Result[0][0] = m[0][0]; + Result[0][1] = m[1][0]; + Result[1][0] = m[0][1]; + Result[1][1] = m[1][1]; + return Result; +} - template - GLM_FUNC_QUALIFIER detail::tmat3x3 rowMajor3( - const detail::tvec3& v1, - const detail::tvec3& v2, - const detail::tvec3& v3) - { - detail::tmat3x3 Result; - Result[0][0] = v1.x; - Result[1][0] = v1.y; - Result[2][0] = v1.z; - Result[0][1] = v2.x; - Result[1][1] = v2.y; - Result[2][1] = v2.z; - Result[0][2] = v3.x; - Result[1][2] = v3.y; - Result[2][2] = v3.z; - return Result; - } +template +GLM_FUNC_QUALIFIER detail::tmat3x3 rowMajor3( + const detail::tvec3& v1, + const detail::tvec3& v2, + const detail::tvec3& v3) +{ + detail::tmat3x3 Result; + Result[0][0] = v1.x; + Result[1][0] = v1.y; + Result[2][0] = v1.z; + Result[0][1] = v2.x; + Result[1][1] = v2.y; + Result[2][1] = v2.z; + Result[0][2] = v3.x; + Result[1][2] = v3.y; + Result[2][2] = v3.z; + return Result; +} - template - GLM_FUNC_QUALIFIER detail::tmat3x3 rowMajor3( - const detail::tmat3x3& m) - { - detail::tmat3x3 Result; - Result[0][0] = m[0][0]; - Result[0][1] = m[1][0]; - Result[0][2] = m[2][0]; - Result[1][0] = m[0][1]; - Result[1][1] = m[1][1]; - Result[1][2] = m[2][1]; - Result[2][0] = m[0][2]; - Result[2][1] = m[1][2]; - Result[2][2] = m[2][2]; - return Result; - } +template +GLM_FUNC_QUALIFIER detail::tmat3x3 rowMajor3( + const detail::tmat3x3& m) +{ + detail::tmat3x3 Result; + Result[0][0] = m[0][0]; + Result[0][1] = m[1][0]; + Result[0][2] = m[2][0]; + Result[1][0] = m[0][1]; + Result[1][1] = m[1][1]; + Result[1][2] = m[2][1]; + Result[2][0] = m[0][2]; + Result[2][1] = m[1][2]; + Result[2][2] = m[2][2]; + return Result; +} - template - GLM_FUNC_QUALIFIER detail::tmat4x4 rowMajor4( - const detail::tvec4& v1, - const detail::tvec4& v2, - const detail::tvec4& v3, - const detail::tvec4& v4) - { - detail::tmat4x4 Result; - Result[0][0] = v1.x; - Result[1][0] = v1.y; - Result[2][0] = v1.z; - Result[3][0] = v1.w; - Result[0][1] = v2.x; - Result[1][1] = v2.y; - Result[2][1] = v2.z; - Result[3][1] = v2.w; - Result[0][2] = v3.x; - Result[1][2] = v3.y; - Result[2][2] = v3.z; - Result[3][2] = v3.w; - Result[0][3] = v4.x; - Result[1][3] = v4.y; - Result[2][3] = v4.z; - Result[3][3] = v4.w; - return Result; - } +template +GLM_FUNC_QUALIFIER detail::tmat4x4 rowMajor4( + const detail::tvec4& v1, + const detail::tvec4& v2, + const detail::tvec4& v3, + const detail::tvec4& v4) +{ + detail::tmat4x4 Result; + Result[0][0] = v1.x; + Result[1][0] = v1.y; + Result[2][0] = v1.z; + Result[3][0] = v1.w; + Result[0][1] = v2.x; + Result[1][1] = v2.y; + Result[2][1] = v2.z; + Result[3][1] = v2.w; + Result[0][2] = v3.x; + Result[1][2] = v3.y; + Result[2][2] = v3.z; + Result[3][2] = v3.w; + Result[0][3] = v4.x; + Result[1][3] = v4.y; + Result[2][3] = v4.z; + Result[3][3] = v4.w; + return Result; +} - template - GLM_FUNC_QUALIFIER detail::tmat4x4 rowMajor4( - const detail::tmat4x4& m) - { - detail::tmat4x4 Result; - Result[0][0] = m[0][0]; - Result[0][1] = m[1][0]; - Result[0][2] = m[2][0]; - Result[0][3] = m[3][0]; - Result[1][0] = m[0][1]; - Result[1][1] = m[1][1]; - Result[1][2] = m[2][1]; - Result[1][3] = m[3][1]; - Result[2][0] = m[0][2]; - Result[2][1] = m[1][2]; - Result[2][2] = m[2][2]; - Result[2][3] = m[3][2]; - Result[3][0] = m[0][3]; - Result[3][1] = m[1][3]; - Result[3][2] = m[2][3]; - Result[3][3] = m[3][3]; - return Result; - } +template +GLM_FUNC_QUALIFIER detail::tmat4x4 rowMajor4( + const detail::tmat4x4& m) +{ + detail::tmat4x4 Result; + Result[0][0] = m[0][0]; + Result[0][1] = m[1][0]; + Result[0][2] = m[2][0]; + Result[0][3] = m[3][0]; + Result[1][0] = m[0][1]; + Result[1][1] = m[1][1]; + Result[1][2] = m[2][1]; + Result[1][3] = m[3][1]; + Result[2][0] = m[0][2]; + Result[2][1] = m[1][2]; + Result[2][2] = m[2][2]; + Result[2][3] = m[3][2]; + Result[3][0] = m[0][3]; + Result[3][1] = m[1][3]; + Result[3][2] = m[2][3]; + Result[3][3] = m[3][3]; + return Result; +} - template - GLM_FUNC_QUALIFIER detail::tmat2x2 colMajor2( - const detail::tvec2& v1, - const detail::tvec2& v2) - { - return detail::tmat2x2(v1, v2); - } +template +GLM_FUNC_QUALIFIER detail::tmat2x2 colMajor2( + const detail::tvec2& v1, + const detail::tvec2& v2) +{ + return detail::tmat2x2(v1, v2); +} - template - GLM_FUNC_QUALIFIER detail::tmat2x2 colMajor2( - const detail::tmat2x2& m) - { - return detail::tmat2x2(m); - } +template +GLM_FUNC_QUALIFIER detail::tmat2x2 colMajor2( + const detail::tmat2x2& m) +{ + return detail::tmat2x2(m); +} - template - GLM_FUNC_QUALIFIER detail::tmat3x3 colMajor3( - const detail::tvec3& v1, - const detail::tvec3& v2, - const detail::tvec3& v3) - { - return detail::tmat3x3(v1, v2, v3); - } +template +GLM_FUNC_QUALIFIER detail::tmat3x3 colMajor3( + const detail::tvec3& v1, + const detail::tvec3& v2, + const detail::tvec3& v3) +{ + return detail::tmat3x3(v1, v2, v3); +} - template - GLM_FUNC_QUALIFIER detail::tmat3x3 colMajor3( - const detail::tmat3x3& m) - { - return detail::tmat3x3(m); - } +template +GLM_FUNC_QUALIFIER detail::tmat3x3 colMajor3( + const detail::tmat3x3& m) +{ + return detail::tmat3x3(m); +} - template - GLM_FUNC_QUALIFIER detail::tmat4x4 colMajor4( - const detail::tvec4& v1, - const detail::tvec4& v2, - const detail::tvec4& v3, - const detail::tvec4& v4) - { - return detail::tmat4x4(v1, v2, v3, v4); - } +template +GLM_FUNC_QUALIFIER detail::tmat4x4 colMajor4( + const detail::tvec4& v1, + const detail::tvec4& v2, + const detail::tvec4& v3, + const detail::tvec4& v4) +{ + return detail::tmat4x4(v1, v2, v3, v4); +} - template - GLM_FUNC_QUALIFIER detail::tmat4x4 colMajor4( - const detail::tmat4x4& m) - { - return detail::tmat4x4(m); - } +template +GLM_FUNC_QUALIFIER detail::tmat4x4 colMajor4( + const detail::tmat4x4& m) +{ + return detail::tmat4x4(m); +} -}//namespace gtx }//namespace glm diff --git a/glm/gtx/matrix_operation.hpp b/glm/gtx/matrix_operation.hpp index 39708d50..893598a7 100644 --- a/glm/gtx/matrix_operation.hpp +++ b/glm/gtx/matrix_operation.hpp @@ -45,10 +45,9 @@ # pragma message("GLM: GLM_GTX_matrix_operation extension included") #endif -namespace glm{ -namespace gtx +namespace glm { - /// \addtogroup gtx_matrix_operation + /// @addtogroup gtx_matrix_operation /// @{ //! Build a diagonal matrix. @@ -106,7 +105,6 @@ namespace gtx detail::tvec4 const & v); /// @} -}//namespace gtx }//namespace glm #include "matrix_operation.inl" diff --git a/glm/gtx/matrix_operation.inl b/glm/gtx/matrix_operation.inl index 74a8eb0e..6bd39fb0 100644 --- a/glm/gtx/matrix_operation.inl +++ b/glm/gtx/matrix_operation.inl @@ -8,120 +8,118 @@ /////////////////////////////////////////////////////////////////////////////////////////////////// namespace glm{ -namespace gtx{ - template - GLM_FUNC_QUALIFIER detail::tmat2x2 diagonal2x2 - ( - detail::tvec2 const & v - ) - { - detail::tmat2x2 Result(valType(1)); - Result[0][0] = v[0]; - Result[1][1] = v[1]; - return Result; - } +template +GLM_FUNC_QUALIFIER detail::tmat2x2 diagonal2x2 +( + detail::tvec2 const & v +) +{ + detail::tmat2x2 Result(valType(1)); + Result[0][0] = v[0]; + Result[1][1] = v[1]; + return Result; +} - template - GLM_FUNC_QUALIFIER detail::tmat2x3 diagonal2x3 - ( - detail::tvec2 const & v - ) - { - detail::tmat2x3 Result(valType(1)); - Result[0][0] = v[0]; - Result[1][1] = v[1]; - return Result; - } +template +GLM_FUNC_QUALIFIER detail::tmat2x3 diagonal2x3 +( + detail::tvec2 const & v +) +{ + detail::tmat2x3 Result(valType(1)); + Result[0][0] = v[0]; + Result[1][1] = v[1]; + return Result; +} - template - GLM_FUNC_QUALIFIER detail::tmat2x4 diagonal2x4 - ( - detail::tvec2 const & v - ) - { - detail::tmat2x4 Result(valType(1)); - Result[0][0] = v[0]; - Result[1][1] = v[1]; - return Result; - } +template +GLM_FUNC_QUALIFIER detail::tmat2x4 diagonal2x4 +( + detail::tvec2 const & v +) +{ + detail::tmat2x4 Result(valType(1)); + Result[0][0] = v[0]; + Result[1][1] = v[1]; + return Result; +} - template - GLM_FUNC_QUALIFIER detail::tmat3x2 diagonal3x2 - ( - detail::tvec2 const & v - ) - { - detail::tmat3x2 Result(valType(1)); - Result[0][0] = v[0]; - Result[1][1] = v[1]; - return Result; - } +template +GLM_FUNC_QUALIFIER detail::tmat3x2 diagonal3x2 +( + detail::tvec2 const & v +) +{ + detail::tmat3x2 Result(valType(1)); + Result[0][0] = v[0]; + Result[1][1] = v[1]; + return Result; +} - template - GLM_FUNC_QUALIFIER detail::tmat3x3 diagonal3x3 - ( - detail::tvec3 const & v - ) - { - detail::tmat3x3 Result(valType(1)); - Result[0][0] = v[0]; - Result[1][1] = v[1]; - Result[2][2] = v[2]; - return Result; - } +template +GLM_FUNC_QUALIFIER detail::tmat3x3 diagonal3x3 +( + detail::tvec3 const & v +) +{ + detail::tmat3x3 Result(valType(1)); + Result[0][0] = v[0]; + Result[1][1] = v[1]; + Result[2][2] = v[2]; + return Result; +} - template - GLM_FUNC_QUALIFIER detail::tmat3x4 diagonal3x4 - ( - detail::tvec3 const & v - ) - { - detail::tmat3x4 Result(valType(1)); - Result[0][0] = v[0]; - Result[1][1] = v[1]; - Result[2][2] = v[2]; - return Result; - } +template +GLM_FUNC_QUALIFIER detail::tmat3x4 diagonal3x4 +( + detail::tvec3 const & v +) +{ + detail::tmat3x4 Result(valType(1)); + Result[0][0] = v[0]; + Result[1][1] = v[1]; + Result[2][2] = v[2]; + return Result; +} - template - GLM_FUNC_QUALIFIER detail::tmat4x4 diagonal4x4 - ( - detail::tvec4 const & v - ) - { - detail::tmat4x4 Result(valType(1)); - Result[0][0] = v[0]; - Result[1][1] = v[1]; - Result[2][2] = v[2]; - Result[3][3] = v[3]; - return Result; - } +template +GLM_FUNC_QUALIFIER detail::tmat4x4 diagonal4x4 +( + detail::tvec4 const & v +) +{ + detail::tmat4x4 Result(valType(1)); + Result[0][0] = v[0]; + Result[1][1] = v[1]; + Result[2][2] = v[2]; + Result[3][3] = v[3]; + return Result; +} - template - GLM_FUNC_QUALIFIER detail::tmat4x3 diagonal4x3 - ( - detail::tvec3 const & v - ) - { - detail::tmat4x3 Result(valType(1)); - Result[0][0] = v[0]; - Result[1][1] = v[1]; - Result[2][2] = v[2]; - return Result; - } +template +GLM_FUNC_QUALIFIER detail::tmat4x3 diagonal4x3 +( + detail::tvec3 const & v +) +{ + detail::tmat4x3 Result(valType(1)); + Result[0][0] = v[0]; + Result[1][1] = v[1]; + Result[2][2] = v[2]; + return Result; +} - template - GLM_FUNC_QUALIFIER detail::tmat4x2 diagonal4x2 - ( - detail::tvec2 const & v - ) - { - detail::tmat4x2 Result(valType(1)); - Result[0][0] = v[0]; - Result[1][1] = v[1]; - return Result; - } +template +GLM_FUNC_QUALIFIER detail::tmat4x2 diagonal4x2 +( + detail::tvec2 const & v +) +{ + detail::tmat4x2 Result(valType(1)); + Result[0][0] = v[0]; + Result[1][1] = v[1]; + return Result; +} -}//namespace gtx }//namespace glm diff --git a/glm/gtx/matrix_query.hpp b/glm/gtx/matrix_query.hpp index fa48f1d1..aa68b284 100644 --- a/glm/gtx/matrix_query.hpp +++ b/glm/gtx/matrix_query.hpp @@ -46,8 +46,7 @@ # pragma message("GLM: GLM_GTX_matrix_query extension included") #endif -namespace glm{ -namespace gtx +namespace glm { /// @addtogroup gtx_matrix_query /// @{ @@ -109,7 +108,6 @@ namespace gtx const typename genType::value_type epsilon = std::numeric_limits::epsilon()); /// @} -}//namespace gtx }//namespace glm #include "matrix_query.inl" diff --git a/glm/gtx/matrix_query.inl b/glm/gtx/matrix_query.inl index 79939920..14762949 100644 --- a/glm/gtx/matrix_query.inl +++ b/glm/gtx/matrix_query.inl @@ -11,132 +11,130 @@ /////////////////////////////////////////////////////////////////////////////////////////////////// namespace glm{ -namespace gtx + +template +GLM_FUNC_QUALIFIER bool isNull( + const detail::tmat2x2& m, + const T epsilon) { - template - GLM_FUNC_QUALIFIER bool isNull( - const detail::tmat2x2& m, - const T epsilon) - { - bool result = true; - for(int i = 0; result && i < 2 ; ++i) - result = isNull(m[i], epsilon); - return result; - } + bool result = true; + for(int i = 0; result && i < 2 ; ++i) + result = isNull(m[i], epsilon); + return result; +} - template - GLM_FUNC_QUALIFIER bool isNull( - const detail::tmat3x3& m, - const T epsilon) - { - bool result = true; - for(int i = 0; result && i < 3 ; ++i) - result = isNull(m[i], epsilon); - return result; - } +template +GLM_FUNC_QUALIFIER bool isNull( + const detail::tmat3x3& m, + const T epsilon) +{ + bool result = true; + for(int i = 0; result && i < 3 ; ++i) + result = isNull(m[i], epsilon); + return result; +} - template - GLM_FUNC_QUALIFIER bool isNull( - const detail::tmat4x4& m, - const T epsilon) - { - bool result = true; - for(int i = 0; result && i < 4 ; ++i) - result = isNull(m[i], epsilon); - return result; - } +template +GLM_FUNC_QUALIFIER bool isNull( + const detail::tmat4x4& m, + const T epsilon) +{ + bool result = true; + for(int i = 0; result && i < 4 ; ++i) + result = isNull(m[i], epsilon); + return result; +} - template - GLM_FUNC_QUALIFIER bool isIdentity( - const genType& m, - const typename genType::value_type epsilon) +template +GLM_FUNC_QUALIFIER bool isIdentity( + const genType& m, + 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 i = typename genType::value_type(0); result && i < genType::col_size(); ++i) - { - 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 - GLM_FUNC_QUALIFIER bool isNormalized( - const detail::tmat2x2& 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 v; - for(int j = 0; j < 2; ++j) - v[j] = m[j][i]; - result = isNormalized(v, epsilon); - } - return result; - } - - template - GLM_FUNC_QUALIFIER bool isNormalized( - const detail::tmat3x3& 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 v; - for(int j = 0; j < 3; ++j) - v[j] = m[j][i]; - result = isNormalized(v, epsilon); - } - return result; - } - - template - GLM_FUNC_QUALIFIER bool isNormalized( - const detail::tmat4x4& 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 v; - for(int j = 0; j < 4; ++j) - v[j] = m[j][i]; - result = isNormalized(v, epsilon); - } - return result; - } - - template - 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); - + for(typename genType::value_type j = typename genType::value_type(0); result && j < i ; ++j) + result = abs(m[i][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; + 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 +GLM_FUNC_QUALIFIER bool isNormalized( + const detail::tmat2x2& 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 v; + for(int j = 0; j < 2; ++j) + v[j] = m[j][i]; + result = isNormalized(v, epsilon); + } + return result; +} + +template +GLM_FUNC_QUALIFIER bool isNormalized( + const detail::tmat3x3& 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 v; + for(int j = 0; j < 3; ++j) + v[j] = m[j][i]; + result = isNormalized(v, epsilon); + } + return result; +} + +template +GLM_FUNC_QUALIFIER bool isNormalized( + const detail::tmat4x4& 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 v; + for(int j = 0; j < 4; ++j) + v[j] = m[j][i]; + result = isNormalized(v, epsilon); + } + return result; +} + +template +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 diff --git a/glm/gtx/mixed_product.hpp b/glm/gtx/mixed_product.hpp index ab36a703..62928255 100644 --- a/glm/gtx/mixed_product.hpp +++ b/glm/gtx/mixed_product.hpp @@ -45,8 +45,7 @@ # pragma message("GLM: GLM_GTX_mixed_product extension included") #endif -namespace glm{ -namespace gtx +namespace glm { /// @addtogroup gtx_mixed_product /// @{ @@ -59,7 +58,6 @@ namespace gtx detail::tvec3 const & v3); /// @} -}// namespace gtx }// namespace glm #include "mixed_product.inl" diff --git a/glm/gtx/mixed_product.inl b/glm/gtx/mixed_product.inl index 1062b95f..1129f597 100644 --- a/glm/gtx/mixed_product.inl +++ b/glm/gtx/mixed_product.inl @@ -8,7 +8,6 @@ /////////////////////////////////////////////////////////////////////////////////////////////////// namespace glm{ -namespace gtx{ template GLM_FUNC_QUALIFIER valType mixedProduct( @@ -19,14 +18,4 @@ GLM_FUNC_QUALIFIER valType mixedProduct( return dot(cross(v1, v2), v3); } -}//namespace gtx }//namespace glm - - - - - - - - - diff --git a/glm/gtx/multiple.hpp b/glm/gtx/multiple.hpp index 404f8906..f8298d2e 100644 --- a/glm/gtx/multiple.hpp +++ b/glm/gtx/multiple.hpp @@ -46,8 +46,7 @@ # pragma message("GLM: GLM_GTX_multiple extension included") #endif -namespace glm{ -namespace gtx +namespace glm { /// @addtogroup gtx_multiple /// @{ @@ -67,7 +66,6 @@ namespace gtx genType const & Multiple); /// @} -}//namespace gtx }//namespace glm #include "multiple.inl" diff --git a/glm/gtx/multiple.inl b/glm/gtx/multiple.inl index 2a482d0e..72d9f4a1 100644 --- a/glm/gtx/multiple.inl +++ b/glm/gtx/multiple.inl @@ -11,179 +11,177 @@ /////////////////////////////////////////////////////////////////////////////////////////////////// namespace glm{ -namespace gtx + +////////////////////// +// higherMultiple + +template +GLM_FUNC_QUALIFIER genType higherMultiple +( + genType const & Source, + genType const & Multiple +) { - ////////////////////// - // higherMultiple + genType Tmp = Source % Multiple; + return Tmp ? Source + Multiple - Tmp : Source; +} - template - GLM_FUNC_QUALIFIER genType higherMultiple - ( - genType const & Source, - genType const & Multiple - ) - { - genType Tmp = Source % Multiple; - return Tmp ? Source + Multiple - Tmp : Source; - } +template <> +GLM_FUNC_QUALIFIER detail::thalf higherMultiple +( + detail::thalf const & Source, + detail::thalf const & Multiple +) +{ + int Tmp = int(float(Source)) % int(float(Multiple)); + return Tmp ? Source + Multiple - detail::thalf(float(Tmp)) : Source; +} - template <> - GLM_FUNC_QUALIFIER detail::thalf higherMultiple - ( - detail::thalf const & Source, - detail::thalf const & Multiple - ) - { - int Tmp = int(float(Source)) % int(float(Multiple)); - return Tmp ? Source + Multiple - detail::thalf(float(Tmp)) : Source; - } +template <> +GLM_FUNC_QUALIFIER float higherMultiple +( + float const & Source, + float const & Multiple +) +{ + int Tmp = int(Source) % int(Multiple); + return Tmp ? Source + Multiple - float(Tmp) : Source; +} - template <> - GLM_FUNC_QUALIFIER float higherMultiple - ( - float const & Source, - float const & Multiple - ) - { - int Tmp = int(Source) % int(Multiple); - return Tmp ? Source + Multiple - float(Tmp) : Source; - } +template <> +GLM_FUNC_QUALIFIER double higherMultiple +( + double const & Source, + double const & Multiple +) +{ + long Tmp = long(Source) % long(Multiple); + return Tmp ? Source + Multiple - double(Tmp) : Source; +} - template <> - GLM_FUNC_QUALIFIER double higherMultiple - ( - double const & Source, - double const & Multiple - ) - { - long Tmp = long(Source) % long(Multiple); - return Tmp ? Source + Multiple - double(Tmp) : Source; - } +template +GLM_FUNC_QUALIFIER detail::tvec2 higherMultiple +( + detail::tvec2 const & Source, + detail::tvec2 const & Multiple +) +{ + detail::tvec2 Result; + for(typename detail::tvec2::size_type i = 0; i < detail::tvec2::value_size(); ++i) + Result[i] = higherMultiple(Source[i], Multiple[i]); + return Result; +} - template - GLM_FUNC_QUALIFIER detail::tvec2 higherMultiple - ( - detail::tvec2 const & Source, - detail::tvec2 const & Multiple - ) - { - detail::tvec2 Result; - for(typename detail::tvec2::size_type i = 0; i < detail::tvec2::value_size(); ++i) - Result[i] = higherMultiple(Source[i], Multiple[i]); - return Result; - } +template +GLM_FUNC_QUALIFIER detail::tvec3 higherMultiple +( + detail::tvec3 const & Source, + detail::tvec3 const & Multiple +) +{ + detail::tvec3 Result; + for(typename detail::tvec3::size_type i = 0; i < detail::tvec3::value_size(); ++i) + Result[i] = higherMultiple(Source[i], Multiple[i]); + return Result; +} - template - GLM_FUNC_QUALIFIER detail::tvec3 higherMultiple - ( - detail::tvec3 const & Source, - detail::tvec3 const & Multiple - ) - { - detail::tvec3 Result; - for(typename detail::tvec3::size_type i = 0; i < detail::tvec3::value_size(); ++i) - Result[i] = higherMultiple(Source[i], Multiple[i]); - return Result; - } +template +GLM_FUNC_QUALIFIER detail::tvec4 higherMultiple +( + detail::tvec4 const & Source, + detail::tvec4 const & Multiple +) +{ + detail::tvec4 Result; + for(typename detail::tvec4::size_type i = 0; i < detail::tvec4::value_size(); ++i) + Result[i] = higherMultiple(Source[i], Multiple[i]); + return Result; +} - template - GLM_FUNC_QUALIFIER detail::tvec4 higherMultiple - ( - detail::tvec4 const & Source, - detail::tvec4 const & Multiple - ) - { - detail::tvec4 Result; - for(typename detail::tvec4::size_type i = 0; i < detail::tvec4::value_size(); ++i) - Result[i] = higherMultiple(Source[i], Multiple[i]); - return Result; - } +////////////////////// +// lowerMultiple - ////////////////////// - // lowerMultiple +template +GLM_FUNC_QUALIFIER genType lowerMultiple +( + genType const & Source, + genType const & Multiple +) +{ + genType Tmp = Source % Multiple; + return Tmp ? Source - Tmp : Source; +} - template - GLM_FUNC_QUALIFIER genType lowerMultiple - ( - genType const & Source, - genType const & Multiple - ) - { - genType Tmp = Source % Multiple; - return Tmp ? Source - Tmp : Source; - } +template <> +GLM_FUNC_QUALIFIER detail::thalf lowerMultiple +( + detail::thalf const & Source, + detail::thalf const & Multiple +) +{ + int Tmp = int(float(Source)) % int(float(Multiple)); + return Tmp ? Source - detail::thalf(float(Tmp)) : Source; +} - template <> - GLM_FUNC_QUALIFIER detail::thalf lowerMultiple - ( - detail::thalf const & Source, - detail::thalf const & Multiple - ) - { - int Tmp = int(float(Source)) % int(float(Multiple)); - return Tmp ? Source - detail::thalf(float(Tmp)) : Source; - } +template <> +GLM_FUNC_QUALIFIER float lowerMultiple +( + float const & Source, + float const & Multiple +) +{ + int Tmp = int(Source) % int(Multiple); + return Tmp ? Source - float(Tmp) : Source; +} - template <> - GLM_FUNC_QUALIFIER float lowerMultiple - ( - float const & Source, - float const & Multiple - ) - { - int Tmp = int(Source) % int(Multiple); - return Tmp ? Source - float(Tmp) : Source; - } +template <> +GLM_FUNC_QUALIFIER double lowerMultiple +( + double const & Source, + double const & Multiple +) +{ + long Tmp = long(Source) % long(Multiple); + return Tmp ? Source - double(Tmp) : Source; +} - template <> - GLM_FUNC_QUALIFIER double lowerMultiple - ( - double const & Source, - double const & Multiple - ) - { - long Tmp = long(Source) % long(Multiple); - return Tmp ? Source - double(Tmp) : Source; - } +template +GLM_FUNC_QUALIFIER detail::tvec2 lowerMultiple +( + detail::tvec2 const & Source, + detail::tvec2 const & Multiple +) +{ + detail::tvec2 Result; + for(typename detail::tvec2::size_type i = 0; i < detail::tvec2::value_size(); ++i) + Result[i] = lowerMultiple(Source[i], Multiple[i]); + return Result; +} - template - GLM_FUNC_QUALIFIER detail::tvec2 lowerMultiple - ( - detail::tvec2 const & Source, - detail::tvec2 const & Multiple - ) - { - detail::tvec2 Result; - for(typename detail::tvec2::size_type i = 0; i < detail::tvec2::value_size(); ++i) - Result[i] = lowerMultiple(Source[i], Multiple[i]); - return Result; - } +template +GLM_FUNC_QUALIFIER detail::tvec3 lowerMultiple +( + detail::tvec3 const & Source, + detail::tvec3 const & Multiple +) +{ + detail::tvec3 Result; + for(typename detail::tvec3::size_type i = 0; i < detail::tvec3::value_size(); ++i) + Result[i] = lowerMultiple(Source[i], Multiple[i]); + return Result; +} - template - GLM_FUNC_QUALIFIER detail::tvec3 lowerMultiple - ( - detail::tvec3 const & Source, - detail::tvec3 const & Multiple - ) - { - detail::tvec3 Result; - for(typename detail::tvec3::size_type i = 0; i < detail::tvec3::value_size(); ++i) - Result[i] = lowerMultiple(Source[i], Multiple[i]); - return Result; - } +template +GLM_FUNC_QUALIFIER detail::tvec4 lowerMultiple +( + detail::tvec4 const & Source, + detail::tvec4 const & Multiple +) +{ + detail::tvec4 Result; + for(typename detail::tvec4::size_type i = 0; i < detail::tvec4::value_size(); ++i) + Result[i] = lowerMultiple(Source[i], Multiple[i]); + return Result; +} - template - GLM_FUNC_QUALIFIER detail::tvec4 lowerMultiple - ( - detail::tvec4 const & Source, - detail::tvec4 const & Multiple - ) - { - detail::tvec4 Result; - for(typename detail::tvec4::size_type i = 0; i < detail::tvec4::value_size(); ++i) - Result[i] = lowerMultiple(Source[i], Multiple[i]); - return Result; - } - -}//namespace gtx }//namespace glm diff --git a/glm/gtx/noise.hpp b/glm/gtx/noise.hpp index 1625bb0a..0152ea46 100644 --- a/glm/gtx/noise.hpp +++ b/glm/gtx/noise.hpp @@ -49,8 +49,7 @@ # pragma message("GLM: GLM_GTX_noise extension included") #endif -namespace glm{ -namespace gtx +namespace glm { /// @addtogroup gtx_noise /// @{ @@ -75,7 +74,6 @@ namespace gtx vecType const & p); /// @} -}//namespace gtx }//namespace glm #include "noise.inl" diff --git a/glm/gtx/noise.inl b/glm/gtx/noise.inl index f8383106..ae8e03c2 100644 --- a/glm/gtx/noise.inl +++ b/glm/gtx/noise.inl @@ -16,774 +16,772 @@ /////////////////////////////////////////////////////////////////////////////////////////////////// namespace glm{ -namespace gtx{ - template - GLM_FUNC_QUALIFIER T permute(T const & x) - { - return mod(((x * T(34)) + T(1)) * x, T(289)); - } +template +GLM_FUNC_QUALIFIER T permute(T const & x) +{ + return mod(((x * T(34)) + T(1)) * x, T(289)); +} - template class vecType> - GLM_FUNC_QUALIFIER vecType permute(vecType const & x) - { - return mod(((x * T(34)) + T(1)) * x, T(289)); - } +template class vecType> +GLM_FUNC_QUALIFIER vecType permute(vecType const & x) +{ + return mod(((x * T(34)) + T(1)) * x, T(289)); +} - template - GLM_FUNC_QUALIFIER T taylorInvSqrt(T const & r) - { - return T(1.79284291400159) - T(0.85373472095314) * r; - } - - template class vecType> - GLM_FUNC_QUALIFIER vecType taylorInvSqrt(vecType const & r) - { - return T(1.79284291400159) - T(0.85373472095314) * r; - } - - template class vecType> - GLM_FUNC_QUALIFIER vecType fade(vecType const & t) - { - return t * t * t * (t * (t * T(6) - T(15)) + T(10)); - } - - template - GLM_FUNC_QUALIFIER detail::tvec4 grad4(T const & j, detail::tvec4 const & ip) - { - detail::tvec3 pXYZ = floor(fract(detail::tvec3(j) * detail::tvec3(ip)) * T(7)) * ip[2] - T(1); - T pW = T(1.5) - dot(abs(pXYZ), detail::tvec3(1)); - detail::tvec4 s = detail::tvec4(lessThan(detail::tvec4(pXYZ, pW), detail::tvec4(0.0))); - pXYZ = pXYZ + (detail::tvec3(s) * T(2) - T(1)) * s.w; - return detail::tvec4(pXYZ, pW); - } - - // Classic Perlin noise - template - GLM_FUNC_QUALIFIER T perlin(detail::tvec2 const & P) - { - detail::tvec4 Pi = floor(detail::tvec4(P.x, P.y, P.x, P.y)) + detail::tvec4(0.0, 0.0, 1.0, 1.0); - detail::tvec4 Pf = fract(detail::tvec4(P.x, P.y, P.x, P.y)) - detail::tvec4(0.0, 0.0, 1.0, 1.0); - Pi = mod(Pi, T(289)); // To avoid truncation effects in permutation - detail::tvec4 ix(Pi.x, Pi.z, Pi.x, Pi.z); - detail::tvec4 iy(Pi.y, Pi.y, Pi.w, Pi.w); - detail::tvec4 fx(Pf.x, Pf.z, Pf.x, Pf.z); - detail::tvec4 fy(Pf.y, Pf.y, Pf.w, Pf.w); - - detail::tvec4 i = permute(permute(ix) + iy); - - detail::tvec4 gx = T(2) * fract(i / T(41)) - T(1); - detail::tvec4 gy = abs(gx) - T(0.5); - detail::tvec4 tx = floor(gx + T(0.5)); - gx = gx - tx; - - detail::tvec2 g00(gx.x, gy.x); - detail::tvec2 g10(gx.y, gy.y); - detail::tvec2 g01(gx.z, gy.z); - detail::tvec2 g11(gx.w, gy.w); - - detail::tvec4 norm = taylorInvSqrt(detail::tvec4(dot(g00, g00), dot(g01, g01), dot(g10, g10), dot(g11, g11))); - g00 *= norm.x; - g01 *= norm.y; - g10 *= norm.z; - g11 *= norm.w; - - T n00 = dot(g00, detail::tvec2(fx.x, fy.x)); - T n10 = dot(g10, detail::tvec2(fx.y, fy.y)); - T n01 = dot(g01, detail::tvec2(fx.z, fy.z)); - T n11 = dot(g11, detail::tvec2(fx.w, fy.w)); - - detail::tvec2 fade_xy = fade(detail::tvec2(Pf.x, Pf.y)); - detail::tvec2 n_x = mix(detail::tvec2(n00, n01), detail::tvec2(n10, n11), fade_xy.x); - T n_xy = mix(n_x.x, n_x.y, fade_xy.y); - return T(2.3) * n_xy; - } - - // Classic Perlin noise - template - GLM_FUNC_QUALIFIER T perlin(detail::tvec3 const & P) - { - detail::tvec3 Pi0 = floor(P); // Integer part for indexing - detail::tvec3 Pi1 = Pi0 + T(1); // Integer part + 1 - Pi0 = mod(Pi0, T(289)); - Pi1 = mod(Pi1, T(289)); - detail::tvec3 Pf0 = fract(P); // Fractional part for interpolation - detail::tvec3 Pf1 = Pf0 - T(1); // Fractional part - 1.0 - detail::tvec4 ix(Pi0.x, Pi1.x, Pi0.x, Pi1.x); - detail::tvec4 iy(Pi0.y, Pi0.y, Pi1.y, Pi1.y); - detail::tvec4 iz0(Pi0.z); - detail::tvec4 iz1(Pi1.z); - - detail::tvec4 ixy = permute(permute(ix) + iy); - detail::tvec4 ixy0 = permute(ixy + iz0); - detail::tvec4 ixy1 = permute(ixy + iz1); - - detail::tvec4 gx0 = ixy0 / T(7); - detail::tvec4 gy0 = fract(floor(gx0) / T(7)) - T(0.5); - gx0 = fract(gx0); - detail::tvec4 gz0 = detail::tvec4(0.5) - abs(gx0) - abs(gy0); - detail::tvec4 sz0 = step(gz0, detail::tvec4(0.0)); - gx0 -= sz0 * (step(0.0, gx0) - T(0.5)); - gy0 -= sz0 * (step(0.0, gy0) - T(0.5)); - - detail::tvec4 gx1 = ixy1 / T(7); - detail::tvec4 gy1 = fract(floor(gx1) / T(7)) - T(0.5); - gx1 = fract(gx1); - detail::tvec4 gz1 = detail::tvec4(0.5) - abs(gx1) - abs(gy1); - detail::tvec4 sz1 = step(gz1, detail::tvec4(0.0)); - gx1 -= sz1 * (step(T(0), gx1) - T(0.5)); - gy1 -= sz1 * (step(T(0), gy1) - T(0.5)); - - detail::tvec3 g000(gx0.x, gy0.x, gz0.x); - detail::tvec3 g100(gx0.y, gy0.y, gz0.y); - detail::tvec3 g010(gx0.z, gy0.z, gz0.z); - detail::tvec3 g110(gx0.w, gy0.w, gz0.w); - detail::tvec3 g001(gx1.x, gy1.x, gz1.x); - detail::tvec3 g101(gx1.y, gy1.y, gz1.y); - detail::tvec3 g011(gx1.z, gy1.z, gz1.z); - detail::tvec3 g111(gx1.w, gy1.w, gz1.w); - - detail::tvec4 norm0 = taylorInvSqrt(detail::tvec4(dot(g000, g000), dot(g010, g010), dot(g100, g100), dot(g110, g110))); - g000 *= norm0.x; - g010 *= norm0.y; - g100 *= norm0.z; - g110 *= norm0.w; - detail::tvec4 norm1 = taylorInvSqrt(detail::tvec4(dot(g001, g001), dot(g011, g011), dot(g101, g101), dot(g111, g111))); - g001 *= norm1.x; - g011 *= norm1.y; - g101 *= norm1.z; - g111 *= norm1.w; - - T n000 = dot(g000, Pf0); - T n100 = dot(g100, detail::tvec3(Pf1.x, Pf0.y, Pf0.z)); - T n010 = dot(g010, detail::tvec3(Pf0.x, Pf1.y, Pf0.z)); - T n110 = dot(g110, detail::tvec3(Pf1.x, Pf1.y, Pf0.z)); - T n001 = dot(g001, detail::tvec3(Pf0.x, Pf0.y, Pf1.z)); - T n101 = dot(g101, detail::tvec3(Pf1.x, Pf0.y, Pf1.z)); - T n011 = dot(g011, detail::tvec3(Pf0.x, Pf1.y, Pf1.z)); - T n111 = dot(g111, Pf1); - - detail::tvec3 fade_xyz = fade(Pf0); - detail::tvec4 n_z = mix(detail::tvec4(n000, n100, n010, n110), detail::tvec4(n001, n101, n011, n111), fade_xyz.z); - detail::tvec2 n_yz = mix( - detail::tvec2(n_z.x, n_z.y), - detail::tvec2(n_z.z, n_z.w), fade_xyz.y); - T n_xyz = mix(n_yz.x, n_yz.y, fade_xyz.x); - return T(2.2) * n_xyz; - } - - // Classic Perlin noise - template - GLM_FUNC_QUALIFIER T perlin(detail::tvec4 const & P) - { - detail::tvec4 Pi0 = floor(P); // Integer part for indexing - detail::tvec4 Pi1 = Pi0 + T(1); // Integer part + 1 - Pi0 = mod(Pi0, T(289)); - Pi1 = mod(Pi1, T(289)); - detail::tvec4 Pf0 = fract(P); // Fractional part for interpolation - detail::tvec4 Pf1 = Pf0 - T(1); // Fractional part - 1.0 - detail::tvec4 ix(Pi0.x, Pi1.x, Pi0.x, Pi1.x); - detail::tvec4 iy(Pi0.y, Pi0.y, Pi1.y, Pi1.y); - detail::tvec4 iz0(Pi0.z); - detail::tvec4 iz1(Pi1.z); - detail::tvec4 iw0(Pi0.w); - detail::tvec4 iw1(Pi1.w); - - detail::tvec4 ixy = permute(permute(ix) + iy); - detail::tvec4 ixy0 = permute(ixy + iz0); - detail::tvec4 ixy1 = permute(ixy + iz1); - detail::tvec4 ixy00 = permute(ixy0 + iw0); - detail::tvec4 ixy01 = permute(ixy0 + iw1); - detail::tvec4 ixy10 = permute(ixy1 + iw0); - detail::tvec4 ixy11 = permute(ixy1 + iw1); - - detail::tvec4 gx00 = ixy00 / T(7); - detail::tvec4 gy00 = floor(gx00) / T(7); - detail::tvec4 gz00 = floor(gy00) / T(6); - gx00 = fract(gx00) - T(0.5); - gy00 = fract(gy00) - T(0.5); - gz00 = fract(gz00) - T(0.5); - detail::tvec4 gw00 = detail::tvec4(0.75) - abs(gx00) - abs(gy00) - abs(gz00); - detail::tvec4 sw00 = step(gw00, detail::tvec4(0.0)); - gx00 -= sw00 * (step(T(0), gx00) - T(0.5)); - gy00 -= sw00 * (step(T(0), gy00) - T(0.5)); - - detail::tvec4 gx01 = ixy01 / T(7); - detail::tvec4 gy01 = floor(gx01) / T(7); - detail::tvec4 gz01 = floor(gy01) / T(6); - gx01 = fract(gx01) - T(0.5); - gy01 = fract(gy01) - T(0.5); - gz01 = fract(gz01) - T(0.5); - detail::tvec4 gw01 = detail::tvec4(0.75) - abs(gx01) - abs(gy01) - abs(gz01); - detail::tvec4 sw01 = step(gw01, detail::tvec4(0.0)); - gx01 -= sw01 * (step(T(0), gx01) - T(0.5)); - gy01 -= sw01 * (step(T(0), gy01) - T(0.5)); - - detail::tvec4 gx10 = ixy10 / T(7); - detail::tvec4 gy10 = floor(gx10) / T(7); - detail::tvec4 gz10 = floor(gy10) / T(6); - gx10 = fract(gx10) - T(0.5); - gy10 = fract(gy10) - T(0.5); - gz10 = fract(gz10) - T(0.5); - detail::tvec4 gw10 = detail::tvec4(0.75) - abs(gx10) - abs(gy10) - abs(gz10); - detail::tvec4 sw10 = step(gw10, detail::tvec4(0)); - gx10 -= sw10 * (step(T(0), gx10) - T(0.5)); - gy10 -= sw10 * (step(T(0), gy10) - T(0.5)); - - detail::tvec4 gx11 = ixy11 / T(7); - detail::tvec4 gy11 = floor(gx11) / T(7); - detail::tvec4 gz11 = floor(gy11) / T(6); - gx11 = fract(gx11) - T(0.5); - gy11 = fract(gy11) - T(0.5); - gz11 = fract(gz11) - T(0.5); - detail::tvec4 gw11 = detail::tvec4(0.75) - abs(gx11) - abs(gy11) - abs(gz11); - detail::tvec4 sw11 = step(gw11, detail::tvec4(0.0)); - gx11 -= sw11 * (step(T(0), gx11) - T(0.5)); - gy11 -= sw11 * (step(T(0), gy11) - T(0.5)); - - detail::tvec4 g0000(gx00.x, gy00.x, gz00.x, gw00.x); - detail::tvec4 g1000(gx00.y, gy00.y, gz00.y, gw00.y); - detail::tvec4 g0100(gx00.z, gy00.z, gz00.z, gw00.z); - detail::tvec4 g1100(gx00.w, gy00.w, gz00.w, gw00.w); - detail::tvec4 g0010(gx10.x, gy10.x, gz10.x, gw10.x); - detail::tvec4 g1010(gx10.y, gy10.y, gz10.y, gw10.y); - detail::tvec4 g0110(gx10.z, gy10.z, gz10.z, gw10.z); - detail::tvec4 g1110(gx10.w, gy10.w, gz10.w, gw10.w); - detail::tvec4 g0001(gx01.x, gy01.x, gz01.x, gw01.x); - detail::tvec4 g1001(gx01.y, gy01.y, gz01.y, gw01.y); - detail::tvec4 g0101(gx01.z, gy01.z, gz01.z, gw01.z); - detail::tvec4 g1101(gx01.w, gy01.w, gz01.w, gw01.w); - detail::tvec4 g0011(gx11.x, gy11.x, gz11.x, gw11.x); - detail::tvec4 g1011(gx11.y, gy11.y, gz11.y, gw11.y); - detail::tvec4 g0111(gx11.z, gy11.z, gz11.z, gw11.z); - detail::tvec4 g1111(gx11.w, gy11.w, gz11.w, gw11.w); - - detail::tvec4 norm00 = taylorInvSqrt(detail::tvec4(dot(g0000, g0000), dot(g0100, g0100), dot(g1000, g1000), dot(g1100, g1100))); - g0000 *= norm00.x; - g0100 *= norm00.y; - g1000 *= norm00.z; - g1100 *= norm00.w; - - detail::tvec4 norm01 = taylorInvSqrt(detail::tvec4(dot(g0001, g0001), dot(g0101, g0101), dot(g1001, g1001), dot(g1101, g1101))); - g0001 *= norm01.x; - g0101 *= norm01.y; - g1001 *= norm01.z; - g1101 *= norm01.w; - - detail::tvec4 norm10 = taylorInvSqrt(detail::tvec4(dot(g0010, g0010), dot(g0110, g0110), dot(g1010, g1010), dot(g1110, g1110))); - g0010 *= norm10.x; - g0110 *= norm10.y; - g1010 *= norm10.z; - g1110 *= norm10.w; - - detail::tvec4 norm11 = taylorInvSqrt(detail::tvec4(dot(g0011, g0011), dot(g0111, g0111), dot(g1011, g1011), dot(g1111, g1111))); - g0011 *= norm11.x; - g0111 *= norm11.y; - g1011 *= norm11.z; - g1111 *= norm11.w; - - T n0000 = dot(g0000, Pf0); - T n1000 = dot(g1000, detail::tvec4(Pf1.x, Pf0.y, Pf0.z, Pf0.w)); - T n0100 = dot(g0100, detail::tvec4(Pf0.x, Pf1.y, Pf0.z, Pf0.w)); - T n1100 = dot(g1100, detail::tvec4(Pf1.x, Pf1.y, Pf0.z, Pf0.w)); - T n0010 = dot(g0010, detail::tvec4(Pf0.x, Pf0.y, Pf1.z, Pf0.w)); - T n1010 = dot(g1010, detail::tvec4(Pf1.x, Pf0.y, Pf1.z, Pf0.w)); - T n0110 = dot(g0110, detail::tvec4(Pf0.x, Pf1.y, Pf1.z, Pf0.w)); - T n1110 = dot(g1110, detail::tvec4(Pf1.x, Pf1.y, Pf1.z, Pf0.w)); - T n0001 = dot(g0001, detail::tvec4(Pf0.x, Pf0.y, Pf0.z, Pf1.w)); - T n1001 = dot(g1001, detail::tvec4(Pf1.x, Pf0.y, Pf0.z, Pf1.w)); - T n0101 = dot(g0101, detail::tvec4(Pf0.x, Pf1.y, Pf0.z, Pf1.w)); - T n1101 = dot(g1101, detail::tvec4(Pf1.x, Pf1.y, Pf0.z, Pf1.w)); - T n0011 = dot(g0011, detail::tvec4(Pf0.x, Pf0.y, Pf1.z, Pf1.w)); - T n1011 = dot(g1011, detail::tvec4(Pf1.x, Pf0.y, Pf1.z, Pf1.w)); - T n0111 = dot(g0111, detail::tvec4(Pf0.x, Pf1.y, Pf1.z, Pf1.w)); - T n1111 = dot(g1111, Pf1); - - detail::tvec4 fade_xyzw = fade(Pf0); - detail::tvec4 n_0w = mix(detail::tvec4(n0000, n1000, n0100, n1100), detail::tvec4(n0001, n1001, n0101, n1101), fade_xyzw.w); - detail::tvec4 n_1w = mix(detail::tvec4(n0010, n1010, n0110, n1110), detail::tvec4(n0011, n1011, n0111, n1111), fade_xyzw.w); - detail::tvec4 n_zw = mix(n_0w, n_1w, fade_xyzw.z); - detail::tvec2 n_yzw = mix(detail::tvec2(n_zw.x, n_zw.y), detail::tvec2(n_zw.z, n_zw.w), fade_xyzw.y); - T n_xyzw = mix(n_yzw.x, n_yzw.y, fade_xyzw.x); - return T(2.2) * n_xyzw; - } - - // Classic Perlin noise, periodic variant - template - GLM_FUNC_QUALIFIER T perlin(detail::tvec2 const & P, detail::tvec2 const & rep) - { - detail::tvec4 Pi = floor(detail::tvec4(P.x, P.y, P.x, P.y)) + detail::tvec4(0.0, 0.0, 1.0, 1.0); - detail::tvec4 Pf = fract(detail::tvec4(P.x, P.y, P.x, P.y)) - detail::tvec4(0.0, 0.0, 1.0, 1.0); - Pi = mod(Pi, detail::tvec4(rep.x, rep.y, rep.x, rep.y)); // To create noise with explicit period - Pi = mod(Pi, T(289)); // To avoid truncation effects in permutation - detail::tvec4 ix(Pi.x, Pi.z, Pi.x, Pi.z); - detail::tvec4 iy(Pi.y, Pi.y, Pi.w, Pi.w); - detail::tvec4 fx(Pf.x, Pf.z, Pf.x, Pf.z); - detail::tvec4 fy(Pf.y, Pf.y, Pf.w, Pf.w); - - detail::tvec4 i = permute(permute(ix) + iy); - - detail::tvec4 gx = T(2) * fract(i / T(41)) - T(1); - detail::tvec4 gy = abs(gx) - T(0.5); - detail::tvec4 tx = floor(gx + T(0.5)); - gx = gx - tx; - - detail::tvec2 g00(gx.x, gy.x); - detail::tvec2 g10(gx.y, gy.y); - detail::tvec2 g01(gx.z, gy.z); - detail::tvec2 g11(gx.w, gy.w); - - detail::tvec4 norm = taylorInvSqrt(detail::tvec4(dot(g00, g00), dot(g01, g01), dot(g10, g10), dot(g11, g11))); - g00 *= norm.x; - g01 *= norm.y; - g10 *= norm.z; - g11 *= norm.w; - - T n00 = dot(g00, detail::tvec2(fx.x, fy.x)); - T n10 = dot(g10, detail::tvec2(fx.y, fy.y)); - T n01 = dot(g01, detail::tvec2(fx.z, fy.z)); - T n11 = dot(g11, detail::tvec2(fx.w, fy.w)); - - detail::tvec2 fade_xy = fade(detail::tvec2(Pf.x, Pf.y)); - detail::tvec2 n_x = mix(detail::tvec2(n00, n01), detail::tvec2(n10, n11), fade_xy.x); - T n_xy = mix(n_x.x, n_x.y, fade_xy.y); - return T(2.3) * n_xy; - } - - // Classic Perlin noise, periodic variant - template - GLM_FUNC_QUALIFIER T perlin(detail::tvec3 const & P, detail::tvec3 const & rep) - { - detail::tvec3 Pi0 = mod(floor(P), rep); // Integer part, modulo period - detail::tvec3 Pi1 = mod(Pi0 + detail::tvec3(1.0), rep); // Integer part + 1, mod period - Pi0 = mod(Pi0, T(289)); - Pi1 = mod(Pi1, T(289)); - detail::tvec3 Pf0 = fract(P); // Fractional part for interpolation - detail::tvec3 Pf1 = Pf0 - detail::tvec3(1.0); // Fractional part - 1.0 - detail::tvec4 ix = detail::tvec4(Pi0.x, Pi1.x, Pi0.x, Pi1.x); - detail::tvec4 iy = detail::tvec4(Pi0.y, Pi0.y, Pi1.y, Pi1.y); - detail::tvec4 iz0(Pi0.z); - detail::tvec4 iz1(Pi1.z); - - detail::tvec4 ixy = permute(permute(ix) + iy); - detail::tvec4 ixy0 = permute(ixy + iz0); - detail::tvec4 ixy1 = permute(ixy + iz1); - - detail::tvec4 gx0 = ixy0 / T(7); - detail::tvec4 gy0 = fract(floor(gx0) / T(7)) - T(0.5); - gx0 = fract(gx0); - detail::tvec4 gz0 = detail::tvec4(0.5) - abs(gx0) - abs(gy0); - detail::tvec4 sz0 = step(gz0, detail::tvec4(0)); - gx0 -= sz0 * (step(0.0, gx0) - T(0.5)); - gy0 -= sz0 * (step(0.0, gy0) - T(0.5)); - - detail::tvec4 gx1 = ixy1 / T(7); - detail::tvec4 gy1 = fract(floor(gx1) / T(7)) - T(0.5); - gx1 = fract(gx1); - detail::tvec4 gz1 = detail::tvec4(0.5) - abs(gx1) - abs(gy1); - detail::tvec4 sz1 = step(gz1, detail::tvec4(0.0)); - gx1 -= sz1 * (step(0.0, gx1) - T(0.5)); - gy1 -= sz1 * (step(0.0, gy1) - T(0.5)); - - detail::tvec3 g000 = detail::tvec3(gx0.x, gy0.x, gz0.x); - detail::tvec3 g100 = detail::tvec3(gx0.y, gy0.y, gz0.y); - detail::tvec3 g010 = detail::tvec3(gx0.z, gy0.z, gz0.z); - detail::tvec3 g110 = detail::tvec3(gx0.w, gy0.w, gz0.w); - detail::tvec3 g001 = detail::tvec3(gx1.x, gy1.x, gz1.x); - detail::tvec3 g101 = detail::tvec3(gx1.y, gy1.y, gz1.y); - detail::tvec3 g011 = detail::tvec3(gx1.z, gy1.z, gz1.z); - detail::tvec3 g111 = detail::tvec3(gx1.w, gy1.w, gz1.w); - - detail::tvec4 norm0 = taylorInvSqrt(detail::tvec4(dot(g000, g000), dot(g010, g010), dot(g100, g100), dot(g110, g110))); - g000 *= norm0.x; - g010 *= norm0.y; - g100 *= norm0.z; - g110 *= norm0.w; - detail::tvec4 norm1 = taylorInvSqrt(detail::tvec4(dot(g001, g001), dot(g011, g011), dot(g101, g101), dot(g111, g111))); - g001 *= norm1.x; - g011 *= norm1.y; - g101 *= norm1.z; - g111 *= norm1.w; - - T n000 = dot(g000, Pf0); - T n100 = dot(g100, detail::tvec3(Pf1.x, Pf0.y, Pf0.z)); - T n010 = dot(g010, detail::tvec3(Pf0.x, Pf1.y, Pf0.z)); - T n110 = dot(g110, detail::tvec3(Pf1.x, Pf1.y, Pf0.z)); - T n001 = dot(g001, detail::tvec3(Pf0.x, Pf0.y, Pf1.z)); - T n101 = dot(g101, detail::tvec3(Pf1.x, Pf0.y, Pf1.z)); - T n011 = dot(g011, detail::tvec3(Pf0.x, Pf1.y, Pf1.z)); - T n111 = dot(g111, Pf1); - - detail::tvec3 fade_xyz = fade(Pf0); - detail::tvec4 n_z = mix(detail::tvec4(n000, n100, n010, n110), detail::tvec4(n001, n101, n011, n111), fade_xyz.z); - detail::tvec2 n_yz = mix(detail::tvec2(n_z.x, n_z.y), detail::tvec2(n_z.z, n_z.w), fade_xyz.y); - T n_xyz = mix(n_yz.x, n_yz.y, fade_xyz.x); - return T(2.2) * n_xyz; - } - - // Classic Perlin noise, periodic version - template - GLM_FUNC_QUALIFIER T perlin(detail::tvec4 const & P, detail::tvec4 const & rep) - { - detail::tvec4 Pi0 = mod(floor(P), rep); // Integer part modulo rep - detail::tvec4 Pi1 = mod(Pi0 + T(1), rep); // Integer part + 1 mod rep - detail::tvec4 Pf0 = fract(P); // Fractional part for interpolation - detail::tvec4 Pf1 = Pf0 - T(1); // Fractional part - 1.0 - detail::tvec4 ix = detail::tvec4(Pi0.x, Pi1.x, Pi0.x, Pi1.x); - detail::tvec4 iy = detail::tvec4(Pi0.y, Pi0.y, Pi1.y, Pi1.y); - detail::tvec4 iz0(Pi0.z); - detail::tvec4 iz1(Pi1.z); - detail::tvec4 iw0(Pi0.w); - detail::tvec4 iw1(Pi1.w); - - detail::tvec4 ixy = permute(permute(ix) + iy); - detail::tvec4 ixy0 = permute(ixy + iz0); - detail::tvec4 ixy1 = permute(ixy + iz1); - detail::tvec4 ixy00 = permute(ixy0 + iw0); - detail::tvec4 ixy01 = permute(ixy0 + iw1); - detail::tvec4 ixy10 = permute(ixy1 + iw0); - detail::tvec4 ixy11 = permute(ixy1 + iw1); - - detail::tvec4 gx00 = ixy00 / T(7); - detail::tvec4 gy00 = floor(gx00) / T(7); - detail::tvec4 gz00 = floor(gy00) / T(6); - gx00 = fract(gx00) - T(0.5); - gy00 = fract(gy00) - T(0.5); - gz00 = fract(gz00) - T(0.5); - detail::tvec4 gw00 = detail::tvec4(0.75) - abs(gx00) - abs(gy00) - abs(gz00); - detail::tvec4 sw00 = step(gw00, detail::tvec4(0)); - gx00 -= sw00 * (step(0.0, gx00) - T(0.5)); - gy00 -= sw00 * (step(0.0, gy00) - T(0.5)); - - detail::tvec4 gx01 = ixy01 / T(7); - detail::tvec4 gy01 = floor(gx01) / T(7); - detail::tvec4 gz01 = floor(gy01) / T(6); - gx01 = fract(gx01) - T(0.5); - gy01 = fract(gy01) - T(0.5); - gz01 = fract(gz01) - T(0.5); - detail::tvec4 gw01 = detail::tvec4(0.75) - abs(gx01) - abs(gy01) - abs(gz01); - detail::tvec4 sw01 = step(gw01, detail::tvec4(0.0)); - gx01 -= sw01 * (step(0.0, gx01) - T(0.5)); - gy01 -= sw01 * (step(0.0, gy01) - T(0.5)); - - detail::tvec4 gx10 = ixy10 / T(7); - detail::tvec4 gy10 = floor(gx10) / T(7); - detail::tvec4 gz10 = floor(gy10) / T(6); - gx10 = fract(gx10) - T(0.5); - gy10 = fract(gy10) - T(0.5); - gz10 = fract(gz10) - T(0.5); - detail::tvec4 gw10 = detail::tvec4(0.75) - abs(gx10) - abs(gy10) - abs(gz10); - detail::tvec4 sw10 = step(gw10, detail::tvec4(0.0)); - gx10 -= sw10 * (step(0.0, gx10) - T(0.5)); - gy10 -= sw10 * (step(0.0, gy10) - T(0.5)); - - detail::tvec4 gx11 = ixy11 / T(7); - detail::tvec4 gy11 = floor(gx11) / T(7); - detail::tvec4 gz11 = floor(gy11) / T(6); - gx11 = fract(gx11) - T(0.5); - gy11 = fract(gy11) - T(0.5); - gz11 = fract(gz11) - T(0.5); - detail::tvec4 gw11 = detail::tvec4(0.75) - abs(gx11) - abs(gy11) - abs(gz11); - detail::tvec4 sw11 = step(gw11, detail::tvec4(0.0)); - gx11 -= sw11 * (step(0.0, gx11) - T(0.5)); - gy11 -= sw11 * (step(0.0, gy11) - T(0.5)); - - detail::tvec4 g0000(gx00.x, gy00.x, gz00.x, gw00.x); - detail::tvec4 g1000(gx00.y, gy00.y, gz00.y, gw00.y); - detail::tvec4 g0100(gx00.z, gy00.z, gz00.z, gw00.z); - detail::tvec4 g1100(gx00.w, gy00.w, gz00.w, gw00.w); - detail::tvec4 g0010(gx10.x, gy10.x, gz10.x, gw10.x); - detail::tvec4 g1010(gx10.y, gy10.y, gz10.y, gw10.y); - detail::tvec4 g0110(gx10.z, gy10.z, gz10.z, gw10.z); - detail::tvec4 g1110(gx10.w, gy10.w, gz10.w, gw10.w); - detail::tvec4 g0001(gx01.x, gy01.x, gz01.x, gw01.x); - detail::tvec4 g1001(gx01.y, gy01.y, gz01.y, gw01.y); - detail::tvec4 g0101(gx01.z, gy01.z, gz01.z, gw01.z); - detail::tvec4 g1101(gx01.w, gy01.w, gz01.w, gw01.w); - detail::tvec4 g0011(gx11.x, gy11.x, gz11.x, gw11.x); - detail::tvec4 g1011(gx11.y, gy11.y, gz11.y, gw11.y); - detail::tvec4 g0111(gx11.z, gy11.z, gz11.z, gw11.z); - detail::tvec4 g1111(gx11.w, gy11.w, gz11.w, gw11.w); - - detail::tvec4 norm00 = taylorInvSqrt(detail::tvec4(dot(g0000, g0000), dot(g0100, g0100), dot(g1000, g1000), dot(g1100, g1100))); - g0000 *= norm00.x; - g0100 *= norm00.y; - g1000 *= norm00.z; - g1100 *= norm00.w; - - detail::tvec4 norm01 = taylorInvSqrt(detail::tvec4(dot(g0001, g0001), dot(g0101, g0101), dot(g1001, g1001), dot(g1101, g1101))); - g0001 *= norm01.x; - g0101 *= norm01.y; - g1001 *= norm01.z; - g1101 *= norm01.w; - - detail::tvec4 norm10 = taylorInvSqrt(detail::tvec4(dot(g0010, g0010), dot(g0110, g0110), dot(g1010, g1010), dot(g1110, g1110))); - g0010 *= norm10.x; - g0110 *= norm10.y; - g1010 *= norm10.z; - g1110 *= norm10.w; - - detail::tvec4 norm11 = taylorInvSqrt(detail::tvec4(dot(g0011, g0011), dot(g0111, g0111), dot(g1011, g1011), dot(g1111, g1111))); - g0011 *= norm11.x; - g0111 *= norm11.y; - g1011 *= norm11.z; - g1111 *= norm11.w; - - T n0000 = dot(g0000, Pf0); - T n1000 = dot(g1000, detail::tvec4(Pf1.x, Pf0.y, Pf0.z, Pf0.w)); - T n0100 = dot(g0100, detail::tvec4(Pf0.x, Pf1.y, Pf0.z, Pf0.w)); - T n1100 = dot(g1100, detail::tvec4(Pf1.x, Pf1.y, Pf0.z, Pf0.w)); - T n0010 = dot(g0010, detail::tvec4(Pf0.x, Pf0.y, Pf1.z, Pf0.w)); - T n1010 = dot(g1010, detail::tvec4(Pf1.x, Pf0.y, Pf1.z, Pf0.w)); - T n0110 = dot(g0110, detail::tvec4(Pf0.x, Pf1.y, Pf1.z, Pf0.w)); - T n1110 = dot(g1110, detail::tvec4(Pf1.x, Pf1.y, Pf1.z, Pf0.w)); - T n0001 = dot(g0001, detail::tvec4(Pf0.x, Pf0.y, Pf0.z, Pf1.w)); - T n1001 = dot(g1001, detail::tvec4(Pf1.x, Pf0.y, Pf0.z, Pf1.w)); - T n0101 = dot(g0101, detail::tvec4(Pf0.x, Pf1.y, Pf0.z, Pf1.w)); - T n1101 = dot(g1101, detail::tvec4(Pf1.x, Pf1.y, Pf0.z, Pf1.w)); - T n0011 = dot(g0011, detail::tvec4(Pf0.x, Pf0.y, Pf1.z, Pf1.w)); - T n1011 = dot(g1011, detail::tvec4(Pf1.x, Pf0.y, Pf1.z, Pf1.w)); - T n0111 = dot(g0111, detail::tvec4(Pf0.x, Pf1.y, Pf1.z, Pf1.w)); - T n1111 = dot(g1111, Pf1); - - detail::tvec4 fade_xyzw = fade(Pf0); - detail::tvec4 n_0w = mix(detail::tvec4(n0000, n1000, n0100, n1100), detail::tvec4(n0001, n1001, n0101, n1101), fade_xyzw.w); - detail::tvec4 n_1w = mix(detail::tvec4(n0010, n1010, n0110, n1110), detail::tvec4(n0011, n1011, n0111, n1111), fade_xyzw.w); - detail::tvec4 n_zw = mix(n_0w, n_1w, fade_xyzw.z); - detail::tvec2 n_yzw = mix(detail::tvec2(n_zw.x, n_zw.y), detail::tvec2(n_zw.z, n_zw.w), fade_xyzw.y); - T n_xyzw = mix(n_yzw.x, n_yzw.y, fade_xyzw.x); - return T(2.2) * n_xyzw; - } - - template - GLM_FUNC_QUALIFIER T simplex(glm::detail::tvec2 const & v) - { - detail::tvec4 const C = detail::tvec4( - T( 0.211324865405187), // (3.0 - sqrt(3.0)) / 6.0 - T( 0.366025403784439), // 0.5 * (sqrt(3.0) - 1.0) - T(-0.577350269189626), // -1.0 + 2.0 * C.x - T( 0.024390243902439)); // 1.0 / 41.0 - - // First corner - detail::tvec2 i = floor(v + dot(v, detail::tvec2(C[1]))); - detail::tvec2 x0 = v - i + dot(i, detail::tvec2(C[0])); - - // Other corners - //i1.x = step( x0.y, x0.x ); // x0.x > x0.y ? 1.0 : 0.0 - //i1.y = 1.0 - i1.x; - detail::tvec2 i1 = (x0.x > x0.y) ? detail::tvec2(1, 0) : detail::tvec2(0, 1); - // x0 = x0 - 0.0 + 0.0 * C.xx ; - // x1 = x0 - i1 + 1.0 * C.xx ; - // x2 = x0 - 1.0 + 2.0 * C.xx ; - detail::tvec4 x12 = detail::tvec4(x0.x, x0.y, x0.x, x0.y) + detail::tvec4(C.x, C.x, C.z, C.z); - x12 = detail::tvec4(detail::tvec2(x12) - i1, x12.z, x12.w); - - // Permutations - i = mod(i, T(289)); // Avoid truncation effects in permutation - detail::tvec3 p = permute( - permute(i.y + detail::tvec3(T(0), i1.y, T(1))) - + i.x + detail::tvec3(T(0), i1.x, T(1))); - - detail::tvec3 m = max(T(0.5) - detail::tvec3( - dot(x0, x0), - dot(detail::tvec2(x12.x, x12.y), detail::tvec2(x12.x, x12.y)), - dot(detail::tvec2(x12.z, x12.w), detail::tvec2(x12.z, x12.w))), T(0)); - m = m * m ; - m = m * m ; - - // Gradients: 41 points uniformly over a line, mapped onto a diamond. - // The ring size 17*17 = 289 is close to a multiple of 41 (41*7 = 287) - - detail::tvec3 x = T(2) * fract(p * C.w) - T(1); - detail::tvec3 h = abs(x) - T(0.5); - detail::tvec3 ox = floor(x + T(0.5)); - detail::tvec3 a0 = x - ox; - - // Normalise gradients implicitly by scaling m - // Inlined for speed: m *= taylorInvSqrt( a0*a0 + h*h ); - m *= T(1.79284291400159) - T(0.85373472095314) * (a0 * a0 + h * h); - - // Compute final noise value at P - detail::tvec3 g; - g.x = a0.x * x0.x + h.x * x0.y; - //g.yz = a0.yz * x12.xz + h.yz * x12.yw; - g.y = a0.y * x12.x + h.y * x12.y; - g.z = a0.z * x12.z + h.z * x12.w; - return T(130) * dot(m, g); - } - - template - GLM_FUNC_QUALIFIER T simplex(detail::tvec3 const & v) - { - detail::tvec2 const C = detail::tvec2(1.0 / 6.0, 1.0 / 3.0); - detail::tvec4 const D = detail::tvec4(0.0, 0.5, 1.0, 2.0); - - // First corner - detail::tvec3 i = floor(v + dot(v, detail::tvec3(C.y))); - detail::tvec3 x0 = v - i + dot(i, detail::tvec3(C.x)); - - // Other corners - detail::tvec3 g = step(detail::tvec3(x0.y, x0.z, x0.x), detail::tvec3(x0.x, x0.y, x0.z)); - detail::tvec3 l = T(1) - g; - detail::tvec3 i1 = min(detail::tvec3(g.x, g.y, g.z), detail::tvec3(l.z, l.x, l.y)); - detail::tvec3 i2 = max(detail::tvec3(g.x, g.y, g.z), detail::tvec3(l.z, l.x, l.y)); - - // x0 = x0 - 0.0 + 0.0 * C.xxx; - // x1 = x0 - i1 + 1.0 * C.xxx; - // x2 = x0 - i2 + 2.0 * C.xxx; - // x3 = x0 - 1.0 + 3.0 * C.xxx; - detail::tvec3 x1 = x0 - i1 + C.x; - detail::tvec3 x2 = x0 - i2 + C.y; // 2.0*C.x = 1/3 = C.y - detail::tvec3 x3 = x0 - D.y; // -1.0+3.0*C.x = -0.5 = -D.y - - // Permutations - i = mod(i, T(289)); - detail::tvec4 p = permute(permute(permute( - i.z + detail::tvec4(0.0, i1.z, i2.z, 1.0)) + - i.y + detail::tvec4(0.0, i1.y, i2.y, 1.0)) + - i.x + detail::tvec4(0.0, i1.x, i2.x, 1.0)); - - // Gradients: 7x7 points over a square, mapped onto an octahedron. - // The ring size 17*17 = 289 is close to a multiple of 49 (49*6 = 294) - T n_ = T(0.142857142857); // 1.0/7.0 - detail::tvec3 ns = n_ * detail::tvec3(D.w, D.y, D.z) - detail::tvec3(D.x, D.z, D.x); - - detail::tvec4 j = p - T(49) * floor(p * ns.z * ns.z); // mod(p,7*7) - - detail::tvec4 x_ = floor(j * ns.z); - detail::tvec4 y_ = floor(j - T(7) * x_); // mod(j,N) - - detail::tvec4 x = x_ * ns.x + ns.y; - detail::tvec4 y = y_ * ns.x + ns.y; - detail::tvec4 h = T(1) - abs(x) - abs(y); - - detail::tvec4 b0 = detail::tvec4(x.x, x.y, y.x, y.y); - detail::tvec4 b1 = detail::tvec4(x.z, x.w, y.z, y.w); - - //vec4 s0 = vec4(lessThan(b0,0.0))*2.0 - 1.0; - //vec4 s1 = vec4(lessThan(b1,0.0))*2.0 - 1.0; - detail::tvec4 s0 = floor(b0) * T(2) + T(1); - detail::tvec4 s1 = floor(b1) * T(2) + T(1); - detail::tvec4 sh = -step(h, detail::tvec4(0)); - - detail::tvec4 a0 = b0 + s0 * detail::tvec4(sh.x, sh.x, sh.y, sh.y); - detail::tvec4 a1 = b1 + s1 * detail::tvec4(sh.z, sh.z, sh.w, sh.w); - - detail::tvec3 p0 = vec3(a0.x, a0.y, h.x); - detail::tvec3 p1 = vec3(a0.z, a0.w, h.y); - detail::tvec3 p2 = vec3(a1.x, a1.y, h.z); - detail::tvec3 p3 = vec3(a1.z, a1.w, h.w); - - //Normalise gradients - detail::tvec4 norm = taylorInvSqrt(detail::tvec4( - dot(p0, p0), - dot(p1, p1), - dot(p2, p2), - dot(p3, p3))); - p0 *= norm.x; - p1 *= norm.y; - p2 *= norm.z; - p3 *= norm.w; - - // Mix final noise value - vec4 m = max(T(0.6) - detail::tvec4( - dot(x0, x0), - dot(x1, x1), - dot(x2, x2), - dot(x3, x3)), T(0)); - m = m * m; - return T(42) * dot(m * m, detail::tvec4( - dot(p0, x0), - dot(p1, x1), - dot(p2, x2), - dot(p3, x3))); - } - - template - GLM_FUNC_QUALIFIER T simplex(detail::tvec4 const & v) - { - detail::tvec4 const C( - 0.138196601125011, // (5 - sqrt(5))/20 G4 - 0.276393202250021, // 2 * G4 - 0.414589803375032, // 3 * G4 - -0.447213595499958); // -1 + 4 * G4 - - // (sqrt(5) - 1)/4 = F4, used once below - T const F4 = T(0.309016994374947451); - - // First corner - detail::tvec4 i = floor(v + dot(v, vec4(F4))); - detail::tvec4 x0 = v - i + dot(i, vec4(C.x)); - - // Other corners - - // Rank sorting originally contributed by Bill Licea-Kane, AMD (formerly ATI) - detail::tvec4 i0; - detail::tvec3 isX = step(detail::tvec3(x0.y, x0.z, x0.w), detail::tvec3(x0.x)); - detail::tvec3 isYZ = step(detail::tvec3(x0.z, x0.w, x0.w), detail::tvec3(x0.y, x0.y, x0.z)); - // i0.x = dot(isX, vec3(1.0)); - //i0.x = isX.x + isX.y + isX.z; - //i0.yzw = T(1) - isX; - i0 = detail::tvec4(isX.x + isX.y + isX.z, T(1) - isX); - // i0.y += dot(isYZ.xy, vec2(1.0)); - i0.y += isYZ.x + isYZ.y; - //i0.zw += 1.0 - detail::tvec2(isYZ.x, isYZ.y); - i0.z += T(1) - isYZ.x; - i0.w += T(1) - isYZ.y; - i0.z += isYZ.z; - i0.w += T(1) - isYZ.z; - - // i0 now contains the unique values 0,1,2,3 in each channel - detail::tvec4 i3 = clamp(i0, 0.0, 1.0); - detail::tvec4 i2 = clamp(i0 - 1.0, 0.0, 1.0); - detail::tvec4 i1 = clamp(i0 - 2.0, 0.0, 1.0); - - // x0 = x0 - 0.0 + 0.0 * C.xxxx - // x1 = x0 - i1 + 0.0 * C.xxxx - // x2 = x0 - i2 + 0.0 * C.xxxx - // x3 = x0 - i3 + 0.0 * C.xxxx - // x4 = x0 - 1.0 + 4.0 * C.xxxx - detail::tvec4 x1 = x0 - i1 + C.x; - detail::tvec4 x2 = x0 - i2 + C.y; - detail::tvec4 x3 = x0 - i3 + C.z; - detail::tvec4 x4 = x0 + C.w; - - // Permutations - i = mod(i, T(289)); - T j0 = permute(permute(permute(permute(i.w) + i.z) + i.y) + i.x); - detail::tvec4 j1 = permute(permute(permute(permute( - i.w + detail::tvec4(i1.w, i2.w, i3.w, T(1))) - + i.z + detail::tvec4(i1.z, i2.z, i3.z, T(1))) - + i.y + detail::tvec4(i1.y, i2.y, i3.y, T(1))) - + i.x + detail::tvec4(i1.x, i2.x, i3.x, T(1))); - - // Gradients: 7x7x6 points over a cube, mapped onto a 4-cross polytope - // 7*7*6 = 294, which is close to the ring size 17*17 = 289. - detail::tvec4 ip = detail::tvec4(T(1) / T(294), T(1) / T(49), T(1) / T(7), T(0)); - - detail::tvec4 p0 = grad4(j0, ip); - detail::tvec4 p1 = grad4(j1.x, ip); - detail::tvec4 p2 = grad4(j1.y, ip); - detail::tvec4 p3 = grad4(j1.z, ip); - detail::tvec4 p4 = grad4(j1.w, ip); - - // Normalise gradients - detail::tvec4 norm = taylorInvSqrt(detail::tvec4(dot(p0, p0), dot(p1, p1), dot(p2, p2), dot(p3, p3))); - p0 *= norm.x; - p1 *= norm.y; - p2 *= norm.z; - p3 *= norm.w; - p4 *= taylorInvSqrt(dot(p4, p4)); - - // Mix contributions from the five corners - detail::tvec3 m0 = max(T(0.6) - detail::tvec3(dot(x0, x0), dot(x1, x1), dot(x2, x2)), T(0)); - detail::tvec2 m1 = max(T(0.6) - detail::tvec2(dot(x3, x3), dot(x4, x4) ), T(0)); - m0 = m0 * m0; - m1 = m1 * m1; - return T(49) * - (dot(m0 * m0, detail::tvec3(dot(p0, x0), dot(p1, x1), dot(p2, x2))) + - dot(m1 * m1, detail::tvec2(dot(p3, x3), dot(p4, x4)))); - } - -}//namespace gtx +template +GLM_FUNC_QUALIFIER T taylorInvSqrt(T const & r) +{ + return T(1.79284291400159) - T(0.85373472095314) * r; +} + +template class vecType> +GLM_FUNC_QUALIFIER vecType taylorInvSqrt(vecType const & r) +{ + return T(1.79284291400159) - T(0.85373472095314) * r; +} + +template class vecType> +GLM_FUNC_QUALIFIER vecType fade(vecType const & t) +{ + return t * t * t * (t * (t * T(6) - T(15)) + T(10)); +} + +template +GLM_FUNC_QUALIFIER detail::tvec4 grad4(T const & j, detail::tvec4 const & ip) +{ + detail::tvec3 pXYZ = floor(fract(detail::tvec3(j) * detail::tvec3(ip)) * T(7)) * ip[2] - T(1); + T pW = T(1.5) - dot(abs(pXYZ), detail::tvec3(1)); + detail::tvec4 s = detail::tvec4(lessThan(detail::tvec4(pXYZ, pW), detail::tvec4(0.0))); + pXYZ = pXYZ + (detail::tvec3(s) * T(2) - T(1)) * s.w; + return detail::tvec4(pXYZ, pW); +} + +// Classic Perlin noise +template +GLM_FUNC_QUALIFIER T perlin(detail::tvec2 const & P) +{ + detail::tvec4 Pi = glm::floor(detail::tvec4(P.x, P.y, P.x, P.y)) + detail::tvec4(0.0, 0.0, 1.0, 1.0); + detail::tvec4 Pf = glm::fract(detail::tvec4(P.x, P.y, P.x, P.y)) - detail::tvec4(0.0, 0.0, 1.0, 1.0); + Pi = mod(Pi, T(289)); // To avoid truncation effects in permutation + detail::tvec4 ix(Pi.x, Pi.z, Pi.x, Pi.z); + detail::tvec4 iy(Pi.y, Pi.y, Pi.w, Pi.w); + detail::tvec4 fx(Pf.x, Pf.z, Pf.x, Pf.z); + detail::tvec4 fy(Pf.y, Pf.y, Pf.w, Pf.w); + + detail::tvec4 i = glm::permute(glm::permute(ix) + iy); + + detail::tvec4 gx = T(2) * glm::fract(i / T(41)) - T(1); + detail::tvec4 gy = glm::abs(gx) - T(0.5); + detail::tvec4 tx = glm::floor(gx + T(0.5)); + gx = gx - tx; + + detail::tvec2 g00(gx.x, gy.x); + detail::tvec2 g10(gx.y, gy.y); + detail::tvec2 g01(gx.z, gy.z); + detail::tvec2 g11(gx.w, gy.w); + + detail::tvec4 norm = taylorInvSqrt(detail::tvec4(dot(g00, g00), dot(g01, g01), dot(g10, g10), dot(g11, g11))); + g00 *= norm.x; + g01 *= norm.y; + g10 *= norm.z; + g11 *= norm.w; + + T n00 = dot(g00, detail::tvec2(fx.x, fy.x)); + T n10 = dot(g10, detail::tvec2(fx.y, fy.y)); + T n01 = dot(g01, detail::tvec2(fx.z, fy.z)); + T n11 = dot(g11, detail::tvec2(fx.w, fy.w)); + + detail::tvec2 fade_xy = fade(detail::tvec2(Pf.x, Pf.y)); + detail::tvec2 n_x = mix(detail::tvec2(n00, n01), detail::tvec2(n10, n11), fade_xy.x); + T n_xy = mix(n_x.x, n_x.y, fade_xy.y); + return T(2.3) * n_xy; +} + +// Classic Perlin noise +template +GLM_FUNC_QUALIFIER T perlin(detail::tvec3 const & P) +{ + detail::tvec3 Pi0 = floor(P); // Integer part for indexing + detail::tvec3 Pi1 = Pi0 + T(1); // Integer part + 1 + Pi0 = mod(Pi0, T(289)); + Pi1 = mod(Pi1, T(289)); + detail::tvec3 Pf0 = fract(P); // Fractional part for interpolation + detail::tvec3 Pf1 = Pf0 - T(1); // Fractional part - 1.0 + detail::tvec4 ix(Pi0.x, Pi1.x, Pi0.x, Pi1.x); + detail::tvec4 iy(Pi0.y, Pi0.y, Pi1.y, Pi1.y); + detail::tvec4 iz0(Pi0.z); + detail::tvec4 iz1(Pi1.z); + + detail::tvec4 ixy = permute(permute(ix) + iy); + detail::tvec4 ixy0 = permute(ixy + iz0); + detail::tvec4 ixy1 = permute(ixy + iz1); + + detail::tvec4 gx0 = ixy0 / T(7); + detail::tvec4 gy0 = fract(floor(gx0) / T(7)) - T(0.5); + gx0 = fract(gx0); + detail::tvec4 gz0 = detail::tvec4(0.5) - abs(gx0) - abs(gy0); + detail::tvec4 sz0 = step(gz0, detail::tvec4(0.0)); + gx0 -= sz0 * (step(0.0, gx0) - T(0.5)); + gy0 -= sz0 * (step(0.0, gy0) - T(0.5)); + + detail::tvec4 gx1 = ixy1 / T(7); + detail::tvec4 gy1 = fract(floor(gx1) / T(7)) - T(0.5); + gx1 = fract(gx1); + detail::tvec4 gz1 = detail::tvec4(0.5) - abs(gx1) - abs(gy1); + detail::tvec4 sz1 = step(gz1, detail::tvec4(0.0)); + gx1 -= sz1 * (step(T(0), gx1) - T(0.5)); + gy1 -= sz1 * (step(T(0), gy1) - T(0.5)); + + detail::tvec3 g000(gx0.x, gy0.x, gz0.x); + detail::tvec3 g100(gx0.y, gy0.y, gz0.y); + detail::tvec3 g010(gx0.z, gy0.z, gz0.z); + detail::tvec3 g110(gx0.w, gy0.w, gz0.w); + detail::tvec3 g001(gx1.x, gy1.x, gz1.x); + detail::tvec3 g101(gx1.y, gy1.y, gz1.y); + detail::tvec3 g011(gx1.z, gy1.z, gz1.z); + detail::tvec3 g111(gx1.w, gy1.w, gz1.w); + + detail::tvec4 norm0 = taylorInvSqrt(detail::tvec4(dot(g000, g000), dot(g010, g010), dot(g100, g100), dot(g110, g110))); + g000 *= norm0.x; + g010 *= norm0.y; + g100 *= norm0.z; + g110 *= norm0.w; + detail::tvec4 norm1 = taylorInvSqrt(detail::tvec4(dot(g001, g001), dot(g011, g011), dot(g101, g101), dot(g111, g111))); + g001 *= norm1.x; + g011 *= norm1.y; + g101 *= norm1.z; + g111 *= norm1.w; + + T n000 = dot(g000, Pf0); + T n100 = dot(g100, detail::tvec3(Pf1.x, Pf0.y, Pf0.z)); + T n010 = dot(g010, detail::tvec3(Pf0.x, Pf1.y, Pf0.z)); + T n110 = dot(g110, detail::tvec3(Pf1.x, Pf1.y, Pf0.z)); + T n001 = dot(g001, detail::tvec3(Pf0.x, Pf0.y, Pf1.z)); + T n101 = dot(g101, detail::tvec3(Pf1.x, Pf0.y, Pf1.z)); + T n011 = dot(g011, detail::tvec3(Pf0.x, Pf1.y, Pf1.z)); + T n111 = dot(g111, Pf1); + + detail::tvec3 fade_xyz = fade(Pf0); + detail::tvec4 n_z = mix(detail::tvec4(n000, n100, n010, n110), detail::tvec4(n001, n101, n011, n111), fade_xyz.z); + detail::tvec2 n_yz = mix( + detail::tvec2(n_z.x, n_z.y), + detail::tvec2(n_z.z, n_z.w), fade_xyz.y); + T n_xyz = mix(n_yz.x, n_yz.y, fade_xyz.x); + return T(2.2) * n_xyz; +} + +// Classic Perlin noise +template +GLM_FUNC_QUALIFIER T perlin(detail::tvec4 const & P) +{ + detail::tvec4 Pi0 = floor(P); // Integer part for indexing + detail::tvec4 Pi1 = Pi0 + T(1); // Integer part + 1 + Pi0 = mod(Pi0, T(289)); + Pi1 = mod(Pi1, T(289)); + detail::tvec4 Pf0 = fract(P); // Fractional part for interpolation + detail::tvec4 Pf1 = Pf0 - T(1); // Fractional part - 1.0 + detail::tvec4 ix(Pi0.x, Pi1.x, Pi0.x, Pi1.x); + detail::tvec4 iy(Pi0.y, Pi0.y, Pi1.y, Pi1.y); + detail::tvec4 iz0(Pi0.z); + detail::tvec4 iz1(Pi1.z); + detail::tvec4 iw0(Pi0.w); + detail::tvec4 iw1(Pi1.w); + + detail::tvec4 ixy = permute(permute(ix) + iy); + detail::tvec4 ixy0 = permute(ixy + iz0); + detail::tvec4 ixy1 = permute(ixy + iz1); + detail::tvec4 ixy00 = permute(ixy0 + iw0); + detail::tvec4 ixy01 = permute(ixy0 + iw1); + detail::tvec4 ixy10 = permute(ixy1 + iw0); + detail::tvec4 ixy11 = permute(ixy1 + iw1); + + detail::tvec4 gx00 = ixy00 / T(7); + detail::tvec4 gy00 = floor(gx00) / T(7); + detail::tvec4 gz00 = floor(gy00) / T(6); + gx00 = fract(gx00) - T(0.5); + gy00 = fract(gy00) - T(0.5); + gz00 = fract(gz00) - T(0.5); + detail::tvec4 gw00 = detail::tvec4(0.75) - abs(gx00) - abs(gy00) - abs(gz00); + detail::tvec4 sw00 = step(gw00, detail::tvec4(0.0)); + gx00 -= sw00 * (step(T(0), gx00) - T(0.5)); + gy00 -= sw00 * (step(T(0), gy00) - T(0.5)); + + detail::tvec4 gx01 = ixy01 / T(7); + detail::tvec4 gy01 = floor(gx01) / T(7); + detail::tvec4 gz01 = floor(gy01) / T(6); + gx01 = fract(gx01) - T(0.5); + gy01 = fract(gy01) - T(0.5); + gz01 = fract(gz01) - T(0.5); + detail::tvec4 gw01 = detail::tvec4(0.75) - abs(gx01) - abs(gy01) - abs(gz01); + detail::tvec4 sw01 = step(gw01, detail::tvec4(0.0)); + gx01 -= sw01 * (step(T(0), gx01) - T(0.5)); + gy01 -= sw01 * (step(T(0), gy01) - T(0.5)); + + detail::tvec4 gx10 = ixy10 / T(7); + detail::tvec4 gy10 = floor(gx10) / T(7); + detail::tvec4 gz10 = floor(gy10) / T(6); + gx10 = fract(gx10) - T(0.5); + gy10 = fract(gy10) - T(0.5); + gz10 = fract(gz10) - T(0.5); + detail::tvec4 gw10 = detail::tvec4(0.75) - abs(gx10) - abs(gy10) - abs(gz10); + detail::tvec4 sw10 = step(gw10, detail::tvec4(0)); + gx10 -= sw10 * (step(T(0), gx10) - T(0.5)); + gy10 -= sw10 * (step(T(0), gy10) - T(0.5)); + + detail::tvec4 gx11 = ixy11 / T(7); + detail::tvec4 gy11 = floor(gx11) / T(7); + detail::tvec4 gz11 = floor(gy11) / T(6); + gx11 = fract(gx11) - T(0.5); + gy11 = fract(gy11) - T(0.5); + gz11 = fract(gz11) - T(0.5); + detail::tvec4 gw11 = detail::tvec4(0.75) - abs(gx11) - abs(gy11) - abs(gz11); + detail::tvec4 sw11 = step(gw11, detail::tvec4(0.0)); + gx11 -= sw11 * (step(T(0), gx11) - T(0.5)); + gy11 -= sw11 * (step(T(0), gy11) - T(0.5)); + + detail::tvec4 g0000(gx00.x, gy00.x, gz00.x, gw00.x); + detail::tvec4 g1000(gx00.y, gy00.y, gz00.y, gw00.y); + detail::tvec4 g0100(gx00.z, gy00.z, gz00.z, gw00.z); + detail::tvec4 g1100(gx00.w, gy00.w, gz00.w, gw00.w); + detail::tvec4 g0010(gx10.x, gy10.x, gz10.x, gw10.x); + detail::tvec4 g1010(gx10.y, gy10.y, gz10.y, gw10.y); + detail::tvec4 g0110(gx10.z, gy10.z, gz10.z, gw10.z); + detail::tvec4 g1110(gx10.w, gy10.w, gz10.w, gw10.w); + detail::tvec4 g0001(gx01.x, gy01.x, gz01.x, gw01.x); + detail::tvec4 g1001(gx01.y, gy01.y, gz01.y, gw01.y); + detail::tvec4 g0101(gx01.z, gy01.z, gz01.z, gw01.z); + detail::tvec4 g1101(gx01.w, gy01.w, gz01.w, gw01.w); + detail::tvec4 g0011(gx11.x, gy11.x, gz11.x, gw11.x); + detail::tvec4 g1011(gx11.y, gy11.y, gz11.y, gw11.y); + detail::tvec4 g0111(gx11.z, gy11.z, gz11.z, gw11.z); + detail::tvec4 g1111(gx11.w, gy11.w, gz11.w, gw11.w); + + detail::tvec4 norm00 = taylorInvSqrt(detail::tvec4(dot(g0000, g0000), dot(g0100, g0100), dot(g1000, g1000), dot(g1100, g1100))); + g0000 *= norm00.x; + g0100 *= norm00.y; + g1000 *= norm00.z; + g1100 *= norm00.w; + + detail::tvec4 norm01 = taylorInvSqrt(detail::tvec4(dot(g0001, g0001), dot(g0101, g0101), dot(g1001, g1001), dot(g1101, g1101))); + g0001 *= norm01.x; + g0101 *= norm01.y; + g1001 *= norm01.z; + g1101 *= norm01.w; + + detail::tvec4 norm10 = taylorInvSqrt(detail::tvec4(dot(g0010, g0010), dot(g0110, g0110), dot(g1010, g1010), dot(g1110, g1110))); + g0010 *= norm10.x; + g0110 *= norm10.y; + g1010 *= norm10.z; + g1110 *= norm10.w; + + detail::tvec4 norm11 = taylorInvSqrt(detail::tvec4(dot(g0011, g0011), dot(g0111, g0111), dot(g1011, g1011), dot(g1111, g1111))); + g0011 *= norm11.x; + g0111 *= norm11.y; + g1011 *= norm11.z; + g1111 *= norm11.w; + + T n0000 = dot(g0000, Pf0); + T n1000 = dot(g1000, detail::tvec4(Pf1.x, Pf0.y, Pf0.z, Pf0.w)); + T n0100 = dot(g0100, detail::tvec4(Pf0.x, Pf1.y, Pf0.z, Pf0.w)); + T n1100 = dot(g1100, detail::tvec4(Pf1.x, Pf1.y, Pf0.z, Pf0.w)); + T n0010 = dot(g0010, detail::tvec4(Pf0.x, Pf0.y, Pf1.z, Pf0.w)); + T n1010 = dot(g1010, detail::tvec4(Pf1.x, Pf0.y, Pf1.z, Pf0.w)); + T n0110 = dot(g0110, detail::tvec4(Pf0.x, Pf1.y, Pf1.z, Pf0.w)); + T n1110 = dot(g1110, detail::tvec4(Pf1.x, Pf1.y, Pf1.z, Pf0.w)); + T n0001 = dot(g0001, detail::tvec4(Pf0.x, Pf0.y, Pf0.z, Pf1.w)); + T n1001 = dot(g1001, detail::tvec4(Pf1.x, Pf0.y, Pf0.z, Pf1.w)); + T n0101 = dot(g0101, detail::tvec4(Pf0.x, Pf1.y, Pf0.z, Pf1.w)); + T n1101 = dot(g1101, detail::tvec4(Pf1.x, Pf1.y, Pf0.z, Pf1.w)); + T n0011 = dot(g0011, detail::tvec4(Pf0.x, Pf0.y, Pf1.z, Pf1.w)); + T n1011 = dot(g1011, detail::tvec4(Pf1.x, Pf0.y, Pf1.z, Pf1.w)); + T n0111 = dot(g0111, detail::tvec4(Pf0.x, Pf1.y, Pf1.z, Pf1.w)); + T n1111 = dot(g1111, Pf1); + + detail::tvec4 fade_xyzw = fade(Pf0); + detail::tvec4 n_0w = mix(detail::tvec4(n0000, n1000, n0100, n1100), detail::tvec4(n0001, n1001, n0101, n1101), fade_xyzw.w); + detail::tvec4 n_1w = mix(detail::tvec4(n0010, n1010, n0110, n1110), detail::tvec4(n0011, n1011, n0111, n1111), fade_xyzw.w); + detail::tvec4 n_zw = mix(n_0w, n_1w, fade_xyzw.z); + detail::tvec2 n_yzw = mix(detail::tvec2(n_zw.x, n_zw.y), detail::tvec2(n_zw.z, n_zw.w), fade_xyzw.y); + T n_xyzw = mix(n_yzw.x, n_yzw.y, fade_xyzw.x); + return T(2.2) * n_xyzw; +} + +// Classic Perlin noise, periodic variant +template +GLM_FUNC_QUALIFIER T perlin(detail::tvec2 const & P, detail::tvec2 const & rep) +{ + detail::tvec4 Pi = floor(detail::tvec4(P.x, P.y, P.x, P.y)) + detail::tvec4(0.0, 0.0, 1.0, 1.0); + detail::tvec4 Pf = fract(detail::tvec4(P.x, P.y, P.x, P.y)) - detail::tvec4(0.0, 0.0, 1.0, 1.0); + Pi = mod(Pi, detail::tvec4(rep.x, rep.y, rep.x, rep.y)); // To create noise with explicit period + Pi = mod(Pi, T(289)); // To avoid truncation effects in permutation + detail::tvec4 ix(Pi.x, Pi.z, Pi.x, Pi.z); + detail::tvec4 iy(Pi.y, Pi.y, Pi.w, Pi.w); + detail::tvec4 fx(Pf.x, Pf.z, Pf.x, Pf.z); + detail::tvec4 fy(Pf.y, Pf.y, Pf.w, Pf.w); + + detail::tvec4 i = permute(permute(ix) + iy); + + detail::tvec4 gx = T(2) * fract(i / T(41)) - T(1); + detail::tvec4 gy = abs(gx) - T(0.5); + detail::tvec4 tx = floor(gx + T(0.5)); + gx = gx - tx; + + detail::tvec2 g00(gx.x, gy.x); + detail::tvec2 g10(gx.y, gy.y); + detail::tvec2 g01(gx.z, gy.z); + detail::tvec2 g11(gx.w, gy.w); + + detail::tvec4 norm = taylorInvSqrt(detail::tvec4(dot(g00, g00), dot(g01, g01), dot(g10, g10), dot(g11, g11))); + g00 *= norm.x; + g01 *= norm.y; + g10 *= norm.z; + g11 *= norm.w; + + T n00 = dot(g00, detail::tvec2(fx.x, fy.x)); + T n10 = dot(g10, detail::tvec2(fx.y, fy.y)); + T n01 = dot(g01, detail::tvec2(fx.z, fy.z)); + T n11 = dot(g11, detail::tvec2(fx.w, fy.w)); + + detail::tvec2 fade_xy = fade(detail::tvec2(Pf.x, Pf.y)); + detail::tvec2 n_x = mix(detail::tvec2(n00, n01), detail::tvec2(n10, n11), fade_xy.x); + T n_xy = mix(n_x.x, n_x.y, fade_xy.y); + return T(2.3) * n_xy; +} + +// Classic Perlin noise, periodic variant +template +GLM_FUNC_QUALIFIER T perlin(detail::tvec3 const & P, detail::tvec3 const & rep) +{ + detail::tvec3 Pi0 = mod(floor(P), rep); // Integer part, modulo period + detail::tvec3 Pi1 = mod(Pi0 + detail::tvec3(1.0), rep); // Integer part + 1, mod period + Pi0 = mod(Pi0, T(289)); + Pi1 = mod(Pi1, T(289)); + detail::tvec3 Pf0 = fract(P); // Fractional part for interpolation + detail::tvec3 Pf1 = Pf0 - detail::tvec3(1.0); // Fractional part - 1.0 + detail::tvec4 ix = detail::tvec4(Pi0.x, Pi1.x, Pi0.x, Pi1.x); + detail::tvec4 iy = detail::tvec4(Pi0.y, Pi0.y, Pi1.y, Pi1.y); + detail::tvec4 iz0(Pi0.z); + detail::tvec4 iz1(Pi1.z); + + detail::tvec4 ixy = permute(permute(ix) + iy); + detail::tvec4 ixy0 = permute(ixy + iz0); + detail::tvec4 ixy1 = permute(ixy + iz1); + + detail::tvec4 gx0 = ixy0 / T(7); + detail::tvec4 gy0 = fract(floor(gx0) / T(7)) - T(0.5); + gx0 = fract(gx0); + detail::tvec4 gz0 = detail::tvec4(0.5) - abs(gx0) - abs(gy0); + detail::tvec4 sz0 = step(gz0, detail::tvec4(0)); + gx0 -= sz0 * (step(0.0, gx0) - T(0.5)); + gy0 -= sz0 * (step(0.0, gy0) - T(0.5)); + + detail::tvec4 gx1 = ixy1 / T(7); + detail::tvec4 gy1 = fract(floor(gx1) / T(7)) - T(0.5); + gx1 = fract(gx1); + detail::tvec4 gz1 = detail::tvec4(0.5) - abs(gx1) - abs(gy1); + detail::tvec4 sz1 = step(gz1, detail::tvec4(0.0)); + gx1 -= sz1 * (step(0.0, gx1) - T(0.5)); + gy1 -= sz1 * (step(0.0, gy1) - T(0.5)); + + detail::tvec3 g000 = detail::tvec3(gx0.x, gy0.x, gz0.x); + detail::tvec3 g100 = detail::tvec3(gx0.y, gy0.y, gz0.y); + detail::tvec3 g010 = detail::tvec3(gx0.z, gy0.z, gz0.z); + detail::tvec3 g110 = detail::tvec3(gx0.w, gy0.w, gz0.w); + detail::tvec3 g001 = detail::tvec3(gx1.x, gy1.x, gz1.x); + detail::tvec3 g101 = detail::tvec3(gx1.y, gy1.y, gz1.y); + detail::tvec3 g011 = detail::tvec3(gx1.z, gy1.z, gz1.z); + detail::tvec3 g111 = detail::tvec3(gx1.w, gy1.w, gz1.w); + + detail::tvec4 norm0 = taylorInvSqrt(detail::tvec4(dot(g000, g000), dot(g010, g010), dot(g100, g100), dot(g110, g110))); + g000 *= norm0.x; + g010 *= norm0.y; + g100 *= norm0.z; + g110 *= norm0.w; + detail::tvec4 norm1 = taylorInvSqrt(detail::tvec4(dot(g001, g001), dot(g011, g011), dot(g101, g101), dot(g111, g111))); + g001 *= norm1.x; + g011 *= norm1.y; + g101 *= norm1.z; + g111 *= norm1.w; + + T n000 = dot(g000, Pf0); + T n100 = dot(g100, detail::tvec3(Pf1.x, Pf0.y, Pf0.z)); + T n010 = dot(g010, detail::tvec3(Pf0.x, Pf1.y, Pf0.z)); + T n110 = dot(g110, detail::tvec3(Pf1.x, Pf1.y, Pf0.z)); + T n001 = dot(g001, detail::tvec3(Pf0.x, Pf0.y, Pf1.z)); + T n101 = dot(g101, detail::tvec3(Pf1.x, Pf0.y, Pf1.z)); + T n011 = dot(g011, detail::tvec3(Pf0.x, Pf1.y, Pf1.z)); + T n111 = dot(g111, Pf1); + + detail::tvec3 fade_xyz = fade(Pf0); + detail::tvec4 n_z = mix(detail::tvec4(n000, n100, n010, n110), detail::tvec4(n001, n101, n011, n111), fade_xyz.z); + detail::tvec2 n_yz = mix(detail::tvec2(n_z.x, n_z.y), detail::tvec2(n_z.z, n_z.w), fade_xyz.y); + T n_xyz = mix(n_yz.x, n_yz.y, fade_xyz.x); + return T(2.2) * n_xyz; +} + +// Classic Perlin noise, periodic version +template +GLM_FUNC_QUALIFIER T perlin(detail::tvec4 const & P, detail::tvec4 const & rep) +{ + detail::tvec4 Pi0 = mod(floor(P), rep); // Integer part modulo rep + detail::tvec4 Pi1 = mod(Pi0 + T(1), rep); // Integer part + 1 mod rep + detail::tvec4 Pf0 = fract(P); // Fractional part for interpolation + detail::tvec4 Pf1 = Pf0 - T(1); // Fractional part - 1.0 + detail::tvec4 ix = detail::tvec4(Pi0.x, Pi1.x, Pi0.x, Pi1.x); + detail::tvec4 iy = detail::tvec4(Pi0.y, Pi0.y, Pi1.y, Pi1.y); + detail::tvec4 iz0(Pi0.z); + detail::tvec4 iz1(Pi1.z); + detail::tvec4 iw0(Pi0.w); + detail::tvec4 iw1(Pi1.w); + + detail::tvec4 ixy = permute(permute(ix) + iy); + detail::tvec4 ixy0 = permute(ixy + iz0); + detail::tvec4 ixy1 = permute(ixy + iz1); + detail::tvec4 ixy00 = permute(ixy0 + iw0); + detail::tvec4 ixy01 = permute(ixy0 + iw1); + detail::tvec4 ixy10 = permute(ixy1 + iw0); + detail::tvec4 ixy11 = permute(ixy1 + iw1); + + detail::tvec4 gx00 = ixy00 / T(7); + detail::tvec4 gy00 = floor(gx00) / T(7); + detail::tvec4 gz00 = floor(gy00) / T(6); + gx00 = fract(gx00) - T(0.5); + gy00 = fract(gy00) - T(0.5); + gz00 = fract(gz00) - T(0.5); + detail::tvec4 gw00 = detail::tvec4(0.75) - abs(gx00) - abs(gy00) - abs(gz00); + detail::tvec4 sw00 = step(gw00, detail::tvec4(0)); + gx00 -= sw00 * (step(0.0, gx00) - T(0.5)); + gy00 -= sw00 * (step(0.0, gy00) - T(0.5)); + + detail::tvec4 gx01 = ixy01 / T(7); + detail::tvec4 gy01 = floor(gx01) / T(7); + detail::tvec4 gz01 = floor(gy01) / T(6); + gx01 = fract(gx01) - T(0.5); + gy01 = fract(gy01) - T(0.5); + gz01 = fract(gz01) - T(0.5); + detail::tvec4 gw01 = detail::tvec4(0.75) - abs(gx01) - abs(gy01) - abs(gz01); + detail::tvec4 sw01 = step(gw01, detail::tvec4(0.0)); + gx01 -= sw01 * (step(0.0, gx01) - T(0.5)); + gy01 -= sw01 * (step(0.0, gy01) - T(0.5)); + + detail::tvec4 gx10 = ixy10 / T(7); + detail::tvec4 gy10 = floor(gx10) / T(7); + detail::tvec4 gz10 = floor(gy10) / T(6); + gx10 = fract(gx10) - T(0.5); + gy10 = fract(gy10) - T(0.5); + gz10 = fract(gz10) - T(0.5); + detail::tvec4 gw10 = detail::tvec4(0.75) - abs(gx10) - abs(gy10) - abs(gz10); + detail::tvec4 sw10 = step(gw10, detail::tvec4(0.0)); + gx10 -= sw10 * (step(0.0, gx10) - T(0.5)); + gy10 -= sw10 * (step(0.0, gy10) - T(0.5)); + + detail::tvec4 gx11 = ixy11 / T(7); + detail::tvec4 gy11 = floor(gx11) / T(7); + detail::tvec4 gz11 = floor(gy11) / T(6); + gx11 = fract(gx11) - T(0.5); + gy11 = fract(gy11) - T(0.5); + gz11 = fract(gz11) - T(0.5); + detail::tvec4 gw11 = detail::tvec4(0.75) - abs(gx11) - abs(gy11) - abs(gz11); + detail::tvec4 sw11 = step(gw11, detail::tvec4(0.0)); + gx11 -= sw11 * (step(0.0, gx11) - T(0.5)); + gy11 -= sw11 * (step(0.0, gy11) - T(0.5)); + + detail::tvec4 g0000(gx00.x, gy00.x, gz00.x, gw00.x); + detail::tvec4 g1000(gx00.y, gy00.y, gz00.y, gw00.y); + detail::tvec4 g0100(gx00.z, gy00.z, gz00.z, gw00.z); + detail::tvec4 g1100(gx00.w, gy00.w, gz00.w, gw00.w); + detail::tvec4 g0010(gx10.x, gy10.x, gz10.x, gw10.x); + detail::tvec4 g1010(gx10.y, gy10.y, gz10.y, gw10.y); + detail::tvec4 g0110(gx10.z, gy10.z, gz10.z, gw10.z); + detail::tvec4 g1110(gx10.w, gy10.w, gz10.w, gw10.w); + detail::tvec4 g0001(gx01.x, gy01.x, gz01.x, gw01.x); + detail::tvec4 g1001(gx01.y, gy01.y, gz01.y, gw01.y); + detail::tvec4 g0101(gx01.z, gy01.z, gz01.z, gw01.z); + detail::tvec4 g1101(gx01.w, gy01.w, gz01.w, gw01.w); + detail::tvec4 g0011(gx11.x, gy11.x, gz11.x, gw11.x); + detail::tvec4 g1011(gx11.y, gy11.y, gz11.y, gw11.y); + detail::tvec4 g0111(gx11.z, gy11.z, gz11.z, gw11.z); + detail::tvec4 g1111(gx11.w, gy11.w, gz11.w, gw11.w); + + detail::tvec4 norm00 = taylorInvSqrt(detail::tvec4(dot(g0000, g0000), dot(g0100, g0100), dot(g1000, g1000), dot(g1100, g1100))); + g0000 *= norm00.x; + g0100 *= norm00.y; + g1000 *= norm00.z; + g1100 *= norm00.w; + + detail::tvec4 norm01 = taylorInvSqrt(detail::tvec4(dot(g0001, g0001), dot(g0101, g0101), dot(g1001, g1001), dot(g1101, g1101))); + g0001 *= norm01.x; + g0101 *= norm01.y; + g1001 *= norm01.z; + g1101 *= norm01.w; + + detail::tvec4 norm10 = taylorInvSqrt(detail::tvec4(dot(g0010, g0010), dot(g0110, g0110), dot(g1010, g1010), dot(g1110, g1110))); + g0010 *= norm10.x; + g0110 *= norm10.y; + g1010 *= norm10.z; + g1110 *= norm10.w; + + detail::tvec4 norm11 = taylorInvSqrt(detail::tvec4(dot(g0011, g0011), dot(g0111, g0111), dot(g1011, g1011), dot(g1111, g1111))); + g0011 *= norm11.x; + g0111 *= norm11.y; + g1011 *= norm11.z; + g1111 *= norm11.w; + + T n0000 = dot(g0000, Pf0); + T n1000 = dot(g1000, detail::tvec4(Pf1.x, Pf0.y, Pf0.z, Pf0.w)); + T n0100 = dot(g0100, detail::tvec4(Pf0.x, Pf1.y, Pf0.z, Pf0.w)); + T n1100 = dot(g1100, detail::tvec4(Pf1.x, Pf1.y, Pf0.z, Pf0.w)); + T n0010 = dot(g0010, detail::tvec4(Pf0.x, Pf0.y, Pf1.z, Pf0.w)); + T n1010 = dot(g1010, detail::tvec4(Pf1.x, Pf0.y, Pf1.z, Pf0.w)); + T n0110 = dot(g0110, detail::tvec4(Pf0.x, Pf1.y, Pf1.z, Pf0.w)); + T n1110 = dot(g1110, detail::tvec4(Pf1.x, Pf1.y, Pf1.z, Pf0.w)); + T n0001 = dot(g0001, detail::tvec4(Pf0.x, Pf0.y, Pf0.z, Pf1.w)); + T n1001 = dot(g1001, detail::tvec4(Pf1.x, Pf0.y, Pf0.z, Pf1.w)); + T n0101 = dot(g0101, detail::tvec4(Pf0.x, Pf1.y, Pf0.z, Pf1.w)); + T n1101 = dot(g1101, detail::tvec4(Pf1.x, Pf1.y, Pf0.z, Pf1.w)); + T n0011 = dot(g0011, detail::tvec4(Pf0.x, Pf0.y, Pf1.z, Pf1.w)); + T n1011 = dot(g1011, detail::tvec4(Pf1.x, Pf0.y, Pf1.z, Pf1.w)); + T n0111 = dot(g0111, detail::tvec4(Pf0.x, Pf1.y, Pf1.z, Pf1.w)); + T n1111 = dot(g1111, Pf1); + + detail::tvec4 fade_xyzw = fade(Pf0); + detail::tvec4 n_0w = mix(detail::tvec4(n0000, n1000, n0100, n1100), detail::tvec4(n0001, n1001, n0101, n1101), fade_xyzw.w); + detail::tvec4 n_1w = mix(detail::tvec4(n0010, n1010, n0110, n1110), detail::tvec4(n0011, n1011, n0111, n1111), fade_xyzw.w); + detail::tvec4 n_zw = mix(n_0w, n_1w, fade_xyzw.z); + detail::tvec2 n_yzw = mix(detail::tvec2(n_zw.x, n_zw.y), detail::tvec2(n_zw.z, n_zw.w), fade_xyzw.y); + T n_xyzw = mix(n_yzw.x, n_yzw.y, fade_xyzw.x); + return T(2.2) * n_xyzw; +} + +template +GLM_FUNC_QUALIFIER T simplex(glm::detail::tvec2 const & v) +{ + detail::tvec4 const C = detail::tvec4( + T( 0.211324865405187), // (3.0 - sqrt(3.0)) / 6.0 + T( 0.366025403784439), // 0.5 * (sqrt(3.0) - 1.0) + T(-0.577350269189626), // -1.0 + 2.0 * C.x + T( 0.024390243902439)); // 1.0 / 41.0 + + // First corner + detail::tvec2 i = floor(v + dot(v, detail::tvec2(C[1]))); + detail::tvec2 x0 = v - i + dot(i, detail::tvec2(C[0])); + + // Other corners + //i1.x = step( x0.y, x0.x ); // x0.x > x0.y ? 1.0 : 0.0 + //i1.y = 1.0 - i1.x; + detail::tvec2 i1 = (x0.x > x0.y) ? detail::tvec2(1, 0) : detail::tvec2(0, 1); + // x0 = x0 - 0.0 + 0.0 * C.xx ; + // x1 = x0 - i1 + 1.0 * C.xx ; + // x2 = x0 - 1.0 + 2.0 * C.xx ; + detail::tvec4 x12 = detail::tvec4(x0.x, x0.y, x0.x, x0.y) + detail::tvec4(C.x, C.x, C.z, C.z); + x12 = detail::tvec4(detail::tvec2(x12) - i1, x12.z, x12.w); + + // Permutations + i = mod(i, T(289)); // Avoid truncation effects in permutation + detail::tvec3 p = permute( + permute(i.y + detail::tvec3(T(0), i1.y, T(1))) + + i.x + detail::tvec3(T(0), i1.x, T(1))); + + detail::tvec3 m = max(T(0.5) - detail::tvec3( + dot(x0, x0), + dot(detail::tvec2(x12.x, x12.y), detail::tvec2(x12.x, x12.y)), + dot(detail::tvec2(x12.z, x12.w), detail::tvec2(x12.z, x12.w))), T(0)); + m = m * m ; + m = m * m ; + + // Gradients: 41 points uniformly over a line, mapped onto a diamond. + // The ring size 17*17 = 289 is close to a multiple of 41 (41*7 = 287) + + detail::tvec3 x = T(2) * fract(p * C.w) - T(1); + detail::tvec3 h = abs(x) - T(0.5); + detail::tvec3 ox = floor(x + T(0.5)); + detail::tvec3 a0 = x - ox; + + // Normalise gradients implicitly by scaling m + // Inlined for speed: m *= taylorInvSqrt( a0*a0 + h*h ); + m *= T(1.79284291400159) - T(0.85373472095314) * (a0 * a0 + h * h); + + // Compute final noise value at P + detail::tvec3 g; + g.x = a0.x * x0.x + h.x * x0.y; + //g.yz = a0.yz * x12.xz + h.yz * x12.yw; + g.y = a0.y * x12.x + h.y * x12.y; + g.z = a0.z * x12.z + h.z * x12.w; + return T(130) * dot(m, g); +} + +template +GLM_FUNC_QUALIFIER T simplex(detail::tvec3 const & v) +{ + detail::tvec2 const C = detail::tvec2(1.0 / 6.0, 1.0 / 3.0); + detail::tvec4 const D = detail::tvec4(0.0, 0.5, 1.0, 2.0); + + // First corner + detail::tvec3 i = floor(v + dot(v, detail::tvec3(C.y))); + detail::tvec3 x0 = v - i + dot(i, detail::tvec3(C.x)); + + // Other corners + detail::tvec3 g = step(detail::tvec3(x0.y, x0.z, x0.x), detail::tvec3(x0.x, x0.y, x0.z)); + detail::tvec3 l = T(1) - g; + detail::tvec3 i1 = min(detail::tvec3(g.x, g.y, g.z), detail::tvec3(l.z, l.x, l.y)); + detail::tvec3 i2 = max(detail::tvec3(g.x, g.y, g.z), detail::tvec3(l.z, l.x, l.y)); + + // x0 = x0 - 0.0 + 0.0 * C.xxx; + // x1 = x0 - i1 + 1.0 * C.xxx; + // x2 = x0 - i2 + 2.0 * C.xxx; + // x3 = x0 - 1.0 + 3.0 * C.xxx; + detail::tvec3 x1 = x0 - i1 + C.x; + detail::tvec3 x2 = x0 - i2 + C.y; // 2.0*C.x = 1/3 = C.y + detail::tvec3 x3 = x0 - D.y; // -1.0+3.0*C.x = -0.5 = -D.y + + // Permutations + i = mod(i, T(289)); + detail::tvec4 p = permute(permute(permute( + i.z + detail::tvec4(0.0, i1.z, i2.z, 1.0)) + + i.y + detail::tvec4(0.0, i1.y, i2.y, 1.0)) + + i.x + detail::tvec4(0.0, i1.x, i2.x, 1.0)); + + // Gradients: 7x7 points over a square, mapped onto an octahedron. + // The ring size 17*17 = 289 is close to a multiple of 49 (49*6 = 294) + T n_ = T(0.142857142857); // 1.0/7.0 + detail::tvec3 ns = n_ * detail::tvec3(D.w, D.y, D.z) - detail::tvec3(D.x, D.z, D.x); + + detail::tvec4 j = p - T(49) * floor(p * ns.z * ns.z); // mod(p,7*7) + + detail::tvec4 x_ = floor(j * ns.z); + detail::tvec4 y_ = floor(j - T(7) * x_); // mod(j,N) + + detail::tvec4 x = x_ * ns.x + ns.y; + detail::tvec4 y = y_ * ns.x + ns.y; + detail::tvec4 h = T(1) - abs(x) - abs(y); + + detail::tvec4 b0 = detail::tvec4(x.x, x.y, y.x, y.y); + detail::tvec4 b1 = detail::tvec4(x.z, x.w, y.z, y.w); + + //vec4 s0 = vec4(lessThan(b0,0.0))*2.0 - 1.0; + //vec4 s1 = vec4(lessThan(b1,0.0))*2.0 - 1.0; + detail::tvec4 s0 = floor(b0) * T(2) + T(1); + detail::tvec4 s1 = floor(b1) * T(2) + T(1); + detail::tvec4 sh = -step(h, detail::tvec4(0)); + + detail::tvec4 a0 = b0 + s0 * detail::tvec4(sh.x, sh.x, sh.y, sh.y); + detail::tvec4 a1 = b1 + s1 * detail::tvec4(sh.z, sh.z, sh.w, sh.w); + + detail::tvec3 p0 = vec3(a0.x, a0.y, h.x); + detail::tvec3 p1 = vec3(a0.z, a0.w, h.y); + detail::tvec3 p2 = vec3(a1.x, a1.y, h.z); + detail::tvec3 p3 = vec3(a1.z, a1.w, h.w); + + //Normalise gradients + detail::tvec4 norm = taylorInvSqrt(detail::tvec4( + dot(p0, p0), + dot(p1, p1), + dot(p2, p2), + dot(p3, p3))); + p0 *= norm.x; + p1 *= norm.y; + p2 *= norm.z; + p3 *= norm.w; + + // Mix final noise value + vec4 m = max(T(0.6) - detail::tvec4( + dot(x0, x0), + dot(x1, x1), + dot(x2, x2), + dot(x3, x3)), T(0)); + m = m * m; + return T(42) * dot(m * m, detail::tvec4( + dot(p0, x0), + dot(p1, x1), + dot(p2, x2), + dot(p3, x3))); +} + +template +GLM_FUNC_QUALIFIER T simplex(detail::tvec4 const & v) +{ + detail::tvec4 const C( + 0.138196601125011, // (5 - sqrt(5))/20 G4 + 0.276393202250021, // 2 * G4 + 0.414589803375032, // 3 * G4 + -0.447213595499958); // -1 + 4 * G4 + + // (sqrt(5) - 1)/4 = F4, used once below + T const F4 = T(0.309016994374947451); + + // First corner + detail::tvec4 i = floor(v + dot(v, vec4(F4))); + detail::tvec4 x0 = v - i + dot(i, vec4(C.x)); + + // Other corners + + // Rank sorting originally contributed by Bill Licea-Kane, AMD (formerly ATI) + detail::tvec4 i0; + detail::tvec3 isX = step(detail::tvec3(x0.y, x0.z, x0.w), detail::tvec3(x0.x)); + detail::tvec3 isYZ = step(detail::tvec3(x0.z, x0.w, x0.w), detail::tvec3(x0.y, x0.y, x0.z)); + // i0.x = dot(isX, vec3(1.0)); + //i0.x = isX.x + isX.y + isX.z; + //i0.yzw = T(1) - isX; + i0 = detail::tvec4(isX.x + isX.y + isX.z, T(1) - isX); + // i0.y += dot(isYZ.xy, vec2(1.0)); + i0.y += isYZ.x + isYZ.y; + //i0.zw += 1.0 - detail::tvec2(isYZ.x, isYZ.y); + i0.z += T(1) - isYZ.x; + i0.w += T(1) - isYZ.y; + i0.z += isYZ.z; + i0.w += T(1) - isYZ.z; + + // i0 now contains the unique values 0,1,2,3 in each channel + detail::tvec4 i3 = clamp(i0, 0.0, 1.0); + detail::tvec4 i2 = clamp(i0 - 1.0, 0.0, 1.0); + detail::tvec4 i1 = clamp(i0 - 2.0, 0.0, 1.0); + + // x0 = x0 - 0.0 + 0.0 * C.xxxx + // x1 = x0 - i1 + 0.0 * C.xxxx + // x2 = x0 - i2 + 0.0 * C.xxxx + // x3 = x0 - i3 + 0.0 * C.xxxx + // x4 = x0 - 1.0 + 4.0 * C.xxxx + detail::tvec4 x1 = x0 - i1 + C.x; + detail::tvec4 x2 = x0 - i2 + C.y; + detail::tvec4 x3 = x0 - i3 + C.z; + detail::tvec4 x4 = x0 + C.w; + + // Permutations + i = mod(i, T(289)); + T j0 = permute(permute(permute(permute(i.w) + i.z) + i.y) + i.x); + detail::tvec4 j1 = permute(permute(permute(permute( + i.w + detail::tvec4(i1.w, i2.w, i3.w, T(1))) + + i.z + detail::tvec4(i1.z, i2.z, i3.z, T(1))) + + i.y + detail::tvec4(i1.y, i2.y, i3.y, T(1))) + + i.x + detail::tvec4(i1.x, i2.x, i3.x, T(1))); + + // Gradients: 7x7x6 points over a cube, mapped onto a 4-cross polytope + // 7*7*6 = 294, which is close to the ring size 17*17 = 289. + detail::tvec4 ip = detail::tvec4(T(1) / T(294), T(1) / T(49), T(1) / T(7), T(0)); + + detail::tvec4 p0 = grad4(j0, ip); + detail::tvec4 p1 = grad4(j1.x, ip); + detail::tvec4 p2 = grad4(j1.y, ip); + detail::tvec4 p3 = grad4(j1.z, ip); + detail::tvec4 p4 = grad4(j1.w, ip); + + // Normalise gradients + detail::tvec4 norm = taylorInvSqrt(detail::tvec4(dot(p0, p0), dot(p1, p1), dot(p2, p2), dot(p3, p3))); + p0 *= norm.x; + p1 *= norm.y; + p2 *= norm.z; + p3 *= norm.w; + p4 *= taylorInvSqrt(dot(p4, p4)); + + // Mix contributions from the five corners + detail::tvec3 m0 = max(T(0.6) - detail::tvec3(dot(x0, x0), dot(x1, x1), dot(x2, x2)), T(0)); + detail::tvec2 m1 = max(T(0.6) - detail::tvec2(dot(x3, x3), dot(x4, x4) ), T(0)); + m0 = m0 * m0; + m1 = m1 * m1; + return T(49) * + (dot(m0 * m0, detail::tvec3(dot(p0, x0), dot(p1, x1), dot(p2, x2))) + + dot(m1 * m1, detail::tvec2(dot(p3, x3), dot(p4, x4)))); +} + }//namespace glm diff --git a/glm/gtx/norm.hpp b/glm/gtx/norm.hpp index f84dd7c3..a34ce45b 100644 --- a/glm/gtx/norm.hpp +++ b/glm/gtx/norm.hpp @@ -49,8 +49,7 @@ # pragma message("GLM: GLM_GTX_norm extension included") #endif -namespace glm{ -namespace gtx +namespace glm { /// @addtogroup gtx_norm /// @{ @@ -155,7 +154,6 @@ namespace gtx unsigned int Depth); /// @} -}//namespace gtx }//namespace glm #include "norm.inl" diff --git a/glm/gtx/norm.inl b/glm/gtx/norm.inl index 949664e3..356a758a 100644 --- a/glm/gtx/norm.inl +++ b/glm/gtx/norm.inl @@ -8,121 +8,119 @@ /////////////////////////////////////////////////////////////////////////////////////////////////// namespace glm{ -namespace gtx + +template +GLM_FUNC_QUALIFIER T length2( + const T x) { - template - GLM_FUNC_QUALIFIER T length2( - const T x) - { - return x * x; - } + return x * x; +} - template - GLM_FUNC_QUALIFIER T length2( - const detail::tvec2& x) - { - return dot(x, x); - } +template +GLM_FUNC_QUALIFIER T length2( + const detail::tvec2& x) +{ + return dot(x, x); +} - template - GLM_FUNC_QUALIFIER T length2( - const detail::tvec3& x) - { - return dot(x, x); - } +template +GLM_FUNC_QUALIFIER T length2( + const detail::tvec3& x) +{ + return dot(x, x); +} - template - GLM_FUNC_QUALIFIER T length2( - const detail::tvec4& x) - { - return dot(x, x); - } +template +GLM_FUNC_QUALIFIER T length2( + const detail::tvec4& x) +{ + return dot(x, x); +} - template - GLM_FUNC_QUALIFIER T length2( - const detail::tquat& q) - { - return q.x * q.x + q.y * q.y + q.z * q.z + q.w * q.w; - } +template +GLM_FUNC_QUALIFIER T length2( + const detail::tquat& q) +{ + return q.x * q.x + q.y * q.y + q.z * q.z + q.w * q.w; +} - template - T distance2( - const T p0, - const T p1) - { - return length2(p1 - p0); - } +template +T distance2( + const T p0, + const T p1) +{ + return length2(p1 - p0); +} - template - T distance2( - const detail::tvec2& p0, - const detail::tvec2& p1) - { - return length2(p1 - p0); - } +template +T distance2( + const detail::tvec2& p0, + const detail::tvec2& p1) +{ + return length2(p1 - p0); +} - template - T distance2( - const detail::tvec3& p0, - const detail::tvec3& p1) - { - return length2(p1 - p0); - } +template +T distance2( + const detail::tvec3& p0, + const detail::tvec3& p1) +{ + return length2(p1 - p0); +} - template - T distance2( - const detail::tvec4& p0, - const detail::tvec4& p1) - { - return length2(p1 - p0); - } +template +T distance2( + const detail::tvec4& p0, + const detail::tvec4& p1) +{ + return length2(p1 - p0); +} - template - GLM_FUNC_QUALIFIER T l1Norm( - const detail::tvec3& a, - const detail::tvec3& b) - { - return abs(b.x - a.x) + abs(b.y - a.y) + abs(b.z - a.z); - } +template +GLM_FUNC_QUALIFIER T l1Norm( + const detail::tvec3& a, + const detail::tvec3& b) +{ + return abs(b.x - a.x) + abs(b.y - a.y) + abs(b.z - a.z); +} - template - GLM_FUNC_QUALIFIER T l1Norm( - const detail::tvec3& v) - { - return abs(v.x) + abs(v.y) + abs(v.z); - } +template +GLM_FUNC_QUALIFIER T l1Norm( + const detail::tvec3& v) +{ + return abs(v.x) + abs(v.y) + abs(v.z); +} - template - GLM_FUNC_QUALIFIER T l2Norm( - const detail::tvec3& a, - const detail::tvec3& b) - { - return length(b - a); - } +template +GLM_FUNC_QUALIFIER T l2Norm( + const detail::tvec3& a, + const detail::tvec3& b) +{ + return length(b - a); +} - template - GLM_FUNC_QUALIFIER T l2Norm( - const detail::tvec3& v) - { - return length(v); - } +template +GLM_FUNC_QUALIFIER T l2Norm( + const detail::tvec3& v) +{ + return length(v); +} - template - GLM_FUNC_QUALIFIER T lxNorm( - const detail::tvec3& x, - const detail::tvec3& y, - 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)); - } +template +GLM_FUNC_QUALIFIER T lxNorm( + const detail::tvec3& x, + const detail::tvec3& y, + 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)); +} - template - GLM_FUNC_QUALIFIER T lxNorm( - const detail::tvec3& v, - unsigned int Depth) - { - return pow(pow(v.x, T(Depth)) + pow(v.y, T(Depth)) + pow(v.z, T(Depth)), T(1) / T(Depth)); - } +template +GLM_FUNC_QUALIFIER T lxNorm( + const detail::tvec3& v, + unsigned int 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 diff --git a/glm/gtx/normal.hpp b/glm/gtx/normal.hpp index 56ccb20b..5ef20355 100644 --- a/glm/gtx/normal.hpp +++ b/glm/gtx/normal.hpp @@ -46,8 +46,7 @@ # pragma message("GLM: GLM_GTX_normal extension included") #endif -namespace glm{ -namespace gtx +namespace glm { /// @addtogroup gtx_normal /// @{ @@ -61,7 +60,6 @@ namespace gtx detail::tvec3 const & p3); /// @} -}//namespace gtx }//namespace glm #include "normal.inl" diff --git a/glm/gtx/normal.inl b/glm/gtx/normal.inl index 689e5e0b..1aa7b8c3 100644 --- a/glm/gtx/normal.inl +++ b/glm/gtx/normal.inl @@ -8,7 +8,6 @@ /////////////////////////////////////////////////////////////////////////////////////////////////// namespace glm{ -namespace gtx{ template GLM_FUNC_QUALIFIER detail::tvec3 triangleNormal @@ -21,5 +20,4 @@ GLM_FUNC_QUALIFIER detail::tvec3 triangleNormal return normalize(cross(p1 - p2, p1 - p3)); } -}//namespace gtx }//namespace glm diff --git a/glm/gtx/normalize_dot.hpp b/glm/gtx/normalize_dot.hpp index bb447f8d..21d0de36 100644 --- a/glm/gtx/normalize_dot.hpp +++ b/glm/gtx/normalize_dot.hpp @@ -47,8 +47,7 @@ # pragma message("GLM: GLM_GTX_normalize_dot extension included") #endif -namespace glm{ -namespace gtx +namespace glm { /// @addtogroup gtx_normalize_dot /// @{ @@ -70,7 +69,6 @@ namespace gtx genType const & y); /// @} -}//namespace gtx }//namespace glm #include "normalize_dot.inl" diff --git a/glm/gtx/normalize_dot.inl b/glm/gtx/normalize_dot.inl index 4653cf6f..c086fb26 100644 --- a/glm/gtx/normalize_dot.inl +++ b/glm/gtx/normalize_dot.inl @@ -8,7 +8,6 @@ ////////////////////////////////////////////////////////////////////////////////// namespace glm{ -namespace gtx{ template GLM_FUNC_QUALIFIER genType normalizeDot @@ -71,7 +70,7 @@ GLM_FUNC_QUALIFIER genType fastNormalizeDot { return glm::dot(x, y) * - glm::gtx::fastInverseSqrt(glm::dot(x, x) * + fastInverseSqrt(glm::dot(x, x) * glm::dot(y, y)); } @@ -84,7 +83,7 @@ GLM_FUNC_QUALIFIER valType fastNormalizeDot { return glm::dot(x, y) * - glm::gtx::fastInverseSqrt(glm::dot(x, x) * + fastInverseSqrt(glm::dot(x, x) * glm::dot(y, y)); } @@ -97,7 +96,7 @@ GLM_FUNC_QUALIFIER valType fastNormalizeDot { return glm::dot(x, y) * - glm::gtx::fastInverseSqrt(glm::dot(x, x) * + fastInverseSqrt(glm::dot(x, x) * glm::dot(y, y)); } @@ -110,9 +109,8 @@ GLM_FUNC_QUALIFIER valType fastNormalizeDot { return glm::dot(x, y) * - glm::gtx::fastInverseSqrt(glm::dot(x, x) * + fastInverseSqrt(glm::dot(x, x) * glm::dot(y, y)); } -}//namespace gtx }//namespace glm diff --git a/glm/gtx/optimum_pow.inl b/glm/gtx/optimum_pow.inl index cc171730..7faa6240 100644 --- a/glm/gtx/optimum_pow.inl +++ b/glm/gtx/optimum_pow.inl @@ -8,54 +8,52 @@ /////////////////////////////////////////////////////////////////////////////////////////////////// namespace glm{ -namespace gtx{ - template - GLM_FUNC_QUALIFIER genType pow2(const genType& x) - { - return x * x; - } +template +GLM_FUNC_QUALIFIER genType pow2(const genType& x) +{ + return x * x; +} - template - GLM_FUNC_QUALIFIER genType pow3(const genType& x) - { - return x * x * x; - } +template +GLM_FUNC_QUALIFIER genType pow3(const genType& x) +{ + return x * x * x; +} - template - GLM_FUNC_QUALIFIER genType pow4(const genType& x) - { - return x * x * x * x; - } +template +GLM_FUNC_QUALIFIER genType pow4(const genType& x) +{ + return x * x * x * x; +} - GLM_FUNC_QUALIFIER bool powOfTwo(int x) - { - return !(x & (x - 1)); - } +GLM_FUNC_QUALIFIER bool powOfTwo(int x) +{ + return !(x & (x - 1)); +} - GLM_FUNC_QUALIFIER detail::tvec2 powOfTwo(const detail::tvec2& x) - { - return detail::tvec2( - powOfTwo(x.x), - powOfTwo(x.y)); - } +GLM_FUNC_QUALIFIER detail::tvec2 powOfTwo(const detail::tvec2& x) +{ + return detail::tvec2( + powOfTwo(x.x), + powOfTwo(x.y)); +} - GLM_FUNC_QUALIFIER detail::tvec3 powOfTwo(const detail::tvec3& x) - { - return detail::tvec3( - powOfTwo(x.x), - powOfTwo(x.y), - powOfTwo(x.z)); - } +GLM_FUNC_QUALIFIER detail::tvec3 powOfTwo(const detail::tvec3& x) +{ + return detail::tvec3( + powOfTwo(x.x), + powOfTwo(x.y), + powOfTwo(x.z)); +} - GLM_FUNC_QUALIFIER detail::tvec4 powOfTwo(const detail::tvec4& x) - { - return detail::tvec4( - powOfTwo(x.x), - powOfTwo(x.y), - powOfTwo(x.z), - powOfTwo(x.w)); - } +GLM_FUNC_QUALIFIER detail::tvec4 powOfTwo(const detail::tvec4& x) +{ + return detail::tvec4( + powOfTwo(x.x), + powOfTwo(x.y), + powOfTwo(x.z), + powOfTwo(x.w)); +} -}//namespace gtx }//namespace glm diff --git a/glm/gtx/orthonormalize.hpp b/glm/gtx/orthonormalize.hpp index 345babbe..54263232 100644 --- a/glm/gtx/orthonormalize.hpp +++ b/glm/gtx/orthonormalize.hpp @@ -46,8 +46,7 @@ # pragma message("GLM: GLM_GTX_orthonormalize extension included") #endif -namespace glm{ -namespace gtx +namespace glm { /// @addtogroup gtx_orthonormalize /// @{ @@ -66,7 +65,6 @@ namespace gtx const detail::tvec3& y); /// @} -}//namespace gtx }//namespace glm #include "orthonormalize.inl" diff --git a/glm/gtx/orthonormalize.inl b/glm/gtx/orthonormalize.inl index 149668dd..f041fe3a 100644 --- a/glm/gtx/orthonormalize.inl +++ b/glm/gtx/orthonormalize.inl @@ -8,40 +8,37 @@ /////////////////////////////////////////////////////////////////////////////////////////////////// namespace glm{ -namespace gtx{ - template - GLM_FUNC_QUALIFIER detail::tmat3x3 orthonormalize - ( - const detail::tmat3x3& m - ) - { - detail::tmat3x3 r = m; +template +GLM_FUNC_QUALIFIER detail::tmat3x3 orthonormalize +( + const detail::tmat3x3& m +) +{ + detail::tmat3x3 r = m; - r[0] = normalize(r[0]); + r[0] = normalize(r[0]); - float d0 = dot(r[0], r[1]); - r[1] -= r[0] * d0; - r[1] = normalize(r[1]); + float d0 = dot(r[0], r[1]); + r[1] -= r[0] * d0; + r[1] = normalize(r[1]); - float d1 = dot(r[1], r[2]); - d0 = dot(r[0], r[2]); - r[2] -= r[0] * d0 + r[1] * d1; - r[2] = normalize(r[2]); + float d1 = dot(r[1], r[2]); + d0 = dot(r[0], r[2]); + r[2] -= r[0] * d0 + r[1] * d1; + r[2] = normalize(r[2]); - return r; - } + return r; +} - template - GLM_FUNC_QUALIFIER detail::tvec3 orthonormalize - ( - const detail::tvec3& x, - const detail::tvec3& y - ) - { - return normalize(x - y * dot(y, x)); - } +template +GLM_FUNC_QUALIFIER detail::tvec3 orthonormalize +( + const detail::tvec3& x, + const detail::tvec3& y +) +{ + return normalize(x - y * dot(y, x)); +} -}//namespace gtx }//namespace glm - diff --git a/glm/gtx/perpendicular.hpp b/glm/gtx/perpendicular.hpp index 8e75fd2b..bee0dd89 100644 --- a/glm/gtx/perpendicular.hpp +++ b/glm/gtx/perpendicular.hpp @@ -47,8 +47,7 @@ # pragma message("GLM: GLM_GTX_perpendicular extension included") #endif -namespace glm{ -namespace gtx +namespace glm { /// @addtogroup gtx_perpendicular /// @{ @@ -75,7 +74,6 @@ namespace gtx detail::tvec4 const & Normal); /// @} -}//namespace gtx }//namespace glm #include "perpendicular.inl" diff --git a/glm/gtx/perpendicular.inl b/glm/gtx/perpendicular.inl index cb1994f4..4edff2ed 100644 --- a/glm/gtx/perpendicular.inl +++ b/glm/gtx/perpendicular.inl @@ -8,7 +8,6 @@ /////////////////////////////////////////////////////////////////////////////////////////////////// namespace glm{ -namespace gtx{ template GLM_FUNC_QUALIFIER detail::tvec2 perp( @@ -34,5 +33,4 @@ GLM_FUNC_QUALIFIER detail::tvec4 perp( return x - proj(x, Normal); } -}//namespace gtx }//namespace glm diff --git a/glm/gtx/polar_coordinates.hpp b/glm/gtx/polar_coordinates.hpp index 7bde12e2..e8399ab9 100644 --- a/glm/gtx/polar_coordinates.hpp +++ b/glm/gtx/polar_coordinates.hpp @@ -45,8 +45,7 @@ # pragma message("GLM: GLM_GTX_polar_coordinates extension included") #endif -namespace glm{ -namespace gtx +namespace glm { /// @addtogroup gtx_polar_coordinates /// @{ @@ -62,7 +61,6 @@ namespace gtx detail::tvec3 euclidean(const detail::tvec3& polar); /// @} -}//namespace gtx }//namespace glm #include "polar_coordinates.inl" diff --git a/glm/gtx/polar_coordinates.inl b/glm/gtx/polar_coordinates.inl index 7e2913ce..f75609ec 100644 --- a/glm/gtx/polar_coordinates.inl +++ b/glm/gtx/polar_coordinates.inl @@ -7,8 +7,7 @@ // File : glm/gtx/polar_coordinates.inl /////////////////////////////////////////////////////////////////////////////////////////////////// -namespace glm{ -namespace gtx +namespace glm { template GLM_FUNC_QUALIFIER detail::tvec3 polar( @@ -36,5 +35,4 @@ namespace gtx cos(latitude) * cos(longitude)); } -}//namespace gtx }//namespace glm diff --git a/glm/gtx/projection.hpp b/glm/gtx/projection.hpp index e8e1036b..a46757b7 100644 --- a/glm/gtx/projection.hpp +++ b/glm/gtx/projection.hpp @@ -45,8 +45,7 @@ # pragma message("GLM: GLM_GTX_projection extension included") #endif -namespace glm{ -namespace gtx +namespace glm { /// @addtogroup gtx_projection /// @{ @@ -73,7 +72,6 @@ namespace gtx detail::tvec4 const & Normal); /// @} -}//namespace gtx }//namespace glm #include "projection.inl" diff --git a/glm/gtx/projection.inl b/glm/gtx/projection.inl index bf1c7ff1..72c7128f 100644 --- a/glm/gtx/projection.inl +++ b/glm/gtx/projection.inl @@ -8,7 +8,6 @@ /////////////////////////////////////////////////////////////////////////////////////////////////// namespace glm{ -namespace gtx{ template GLM_FUNC_QUALIFIER detail::tvec2 proj( @@ -34,5 +33,4 @@ GLM_FUNC_QUALIFIER detail::tvec4 proj( return glm::dot(x, Normal) / glm::dot(Normal, Normal) * Normal; } -}//namespace gtx }//namespace glm diff --git a/glm/gtx/quaternion.hpp b/glm/gtx/quaternion.hpp index a931dd61..70df9beb 100644 --- a/glm/gtx/quaternion.hpp +++ b/glm/gtx/quaternion.hpp @@ -50,8 +50,7 @@ # pragma message("GLM: GLM_GTX_quaternion extension included") #endif -namespace glm{ -namespace gtx +namespace glm { /// @addtogroup gtx_quaternion /// @{ @@ -191,25 +190,25 @@ namespace gtx //! From GLM_GTX_quaternion extension. template detail::tmat3x3 toMat3( - detail::tquat const & x){return gtc::mat3_cast(x);} + detail::tquat const & x){return mat3_cast(x);} //! Converts a quaternion to a 4 * 4 matrix. //! From GLM_GTX_quaternion extension. template detail::tmat4x4 toMat4( - detail::tquat const & x){return gtc::mat4_cast(x);} + detail::tquat const & x){return mat4_cast(x);} //! Converts a 3 * 3 matrix to a quaternion. //! From GLM_GTX_quaternion extension. template detail::tquat toQuat( - detail::tmat3x3 const & x){return gtc::quat_cast(x);} + detail::tmat3x3 const & x){return quat_cast(x);} //! Converts a 4 * 4 matrix to a quaternion. //! From GLM_GTX_quaternion extension. template detail::tquat toQuat( - detail::tmat4x4 const & x){return gtc::quat_cast(x);} + detail::tmat4x4 const & x){return quat_cast(x);} //! Quaternion interpolation using the rotation short path. //! From GLM_GTX_quaternion extension. @@ -228,7 +227,6 @@ namespace gtx T const & a); /// @} -}//namespace gtx }//namespace glm #include "quaternion.inl" diff --git a/glm/gtx/quaternion.inl b/glm/gtx/quaternion.inl index a24e3bcb..68dea929 100644 --- a/glm/gtx/quaternion.inl +++ b/glm/gtx/quaternion.inl @@ -10,292 +10,290 @@ #include namespace glm{ -namespace gtx + +template +GLM_FUNC_QUALIFIER detail::tvec3 cross +( + detail::tvec3 const & v, + detail::tquat const & q +) { - template - GLM_FUNC_QUALIFIER detail::tvec3 cross - ( - detail::tvec3 const & v, - detail::tquat const & q - ) + return inverse(q) * v; +} + +template +GLM_FUNC_QUALIFIER detail::tvec3 cross +( + detail::tquat const & q, + detail::tvec3 const & v +) +{ + return q * v; +} + +template +GLM_FUNC_QUALIFIER detail::tquat squad +( + detail::tquat const & q1, + detail::tquat const & q2, + detail::tquat const & s1, + detail::tquat const & s2, + T const & h) +{ + return mix(mix(q1, q2, h), mix(s1, s2, h), T(2) * h (T(1) - h)); +} + +template +GLM_FUNC_QUALIFIER detail::tquat intermediate +( + detail::tquat const & prev, + detail::tquat const & curr, + detail::tquat const & next +) +{ + detail::tquat invQuat = inverse(curr); + return ext((log(next + invQuat) + log(prev + invQuat)) / T(-4)) * curr; +} + +template +GLM_FUNC_QUALIFIER detail::tquat exp +( + detail::tquat const & q, + T const & exponent +) +{ + detail::tvec3 u(q.x, q.y, q.z); + float a = glm::length(u); + detail::tvec3 v(u / a); + return detail::tquat(cos(a), sin(a) * v); +} + +template +GLM_FUNC_QUALIFIER detail::tquat log +( + detail::tquat const & q +) +{ + if((q.x == T(0)) && (q.y == T(0)) && (q.z == T(0))) { - return gtc::inverse(q) * v; - } - - template - GLM_FUNC_QUALIFIER detail::tvec3 cross - ( - detail::tquat const & q, - detail::tvec3 const & v - ) - { - return q * v; - } - - template - GLM_FUNC_QUALIFIER detail::tquat squad - ( - detail::tquat const & q1, - detail::tquat const & q2, - detail::tquat const & s1, - detail::tquat const & s2, - T const & h) - { - return mix(mix(q1, q2, h), mix(s1, s2, h), T(2) * h (T(1) - h)); - } - - template - GLM_FUNC_QUALIFIER detail::tquat intermediate - ( - detail::tquat const & prev, - detail::tquat const & curr, - detail::tquat const & next - ) - { - detail::tquat invQuat = gtc::inverse(curr); - return ext((log(next + invQuat) + log(prev + invQuat)) / T(-4)) * curr; - } - - template - GLM_FUNC_QUALIFIER detail::tquat exp - ( - detail::tquat const & q, - T const & exponent - ) - { - detail::tvec3 u(q.x, q.y, q.z); - float a = glm::length(u); - detail::tvec3 v(u / a); - return detail::tquat(cos(a), sin(a) * v); - } - - template - GLM_FUNC_QUALIFIER detail::tquat log - ( - detail::tquat const & q - ) - { - if((q.x == T(0)) && (q.y == T(0)) && (q.z == T(0))) - { - if(q.w > T(0)) - return detail::tquat(log(q.w), T(0), T(0), T(0)); - else if(q.w < T(0)) - return detail::tquat(log(-q.w), T(3.1415926535897932384626433832795), T(0),T(0)); - else - return detail::tquat(std::numeric_limits::infinity(), std::numeric_limits::infinity(), std::numeric_limits::infinity(), std::numeric_limits::infinity()); - } - else - { - T Vec3Len = sqrt(q.x * q.x + q.y * q.y + q.z * q.z); - T QuatLen = sqrt(Vec3Len * Vec3Len + q.w * q.w); - T t = atan(Vec3Len, T(q.w)) / Vec3Len; - return detail::tquat(t * q.x, t * q.y, t * q.z, log(QuatLen)); - } - } - - template - GLM_FUNC_QUALIFIER detail::tquat pow - ( - detail::tquat const & x, - T const & y - ) - { - if(abs(x.w) > T(0.9999)) - return x; - float Angle = acos(y); - float NewAngle = Angle * y; - float Div = sin(NewAngle) / sin(Angle); - return detail::tquat( - cos(NewAngle), - x.x * Div, - x.y * Div, - x.z * Div); - } - - //template - //GLM_FUNC_QUALIFIER detail::tquat sqrt - //( - // detail::tquat const & q - //) - //{ - // T q0 = T(1) - dot(q, q); - // return T(2) * (T(1) + q0) * q; - //} - - template - GLM_FUNC_QUALIFIER detail::tvec3 rotate - ( - detail::tquat const & q, - detail::tvec3 const & v - ) - { - return q * v; - } - - template - GLM_FUNC_QUALIFIER detail::tvec4 rotate - ( - detail::tquat const & q, - detail::tvec4 const & v - ) - { - return q * v; - } - - template - GLM_FUNC_QUALIFIER T angle - ( - detail::tquat const & x - ) - { - return glm::degrees(acos(x.w) * T(2)); - } - - template - GLM_FUNC_QUALIFIER detail::tvec3 axis - ( - detail::tquat const & x - ) - { - T tmp1 = T(1) - x.w * x.w; - if(tmp1 <= T(0)) - return detail::tvec3(0, 0, 1); - T tmp2 = T(1) / sqrt(tmp1); - return detail::tvec3(x.x * tmp2, x.y * tmp2, x.z * tmp2); - } - - template - GLM_FUNC_QUALIFIER detail::tquat angleAxis - ( - valType const & angle, - valType const & x, - valType const & y, - valType const & z - ) - { - return angleAxis(angle, detail::tvec3(x, y, z)); - } - - template - GLM_FUNC_QUALIFIER detail::tquat angleAxis - ( - valType const & angle, - detail::tvec3 const & v - ) - { - detail::tquat result; - - valType a = glm::radians(angle); - valType s = glm::sin(a * valType(0.5)); - - result.w = glm::cos(a * valType(0.5)); - result.x = v.x * s; - result.y = v.y * s; - result.z = v.z * s; - return result; - } - - template - GLM_FUNC_QUALIFIER T extractRealComponent - ( - detail::tquat const & q - ) - { - T w = T(1.0) - q.x * q.x - q.y * q.y - q.z * q.z; - if(w < T(0)) - return T(0); + if(q.w > T(0)) + return detail::tquat(log(q.w), T(0), T(0), T(0)); + else if(q.w < T(0)) + return detail::tquat(log(-q.w), T(3.1415926535897932384626433832795), T(0),T(0)); else - return -sqrt(w); + return detail::tquat(std::numeric_limits::infinity(), std::numeric_limits::infinity(), std::numeric_limits::infinity(), std::numeric_limits::infinity()); + } + else + { + T Vec3Len = sqrt(q.x * q.x + q.y * q.y + q.z * q.z); + T QuatLen = sqrt(Vec3Len * Vec3Len + q.w * q.w); + T t = atan(Vec3Len, T(q.w)) / Vec3Len; + return detail::tquat(t * q.x, t * q.y, t * q.z, log(QuatLen)); + } +} + +template +GLM_FUNC_QUALIFIER detail::tquat pow +( + detail::tquat const & x, + T const & y +) +{ + if(abs(x.w) > T(0.9999)) + return x; + float Angle = acos(y); + float NewAngle = Angle * y; + float Div = sin(NewAngle) / sin(Angle); + return detail::tquat( + cos(NewAngle), + x.x * Div, + x.y * Div, + x.z * Div); +} + +//template +//GLM_FUNC_QUALIFIER detail::tquat sqrt +//( +// detail::tquat const & q +//) +//{ +// T q0 = T(1) - dot(q, q); +// return T(2) * (T(1) + q0) * q; +//} + +template +GLM_FUNC_QUALIFIER detail::tvec3 rotate +( + detail::tquat const & q, + detail::tvec3 const & v +) +{ + return q * v; +} + +template +GLM_FUNC_QUALIFIER detail::tvec4 rotate +( + detail::tquat const & q, + detail::tvec4 const & v +) +{ + return q * v; +} + +template +GLM_FUNC_QUALIFIER T angle +( + detail::tquat const & x +) +{ + return glm::degrees(acos(x.w) * T(2)); +} + +template +GLM_FUNC_QUALIFIER detail::tvec3 axis +( + detail::tquat const & x +) +{ + T tmp1 = T(1) - x.w * x.w; + if(tmp1 <= T(0)) + return detail::tvec3(0, 0, 1); + T tmp2 = T(1) / sqrt(tmp1); + return detail::tvec3(x.x * tmp2, x.y * tmp2, x.z * tmp2); +} + +template +GLM_FUNC_QUALIFIER detail::tquat angleAxis +( + valType const & angle, + valType const & x, + valType const & y, + valType const & z +) +{ + return angleAxis(angle, detail::tvec3(x, y, z)); +} + +template +GLM_FUNC_QUALIFIER detail::tquat angleAxis +( + valType const & angle, + detail::tvec3 const & v +) +{ + detail::tquat result; + + valType a = glm::radians(angle); + valType s = glm::sin(a * valType(0.5)); + + result.w = glm::cos(a * valType(0.5)); + result.x = v.x * s; + result.y = v.y * s; + result.z = v.z * s; + return result; +} + +template +GLM_FUNC_QUALIFIER T extractRealComponent +( + detail::tquat const & q +) +{ + T w = T(1.0) - q.x * q.x - q.y * q.y - q.z * q.z; + if(w < T(0)) + return T(0); + else + return -sqrt(w); +} + +template +GLM_FUNC_QUALIFIER valType roll +( + detail::tquat const & q +) +{ + return atan2(valType(2) * (q.x * q.y + q.w * q.z), q.w * q.w + q.x * q.x - q.y * q.y - q.z * q.z); +} + +template +GLM_FUNC_QUALIFIER valType pitch +( + detail::tquat const & q +) +{ + return atan2(valType(2) * (q.y * q.z + q.w * q.x), q.w * q.w - q.x * q.x - q.y * q.y + q.z * q.z); +} + +template +GLM_FUNC_QUALIFIER valType yaw +( + detail::tquat const & q +) +{ + return asin(valType(-2) * (q.x * q.z - q.w * q.y)); +} + +template +GLM_FUNC_QUALIFIER detail::tvec3 eularAngles +( + detail::tquat const & x +) +{ + return detail::tvec3(pitch(x), yaw(x), roll(x)); +} + +template +GLM_FUNC_QUALIFIER detail::tquat shortMix +( + detail::tquat const & x, + detail::tquat const & y, + T const & a +) +{ + if(a <= typename detail::tquat::value_type(0)) return x; + if(a >= typename detail::tquat::value_type(1)) return y; + + T fCos = dot(x, y); + detail::tquat y2(y); //BUG!!! tquat y2; + if(fCos < T(0)) + { + y2 = -y; + fCos = -fCos; } - template - GLM_FUNC_QUALIFIER valType roll - ( - detail::tquat const & q - ) - { - return atan2(valType(2) * (q.x * q.y + q.w * q.z), q.w * q.w + q.x * q.x - q.y * q.y - q.z * q.z); - } - - template - GLM_FUNC_QUALIFIER valType pitch - ( - detail::tquat const & q - ) - { - return atan2(valType(2) * (q.y * q.z + q.w * q.x), q.w * q.w - q.x * q.x - q.y * q.y + q.z * q.z); - } - - template - GLM_FUNC_QUALIFIER valType yaw - ( - detail::tquat const & q - ) - { - return asin(valType(-2) * (q.x * q.z - q.w * q.y)); - } - - template - GLM_FUNC_QUALIFIER detail::tvec3 eularAngles - ( - detail::tquat const & x - ) + //if(fCos > 1.0f) // problem + T k0, k1; + if(fCos > T(0.9999)) { - return detail::tvec3(pitch(x), yaw(x), roll(x)); + k0 = T(1) - a; + k1 = T(0) + a; //BUG!!! 1.0f + a; + } + else + { + T fSin = sqrt(T(1) - fCos * fCos); + T fAngle = atan(fSin, fCos); + T fOneOverSin = T(1) / fSin; + k0 = sin((T(1) - a) * fAngle) * fOneOverSin; + k1 = sin((T(0) + a) * fAngle) * fOneOverSin; } - template - GLM_FUNC_QUALIFIER detail::tquat shortMix - ( - detail::tquat const & x, - detail::tquat const & y, - T const & a - ) - { - if(a <= typename detail::tquat::value_type(0)) return x; - if(a >= typename detail::tquat::value_type(1)) return y; + return detail::tquat( + k0 * x.w + k1 * y2.w, + k0 * x.x + k1 * y2.x, + k0 * x.y + k1 * y2.y, + k0 * x.z + k1 * y2.z); +} - T fCos = dot(x, y); - detail::tquat y2(y); //BUG!!! tquat y2; - if(fCos < T(0)) - { - y2 = -y; - fCos = -fCos; - } +template +GLM_FUNC_QUALIFIER detail::tquat fastMix +( + detail::tquat const & x, + detail::tquat const & y, + T const & a +) +{ + return glm::normalize(x * (T(1) - a) + (y * a)); +} - //if(fCos > 1.0f) // problem - T k0, k1; - if(fCos > T(0.9999)) - { - k0 = T(1) - a; - k1 = T(0) + a; //BUG!!! 1.0f + a; - } - else - { - T fSin = sqrt(T(1) - fCos * fCos); - T fAngle = atan(fSin, fCos); - T fOneOverSin = T(1) / fSin; - k0 = sin((T(1) - a) * fAngle) * fOneOverSin; - k1 = sin((T(0) + a) * fAngle) * fOneOverSin; - } - - return detail::tquat( - k0 * x.w + k1 * y2.w, - k0 * x.x + k1 * y2.x, - k0 * x.y + k1 * y2.y, - k0 * x.z + k1 * y2.z); - } - - template - GLM_FUNC_QUALIFIER detail::tquat fastMix - ( - detail::tquat const & x, - detail::tquat const & y, - T const & a - ) - { - return glm::normalize(x * (T(1) - a) + (y * a)); - } - -}//namespace gtx }//namespace glm diff --git a/glm/gtx/random.hpp b/glm/gtx/random.hpp index cc7aea9f..6232ea52 100644 --- a/glm/gtx/random.hpp +++ b/glm/gtx/random.hpp @@ -47,8 +47,7 @@ # pragma message("GLM: GLM_GTX_random extension included") #endif -namespace glm{ -namespace gtx +namespace glm { /// @addtogroup gtx_random /// @{ @@ -101,7 +100,6 @@ namespace gtx template detail::tvec4 gaussRand4(const detail::tvec4& mean, const detail::tvec4& std_deviation); //!< \brief Gererate 4 random floating numbers according a Gauss distribution. (From GLM_GTX_random extension) /// @} -}//namespace gtx }//namespace glm #include "random.inl" diff --git a/glm/gtx/random.inl b/glm/gtx/random.inl index 67c64e22..571fea56 100644 --- a/glm/gtx/random.inl +++ b/glm/gtx/random.inl @@ -11,524 +11,522 @@ #include namespace glm{ -namespace gtx + +template <> +GLM_FUNC_QUALIFIER float signedRand1() { - template <> - GLM_FUNC_QUALIFIER float signedRand1() + #if(GLM_COMPILER & GLM_COMPILER_VC)// && (GLM_COMPILER < GLM_COMPILER_VC2010) + #define RAND_SHIFT_NUM 5 + #else + #define RAND_SHIFT_NUM 0 + #endif + return float((std::rand() - (RAND_MAX >> 1) - 1) << 1) / float(RAND_MAX - RAND_SHIFT_NUM); +} + +template <> +GLM_FUNC_QUALIFIER double signedRand1() +{ + return double(signedRand1()); +} + +template +GLM_FUNC_QUALIFIER detail::tvec2 signedRand2() +{ + return detail::tvec2( + signedRand1(), + signedRand1()); +} + +template +GLM_FUNC_QUALIFIER detail::tvec3 signedRand3() +{ + return detail::tvec3( + signedRand1(), + signedRand1(), + signedRand1()); +} + +template +GLM_FUNC_QUALIFIER detail::tvec4 signedRand4() +{ + return detail::tvec4( + signedRand1(), + signedRand1(), + signedRand1(), + signedRand1()); +} + +template +GLM_FUNC_QUALIFIER detail::tvec2 normalizedRand2() +{ + T a = compRand1(T(0), T(6.283185307179586476925286766559f)); + return detail::tvec2(cos(a), sin(a)); +} + +template +GLM_FUNC_QUALIFIER detail::tvec3 normalizedRand3() +{ + T z = compRand1(T(-1), T(1)); + T a = compRand1(T(0), T(6.283185307179586476925286766559f)); + + T r = sqrt(T(1) - z * z); + + T x = r * cos(a); + T y = r * sin(a); + + return detail::tvec3(x, y, z); +} + +template +GLM_FUNC_QUALIFIER detail::tvec3 normalizedRand3( + T Min, + T Max) +{ + return normalizedRand3() * compRand1(Min, Max); +} + +template <> +GLM_FUNC_QUALIFIER float compRand1() +{ + return float(std::rand()) / float(RAND_MAX); +} + +template <> +GLM_FUNC_QUALIFIER double compRand1() +{ + return double(std::rand()) / double(RAND_MAX); +} + +GLM_FUNC_QUALIFIER detail::thalf compRand1( + detail::thalf Min, + detail::thalf Max) +{ + return compRand1() * (Max - Min) + Min; +} + +GLM_FUNC_QUALIFIER float compRand1( + float Min, + float Max) +{ + return compRand1() * (Max - Min) + Min; +} + +GLM_FUNC_QUALIFIER double compRand1( + double Min, + double Max) +{ + return compRand1() * (Max - Min) + Min; +} + +template +GLM_FUNC_QUALIFIER T compRand1( + T Min, + T Max) +{ + return T(compRand1() * double(Max - Min) + double(Min)); +} + +template +GLM_FUNC_QUALIFIER detail::tvec2 compRand2( + T Min, + T Max) +{ + return detail::tvec2( + compRand1(Min, Max), + compRand1(Min, Max)); +} + +template +GLM_FUNC_QUALIFIER detail::tvec3 compRand3( + T Min, + T Max) +{ + return detail::tvec3( + compRand1(Min, Max), + compRand1(Min, Max), + compRand1(Min, Max)); +} + +template +GLM_FUNC_QUALIFIER detail::tvec4 compRand4( + T Min, + T Max) +{ + return detail::tvec4( + compRand1(Min, Max), + compRand1(Min, Max), + compRand1(Min, Max), + compRand1(Min, Max)); +} + +template +GLM_FUNC_QUALIFIER detail::tvec2 compRand2( + T Min, + const detail::tvec2& Max) +{ + return detail::tvec2( + compRand1(Min.x, Max.x), + compRand1(Min.y, Max.y)); +} + +template +GLM_FUNC_QUALIFIER detail::tvec3 compRand3( + T Min, + const detail::tvec3& Max) +{ + return detail::tvec3( + compRand1(Min.x, Max.x), + compRand1(Min.y, Max.y), + compRand1(Min.z, Max.z)); +} + +template +GLM_FUNC_QUALIFIER detail::tvec4 compRand4( + T Min, + const detail::tvec4& Max) +{ + return detail::tvec4( + compRand1(Min.x, Max.x), + compRand1(Min.y, Max.y), + compRand1(Min.z, Max.z), + compRand1(Min.w, Max.w)); +} + +template +GLM_FUNC_QUALIFIER detail::tvec2 compRand2( + const detail::tvec2& Min, + T Max) +{ + return detail::tvec2( + compRand1(Min.x, Max.x), + compRand1(Min.y, Max.y)); +} + +template +GLM_FUNC_QUALIFIER detail::tvec3 compRand3( + const detail::tvec3& Min, + T Max) +{ + return detail::tvec3( + compRand1(Min.x, Max.x), + compRand1(Min.y, Max.y), + compRand1(Min.z, Max.z)); +} + +template +GLM_FUNC_QUALIFIER detail::tvec4 compRand4( + const detail::tvec4& Min, + T Max) +{ + return detail::tvec4( + compRand1(Min.x, Max.x), + compRand1(Min.y, Max.y), + compRand1(Min.z, Max.z), + compRand1(Min.w, Max.w)); +} + +template +GLM_FUNC_QUALIFIER detail::tvec2 compRand2( + const detail::tvec2& Min, + const detail::tvec2& Max) +{ + return detail::tvec2( + compRand1(Min.x, Max.x), + compRand1(Min.y, Max.y)); +} + +template +GLM_FUNC_QUALIFIER detail::tvec3 compRand3( + const detail::tvec3& Min, + const detail::tvec3& Max) +{ + return detail::tvec3( + compRand1(Min.x, Max.x), + compRand1(Min.y, Max.y), + compRand1(Min.z, Max.z)); +} + +template +GLM_FUNC_QUALIFIER detail::tvec4 compRand4( + const detail::tvec4& Min, + const detail::tvec4& Max) +{ + return detail::tvec4( + compRand1(Min.x, Max.x), + compRand1(Min.y, Max.y), + compRand1(Min.z, Max.z), + compRand1(Min.w, Max.w)); +} + +template +GLM_FUNC_QUALIFIER detail::tvec2 vecRand2() +{ + detail::tvec2 result(float(0)); + do { - #if(GLM_COMPILER & GLM_COMPILER_VC)// && (GLM_COMPILER < GLM_COMPILER_VC2010) - #define RAND_SHIFT_NUM 5 - #else - #define RAND_SHIFT_NUM 0 - #endif - return float((std::rand() - (RAND_MAX >> 1) - 1) << 1) / float(RAND_MAX - RAND_SHIFT_NUM); - } + result = compRand2(float(-1), float(1)); + } while (length(result) > float(1)); - template <> - GLM_FUNC_QUALIFIER double signedRand1() + return result; +} + +template +GLM_FUNC_QUALIFIER detail::tvec2 vecRand2() +{ + detail::tvec2 result(double(0)); + do { - return double(signedRand1()); - } + result = compRand2(double(-1), double(1)); + } while (length(result) > double(1)); - template - GLM_FUNC_QUALIFIER detail::tvec2 signedRand2() + return result; +} + +template +GLM_FUNC_QUALIFIER detail::tvec2 vecRand2( + T MinRadius, + T MaxRadius) +{ + assert(MinRadius <= MaxRadius); + + detail::tvec2 Result(T(0)); + T LenRadius(0); + + do { - return detail::tvec2( - signedRand1(), - signedRand1()); + Result = compRand2(-MaxRadius, MaxRadius); + LenRadius = length(Result); } + while(LenRadius > MaxRadius || LenRadius < MinRadius); - template - GLM_FUNC_QUALIFIER detail::tvec3 signedRand3() + return Result; +} + +template +GLM_FUNC_QUALIFIER detail::tvec3 vecRand3() +{ + detail::tvec3 Result(T(0)); + do { - return detail::tvec3( - signedRand1(), - signedRand1(), - signedRand1()); + Result = compRand3(T(-1), T(1)); } + while(length(Result) > T(1)); - template - GLM_FUNC_QUALIFIER detail::tvec4 signedRand4() + return Result; +} + +template +GLM_FUNC_QUALIFIER detail::tvec3 vecRand3( + T MinRadius, + T MaxRadius) +{ + assert(MinRadius <= MaxRadius); + + detail::tvec3 Result(0); + T LenRadius(0); + + do { - return detail::tvec4( - signedRand1(), - signedRand1(), - signedRand1(), - signedRand1()); + Result = compRand3(-MaxRadius, MaxRadius); + LenRadius = length(Result); } + while(LenRadius > MaxRadius || LenRadius < MinRadius); - template - GLM_FUNC_QUALIFIER detail::tvec2 normalizedRand2() - { - T a = compRand1(T(0), T(6.283185307179586476925286766559f)); - return detail::tvec2(cos(a), sin(a)); - } + return Result; +} - template - GLM_FUNC_QUALIFIER detail::tvec3 normalizedRand3() - { - T z = compRand1(T(-1), T(1)); - T a = compRand1(T(0), T(6.283185307179586476925286766559f)); - - T r = sqrt(T(1) - z * z); - - T x = r * cos(a); - T y = r * sin(a); - - return detail::tvec3(x, y, z); - } - - template - GLM_FUNC_QUALIFIER detail::tvec3 normalizedRand3( - T Min, - T Max) - { - return normalizedRand3() * compRand1(Min, Max); - } - - template <> - GLM_FUNC_QUALIFIER float compRand1() +template +GLM_FUNC_QUALIFIER detail::tvec4 vecRand4() +{ + detail::tvec4 result(float(0)); + do { - return float(std::rand()) / float(RAND_MAX); - } + result = compRand4(float(-1), float(1)); + } while (length(result) > float(1)); - template <> - GLM_FUNC_QUALIFIER double compRand1() + return result; +} + +template +GLM_FUNC_QUALIFIER detail::tvec4 vecRand4() +{ + detail::tvec4 result(double(0)); + do { - return double(std::rand()) / double(RAND_MAX); - } + result = compRand4(double(-1), double(1)); + } while (length(result) > double(1)); - GLM_FUNC_QUALIFIER glm::half compRand1( - glm::half Min, - glm::half Max) + return result; +} + +template +GLM_FUNC_QUALIFIER detail::tvec4 vecRand4( + T MinRadius, + T MaxRadius) +{ + assert(MinRadius <= MaxRadius); + + detail::tvec4 Result(T(0)); + T LenRadius(T(0)); + + do { - return compRand1() * (Max - Min) + Min; + Result = compRand4(-MaxRadius, MaxRadius); + LenRadius = length(Result); } + while(LenRadius > MaxRadius || LenRadius < MinRadius); - GLM_FUNC_QUALIFIER float compRand1( - float Min, - float Max) - { - return compRand1() * (Max - Min) + Min; - } + return Result; +} - GLM_FUNC_QUALIFIER double compRand1( - double Min, - double Max) - { - return compRand1() * (Max - Min) + Min; - } +template +GLM_FUNC_QUALIFIER T gaussRand1( + T mean, + T std_deviation) +{ + T w, x1, x2; - template - GLM_FUNC_QUALIFIER T compRand1( - T Min, - T Max) - { - return T(compRand1() * double(Max - Min) + double(Min)); - } - - template - GLM_FUNC_QUALIFIER detail::tvec2 compRand2( - T Min, - T Max) - { - return detail::tvec2( - compRand1(Min, Max), - compRand1(Min, Max)); - } - - template - GLM_FUNC_QUALIFIER detail::tvec3 compRand3( - T Min, - T Max) - { - return detail::tvec3( - compRand1(Min, Max), - compRand1(Min, Max), - compRand1(Min, Max)); - } - - template - GLM_FUNC_QUALIFIER detail::tvec4 compRand4( - T Min, - T Max) - { - return detail::tvec4( - compRand1(Min, Max), - compRand1(Min, Max), - compRand1(Min, Max), - compRand1(Min, Max)); - } - - template - GLM_FUNC_QUALIFIER detail::tvec2 compRand2( - T Min, - const detail::tvec2& Max) - { - return detail::tvec2( - compRand1(Min.x, Max.x), - compRand1(Min.y, Max.y)); - } - - template - GLM_FUNC_QUALIFIER detail::tvec3 compRand3( - T Min, - const detail::tvec3& Max) - { - return detail::tvec3( - compRand1(Min.x, Max.x), - compRand1(Min.y, Max.y), - compRand1(Min.z, Max.z)); - } - - template - GLM_FUNC_QUALIFIER detail::tvec4 compRand4( - T Min, - const detail::tvec4& Max) - { - return detail::tvec4( - compRand1(Min.x, Max.x), - compRand1(Min.y, Max.y), - compRand1(Min.z, Max.z), - compRand1(Min.w, Max.w)); - } - - template - GLM_FUNC_QUALIFIER detail::tvec2 compRand2( - const detail::tvec2& Min, - T Max) - { - return detail::tvec2( - compRand1(Min.x, Max.x), - compRand1(Min.y, Max.y)); - } - - template - GLM_FUNC_QUALIFIER detail::tvec3 compRand3( - const detail::tvec3& Min, - T Max) - { - return detail::tvec3( - compRand1(Min.x, Max.x), - compRand1(Min.y, Max.y), - compRand1(Min.z, Max.z)); - } - - template - GLM_FUNC_QUALIFIER detail::tvec4 compRand4( - const detail::tvec4& Min, - T Max) - { - return detail::tvec4( - compRand1(Min.x, Max.x), - compRand1(Min.y, Max.y), - compRand1(Min.z, Max.z), - compRand1(Min.w, Max.w)); - } - - template - GLM_FUNC_QUALIFIER detail::tvec2 compRand2( - const detail::tvec2& Min, - const detail::tvec2& Max) - { - return detail::tvec2( - compRand1(Min.x, Max.x), - compRand1(Min.y, Max.y)); - } - - template - GLM_FUNC_QUALIFIER detail::tvec3 compRand3( - const detail::tvec3& Min, - const detail::tvec3& Max) - { - return detail::tvec3( - compRand1(Min.x, Max.x), - compRand1(Min.y, Max.y), - compRand1(Min.z, Max.z)); - } - - template - GLM_FUNC_QUALIFIER detail::tvec4 compRand4( - const detail::tvec4& Min, - const detail::tvec4& Max) - { - return detail::tvec4( - compRand1(Min.x, Max.x), - compRand1(Min.y, Max.y), - compRand1(Min.z, Max.z), - compRand1(Min.w, Max.w)); - } - - template - GLM_FUNC_QUALIFIER detail::tvec2 vecRand2() + do { - detail::tvec2 result(float(0)); - do - { - result = compRand2(float(-1), float(1)); - } while (length(result) > float(1)); + x1 = compRand1(T(-1), T(1)); + x2 = compRand1(T(-1), T(1)); - return result; - } + w = x1 * x1 + x2 * x2; + } while(w > T(1)); - template - GLM_FUNC_QUALIFIER detail::tvec2 vecRand2() - { - detail::tvec2 result(double(0)); - do - { - result = compRand2(double(-1), double(1)); - } while (length(result) > double(1)); + return x2 * std_deviation * std_deviation * sqrt((T(-2) * log(w)) / w) + mean; +} - return result; - } +template +GLM_FUNC_QUALIFIER detail::tvec2 gaussRand2( + T mean, + T std_deviation) +{ + return detail::tvec2( + gaussRand1(mean, std_deviation), + gaussRand1(mean, std_deviation)); +} - template - GLM_FUNC_QUALIFIER detail::tvec2 vecRand2( - T MinRadius, - T MaxRadius) - { - assert(MinRadius <= MaxRadius); +template +GLM_FUNC_QUALIFIER detail::tvec3 gaussRand3( + T mean, + T std_deviation) +{ + return detail::tvec3( + gaussRand1(mean, std_deviation), + gaussRand1(mean, std_deviation), + gaussRand1(mean, std_deviation)); +} - detail::tvec2 Result(T(0)); - T LenRadius(0); +template +GLM_FUNC_QUALIFIER detail::tvec4 gaussRand4( + T mean, + T std_deviation) +{ + return detail::tvec4( + gaussRand1(mean, std_deviation), + gaussRand1(mean, std_deviation), + gaussRand1(mean, std_deviation), + gaussRand1(mean, std_deviation)); +} - do - { - Result = compRand2(-MaxRadius, MaxRadius); - LenRadius = length(Result); - } - while(LenRadius > MaxRadius || LenRadius < MinRadius); +template +GLM_FUNC_QUALIFIER detail::tvec2 gaussRand2( + T mean, + const detail::tvec2& std_deviation) +{ + return detail::tvec2( + gaussRand1(mean, std_deviation.x), + gaussRand1(mean, std_deviation.y)); +} - return Result; - } +template +GLM_FUNC_QUALIFIER detail::tvec3 gaussRand3( + T mean, + const detail::tvec3& std_deviation) +{ + return detail::tvec3( + gaussRand1(mean, std_deviation.x), + gaussRand1(mean, std_deviation.y), + gaussRand1(mean, std_deviation.z)); +} - template - GLM_FUNC_QUALIFIER detail::tvec3 vecRand3() - { - detail::tvec3 Result(T(0)); - do - { - Result = compRand3(T(-1), T(1)); - } - while(length(Result) > T(1)); +template +GLM_FUNC_QUALIFIER detail::tvec4 gaussRand4( + T mean, + const detail::tvec4& std_deviation) +{ + return detail::tvec4( + gaussRand1(mean, std_deviation.x), + gaussRand1(mean, std_deviation.y), + gaussRand1(mean, std_deviation.z), + gaussRand1(mean, std_deviation.w)); +} - return Result; - } +template +GLM_FUNC_QUALIFIER detail::tvec2 gaussRand2( + const detail::tvec2& mean, + T std_deviation) +{ + return detail::tvec2( + gaussRand1(mean.x, std_deviation), + gaussRand1(mean.y, std_deviation)); +} - template - GLM_FUNC_QUALIFIER detail::tvec3 vecRand3( - T MinRadius, - T MaxRadius) - { - assert(MinRadius <= MaxRadius); +template +GLM_FUNC_QUALIFIER detail::tvec3 gaussRand3( + const detail::tvec3& mean, + T std_deviation) +{ + return detail::tvec3( + gaussRand1(mean.x, std_deviation), + gaussRand1(mean.y, std_deviation), + gaussRand1(mean.z, std_deviation)); +} - detail::tvec3 Result(0); - T LenRadius(0); +template +GLM_FUNC_QUALIFIER detail::tvec4 gaussRand4( + const detail::tvec4& mean, + T std_deviation) +{ + return detail::tvec4( + gaussRand1(mean.x, std_deviation), + gaussRand1(mean.y, std_deviation), + gaussRand1(mean.z, std_deviation), + gaussRand1(mean.w, std_deviation)); +} - do - { - Result = compRand3(-MaxRadius, MaxRadius); - LenRadius = length(Result); - } - while(LenRadius > MaxRadius || LenRadius < MinRadius); +template +GLM_FUNC_QUALIFIER detail::tvec2 gaussRand2( + const detail::tvec2& mean, + const detail::tvec2& std_deviation) +{ + return detail::tvec2( + gaussRand1(mean.x, std_deviation.x), + gaussRand1(mean.y, std_deviation.y)); +} - return Result; - } +template +GLM_FUNC_QUALIFIER detail::tvec3 gaussRand3( + const detail::tvec3& mean, + const detail::tvec3& std_deviation) +{ + return detail::tvec3( + gaussRand1(mean.x, std_deviation.x), + gaussRand1(mean.y, std_deviation.y), + gaussRand1(mean.z, std_deviation.z)); +} - template - GLM_FUNC_QUALIFIER detail::tvec4 vecRand4() - { - detail::tvec4 result(float(0)); - do - { - result = compRand4(float(-1), float(1)); - } while (length(result) > float(1)); +template +GLM_FUNC_QUALIFIER detail::tvec4 gaussRand4( + const detail::tvec4& mean, + const detail::tvec4& std_deviation) +{ + return detail::tvec4( + gaussRand1(mean.x, std_deviation.x), + gaussRand1(mean.y, std_deviation.y), + gaussRand1(mean.z, std_deviation.z), + gaussRand1(mean.w, std_deviation.w)); +} - return result; - } - - template - GLM_FUNC_QUALIFIER detail::tvec4 vecRand4() - { - detail::tvec4 result(double(0)); - do - { - result = compRand4(double(-1), double(1)); - } while (length(result) > double(1)); - - return result; - } - - template - GLM_FUNC_QUALIFIER detail::tvec4 vecRand4( - T MinRadius, - T MaxRadius) - { - assert(MinRadius <= MaxRadius); - - detail::tvec4 Result(T(0)); - T LenRadius(T(0)); - - do - { - Result = compRand4(-MaxRadius, MaxRadius); - LenRadius = length(Result); - } - while(LenRadius > MaxRadius || LenRadius < MinRadius); - - return Result; - } - - template - GLM_FUNC_QUALIFIER T gaussRand1( - T mean, - T std_deviation) - { - T w, x1, x2; - - do - { - x1 = compRand1(T(-1), T(1)); - x2 = compRand1(T(-1), T(1)); - - w = x1 * x1 + x2 * x2; - } while(w > T(1)); - - return x2 * std_deviation * std_deviation * sqrt((T(-2) * log(w)) / w) + mean; - } - - template - GLM_FUNC_QUALIFIER detail::tvec2 gaussRand2( - T mean, - T std_deviation) - { - return detail::tvec2( - gaussRand1(mean, std_deviation), - gaussRand1(mean, std_deviation)); - } - - template - GLM_FUNC_QUALIFIER detail::tvec3 gaussRand3( - T mean, - T std_deviation) - { - return detail::tvec3( - gaussRand1(mean, std_deviation), - gaussRand1(mean, std_deviation), - gaussRand1(mean, std_deviation)); - } - - template - GLM_FUNC_QUALIFIER detail::tvec4 gaussRand4( - T mean, - T std_deviation) - { - return detail::tvec4( - gaussRand1(mean, std_deviation), - gaussRand1(mean, std_deviation), - gaussRand1(mean, std_deviation), - gaussRand1(mean, std_deviation)); - } - - template - GLM_FUNC_QUALIFIER detail::tvec2 gaussRand2( - T mean, - const detail::tvec2& std_deviation) - { - return detail::tvec2( - gaussRand1(mean, std_deviation.x), - gaussRand1(mean, std_deviation.y)); - } - - template - GLM_FUNC_QUALIFIER detail::tvec3 gaussRand3( - T mean, - const detail::tvec3& std_deviation) - { - return detail::tvec3( - gaussRand1(mean, std_deviation.x), - gaussRand1(mean, std_deviation.y), - gaussRand1(mean, std_deviation.z)); - } - - template - GLM_FUNC_QUALIFIER detail::tvec4 gaussRand4( - T mean, - const detail::tvec4& std_deviation) - { - return detail::tvec4( - gaussRand1(mean, std_deviation.x), - gaussRand1(mean, std_deviation.y), - gaussRand1(mean, std_deviation.z), - gaussRand1(mean, std_deviation.w)); - } - - template - GLM_FUNC_QUALIFIER detail::tvec2 gaussRand2( - const detail::tvec2& mean, - T std_deviation) - { - return detail::tvec2( - gaussRand1(mean.x, std_deviation), - gaussRand1(mean.y, std_deviation)); - } - - template - GLM_FUNC_QUALIFIER detail::tvec3 gaussRand3( - const detail::tvec3& mean, - T std_deviation) - { - return detail::tvec3( - gaussRand1(mean.x, std_deviation), - gaussRand1(mean.y, std_deviation), - gaussRand1(mean.z, std_deviation)); - } - - template - GLM_FUNC_QUALIFIER detail::tvec4 gaussRand4( - const detail::tvec4& mean, - T std_deviation) - { - return detail::tvec4( - gaussRand1(mean.x, std_deviation), - gaussRand1(mean.y, std_deviation), - gaussRand1(mean.z, std_deviation), - gaussRand1(mean.w, std_deviation)); - } - - template - GLM_FUNC_QUALIFIER detail::tvec2 gaussRand2( - const detail::tvec2& mean, - const detail::tvec2& std_deviation) - { - return detail::tvec2( - gaussRand1(mean.x, std_deviation.x), - gaussRand1(mean.y, std_deviation.y)); - } - - template - GLM_FUNC_QUALIFIER detail::tvec3 gaussRand3( - const detail::tvec3& mean, - const detail::tvec3& std_deviation) - { - return detail::tvec3( - gaussRand1(mean.x, std_deviation.x), - gaussRand1(mean.y, std_deviation.y), - gaussRand1(mean.z, std_deviation.z)); - } - - template - GLM_FUNC_QUALIFIER detail::tvec4 gaussRand4( - const detail::tvec4& mean, - const detail::tvec4& std_deviation) - { - return detail::tvec4( - gaussRand1(mean.x, std_deviation.x), - gaussRand1(mean.y, std_deviation.y), - gaussRand1(mean.z, std_deviation.z), - gaussRand1(mean.w, std_deviation.w)); - } - -}//namespace gtx }//namespace glm diff --git a/glm/gtx/raw_data.hpp b/glm/gtx/raw_data.hpp index 84bb46f4..f752ee39 100644 --- a/glm/gtx/raw_data.hpp +++ b/glm/gtx/raw_data.hpp @@ -46,8 +46,7 @@ # pragma message("GLM: GLM_GTX_raw_data extension included") #endif -namespace glm{ -namespace gtx +namespace glm { /// @addtogroup gtx_raw_data /// @{ @@ -69,7 +68,6 @@ namespace gtx typedef uint64 qword; /// @} -}// namespace gtx }// namespace glm #include "raw_data.inl" diff --git a/glm/gtx/reciprocal.hpp b/glm/gtx/reciprocal.hpp index 12212fa2..74f89c37 100644 --- a/glm/gtx/reciprocal.hpp +++ b/glm/gtx/reciprocal.hpp @@ -45,8 +45,7 @@ # pragma message("GLM: GLM_GTX_reciprocal extension included") #endif -namespace glm{ -namespace gtx +namespace glm { /// @addtogroup gtx_reciprocal /// @{ @@ -115,7 +114,6 @@ namespace gtx genType acoth(genType const & x); /// @} -}//namespace gtx }//namespace glm #include "reciprocal.inl" diff --git a/glm/gtx/reciprocal.inl b/glm/gtx/reciprocal.inl index bcd10423..7172694f 100644 --- a/glm/gtx/reciprocal.inl +++ b/glm/gtx/reciprocal.inl @@ -8,7 +8,6 @@ /////////////////////////////////////////////////////////////////////////////////////////////////// namespace glm{ -namespace gtx{ // sec template @@ -587,5 +586,4 @@ GLM_FUNC_QUALIFIER detail::tvec4 acoth acoth(x.w)); } -}//namespace gtx }//namespace glm diff --git a/glm/gtx/rotate_vector.hpp b/glm/gtx/rotate_vector.hpp index 396300c3..d914369b 100644 --- a/glm/gtx/rotate_vector.hpp +++ b/glm/gtx/rotate_vector.hpp @@ -47,8 +47,7 @@ # pragma message("GLM: GLM_GTX_rotate_vector extension included") #endif -namespace glm{ -namespace gtx +namespace glm { /// @addtogroup gtx_rotate_vector /// @{ @@ -126,7 +125,6 @@ namespace gtx detail::tvec3 const & Up); /// @} -}//namespace gtx }//namespace glm #include "rotate_vector.inl" diff --git a/glm/gtx/rotate_vector.inl b/glm/gtx/rotate_vector.inl index 5a73459b..f96a90e3 100644 --- a/glm/gtx/rotate_vector.inl +++ b/glm/gtx/rotate_vector.inl @@ -8,140 +8,138 @@ /////////////////////////////////////////////////////////////////////////////////////////////////// namespace glm{ -namespace gtx{ - template - GLM_FUNC_QUALIFIER detail::tvec2 rotate( - detail::tvec2 const & v, - T const & angle) - { - detail::tvec2 Result; - const T Cos = cos(radians(angle)); - const T Sin = sin(radians(angle)); - Result.x = v.x * Cos - v.y * Sin; - Result.y = v.x * Sin + v.y * Cos; - return Result; - } +template +GLM_FUNC_QUALIFIER detail::tvec2 rotate( + detail::tvec2 const & v, + T const & angle) +{ + detail::tvec2 Result; + const T Cos = cos(radians(angle)); + const T Sin = sin(radians(angle)); + Result.x = v.x * Cos - v.y * Sin; + Result.y = v.x * Sin + v.y * Cos; + return Result; +} - template - GLM_FUNC_QUALIFIER detail::tvec3 rotate( - const detail::tvec3 & v, - T const & angle, - const detail::tvec3 & normal) - { - return detail::tmat3x3(glm::gtx::rotate(angle, normal)) * v; - } +template +GLM_FUNC_QUALIFIER detail::tvec3 rotate( + const detail::tvec3 & v, + T const & angle, + const detail::tvec3 & normal) +{ + return detail::tmat3x3(glm::rotate(angle, normal)) * v; +} /* - template - GLM_FUNC_QUALIFIER detail::tvec3 rotateGTX( - const detail::tvec3& x, - T angle, - const detail::tvec3& normal) - { - const T Cos = cos(radians(angle)); - const T Sin = sin(radians(angle)); - return x * Cos + ((x * normal) * (T(1) - Cos)) * normal + cross(x, normal) * Sin; - } +template +GLM_FUNC_QUALIFIER detail::tvec3 rotateGTX( + const detail::tvec3& x, + T angle, + const detail::tvec3& normal) +{ + const T Cos = cos(radians(angle)); + const T Sin = sin(radians(angle)); + return x * Cos + ((x * normal) * (T(1) - Cos)) * normal + cross(x, normal) * Sin; +} */ - template - GLM_FUNC_QUALIFIER detail::tvec4 rotate( - detail::tvec4 const & v, - T const & angle, - detail::tvec3 const & normal) - { - return glm::gtx::rotate(angle, normal) * v; - } +template +GLM_FUNC_QUALIFIER detail::tvec4 rotate( + detail::tvec4 const & v, + T const & angle, + detail::tvec3 const & normal) +{ + return rotate(angle, normal) * v; +} - template - GLM_FUNC_QUALIFIER detail::tvec3 rotateX( - detail::tvec3 const & v, - T const & angle) - { - detail::tvec3 Result = v; - const T Cos = cos(radians(angle)); - const T Sin = sin(radians(angle)); - Result.y = v.y * Cos - v.z * Sin; - Result.z = v.y * Sin + v.z * Cos; - return Result; - } +template +GLM_FUNC_QUALIFIER detail::tvec3 rotateX( + detail::tvec3 const & v, + T const & angle) +{ + detail::tvec3 Result = v; + const T Cos = cos(radians(angle)); + const T Sin = sin(radians(angle)); + Result.y = v.y * Cos - v.z * Sin; + Result.z = v.y * Sin + v.z * Cos; + return Result; +} - template - GLM_FUNC_QUALIFIER detail::tvec3 rotateY( - detail::tvec3 const & v, - T const & angle) - { - detail::tvec3 Result = v; - const T Cos = cos(radians(angle)); - const T Sin = sin(radians(angle)); - Result.x = v.x * Cos + v.z * Sin; - Result.z = -v.x * Sin + v.z * Cos; - return Result; - } +template +GLM_FUNC_QUALIFIER detail::tvec3 rotateY( + detail::tvec3 const & v, + T const & angle) +{ + detail::tvec3 Result = v; + const T Cos = cos(radians(angle)); + const T Sin = sin(radians(angle)); + Result.x = v.x * Cos + v.z * Sin; + Result.z = -v.x * Sin + v.z * Cos; + return Result; +} - template - GLM_FUNC_QUALIFIER detail::tvec3 rotateZ( - detail::tvec3 const & v, - T const & angle) - { - detail::tvec3 Result = v; - const T Cos = cos(radians(angle)); - const T Sin = sin(radians(angle)); - Result.x = v.x * Cos - v.y * Sin; - Result.y = v.x * Sin + v.y * Cos; - return Result; - } +template +GLM_FUNC_QUALIFIER detail::tvec3 rotateZ( + detail::tvec3 const & v, + T const & angle) +{ + detail::tvec3 Result = v; + const T Cos = cos(radians(angle)); + const T Sin = sin(radians(angle)); + Result.x = v.x * Cos - v.y * Sin; + Result.y = v.x * Sin + v.y * Cos; + return Result; +} - template - GLM_FUNC_QUALIFIER detail::tvec4 rotateX( - detail::tvec4 const & v, - T const & angle) - { - detail::tvec4 Result = v; - const T Cos = cos(radians(angle)); - const T Sin = sin(radians(angle)); - Result.y = v.y * Cos - v.z * Sin; - Result.z = v.y * Sin + v.z * Cos; - return Result; - } +template +GLM_FUNC_QUALIFIER detail::tvec4 rotateX( + detail::tvec4 const & v, + T const & angle) +{ + detail::tvec4 Result = v; + const T Cos = cos(radians(angle)); + const T Sin = sin(radians(angle)); + Result.y = v.y * Cos - v.z * Sin; + Result.z = v.y * Sin + v.z * Cos; + return Result; +} - template - GLM_FUNC_QUALIFIER detail::tvec4 rotateY( - detail::tvec4 const & v, - T const & angle) - { - detail::tvec4 Result = v; - const T Cos = cos(radians(angle)); - const T Sin = sin(radians(angle)); - Result.x = v.x * Cos + v.z * Sin; - Result.z = -v.x * Sin + v.z * Cos; - return Result; - } +template +GLM_FUNC_QUALIFIER detail::tvec4 rotateY( + detail::tvec4 const & v, + T const & angle) +{ + detail::tvec4 Result = v; + const T Cos = cos(radians(angle)); + const T Sin = sin(radians(angle)); + Result.x = v.x * Cos + v.z * Sin; + Result.z = -v.x * Sin + v.z * Cos; + return Result; +} - template - GLM_FUNC_QUALIFIER detail::tvec4 rotateZ( - detail::tvec4 const & v, - T const & angle) - { - detail::tvec4 Result = v; - const T Cos = cos(radians(angle)); - const T Sin = sin(radians(angle)); - Result.x = v.x * Cos - v.y * Sin; - Result.y = v.x * Sin + v.y * Cos; - return Result; - } +template +GLM_FUNC_QUALIFIER detail::tvec4 rotateZ( + detail::tvec4 const & v, + T const & angle) +{ + detail::tvec4 Result = v; + const T Cos = cos(radians(angle)); + const T Sin = sin(radians(angle)); + Result.x = v.x * Cos - v.y * Sin; + Result.y = v.x * Sin + v.y * Cos; + return Result; +} - template - GLM_FUNC_QUALIFIER detail::tmat4x4 orientation( - detail::tvec3 const & Normal, - detail::tvec3 const & Up) - { - if(all(equal(Normal, Up))) - return detail::tmat4x4(T(1)); +template +GLM_FUNC_QUALIFIER detail::tmat4x4 orientation( + detail::tvec3 const & Normal, + detail::tvec3 const & Up) +{ + if(all(equal(Normal, Up))) + return detail::tmat4x4(T(1)); - detail::tvec3 RotationAxis = cross(Up, Normal); - T Angle = degrees(acos(dot(Normal, Up))); - return glm::gtx::rotate(Angle, RotationAxis); - } + detail::tvec3 RotationAxis = cross(Up, Normal); + T Angle = degrees(acos(dot(Normal, Up))); + return rotate(Angle, RotationAxis); +} -}//namespace gtx }//namespace glm diff --git a/glm/gtx/simd_mat4.hpp b/glm/gtx/simd_mat4.hpp index 47ca7ecb..90496318 100644 --- a/glm/gtx/simd_mat4.hpp +++ b/glm/gtx/simd_mat4.hpp @@ -152,8 +152,6 @@ namespace detail fmat4x4SIMD const operator++ (fmat4x4SIMD const & m, int); }//namespace detail -namespace gtx -{ typedef detail::fmat4x4SIMD simdMat4; /// @addtogroup gtx_simd_mat4 @@ -195,7 +193,6 @@ namespace gtx detail::fmat4x4SIMD const & m); /// @} -}// namespace gtx }// namespace glm #include "simd_mat4.inl" diff --git a/glm/gtx/simd_mat4.inl b/glm/gtx/simd_mat4.inl index 4c43099b..c71593fa 100644 --- a/glm/gtx/simd_mat4.inl +++ b/glm/gtx/simd_mat4.inl @@ -8,300 +8,297 @@ /////////////////////////////////////////////////////////////////////////////////////////////////// namespace glm{ -namespace detail +namespace detail{ + +GLM_FUNC_QUALIFIER fmat4x4SIMD::size_type fmat4x4SIMD::value_size() { - GLM_FUNC_QUALIFIER fmat4x4SIMD::size_type fmat4x4SIMD::value_size() - { - return sizeof(value_type); - } + return sizeof(value_type); +} - GLM_FUNC_QUALIFIER fmat4x4SIMD::size_type fmat4x4SIMD::col_size() - { - return 4; - } +GLM_FUNC_QUALIFIER fmat4x4SIMD::size_type fmat4x4SIMD::col_size() +{ + return 4; +} - GLM_FUNC_QUALIFIER fmat4x4SIMD::size_type fmat4x4SIMD::row_size() - { - return 4; - } +GLM_FUNC_QUALIFIER fmat4x4SIMD::size_type fmat4x4SIMD::row_size() +{ + return 4; +} - GLM_FUNC_QUALIFIER fmat4x4SIMD::fmat4x4SIMD() - {} +GLM_FUNC_QUALIFIER fmat4x4SIMD::fmat4x4SIMD() +{} - GLM_FUNC_QUALIFIER fmat4x4SIMD::fmat4x4SIMD(float const & s) - { - this->Data[0] = fvec4SIMD(s, 0, 0, 0); - this->Data[1] = fvec4SIMD(0, s, 0, 0); - this->Data[2] = fvec4SIMD(0, 0, s, 0); - this->Data[3] = fvec4SIMD(0, 0, 0, s); - } +GLM_FUNC_QUALIFIER fmat4x4SIMD::fmat4x4SIMD(float const & s) +{ + this->Data[0] = fvec4SIMD(s, 0, 0, 0); + this->Data[1] = fvec4SIMD(0, s, 0, 0); + this->Data[2] = fvec4SIMD(0, 0, s, 0); + this->Data[3] = fvec4SIMD(0, 0, 0, s); +} - GLM_FUNC_QUALIFIER fmat4x4SIMD::fmat4x4SIMD - ( - float const & x0, float const & y0, float const & z0, float const & w0, - float const & x1, float const & y1, float const & z1, float const & w1, - float const & x2, float const & y2, float const & z2, float const & w2, - float const & x3, float const & y3, float const & z3, float const & w3 - ) - { - this->Data[0] = fvec4SIMD(x0, y0, z0, w0); - this->Data[1] = fvec4SIMD(x1, y1, z1, w1); - this->Data[2] = fvec4SIMD(x2, y2, z2, w2); - this->Data[3] = fvec4SIMD(x3, y3, z3, w3); - } +GLM_FUNC_QUALIFIER fmat4x4SIMD::fmat4x4SIMD +( + float const & x0, float const & y0, float const & z0, float const & w0, + float const & x1, float const & y1, float const & z1, float const & w1, + float const & x2, float const & y2, float const & z2, float const & w2, + float const & x3, float const & y3, float const & z3, float const & w3 +) +{ + this->Data[0] = fvec4SIMD(x0, y0, z0, w0); + this->Data[1] = fvec4SIMD(x1, y1, z1, w1); + this->Data[2] = fvec4SIMD(x2, y2, z2, w2); + this->Data[3] = fvec4SIMD(x3, y3, z3, w3); +} - GLM_FUNC_QUALIFIER fmat4x4SIMD::fmat4x4SIMD - ( - fvec4SIMD const & v0, - fvec4SIMD const & v1, - fvec4SIMD const & v2, - fvec4SIMD const & v3 - ) - { - this->Data[0] = v0; - this->Data[1] = v1; - this->Data[2] = v2; - this->Data[3] = v3; - } +GLM_FUNC_QUALIFIER fmat4x4SIMD::fmat4x4SIMD +( + fvec4SIMD const & v0, + fvec4SIMD const & v1, + fvec4SIMD const & v2, + fvec4SIMD const & v3 +) +{ + this->Data[0] = v0; + this->Data[1] = v1; + this->Data[2] = v2; + this->Data[3] = v3; +} - GLM_FUNC_QUALIFIER fmat4x4SIMD::fmat4x4SIMD - ( - tmat4x4 const & m - ) - { - this->Data[0] = fvec4SIMD(m[0]); - this->Data[1] = fvec4SIMD(m[1]); - this->Data[2] = fvec4SIMD(m[2]); - this->Data[3] = fvec4SIMD(m[3]); - } +GLM_FUNC_QUALIFIER fmat4x4SIMD::fmat4x4SIMD +( + tmat4x4 const & m +) +{ + this->Data[0] = fvec4SIMD(m[0]); + this->Data[1] = fvec4SIMD(m[1]); + this->Data[2] = fvec4SIMD(m[2]); + this->Data[3] = fvec4SIMD(m[3]); +} - ////////////////////////////////////// - // Accesses +////////////////////////////////////// +// Accesses - GLM_FUNC_QUALIFIER fvec4SIMD & fmat4x4SIMD::operator[] - ( - fmat4x4SIMD::size_type i - ) - { - assert( - i >= fmat4x4SIMD::size_type(0) && - i < fmat4x4SIMD::col_size()); +GLM_FUNC_QUALIFIER fvec4SIMD & fmat4x4SIMD::operator[] +( + fmat4x4SIMD::size_type i +) +{ + assert( + i >= fmat4x4SIMD::size_type(0) && + i < fmat4x4SIMD::col_size()); - return this->Data[i]; - } + return this->Data[i]; +} - GLM_FUNC_QUALIFIER fvec4SIMD const & fmat4x4SIMD::operator[] - ( - fmat4x4SIMD::size_type i - ) const - { - assert( - i >= fmat4x4SIMD::size_type(0) && - i < fmat4x4SIMD::col_size()); +GLM_FUNC_QUALIFIER fvec4SIMD const & fmat4x4SIMD::operator[] +( + fmat4x4SIMD::size_type i +) const +{ + assert( + i >= fmat4x4SIMD::size_type(0) && + i < fmat4x4SIMD::col_size()); - return this->Data[i]; - } + return this->Data[i]; +} - ////////////////////////////////////////////////////////////// - // mat4 operators +////////////////////////////////////////////////////////////// +// mat4 operators - GLM_FUNC_QUALIFIER fmat4x4SIMD& fmat4x4SIMD::operator= - ( - fmat4x4SIMD const & m - ) - { - this->Data[0] = m[0]; - this->Data[1] = m[1]; - this->Data[2] = m[2]; - this->Data[3] = m[3]; - return *this; - } +GLM_FUNC_QUALIFIER fmat4x4SIMD& fmat4x4SIMD::operator= +( + fmat4x4SIMD const & m +) +{ + this->Data[0] = m[0]; + this->Data[1] = m[1]; + this->Data[2] = m[2]; + this->Data[3] = m[3]; + return *this; +} - GLM_FUNC_QUALIFIER fmat4x4SIMD & fmat4x4SIMD::operator+= - ( - fmat4x4SIMD const & m - ) - { - this->Data[0].Data = _mm_add_ps(this->Data[0].Data, m[0].Data); - this->Data[1].Data = _mm_add_ps(this->Data[1].Data, m[1].Data); - this->Data[2].Data = _mm_add_ps(this->Data[2].Data, m[2].Data); - this->Data[3].Data = _mm_add_ps(this->Data[3].Data, m[3].Data); - return *this; - } +GLM_FUNC_QUALIFIER fmat4x4SIMD & fmat4x4SIMD::operator+= +( + fmat4x4SIMD const & m +) +{ + this->Data[0].Data = _mm_add_ps(this->Data[0].Data, m[0].Data); + this->Data[1].Data = _mm_add_ps(this->Data[1].Data, m[1].Data); + this->Data[2].Data = _mm_add_ps(this->Data[2].Data, m[2].Data); + this->Data[3].Data = _mm_add_ps(this->Data[3].Data, m[3].Data); + return *this; +} - GLM_FUNC_QUALIFIER fmat4x4SIMD & fmat4x4SIMD::operator-= - ( - fmat4x4SIMD const & m - ) - { - this->Data[0].Data = _mm_sub_ps(this->Data[0].Data, m[0].Data); - this->Data[1].Data = _mm_sub_ps(this->Data[1].Data, m[1].Data); - this->Data[2].Data = _mm_sub_ps(this->Data[2].Data, m[2].Data); - this->Data[3].Data = _mm_sub_ps(this->Data[3].Data, m[3].Data); +GLM_FUNC_QUALIFIER fmat4x4SIMD & fmat4x4SIMD::operator-= +( + fmat4x4SIMD const & m +) +{ + this->Data[0].Data = _mm_sub_ps(this->Data[0].Data, m[0].Data); + this->Data[1].Data = _mm_sub_ps(this->Data[1].Data, m[1].Data); + this->Data[2].Data = _mm_sub_ps(this->Data[2].Data, m[2].Data); + this->Data[3].Data = _mm_sub_ps(this->Data[3].Data, m[3].Data); - return *this; - } + return *this; +} - GLM_FUNC_QUALIFIER fmat4x4SIMD & fmat4x4SIMD::operator*= - ( - fmat4x4SIMD const & m - ) - { - sse_mul_ps(&this->Data[0].Data, &m.Data[0].Data, &this->Data[0].Data); - return *this; - } +GLM_FUNC_QUALIFIER fmat4x4SIMD & fmat4x4SIMD::operator*= +( + fmat4x4SIMD const & m +) +{ + sse_mul_ps(&this->Data[0].Data, &m.Data[0].Data, &this->Data[0].Data); + return *this; +} - GLM_FUNC_QUALIFIER fmat4x4SIMD & fmat4x4SIMD::operator/= - ( - fmat4x4SIMD const & m - ) - { - __m128 Inv[4]; - sse_inverse_ps(&this->Data[0].Data, Inv); - sse_mul_ps(&this->Data[0].Data, Inv, &this->Data[0].Data); - return *this; - } +GLM_FUNC_QUALIFIER fmat4x4SIMD & fmat4x4SIMD::operator/= +( + fmat4x4SIMD const & m +) +{ + __m128 Inv[4]; + sse_inverse_ps(&this->Data[0].Data, Inv); + sse_mul_ps(&this->Data[0].Data, Inv, &this->Data[0].Data); + return *this; +} - GLM_FUNC_QUALIFIER fmat4x4SIMD & fmat4x4SIMD::operator+= - ( - float const & s - ) - { - __m128 Operand = _mm_set_ps1(s); - this->Data[0].Data = _mm_add_ps(this->Data[0].Data, Operand); - this->Data[1].Data = _mm_add_ps(this->Data[1].Data, Operand); - this->Data[2].Data = _mm_add_ps(this->Data[2].Data, Operand); - this->Data[3].Data = _mm_add_ps(this->Data[3].Data, Operand); - return *this; - } +GLM_FUNC_QUALIFIER fmat4x4SIMD & fmat4x4SIMD::operator+= +( + float const & s +) +{ + __m128 Operand = _mm_set_ps1(s); + this->Data[0].Data = _mm_add_ps(this->Data[0].Data, Operand); + this->Data[1].Data = _mm_add_ps(this->Data[1].Data, Operand); + this->Data[2].Data = _mm_add_ps(this->Data[2].Data, Operand); + this->Data[3].Data = _mm_add_ps(this->Data[3].Data, Operand); + return *this; +} - GLM_FUNC_QUALIFIER fmat4x4SIMD & fmat4x4SIMD::operator-= - ( - float const & s - ) - { - __m128 Operand = _mm_set_ps1(s); - this->Data[0].Data = _mm_sub_ps(this->Data[0].Data, Operand); - this->Data[1].Data = _mm_sub_ps(this->Data[1].Data, Operand); - this->Data[2].Data = _mm_sub_ps(this->Data[2].Data, Operand); - this->Data[3].Data = _mm_sub_ps(this->Data[3].Data, Operand); - return *this; - } +GLM_FUNC_QUALIFIER fmat4x4SIMD & fmat4x4SIMD::operator-= +( + float const & s +) +{ + __m128 Operand = _mm_set_ps1(s); + this->Data[0].Data = _mm_sub_ps(this->Data[0].Data, Operand); + this->Data[1].Data = _mm_sub_ps(this->Data[1].Data, Operand); + this->Data[2].Data = _mm_sub_ps(this->Data[2].Data, Operand); + this->Data[3].Data = _mm_sub_ps(this->Data[3].Data, Operand); + return *this; +} - GLM_FUNC_QUALIFIER fmat4x4SIMD & fmat4x4SIMD::operator*= - ( - float const & s - ) - { - __m128 Operand = _mm_set_ps1(s); - this->Data[0].Data = _mm_mul_ps(this->Data[0].Data, Operand); - this->Data[1].Data = _mm_mul_ps(this->Data[1].Data, Operand); - this->Data[2].Data = _mm_mul_ps(this->Data[2].Data, Operand); - this->Data[3].Data = _mm_mul_ps(this->Data[3].Data, Operand); - return *this; - } +GLM_FUNC_QUALIFIER fmat4x4SIMD & fmat4x4SIMD::operator*= +( + float const & s +) +{ + __m128 Operand = _mm_set_ps1(s); + this->Data[0].Data = _mm_mul_ps(this->Data[0].Data, Operand); + this->Data[1].Data = _mm_mul_ps(this->Data[1].Data, Operand); + this->Data[2].Data = _mm_mul_ps(this->Data[2].Data, Operand); + this->Data[3].Data = _mm_mul_ps(this->Data[3].Data, Operand); + return *this; +} - GLM_FUNC_QUALIFIER fmat4x4SIMD & fmat4x4SIMD::operator/= - ( - float const & s - ) - { - __m128 Operand = _mm_div_ps(one, _mm_set_ps1(s)); - this->Data[0].Data = _mm_mul_ps(this->Data[0].Data, Operand); - this->Data[1].Data = _mm_mul_ps(this->Data[1].Data, Operand); - this->Data[2].Data = _mm_mul_ps(this->Data[2].Data, Operand); - this->Data[3].Data = _mm_mul_ps(this->Data[3].Data, Operand); - return *this; - } +GLM_FUNC_QUALIFIER fmat4x4SIMD & fmat4x4SIMD::operator/= +( + float const & s +) +{ + __m128 Operand = _mm_div_ps(one, _mm_set_ps1(s)); + this->Data[0].Data = _mm_mul_ps(this->Data[0].Data, Operand); + this->Data[1].Data = _mm_mul_ps(this->Data[1].Data, Operand); + this->Data[2].Data = _mm_mul_ps(this->Data[2].Data, Operand); + this->Data[3].Data = _mm_mul_ps(this->Data[3].Data, Operand); + return *this; +} - GLM_FUNC_QUALIFIER fmat4x4SIMD & fmat4x4SIMD::operator++ () - { - this->Data[0].Data = _mm_add_ps(this->Data[0].Data, one); - this->Data[1].Data = _mm_add_ps(this->Data[1].Data, one); - this->Data[2].Data = _mm_add_ps(this->Data[2].Data, one); - this->Data[3].Data = _mm_add_ps(this->Data[3].Data, one); - return *this; - } +GLM_FUNC_QUALIFIER fmat4x4SIMD & fmat4x4SIMD::operator++ () +{ + this->Data[0].Data = _mm_add_ps(this->Data[0].Data, one); + this->Data[1].Data = _mm_add_ps(this->Data[1].Data, one); + this->Data[2].Data = _mm_add_ps(this->Data[2].Data, one); + this->Data[3].Data = _mm_add_ps(this->Data[3].Data, one); + return *this; +} - GLM_FUNC_QUALIFIER fmat4x4SIMD & fmat4x4SIMD::operator-- () - { - this->Data[0].Data = _mm_sub_ps(this->Data[0].Data, one); - this->Data[1].Data = _mm_sub_ps(this->Data[1].Data, one); - this->Data[2].Data = _mm_sub_ps(this->Data[2].Data, one); - this->Data[3].Data = _mm_sub_ps(this->Data[3].Data, one); - return *this; - } +GLM_FUNC_QUALIFIER fmat4x4SIMD & fmat4x4SIMD::operator-- () +{ + this->Data[0].Data = _mm_sub_ps(this->Data[0].Data, one); + this->Data[1].Data = _mm_sub_ps(this->Data[1].Data, one); + this->Data[2].Data = _mm_sub_ps(this->Data[2].Data, one); + this->Data[3].Data = _mm_sub_ps(this->Data[3].Data, one); + return *this; +} }//namespace detail -namespace gtx +GLM_FUNC_QUALIFIER detail::tmat4x4 mat4_cast +( + detail::fmat4x4SIMD const & x +) { - GLM_FUNC_QUALIFIER detail::tmat4x4 mat4_cast - ( - detail::fmat4x4SIMD const & x - ) - { - GLM_ALIGN(16) detail::tmat4x4 Result; - _mm_store_ps(&Result[0][0], x.Data[0].Data); - _mm_store_ps(&Result[1][0], x.Data[1].Data); - _mm_store_ps(&Result[2][0], x.Data[2].Data); - _mm_store_ps(&Result[3][0], x.Data[3].Data); - return Result; - } + GLM_ALIGN(16) detail::tmat4x4 Result; + _mm_store_ps(&Result[0][0], x.Data[0].Data); + _mm_store_ps(&Result[1][0], x.Data[1].Data); + _mm_store_ps(&Result[2][0], x.Data[2].Data); + _mm_store_ps(&Result[3][0], x.Data[3].Data); + return Result; +} - GLM_FUNC_QUALIFIER detail::fmat4x4SIMD matrixCompMult - ( - detail::fmat4x4SIMD const & x, - detail::fmat4x4SIMD const & y - ) - { - detail::fmat4x4SIMD result; - result[0] = x[0] * y[0]; - result[1] = x[1] * y[1]; - result[2] = x[2] * y[2]; - result[3] = x[3] * y[3]; - return result; - } +GLM_FUNC_QUALIFIER detail::fmat4x4SIMD matrixCompMult +( + detail::fmat4x4SIMD const & x, + detail::fmat4x4SIMD const & y +) +{ + detail::fmat4x4SIMD result; + result[0] = x[0] * y[0]; + result[1] = x[1] * y[1]; + result[2] = x[2] * y[2]; + result[3] = x[3] * y[3]; + return result; +} - GLM_FUNC_QUALIFIER detail::fmat4x4SIMD outerProduct - ( - detail::fvec4SIMD const & c, - detail::fvec4SIMD const & r - ) - { - __m128 Shu0 = _mm_shuffle_ps(r.Data, r.Data, _MM_SHUFFLE(0, 0, 0, 0)); - __m128 Shu1 = _mm_shuffle_ps(r.Data, r.Data, _MM_SHUFFLE(1, 1, 1, 1)); - __m128 Shu2 = _mm_shuffle_ps(r.Data, r.Data, _MM_SHUFFLE(2, 2, 2, 2)); - __m128 Shu3 = _mm_shuffle_ps(r.Data, r.Data, _MM_SHUFFLE(3, 3, 3, 3)); +GLM_FUNC_QUALIFIER detail::fmat4x4SIMD outerProduct +( + detail::fvec4SIMD const & c, + detail::fvec4SIMD const & r +) +{ + __m128 Shu0 = _mm_shuffle_ps(r.Data, r.Data, _MM_SHUFFLE(0, 0, 0, 0)); + __m128 Shu1 = _mm_shuffle_ps(r.Data, r.Data, _MM_SHUFFLE(1, 1, 1, 1)); + __m128 Shu2 = _mm_shuffle_ps(r.Data, r.Data, _MM_SHUFFLE(2, 2, 2, 2)); + __m128 Shu3 = _mm_shuffle_ps(r.Data, r.Data, _MM_SHUFFLE(3, 3, 3, 3)); - detail::fmat4x4SIMD result(detail::fmat4x4SIMD::null); - result[0].Data = _mm_mul_ps(c.Data, Shu0); - result[1].Data = _mm_mul_ps(c.Data, Shu1); - result[2].Data = _mm_mul_ps(c.Data, Shu2); - result[3].Data = _mm_mul_ps(c.Data, Shu3); - return result; - } + detail::fmat4x4SIMD result(detail::fmat4x4SIMD::null); + result[0].Data = _mm_mul_ps(c.Data, Shu0); + result[1].Data = _mm_mul_ps(c.Data, Shu1); + result[2].Data = _mm_mul_ps(c.Data, Shu2); + result[3].Data = _mm_mul_ps(c.Data, Shu3); + return result; +} - GLM_FUNC_QUALIFIER detail::fmat4x4SIMD transpose(detail::fmat4x4SIMD const & m) - { - detail::fmat4x4SIMD result; - detail::sse_transpose_ps(&m[0].Data, &result[0].Data); - return result; - } +GLM_FUNC_QUALIFIER detail::fmat4x4SIMD transpose(detail::fmat4x4SIMD const & m) +{ + detail::fmat4x4SIMD result; + detail::sse_transpose_ps(&m[0].Data, &result[0].Data); + return result; +} - GLM_FUNC_QUALIFIER float determinant(detail::fmat4x4SIMD const & m) - { - float Result; - _mm_store_ss(&Result, detail::sse_det_ps(&m[0].Data)); - return Result; - } +GLM_FUNC_QUALIFIER float determinant(detail::fmat4x4SIMD const & m) +{ + float Result; + _mm_store_ss(&Result, detail::sse_det_ps(&m[0].Data)); + return Result; +} - GLM_FUNC_QUALIFIER detail::fmat4x4SIMD inverse(detail::fmat4x4SIMD const & m) - { - detail::fmat4x4SIMD result; - detail::sse_inverse_ps(&m[0].Data, &result[0].Data); - return result; - } +GLM_FUNC_QUALIFIER detail::fmat4x4SIMD inverse(detail::fmat4x4SIMD const & m) +{ + detail::fmat4x4SIMD result; + detail::sse_inverse_ps(&m[0].Data, &result[0].Data); + return result; +} -}//namespace gtx }//namespace glm diff --git a/glm/gtx/simd_vec4.hpp b/glm/gtx/simd_vec4.hpp index 1b7b88e2..4eaf5cdf 100644 --- a/glm/gtx/simd_vec4.hpp +++ b/glm/gtx/simd_vec4.hpp @@ -135,8 +135,6 @@ namespace detail }; }//namespace detail -namespace gtx -{ typedef glm::detail::fvec4SIMD simdVec4; /// @addtogroup gtx_simd_vec4 @@ -486,7 +484,6 @@ namespace gtx detail::fvec4SIMD const & x); /// @} -}//namespace gtx }//namespace glm #include "simd_vec4.inl" diff --git a/glm/gtx/simd_vec4.inl b/glm/gtx/simd_vec4.inl index c95678be..4d8819a2 100644 --- a/glm/gtx/simd_vec4.inl +++ b/glm/gtx/simd_vec4.inl @@ -8,720 +8,717 @@ /////////////////////////////////////////////////////////////////////////////////////////////////// namespace glm{ -namespace detail +namespace detail{ + +template +struct mask { - template - struct mask - { - enum{value = Value}; - }; + enum{value = Value}; +}; - ////////////////////////////////////// - // Implicit basic constructors +////////////////////////////////////// +// Implicit basic constructors - GLM_FUNC_QUALIFIER fvec4SIMD::fvec4SIMD() - {} +GLM_FUNC_QUALIFIER fvec4SIMD::fvec4SIMD() +{} - GLM_FUNC_QUALIFIER fvec4SIMD::fvec4SIMD(__m128 const & Data) : - Data(Data) - {} +GLM_FUNC_QUALIFIER fvec4SIMD::fvec4SIMD(__m128 const & Data) : + Data(Data) +{} - GLM_FUNC_QUALIFIER fvec4SIMD::fvec4SIMD(fvec4SIMD const & v) : - Data(v.Data) - {} +GLM_FUNC_QUALIFIER fvec4SIMD::fvec4SIMD(fvec4SIMD const & v) : + Data(v.Data) +{} - GLM_FUNC_QUALIFIER fvec4SIMD::fvec4SIMD(tvec4 const & v) : - Data(_mm_set_ps(v.w, v.z, v.y, v.x)) - {} +GLM_FUNC_QUALIFIER fvec4SIMD::fvec4SIMD(tvec4 const & v) : + Data(_mm_set_ps(v.w, v.z, v.y, v.x)) +{} - ////////////////////////////////////// - // Explicit basic constructors +////////////////////////////////////// +// Explicit basic constructors - GLM_FUNC_QUALIFIER fvec4SIMD::fvec4SIMD(float const & s) : - Data(_mm_set1_ps(s)) - {} +GLM_FUNC_QUALIFIER fvec4SIMD::fvec4SIMD(float const & s) : + Data(_mm_set1_ps(s)) +{} - GLM_FUNC_QUALIFIER fvec4SIMD::fvec4SIMD(float const & x, float const & y, float const & z, float const & w) : - // Data(_mm_setr_ps(x, y, z, w)) - Data(_mm_set_ps(w, z, y, x)) - {} +GLM_FUNC_QUALIFIER fvec4SIMD::fvec4SIMD(float const & x, float const & y, float const & z, float const & w) : +// Data(_mm_setr_ps(x, y, z, w)) + Data(_mm_set_ps(w, z, y, x)) +{} /* - GLM_FUNC_QUALIFIER fvec4SIMD::fvec4SIMD(float const v[4]) : - Data(_mm_load_ps(v)) - {} +GLM_FUNC_QUALIFIER fvec4SIMD::fvec4SIMD(float const v[4]) : + Data(_mm_load_ps(v)) +{} */ - ////////////////////////////////////// - // Swizzle constructors +////////////////////////////////////// +// Swizzle constructors - //fvec4SIMD(ref4 const & r); +//fvec4SIMD(ref4 const & r); - ////////////////////////////////////// - // Convertion vector constructors +////////////////////////////////////// +// Convertion vector constructors - GLM_FUNC_QUALIFIER fvec4SIMD::fvec4SIMD(vec2 const & v, float const & s1, float const & s2) : - Data(_mm_set_ps(s2, s1, v.y, v.x)) - {} +GLM_FUNC_QUALIFIER fvec4SIMD::fvec4SIMD(vec2 const & v, float const & s1, float const & s2) : + Data(_mm_set_ps(s2, s1, v.y, v.x)) +{} - GLM_FUNC_QUALIFIER fvec4SIMD::fvec4SIMD(float const & s1, vec2 const & v, float const & s2) : - Data(_mm_set_ps(s2, v.y, v.x, s1)) - {} +GLM_FUNC_QUALIFIER fvec4SIMD::fvec4SIMD(float const & s1, vec2 const & v, float const & s2) : + Data(_mm_set_ps(s2, v.y, v.x, s1)) +{} - GLM_FUNC_QUALIFIER fvec4SIMD::fvec4SIMD(float const & s1, float const & s2, vec2 const & v) : - Data(_mm_set_ps(v.y, v.x, s2, s1)) - {} +GLM_FUNC_QUALIFIER fvec4SIMD::fvec4SIMD(float const & s1, float const & s2, vec2 const & v) : + Data(_mm_set_ps(v.y, v.x, s2, s1)) +{} - GLM_FUNC_QUALIFIER fvec4SIMD::fvec4SIMD(vec3 const & v, float const & s) : - Data(_mm_set_ps(s, v.z, v.y, v.x)) - {} +GLM_FUNC_QUALIFIER fvec4SIMD::fvec4SIMD(vec3 const & v, float const & s) : + Data(_mm_set_ps(s, v.z, v.y, v.x)) +{} - GLM_FUNC_QUALIFIER fvec4SIMD::fvec4SIMD(float const & s, vec3 const & v) : - Data(_mm_set_ps(v.z, v.y, v.x, s)) - {} +GLM_FUNC_QUALIFIER fvec4SIMD::fvec4SIMD(float const & s, vec3 const & v) : + Data(_mm_set_ps(v.z, v.y, v.x, s)) +{} - GLM_FUNC_QUALIFIER fvec4SIMD::fvec4SIMD(vec2 const & v1, vec2 const & v2) : - Data(_mm_set_ps(v2.y, v2.x, v1.y, v1.x)) - {} +GLM_FUNC_QUALIFIER fvec4SIMD::fvec4SIMD(vec2 const & v1, vec2 const & v2) : + Data(_mm_set_ps(v2.y, v2.x, v1.y, v1.x)) +{} - //GLM_FUNC_QUALIFIER fvec4SIMD::fvec4SIMD(ivec4SIMD const & v) : - // Data(_mm_cvtepi32_ps(v.Data)) - //{} +//GLM_FUNC_QUALIFIER fvec4SIMD::fvec4SIMD(ivec4SIMD const & v) : +// Data(_mm_cvtepi32_ps(v.Data)) +//{} - ////////////////////////////////////// - // Unary arithmetic operators +////////////////////////////////////// +// Unary arithmetic operators - GLM_FUNC_QUALIFIER fvec4SIMD& fvec4SIMD::operator=(fvec4SIMD const & v) - { - this->Data = v.Data; - return *this; - } +GLM_FUNC_QUALIFIER fvec4SIMD& fvec4SIMD::operator=(fvec4SIMD const & v) +{ + this->Data = v.Data; + return *this; +} - GLM_FUNC_QUALIFIER fvec4SIMD& fvec4SIMD::operator+=(float const & s) - { - this->Data = _mm_add_ps(Data, _mm_set_ps1(s)); - return *this; - } +GLM_FUNC_QUALIFIER fvec4SIMD& fvec4SIMD::operator+=(float const & s) +{ + this->Data = _mm_add_ps(Data, _mm_set_ps1(s)); + return *this; +} - GLM_FUNC_QUALIFIER fvec4SIMD& fvec4SIMD::operator+=(fvec4SIMD const & v) - { - this->Data = _mm_add_ps(this->Data , v.Data); - return *this; - } +GLM_FUNC_QUALIFIER fvec4SIMD& fvec4SIMD::operator+=(fvec4SIMD const & v) +{ + this->Data = _mm_add_ps(this->Data , v.Data); + return *this; +} - GLM_FUNC_QUALIFIER fvec4SIMD& fvec4SIMD::operator-=(float const & s) - { - this->Data = _mm_sub_ps(Data, _mm_set_ps1(s)); - return *this; - } +GLM_FUNC_QUALIFIER fvec4SIMD& fvec4SIMD::operator-=(float const & s) +{ + this->Data = _mm_sub_ps(Data, _mm_set_ps1(s)); + return *this; +} - GLM_FUNC_QUALIFIER fvec4SIMD& fvec4SIMD::operator-=(fvec4SIMD const & v) - { - this->Data = _mm_sub_ps(this->Data , v.Data); - return *this; - } +GLM_FUNC_QUALIFIER fvec4SIMD& fvec4SIMD::operator-=(fvec4SIMD const & v) +{ + this->Data = _mm_sub_ps(this->Data , v.Data); + return *this; +} - GLM_FUNC_QUALIFIER fvec4SIMD& fvec4SIMD::operator*=(float const & s) - { - this->Data = _mm_mul_ps(this->Data, _mm_set_ps1(s)); - return *this; - } +GLM_FUNC_QUALIFIER fvec4SIMD& fvec4SIMD::operator*=(float const & s) +{ + this->Data = _mm_mul_ps(this->Data, _mm_set_ps1(s)); + return *this; +} - GLM_FUNC_QUALIFIER fvec4SIMD& fvec4SIMD::operator*=(fvec4SIMD const & v) - { - this->Data = _mm_mul_ps(this->Data , v.Data); - return *this; - } +GLM_FUNC_QUALIFIER fvec4SIMD& fvec4SIMD::operator*=(fvec4SIMD const & v) +{ + this->Data = _mm_mul_ps(this->Data , v.Data); + return *this; +} - GLM_FUNC_QUALIFIER fvec4SIMD& fvec4SIMD::operator/=(float const & s) - { - this->Data = _mm_div_ps(Data, _mm_set1_ps(s)); - return *this; - } +GLM_FUNC_QUALIFIER fvec4SIMD& fvec4SIMD::operator/=(float const & s) +{ + this->Data = _mm_div_ps(Data, _mm_set1_ps(s)); + return *this; +} - GLM_FUNC_QUALIFIER fvec4SIMD& fvec4SIMD::operator/=(fvec4SIMD const & v) - { - this->Data = _mm_div_ps(this->Data , v.Data); - return *this; - } +GLM_FUNC_QUALIFIER fvec4SIMD& fvec4SIMD::operator/=(fvec4SIMD const & v) +{ + this->Data = _mm_div_ps(this->Data , v.Data); + return *this; +} - GLM_FUNC_QUALIFIER fvec4SIMD& fvec4SIMD::operator++() - { - this->Data = _mm_add_ps(this->Data , glm::detail::one); - return *this; - } +GLM_FUNC_QUALIFIER fvec4SIMD& fvec4SIMD::operator++() +{ + this->Data = _mm_add_ps(this->Data , glm::detail::one); + return *this; +} - GLM_FUNC_QUALIFIER fvec4SIMD& fvec4SIMD::operator--() - { - this->Data = _mm_sub_ps(this->Data, glm::detail::one); - return *this; - } +GLM_FUNC_QUALIFIER fvec4SIMD& fvec4SIMD::operator--() +{ + this->Data = _mm_sub_ps(this->Data, glm::detail::one); + return *this; +} - ////////////////////////////////////// - // Swizzle operators +////////////////////////////////////// +// Swizzle operators - template - GLM_FUNC_QUALIFIER fvec4SIMD fvec4SIMD::swizzle() const - { - __m128 Data = _mm_shuffle_ps( - this->Data, this->Data, - mask<(W << 6) | (Z << 4) | (Y << 2) | (X << 0)>::value); - return fvec4SIMD(Data); - } +template +GLM_FUNC_QUALIFIER fvec4SIMD fvec4SIMD::swizzle() const +{ + __m128 Data = _mm_shuffle_ps( + this->Data, this->Data, + mask<(W << 6) | (Z << 4) | (Y << 2) | (X << 0)>::value); + return fvec4SIMD(Data); +} - template - GLM_FUNC_QUALIFIER fvec4SIMD& fvec4SIMD::swizzle() - { - this->Data = _mm_shuffle_ps( - this->Data, this->Data, - mask<(W << 6) | (Z << 4) | (Y << 2) | (X << 0)>::value); - return *this; - } +template +GLM_FUNC_QUALIFIER fvec4SIMD& fvec4SIMD::swizzle() +{ + this->Data = _mm_shuffle_ps( + this->Data, this->Data, + mask<(W << 6) | (Z << 4) | (Y << 2) | (X << 0)>::value); + return *this; +} - // operator+ - GLM_FUNC_QUALIFIER fvec4SIMD operator+ (fvec4SIMD const & v, float s) - { - return fvec4SIMD(_mm_add_ps(v.Data, _mm_set1_ps(s))); - } +// operator+ +GLM_FUNC_QUALIFIER fvec4SIMD operator+ (fvec4SIMD const & v, float s) +{ + return fvec4SIMD(_mm_add_ps(v.Data, _mm_set1_ps(s))); +} - GLM_FUNC_QUALIFIER fvec4SIMD operator+ (float s, fvec4SIMD const & v) - { - return fvec4SIMD(_mm_add_ps(_mm_set1_ps(s), v.Data)); - } +GLM_FUNC_QUALIFIER fvec4SIMD operator+ (float s, fvec4SIMD const & v) +{ + return fvec4SIMD(_mm_add_ps(_mm_set1_ps(s), v.Data)); +} - GLM_FUNC_QUALIFIER fvec4SIMD operator+ (fvec4SIMD const & v1, fvec4SIMD const & v2) - { - return fvec4SIMD(_mm_add_ps(v1.Data, v2.Data)); - } +GLM_FUNC_QUALIFIER fvec4SIMD operator+ (fvec4SIMD const & v1, fvec4SIMD const & v2) +{ + return fvec4SIMD(_mm_add_ps(v1.Data, v2.Data)); +} - //operator- - GLM_FUNC_QUALIFIER fvec4SIMD operator- (fvec4SIMD const & v, float s) - { - return fvec4SIMD(_mm_sub_ps(v.Data, _mm_set1_ps(s))); - } +//operator- +GLM_FUNC_QUALIFIER fvec4SIMD operator- (fvec4SIMD const & v, float s) +{ + return fvec4SIMD(_mm_sub_ps(v.Data, _mm_set1_ps(s))); +} - GLM_FUNC_QUALIFIER fvec4SIMD operator- (float s, fvec4SIMD const & v) - { - return fvec4SIMD(_mm_sub_ps(_mm_set1_ps(s), v.Data)); - } +GLM_FUNC_QUALIFIER fvec4SIMD operator- (float s, fvec4SIMD const & v) +{ + return fvec4SIMD(_mm_sub_ps(_mm_set1_ps(s), v.Data)); +} - GLM_FUNC_QUALIFIER fvec4SIMD operator- (fvec4SIMD const & v1, fvec4SIMD const & v2) - { - return fvec4SIMD(_mm_sub_ps(v1.Data, v2.Data)); - } +GLM_FUNC_QUALIFIER fvec4SIMD operator- (fvec4SIMD const & v1, fvec4SIMD const & v2) +{ + return fvec4SIMD(_mm_sub_ps(v1.Data, v2.Data)); +} - //operator* - GLM_FUNC_QUALIFIER fvec4SIMD operator* (fvec4SIMD const & v, float s) - { - __m128 par0 = v.Data; - __m128 par1 = _mm_set1_ps(s); - return fvec4SIMD(_mm_mul_ps(par0, par1)); - } +//operator* +GLM_FUNC_QUALIFIER fvec4SIMD operator* (fvec4SIMD const & v, float s) +{ + __m128 par0 = v.Data; + __m128 par1 = _mm_set1_ps(s); + return fvec4SIMD(_mm_mul_ps(par0, par1)); +} - GLM_FUNC_QUALIFIER fvec4SIMD operator* (float s, fvec4SIMD const & v) - { - __m128 par0 = _mm_set1_ps(s); - __m128 par1 = v.Data; - return fvec4SIMD(_mm_mul_ps(par0, par1)); - } +GLM_FUNC_QUALIFIER fvec4SIMD operator* (float s, fvec4SIMD const & v) +{ + __m128 par0 = _mm_set1_ps(s); + __m128 par1 = v.Data; + return fvec4SIMD(_mm_mul_ps(par0, par1)); +} - GLM_FUNC_QUALIFIER fvec4SIMD operator* (fvec4SIMD const & v1, fvec4SIMD const & v2) - { - return fvec4SIMD(_mm_mul_ps(v1.Data, v2.Data)); - } +GLM_FUNC_QUALIFIER fvec4SIMD operator* (fvec4SIMD const & v1, fvec4SIMD const & v2) +{ + return fvec4SIMD(_mm_mul_ps(v1.Data, v2.Data)); +} - //operator/ - GLM_FUNC_QUALIFIER fvec4SIMD operator/ (fvec4SIMD const & v, float s) - { - __m128 par0 = v.Data; - __m128 par1 = _mm_set1_ps(s); - return fvec4SIMD(_mm_div_ps(par0, par1)); - } +//operator/ +GLM_FUNC_QUALIFIER fvec4SIMD operator/ (fvec4SIMD const & v, float s) +{ + __m128 par0 = v.Data; + __m128 par1 = _mm_set1_ps(s); + return fvec4SIMD(_mm_div_ps(par0, par1)); +} - GLM_FUNC_QUALIFIER fvec4SIMD operator/ (float s, fvec4SIMD const & v) - { - __m128 par0 = _mm_set1_ps(s); - __m128 par1 = v.Data; - return fvec4SIMD(_mm_div_ps(par0, par1)); - } +GLM_FUNC_QUALIFIER fvec4SIMD operator/ (float s, fvec4SIMD const & v) +{ + __m128 par0 = _mm_set1_ps(s); + __m128 par1 = v.Data; + return fvec4SIMD(_mm_div_ps(par0, par1)); +} - GLM_FUNC_QUALIFIER fvec4SIMD operator/ (fvec4SIMD const & v1, fvec4SIMD const & v2) - { - return fvec4SIMD(_mm_div_ps(v1.Data, v2.Data)); - } +GLM_FUNC_QUALIFIER fvec4SIMD operator/ (fvec4SIMD const & v1, fvec4SIMD const & v2) +{ + return fvec4SIMD(_mm_div_ps(v1.Data, v2.Data)); +} - // Unary constant operators - GLM_FUNC_QUALIFIER fvec4SIMD operator- (fvec4SIMD const & v) - { - return fvec4SIMD(_mm_sub_ps(_mm_setzero_ps(), v.Data)); - } +// Unary constant operators +GLM_FUNC_QUALIFIER fvec4SIMD operator- (fvec4SIMD const & v) +{ + return fvec4SIMD(_mm_sub_ps(_mm_setzero_ps(), v.Data)); +} - GLM_FUNC_QUALIFIER fvec4SIMD operator++ (fvec4SIMD const & v, int) - { - return fvec4SIMD(_mm_add_ps(v.Data, glm::detail::one)); - } +GLM_FUNC_QUALIFIER fvec4SIMD operator++ (fvec4SIMD const & v, int) +{ + return fvec4SIMD(_mm_add_ps(v.Data, glm::detail::one)); +} - GLM_FUNC_QUALIFIER fvec4SIMD operator-- (fvec4SIMD const & v, int) - { - return fvec4SIMD(_mm_sub_ps(v.Data, glm::detail::one)); - } +GLM_FUNC_QUALIFIER fvec4SIMD operator-- (fvec4SIMD const & v, int) +{ + return fvec4SIMD(_mm_sub_ps(v.Data, glm::detail::one)); +} }//namespace detail -namespace gtx{ +GLM_FUNC_QUALIFIER detail::tvec4 vec4_cast +( + detail::fvec4SIMD const & x +) +{ + GLM_ALIGN(16) detail::tvec4 Result; + _mm_store_ps(&Result[0], x.Data); + return Result; +} - GLM_FUNC_QUALIFIER detail::tvec4 vec4_cast - ( - detail::fvec4SIMD const & x - ) - { - GLM_ALIGN(16) detail::tvec4 Result; - _mm_store_ps(&Result[0], x.Data); - return Result; - } +// Other possible implementation +//float abs(float a) +//{ +// return max(-a, a); +//} +GLM_FUNC_QUALIFIER detail::fvec4SIMD abs +( + detail::fvec4SIMD const & x +) +{ + return detail::sse_abs_ps(x.Data); +} - // Other possible implementation - //float abs(float a) - //{ - // return max(-a, a); - //} - GLM_FUNC_QUALIFIER detail::fvec4SIMD abs - ( - detail::fvec4SIMD const & x - ) - { - return detail::sse_abs_ps(x.Data); - } +GLM_FUNC_QUALIFIER detail::fvec4SIMD sign +( + detail::fvec4SIMD const & x +) +{ + return detail::sse_sgn_ps(x.Data); +} - GLM_FUNC_QUALIFIER detail::fvec4SIMD sign - ( - detail::fvec4SIMD const & x - ) - { - return detail::sse_sgn_ps(x.Data); - } +GLM_FUNC_QUALIFIER detail::fvec4SIMD floor +( + detail::fvec4SIMD const & x +) +{ + return detail::sse_flr_ps(x.Data); +} - GLM_FUNC_QUALIFIER detail::fvec4SIMD floor - ( - detail::fvec4SIMD const & x - ) - { - return detail::sse_flr_ps(x.Data); - } +GLM_FUNC_QUALIFIER detail::fvec4SIMD trunc +( + detail::fvec4SIMD const & x +) +{ + //return x < 0 ? -floor(-x) : floor(x); - GLM_FUNC_QUALIFIER detail::fvec4SIMD trunc - ( - detail::fvec4SIMD const & x - ) - { - //return x < 0 ? -floor(-x) : floor(x); + __m128 Flr0 = detail::sse_flr_ps(_mm_sub_ps(_mm_setzero_ps(), x.Data)); + __m128 Sub0 = _mm_sub_ps(Flr0, x.Data); + __m128 Flr1 = detail::sse_flr_ps(x.Data); - __m128 Flr0 = detail::sse_flr_ps(_mm_sub_ps(_mm_setzero_ps(), x.Data)); - __m128 Sub0 = _mm_sub_ps(Flr0, x.Data); - __m128 Flr1 = detail::sse_flr_ps(x.Data); + __m128 Cmp0 = _mm_cmplt_ps(x.Data, glm::detail::zero); + __m128 Cmp1 = _mm_cmpnlt_ps(x.Data, glm::detail::zero); - __m128 Cmp0 = _mm_cmplt_ps(x.Data, glm::detail::zero); - __m128 Cmp1 = _mm_cmpnlt_ps(x.Data, glm::detail::zero); + __m128 And0 = _mm_and_ps(Sub0, Cmp0); + __m128 And1 = _mm_and_ps(Flr1, Cmp1); - __m128 And0 = _mm_and_ps(Sub0, Cmp0); - __m128 And1 = _mm_and_ps(Flr1, Cmp1); + return _mm_or_ps(And0, And1); +} - return _mm_or_ps(And0, And1); - } +GLM_FUNC_QUALIFIER detail::fvec4SIMD round +( + detail::fvec4SIMD const & x +) +{ + return detail::sse_rnd_ps(x.Data); +} - GLM_FUNC_QUALIFIER detail::fvec4SIMD round - ( - detail::fvec4SIMD const & x - ) - { - return detail::sse_rnd_ps(x.Data); - } +//GLM_FUNC_QUALIFIER detail::fvec4SIMD roundEven +//( +// detail::fvec4SIMD const & x +//) +//{ - //GLM_FUNC_QUALIFIER detail::fvec4SIMD roundEven - //( - // detail::fvec4SIMD const & x - //) - //{ +//} - //} +GLM_FUNC_QUALIFIER detail::fvec4SIMD ceil +( + detail::fvec4SIMD const & x +) +{ + return detail::sse_ceil_ps(x.Data); +} - GLM_FUNC_QUALIFIER detail::fvec4SIMD ceil - ( - detail::fvec4SIMD const & x - ) - { - return detail::sse_ceil_ps(x.Data); - } +GLM_FUNC_QUALIFIER detail::fvec4SIMD fract +( + detail::fvec4SIMD const & x +) +{ + return detail::sse_frc_ps(x.Data); +} - GLM_FUNC_QUALIFIER detail::fvec4SIMD fract - ( - detail::fvec4SIMD const & x - ) - { - return detail::sse_frc_ps(x.Data); - } +GLM_FUNC_QUALIFIER detail::fvec4SIMD mod +( + detail::fvec4SIMD const & x, + detail::fvec4SIMD const & y +) +{ + return detail::sse_mod_ps(x.Data, y.Data); +} - GLM_FUNC_QUALIFIER detail::fvec4SIMD mod - ( - detail::fvec4SIMD const & x, - detail::fvec4SIMD const & y - ) - { - return detail::sse_mod_ps(x.Data, y.Data); - } +GLM_FUNC_QUALIFIER detail::fvec4SIMD mod +( + detail::fvec4SIMD const & x, + float const & y +) +{ + return detail::sse_mod_ps(x.Data, _mm_set1_ps(y)); +} - GLM_FUNC_QUALIFIER detail::fvec4SIMD mod - ( - detail::fvec4SIMD const & x, - float const & y - ) - { - return detail::sse_mod_ps(x.Data, _mm_set1_ps(y)); - } +//GLM_FUNC_QUALIFIER detail::fvec4SIMD modf +//( +// detail::fvec4SIMD const & x, +// detail::fvec4SIMD & i +//) +//{ - //GLM_FUNC_QUALIFIER detail::fvec4SIMD modf - //( - // detail::fvec4SIMD const & x, - // detail::fvec4SIMD & i - //) - //{ +//} - //} +GLM_FUNC_QUALIFIER detail::fvec4SIMD min +( + detail::fvec4SIMD const & x, + detail::fvec4SIMD const & y +) +{ + return _mm_min_ps(x.Data, y.Data); +} - GLM_FUNC_QUALIFIER detail::fvec4SIMD min - ( - detail::fvec4SIMD const & x, - detail::fvec4SIMD const & y - ) - { - return _mm_min_ps(x.Data, y.Data); - } +GLM_FUNC_QUALIFIER detail::fvec4SIMD min +( + detail::fvec4SIMD const & x, + float const & y +) +{ + return _mm_min_ps(x.Data, _mm_set1_ps(y)); +} - GLM_FUNC_QUALIFIER detail::fvec4SIMD min - ( - detail::fvec4SIMD const & x, - float const & y - ) - { - return _mm_min_ps(x.Data, _mm_set1_ps(y)); - } +GLM_FUNC_QUALIFIER detail::fvec4SIMD max +( + detail::fvec4SIMD const & x, + detail::fvec4SIMD const & y +) +{ + return _mm_max_ps(x.Data, y.Data); +} - GLM_FUNC_QUALIFIER detail::fvec4SIMD max - ( - detail::fvec4SIMD const & x, - detail::fvec4SIMD const & y - ) - { - return _mm_max_ps(x.Data, y.Data); - } +GLM_FUNC_QUALIFIER detail::fvec4SIMD max +( + detail::fvec4SIMD const & x, + float const & y +) +{ + return _mm_max_ps(x.Data, _mm_set1_ps(y)); +} - GLM_FUNC_QUALIFIER detail::fvec4SIMD max - ( - detail::fvec4SIMD const & x, - float const & y - ) - { - return _mm_max_ps(x.Data, _mm_set1_ps(y)); - } +GLM_FUNC_QUALIFIER detail::fvec4SIMD clamp +( + detail::fvec4SIMD const & x, + detail::fvec4SIMD const & minVal, + detail::fvec4SIMD const & maxVal +) +{ + return detail::sse_clp_ps(x.Data, minVal.Data, maxVal.Data); +} - GLM_FUNC_QUALIFIER detail::fvec4SIMD clamp - ( - detail::fvec4SIMD const & x, - detail::fvec4SIMD const & minVal, - detail::fvec4SIMD const & maxVal - ) - { - return detail::sse_clp_ps(x.Data, minVal.Data, maxVal.Data); - } +GLM_FUNC_QUALIFIER detail::fvec4SIMD clamp +( + detail::fvec4SIMD const & x, + float const & minVal, + float const & maxVal +) +{ + return detail::sse_clp_ps(x.Data, _mm_set1_ps(minVal), _mm_set1_ps(maxVal)); +} - GLM_FUNC_QUALIFIER detail::fvec4SIMD clamp - ( - detail::fvec4SIMD const & x, - float const & minVal, - float const & maxVal - ) - { - return detail::sse_clp_ps(x.Data, _mm_set1_ps(minVal), _mm_set1_ps(maxVal)); - } +GLM_FUNC_QUALIFIER detail::fvec4SIMD mix +( + detail::fvec4SIMD const & x, + detail::fvec4SIMD const & y, + detail::fvec4SIMD const & a +) +{ + __m128 Sub0 = _mm_sub_ps(y.Data, x.Data); + __m128 Mul0 = _mm_mul_ps(a.Data, Sub0); + return _mm_mul_ps(x.Data, Mul0); +} - GLM_FUNC_QUALIFIER detail::fvec4SIMD mix - ( - detail::fvec4SIMD const & x, - detail::fvec4SIMD const & y, - detail::fvec4SIMD const & a - ) - { - __m128 Sub0 = _mm_sub_ps(y.Data, x.Data); - __m128 Mul0 = _mm_mul_ps(a.Data, Sub0); - return _mm_mul_ps(x.Data, Mul0); - } +GLM_FUNC_QUALIFIER detail::fvec4SIMD step +( + detail::fvec4SIMD const & edge, + detail::fvec4SIMD const & x +) +{ + __m128 cmp0 = _mm_cmpngt_ps(x.Data, edge.Data); + return _mm_max_ps(_mm_min_ps(cmp0, _mm_setzero_ps()), detail::one); +} - GLM_FUNC_QUALIFIER detail::fvec4SIMD step - ( - detail::fvec4SIMD const & edge, - detail::fvec4SIMD const & x - ) - { - __m128 cmp0 = _mm_cmpngt_ps(x.Data, edge.Data); - return _mm_max_ps(_mm_min_ps(cmp0, _mm_setzero_ps()), detail::one); - } +GLM_FUNC_QUALIFIER detail::fvec4SIMD step +( + float const & edge, + detail::fvec4SIMD const & x +) +{ + __m128 cmp0 = _mm_cmpngt_ps(x.Data, _mm_set1_ps(edge)); + return _mm_max_ps(_mm_min_ps(cmp0, _mm_setzero_ps()), detail::one); +} - GLM_FUNC_QUALIFIER detail::fvec4SIMD step - ( - float const & edge, - detail::fvec4SIMD const & x - ) - { - __m128 cmp0 = _mm_cmpngt_ps(x.Data, _mm_set1_ps(edge)); - return _mm_max_ps(_mm_min_ps(cmp0, _mm_setzero_ps()), detail::one); - } +GLM_FUNC_QUALIFIER detail::fvec4SIMD smoothstep +( + detail::fvec4SIMD const & edge0, + detail::fvec4SIMD const & edge1, + detail::fvec4SIMD const & x +) +{ + return detail::sse_ssp_ps(edge0.Data, edge1.Data, x.Data); +} - GLM_FUNC_QUALIFIER detail::fvec4SIMD smoothstep - ( - detail::fvec4SIMD const & edge0, - detail::fvec4SIMD const & edge1, - detail::fvec4SIMD const & x - ) - { - return detail::sse_ssp_ps(edge0.Data, edge1.Data, x.Data); - } +GLM_FUNC_QUALIFIER detail::fvec4SIMD smoothstep +( + float const & edge0, + float const & edge1, + detail::fvec4SIMD const & x +) +{ + return detail::sse_ssp_ps(_mm_set1_ps(edge0), _mm_set1_ps(edge1), x.Data); +} - GLM_FUNC_QUALIFIER detail::fvec4SIMD smoothstep - ( - float const & edge0, - float const & edge1, - detail::fvec4SIMD const & x - ) - { - return detail::sse_ssp_ps(_mm_set1_ps(edge0), _mm_set1_ps(edge1), x.Data); - } +//GLM_FUNC_QUALIFIER bvec4 isnan(detail::fvec4SIMD const & x) +//{ - //GLM_FUNC_QUALIFIER bvec4 isnan(detail::fvec4SIMD const & x) - //{ +//} - //} +//GLM_FUNC_QUALIFIER bvec4 isinf(detail::fvec4SIMD const & x) +//{ - //GLM_FUNC_QUALIFIER bvec4 isinf(detail::fvec4SIMD const & x) - //{ +//} - //} +//GLM_FUNC_QUALIFIER detail::ivec4SIMD floatBitsToInt +//( +// detail::fvec4SIMD const & value +//) +//{ - //GLM_FUNC_QUALIFIER detail::ivec4SIMD floatBitsToInt - //( - // detail::fvec4SIMD const & value - //) - //{ +//} - //} +//GLM_FUNC_QUALIFIER detail::fvec4SIMD intBitsToFloat +//( +// detail::ivec4SIMD const & value +//) +//{ - //GLM_FUNC_QUALIFIER detail::fvec4SIMD intBitsToFloat - //( - // detail::ivec4SIMD const & value - //) - //{ +//} - //} +GLM_FUNC_QUALIFIER detail::fvec4SIMD fma +( + detail::fvec4SIMD const & a, + detail::fvec4SIMD const & b, + detail::fvec4SIMD const & c +) +{ + return _mm_add_ps(_mm_mul_ps(a.Data, b.Data), c.Data); +} - GLM_FUNC_QUALIFIER detail::fvec4SIMD fma - ( - detail::fvec4SIMD const & a, - detail::fvec4SIMD const & b, - detail::fvec4SIMD const & c - ) - { - return _mm_add_ps(_mm_mul_ps(a.Data, b.Data), c.Data); - } +GLM_FUNC_QUALIFIER float length +( + detail::fvec4SIMD const & x +) +{ + detail::fvec4SIMD dot0 = detail::sse_dot_ss(x.Data, x.Data); + detail::fvec4SIMD sqt0 = sqrt(dot0); + float Result = 0; + _mm_store_ss(&Result, sqt0.Data); + return Result; +} - GLM_FUNC_QUALIFIER float length - ( - detail::fvec4SIMD const & x - ) - { - detail::fvec4SIMD dot0 = detail::sse_dot_ss(x.Data, x.Data); - detail::fvec4SIMD sqt0 = sqrt(dot0); - float Result = 0; - _mm_store_ss(&Result, sqt0.Data); - return Result; - } +GLM_FUNC_QUALIFIER float fastLength +( + detail::fvec4SIMD const & x +) +{ + detail::fvec4SIMD dot0 = detail::sse_dot_ss(x.Data, x.Data); + detail::fvec4SIMD sqt0 = fastSqrt(dot0); + float Result = 0; + _mm_store_ss(&Result, sqt0.Data); + return Result; +} - GLM_FUNC_QUALIFIER float fastLength - ( - detail::fvec4SIMD const & x - ) - { - detail::fvec4SIMD dot0 = detail::sse_dot_ss(x.Data, x.Data); - detail::fvec4SIMD sqt0 = fastSqrt(dot0); - float Result = 0; - _mm_store_ss(&Result, sqt0.Data); - return Result; - } +GLM_FUNC_QUALIFIER float niceLength +( + detail::fvec4SIMD const & x +) +{ + detail::fvec4SIMD dot0 = detail::sse_dot_ss(x.Data, x.Data); + detail::fvec4SIMD sqt0 = niceSqrt(dot0); + float Result = 0; + _mm_store_ss(&Result, sqt0.Data); + return Result; +} - GLM_FUNC_QUALIFIER float niceLength - ( - detail::fvec4SIMD const & x - ) - { - detail::fvec4SIMD dot0 = detail::sse_dot_ss(x.Data, x.Data); - detail::fvec4SIMD sqt0 = niceSqrt(dot0); - float Result = 0; - _mm_store_ss(&Result, sqt0.Data); - return Result; - } +GLM_FUNC_QUALIFIER detail::fvec4SIMD length4 +( + detail::fvec4SIMD const & x +) +{ + return sqrt(dot4(x, x)); +} - GLM_FUNC_QUALIFIER detail::fvec4SIMD length4 - ( - detail::fvec4SIMD const & x - ) - { - return sqrt(dot4(x, x)); - } +GLM_FUNC_QUALIFIER detail::fvec4SIMD fastLength4 +( + detail::fvec4SIMD const & x +) +{ + return fastSqrt(dot4(x, x)); +} - GLM_FUNC_QUALIFIER detail::fvec4SIMD fastLength4 - ( - detail::fvec4SIMD const & x - ) - { - return fastSqrt(dot4(x, x)); - } +GLM_FUNC_QUALIFIER detail::fvec4SIMD niceLength4 +( + detail::fvec4SIMD const & x +) +{ + return niceSqrt(dot4(x, x)); +} - GLM_FUNC_QUALIFIER detail::fvec4SIMD niceLength4 - ( - detail::fvec4SIMD const & x - ) - { - return niceSqrt(dot4(x, x)); - } +GLM_FUNC_QUALIFIER float distance +( + detail::fvec4SIMD const & p0, + detail::fvec4SIMD const & p1 +) +{ + float Result = 0; + _mm_store_ss(&Result, detail::sse_dst_ps(p0.Data, p1.Data)); + return Result; +} - GLM_FUNC_QUALIFIER float distance - ( - detail::fvec4SIMD const & p0, - detail::fvec4SIMD const & p1 - ) - { - float Result = 0; - _mm_store_ss(&Result, detail::sse_dst_ps(p0.Data, p1.Data)); - return Result; - } +GLM_FUNC_QUALIFIER detail::fvec4SIMD distance4 +( + detail::fvec4SIMD const & p0, + detail::fvec4SIMD const & p1 +) +{ + return detail::sse_dst_ps(p0.Data, p1.Data); +} - GLM_FUNC_QUALIFIER detail::fvec4SIMD distance4 - ( - detail::fvec4SIMD const & p0, - detail::fvec4SIMD const & p1 - ) - { - return detail::sse_dst_ps(p0.Data, p1.Data); - } +GLM_FUNC_QUALIFIER float dot +( + detail::fvec4SIMD const & x, + detail::fvec4SIMD const & y +) +{ + float Result = 0; + _mm_store_ss(&Result, detail::sse_dot_ss(x.Data, y.Data)); + return Result; +} - GLM_FUNC_QUALIFIER float dot - ( - detail::fvec4SIMD const & x, - detail::fvec4SIMD const & y - ) - { - float Result = 0; - _mm_store_ss(&Result, detail::sse_dot_ss(x.Data, y.Data)); - return Result; - } +GLM_FUNC_QUALIFIER detail::fvec4SIMD dot4 +( + detail::fvec4SIMD const & x, + detail::fvec4SIMD const & y +) +{ + return detail::sse_dot_ps(x.Data, y.Data); +} - GLM_FUNC_QUALIFIER detail::fvec4SIMD dot4 - ( - detail::fvec4SIMD const & x, - detail::fvec4SIMD const & y - ) - { - return detail::sse_dot_ps(x.Data, y.Data); - } +GLM_FUNC_QUALIFIER detail::fvec4SIMD cross +( + detail::fvec4SIMD const & x, + detail::fvec4SIMD const & y +) +{ + return detail::sse_xpd_ps(x.Data, y.Data); +} - GLM_FUNC_QUALIFIER detail::fvec4SIMD cross - ( - detail::fvec4SIMD const & x, - detail::fvec4SIMD const & y - ) - { - return detail::sse_xpd_ps(x.Data, y.Data); - } +GLM_FUNC_QUALIFIER detail::fvec4SIMD normalize +( + detail::fvec4SIMD const & x +) +{ + __m128 dot0 = detail::sse_dot_ps(x.Data, x.Data); + __m128 isr0 = inversesqrt(detail::fvec4SIMD(dot0)).Data; + __m128 mul0 = _mm_mul_ps(x.Data, isr0); + return mul0; +} - GLM_FUNC_QUALIFIER detail::fvec4SIMD normalize - ( - detail::fvec4SIMD const & x - ) - { - __m128 dot0 = detail::sse_dot_ps(x.Data, x.Data); - __m128 isr0 = inversesqrt(dot0).Data; - __m128 mul0 = _mm_mul_ps(x.Data, isr0); - return mul0; - } +GLM_FUNC_QUALIFIER detail::fvec4SIMD fastNormalize +( + detail::fvec4SIMD const & x +) +{ + __m128 dot0 = detail::sse_dot_ps(x.Data, x.Data); + __m128 isr0 = fastInversesqrt(dot0).Data; + __m128 mul0 = _mm_mul_ps(x.Data, isr0); + return mul0; +} - GLM_FUNC_QUALIFIER detail::fvec4SIMD fastNormalize - ( - detail::fvec4SIMD const & x - ) - { - __m128 dot0 = detail::sse_dot_ps(x.Data, x.Data); - __m128 isr0 = fastInversesqrt(dot0).Data; - __m128 mul0 = _mm_mul_ps(x.Data, isr0); - return mul0; - } +GLM_FUNC_QUALIFIER detail::fvec4SIMD faceforward +( + detail::fvec4SIMD const & N, + detail::fvec4SIMD const & I, + detail::fvec4SIMD const & Nref +) +{ + return detail::sse_ffd_ps(N.Data, I.Data, Nref.Data); +} - GLM_FUNC_QUALIFIER detail::fvec4SIMD faceforward - ( - detail::fvec4SIMD const & N, - detail::fvec4SIMD const & I, - detail::fvec4SIMD const & Nref - ) - { - return detail::sse_ffd_ps(N.Data, I.Data, Nref.Data); - } +GLM_FUNC_QUALIFIER detail::fvec4SIMD reflect +( + detail::fvec4SIMD const & I, + detail::fvec4SIMD const & N +) +{ + return detail::sse_rfe_ps(I.Data, N.Data); +} - GLM_FUNC_QUALIFIER detail::fvec4SIMD reflect - ( - detail::fvec4SIMD const & I, - detail::fvec4SIMD const & N - ) - { - return detail::sse_rfe_ps(I.Data, N.Data); - } +GLM_FUNC_QUALIFIER detail::fvec4SIMD refract +( + detail::fvec4SIMD const & I, + detail::fvec4SIMD const & N, + float const & eta +) +{ + return detail::sse_rfa_ps(I.Data, N.Data, _mm_set1_ps(eta)); +} - GLM_FUNC_QUALIFIER detail::fvec4SIMD refract - ( - detail::fvec4SIMD const & I, - detail::fvec4SIMD const & N, - float const & eta - ) - { - return detail::sse_rfa_ps(I.Data, N.Data, _mm_set1_ps(eta)); - } +GLM_FUNC_QUALIFIER detail::fvec4SIMD sqrt(detail::fvec4SIMD const & x) +{ + return _mm_mul_ps(inversesqrt(x).Data, x.Data); +} - GLM_FUNC_QUALIFIER detail::fvec4SIMD sqrt(detail::fvec4SIMD const & x) - { - return _mm_mul_ps(inversesqrt(x.Data).Data, x.Data); - } +GLM_FUNC_QUALIFIER detail::fvec4SIMD niceSqrt(detail::fvec4SIMD const & x) +{ + return _mm_sqrt_ps(x.Data); +} - GLM_FUNC_QUALIFIER detail::fvec4SIMD niceSqrt(detail::fvec4SIMD const & x) - { - return _mm_sqrt_ps(x.Data); - } +GLM_FUNC_QUALIFIER detail::fvec4SIMD fastSqrt(detail::fvec4SIMD const & x) +{ + return _mm_mul_ps(fastInversesqrt(x.Data).Data, x.Data); +} - GLM_FUNC_QUALIFIER detail::fvec4SIMD fastSqrt(detail::fvec4SIMD const & x) - { - return _mm_mul_ps(fastInversesqrt(x.Data).Data, x.Data); - } +// SSE scalar reciprocal sqrt using rsqrt op, plus one Newton-Rhaphson iteration +// By Elan Ruskin, http://assemblyrequired.crashworks.org/ +GLM_FUNC_QUALIFIER detail::fvec4SIMD inversesqrt(detail::fvec4SIMD const & x) +{ + GLM_ALIGN(4) static const __m128 three = {3, 3, 3, 3}; // aligned consts for fast load + GLM_ALIGN(4) static const __m128 half = {0.5,0.5,0.5,0.5}; - // SSE scalar reciprocal sqrt using rsqrt op, plus one Newton-Rhaphson iteration - // By Elan Ruskin, http://assemblyrequired.crashworks.org/ - GLM_FUNC_QUALIFIER detail::fvec4SIMD inversesqrt(detail::fvec4SIMD const & x) - { - GLM_ALIGN(4) static const __m128 three = {3, 3, 3, 3}; // aligned consts for fast load - GLM_ALIGN(4) static const __m128 half = {0.5,0.5,0.5,0.5}; + __m128 recip = _mm_rsqrt_ps(x.Data); // "estimate" opcode + __m128 halfrecip = _mm_mul_ps(half, recip); + __m128 threeminus_xrr = _mm_sub_ps(three, _mm_mul_ps(x.Data, _mm_mul_ps(recip, recip))); + return _mm_mul_ps(halfrecip, threeminus_xrr); +} - __m128 recip = _mm_rsqrt_ps(x.Data); // "estimate" opcode - __m128 halfrecip = _mm_mul_ps(half, recip); - __m128 threeminus_xrr = _mm_sub_ps(three, _mm_mul_ps(x.Data, _mm_mul_ps(recip, recip))); - return _mm_mul_ps(halfrecip, threeminus_xrr); - } +GLM_FUNC_QUALIFIER detail::fvec4SIMD fastInversesqrt(detail::fvec4SIMD const & x) +{ + return _mm_rsqrt_ps(x.Data); +} - GLM_FUNC_QUALIFIER detail::fvec4SIMD fastInversesqrt(detail::fvec4SIMD const & x) - { - return _mm_rsqrt_ps(x.Data); - } - -}//namespace gtx }//namespace glm diff --git a/glm/gtx/spline.hpp b/glm/gtx/spline.hpp index 4ae49c93..54fb09fa 100644 --- a/glm/gtx/spline.hpp +++ b/glm/gtx/spline.hpp @@ -46,8 +46,7 @@ # pragma message("GLM: GLM_GTX_spline extension included") #endif -namespace glm{ -namespace gtx +namespace glm { /// @addtogroup gtx_spline /// @{ @@ -83,7 +82,6 @@ namespace gtx typename genType::value_type const & s); /// @} -}//namespace gtx }//namespace glm #include "spline.inl" diff --git a/glm/gtx/spline.inl b/glm/gtx/spline.inl index 070031ff..d836a313 100644 --- a/glm/gtx/spline.inl +++ b/glm/gtx/spline.inl @@ -8,65 +8,63 @@ /////////////////////////////////////////////////////////////////////////////////////////////////// namespace glm{ -namespace gtx + +template +GLM_FUNC_QUALIFIER genType catmullRom +( + genType const & v1, + genType const & v2, + genType const & v3, + genType const & v4, + typename genType::value_type const & s +) { - template - GLM_FUNC_QUALIFIER genType catmullRom - ( - genType const & v1, - genType const & v2, - genType const & v3, - genType const & v4, - typename genType::value_type const & s - ) - { - typename genType::value_type s1 = s; - typename genType::value_type s2 = pow2(s); - typename genType::value_type s3 = pow3(s); + typename genType::value_type s1 = s; + typename genType::value_type s2 = pow2(s); + typename genType::value_type s3 = pow3(s); - typename genType::value_type f1 = -s3 + typename genType::value_type(2) * s2 - s; - typename genType::value_type f2 = typename genType::value_type(3) * s3 - typename genType::value_type(5) * s2 + typename genType::value_type(2); - typename genType::value_type f3 = typename genType::value_type(-3) * s3 + typename genType::value_type(4) * s2 + s; - typename genType::value_type f4 = s3 - s2; + typename genType::value_type f1 = -s3 + typename genType::value_type(2) * s2 - s; + typename genType::value_type f2 = typename genType::value_type(3) * s3 - typename genType::value_type(5) * s2 + typename genType::value_type(2); + typename genType::value_type f3 = typename genType::value_type(-3) * s3 + typename genType::value_type(4) * s2 + s; + typename genType::value_type f4 = s3 - s2; - return (f1 * v1 + f2 * v2 + f3 * v3 + f4 * v4) / typename genType::value_type(2); + return (f1 * v1 + f2 * v2 + f3 * v3 + f4 * v4) / typename genType::value_type(2); - } +} - template - GLM_FUNC_QUALIFIER genType hermite - ( - genType const & v1, - genType const & t1, - genType const & v2, - genType const & t2, - typename genType::value_type const & s - ) - { - typename genType::value_type s1 = s; - typename genType::value_type s2 = pow2(s); - typename genType::value_type s3 = pow3(s); +template +GLM_FUNC_QUALIFIER genType hermite +( + genType const & v1, + genType const & t1, + genType const & v2, + genType const & t2, + typename genType::value_type const & s +) +{ + typename genType::value_type s1 = s; + typename genType::value_type s2 = pow2(s); + typename genType::value_type s3 = pow3(s); - typename genType::value_type f1 = typename genType::value_type(2) * s3 - typename genType::value_type(3) * s2 + typename genType::value_type(1); - typename genType::value_type f2 = typename genType::value_type(-2) * s3 + typename genType::value_type(3) * s2; - typename genType::value_type f3 = s3 - typename genType::value_type(2) * s2 + s; - typename genType::value_type f4 = s3 - s2; + typename genType::value_type f1 = typename genType::value_type(2) * s3 - typename genType::value_type(3) * s2 + typename genType::value_type(1); + typename genType::value_type f2 = typename genType::value_type(-2) * s3 + typename genType::value_type(3) * s2; + typename genType::value_type f3 = s3 - typename genType::value_type(2) * s2 + s; + typename genType::value_type f4 = s3 - s2; - return f1 * v1 + f2 * v2 + f3 * t1 + f4 * t2; - } + return f1 * v1 + f2 * v2 + f3 * t1 + f4 * t2; +} - template - GLM_FUNC_QUALIFIER genType cubic - ( - genType const & v1, - genType const & v2, - genType const & v3, - genType const & v4, - typename genType::value_type const & s - ) - { - return ((v1 * s + v2) * s + v3) * s + v4; - } +template +GLM_FUNC_QUALIFIER genType cubic +( + genType const & v1, + genType const & v2, + genType const & v3, + genType const & v4, + typename genType::value_type const & s +) +{ + return ((v1 * s + v2) * s + v3) * s + v4; +} -}//namespace gtx }//namespace glm diff --git a/glm/gtx/std_based_type.hpp b/glm/gtx/std_based_type.hpp index ccaabfdb..7bd0e3e4 100644 --- a/glm/gtx/std_based_type.hpp +++ b/glm/gtx/std_based_type.hpp @@ -46,8 +46,7 @@ # pragma message("GLM: GLM_GTX_std_based_type extension included") #endif -namespace glm{ -namespace gtx +namespace glm { /// @addtogroup gtx_std_based_type /// @{ @@ -77,7 +76,6 @@ namespace gtx typedef detail::tvec4 size4_t; /// @} -}//namespace gtx }//namespace glm #include "std_based_type.inl" diff --git a/glm/gtx/string_cast.hpp b/glm/gtx/string_cast.hpp index 0ad8eaa3..243f8f0a 100644 --- a/glm/gtx/string_cast.hpp +++ b/glm/gtx/string_cast.hpp @@ -54,8 +54,7 @@ # pragma message("GLM: GLM_GTX_string_cast extension included") #endif -namespace glm{ -namespace gtx +namespace glm { /// @addtogroup gtx_string_cast /// @{ @@ -66,7 +65,6 @@ namespace gtx std::string to_string(genType const & x); /// @} -}//namespace gtx }//namespace glm #include "string_cast.inl" diff --git a/glm/gtx/string_cast.inl b/glm/gtx/string_cast.inl index 51b6393f..9c451656 100644 --- a/glm/gtx/string_cast.inl +++ b/glm/gtx/string_cast.inl @@ -33,8 +33,6 @@ namespace detail static const char* False = "false"; }//namespace detail -namespace gtx{ - //////////////////////////////// // Scalars @@ -591,5 +589,4 @@ namespace gtx{ x[3][0], x[3][1], x[3][2], x[3][3]); } -}//namespace gtx }//namespace glm diff --git a/glm/gtx/transform.hpp b/glm/gtx/transform.hpp index 707e9615..172106cb 100644 --- a/glm/gtx/transform.hpp +++ b/glm/gtx/transform.hpp @@ -49,22 +49,21 @@ # pragma message("GLM: GLM_GTX_transform extension included") #endif -namespace glm{ -namespace gtx +namespace glm { /// @addtogroup gtx_transform /// @{ //! Builds a translation 4 * 4 matrix created from 3 scalars. //! - From \link gtx_transform GLM_GTX_transform \endlink extension - //! - See also: \link glm::gtc::translate GLM_GTC_matrix_transform \endlink + //! - See also: \link glm::translate GLM_GTC_matrix_transform \endlink template detail::tmat4x4 translate( T x, T y, T z); //! Transforms a matrix with a translation 4 * 4 matrix created from 3 scalars. //! - From \link gtx_transform GLM_GTX_transform \endlink extension - //! - See also: \link glm::gtc::translate GLM_GTC_matrix_transform \endlink + //! - See also: \link glm::translate GLM_GTC_matrix_transform \endlink template detail::tmat4x4 translate( detail::tmat4x4 const & m, @@ -72,14 +71,14 @@ namespace gtx //! Transforms a matrix with a translation 4 * 4 matrix created from 3 scalars. //! - From \link gtx_transform GLM_GTX_transform \endlink extension - //! - See also: \link glm::gtc::translate GLM_GTC_matrix_transform \endlink + //! - See also: \link glm::translate GLM_GTC_matrix_transform \endlink template detail::tmat4x4 translate( detail::tvec3 const & v); //! Builds a rotation 4 * 4 matrix created from an axis of 3 scalars and an angle expressed in degrees. //! - From \link gtx_transform GLM_GTX_transform \endlink extension - //! - See also: \link glm::gtc::rotate GLM_GTC_matrix_transform \endlink + //! - See also: \link glm::rotate GLM_GTC_matrix_transform \endlink template detail::tmat4x4 rotate( T angle, @@ -87,7 +86,7 @@ namespace gtx //! Builds a rotation 4 * 4 matrix created from an axis of 3 scalars and an angle expressed in degrees. //! - From \link gtx_transform GLM_GTX_transform \endlink extension - //! - See also: \link glm::gtc::rotate GLM_GTC_matrix_transform \endlink + //! - See also: \link glm::rotate GLM_GTC_matrix_transform \endlink template detail::tmat4x4 rotate( T angle, @@ -95,7 +94,7 @@ namespace gtx //! Transforms a matrix with a rotation 4 * 4 matrix created from an axis of 3 scalars and an angle expressed in degrees. //! - From \link gtx_transform GLM_GTX_transform \endlink extension - //! - See also: \link glm::gtc::rotate GLM_GTC_matrix_transform \endlink + //! - See also: \link glm::rotate GLM_GTC_matrix_transform \endlink template detail::tmat4x4 rotate( detail::tmat4x4 const & m, @@ -104,14 +103,14 @@ namespace gtx //! Builds a scale 4 * 4 matrix created from 3 scalars. //! - From \link gtx_transform GLM_GTX_transform \endlink extension - //! - See also: \link glm::gtc::scale GLM_GTC_matrix_transform \endlink + //! - See also: \link glm::scale GLM_GTC_matrix_transform \endlink template detail::tmat4x4 scale( T x, T y, T z); //! Transforms a matrix with a scale 4 * 4 matrix created from 3 scalars. //! - From \link gtx_transform GLM_GTX_transform \endlink extension - //! - See also: \link glm::gtc::scale GLM_GTC_matrix_transform \endlink + //! - See also: \link glm::scale GLM_GTC_matrix_transform \endlink template detail::tmat4x4 scale( detail::tmat4x4 const & m, @@ -119,13 +118,12 @@ namespace gtx //! Transforms a matrix with a scale 4 * 4 matrix created from a vector of 3 components. //! - From \link gtx_transform GLM_GTX_transform \endlink extension - //! - See also: \link glm::gtc::scale GLM_GTC_matrix_transform \endlink + //! - See also: \link glm::scale GLM_GTC_matrix_transform \endlink template detail::tmat4x4 scale( detail::tvec3 const & v); /// @} -}// namespace gtx }// namespace glm #include "transform.inl" diff --git a/glm/gtx/transform.inl b/glm/gtx/transform.inl index 6f4d7a2c..f78bfb71 100644 --- a/glm/gtx/transform.inl +++ b/glm/gtx/transform.inl @@ -7,14 +7,13 @@ // File : glm/gtx/transform.inl /////////////////////////////////////////////////////////////////////////////////////////////////// -namespace glm{ -namespace gtx +namespace glm { template GLM_FUNC_QUALIFIER detail::tmat4x4 translate( T x, T y, T z) { - return gtc::translate( + return translate( detail::tmat4x4(1.0f), detail::tvec3(x, y , z)); } @@ -24,7 +23,7 @@ namespace gtx detail::tmat4x4 const & m, T x, T y, T z) { - return gtc::translate( + return translate( m, detail::tvec3(x, y , z)); } @@ -32,7 +31,7 @@ namespace gtx GLM_FUNC_QUALIFIER detail::tmat4x4 translate( detail::tvec3 const & v) { - return gtc::translate( + return translate( detail::tmat4x4(1.0f), v); } @@ -41,7 +40,7 @@ namespace gtx T angle, T x, T y, T z) { - return gtc::rotate( + return rotate( detail::tmat4x4(1), angle, detail::tvec3(x, y, z)); } @@ -50,7 +49,7 @@ namespace gtx T angle, detail::tvec3 const & v) { - return gtc::rotate( + return rotate( detail::tmat4x4(1), angle, v); } @@ -60,14 +59,14 @@ namespace gtx T angle, T x, T y, T z) { - return gtc::rotate( + return rotate( m, angle, detail::tvec3(x, y, z)); } template GLM_FUNC_QUALIFIER detail::tmat4x4 scale(T x, T y, T z) { - return gtc::scale( + return scale( detail::tmat4x4(1), detail::tvec3(x, y, z)); } @@ -76,7 +75,7 @@ namespace gtx detail::tmat4x4 const & m, T x, T y, T z) { - return gtc::scale( + return scale( m, detail::tvec3(x, y, z)); } @@ -84,9 +83,8 @@ namespace gtx GLM_FUNC_QUALIFIER detail::tmat4x4 scale( detail::tvec3 const & v) { - return gtc::scale( + return scale( detail::tmat4x4(1.0f), v); } -}//namespace gtx }//namespace glm diff --git a/glm/gtx/transform2.hpp b/glm/gtx/transform2.hpp index bebff937..f709ae54 100644 --- a/glm/gtx/transform2.hpp +++ b/glm/gtx/transform2.hpp @@ -47,8 +47,7 @@ # pragma message("GLM: GLM_GTX_transform2 extension included") #endif -namespace glm{ -namespace gtx +namespace glm { /// @addtogroup gtx_transform2 /// @{ @@ -129,7 +128,6 @@ namespace gtx valType bias); /// @} -}// namespace gtx }// namespace glm #include "transform2.inl" diff --git a/glm/gtx/transform2.inl b/glm/gtx/transform2.inl index 357baa7f..915e6430 100644 --- a/glm/gtx/transform2.inl +++ b/glm/gtx/transform2.inl @@ -8,150 +8,148 @@ /////////////////////////////////////////////////////////////////////////////////////////////////// namespace glm{ -namespace gtx{ - template - GLM_FUNC_QUALIFIER detail::tmat3x3 shearX2D( - const detail::tmat3x3& m, - T s) - { - detail::tmat3x3 r(1); - r[0][1] = s; - return m * r; - } +template +GLM_FUNC_QUALIFIER detail::tmat3x3 shearX2D( + const detail::tmat3x3& m, + T s) +{ + detail::tmat3x3 r(1); + r[0][1] = s; + return m * r; +} - template - GLM_FUNC_QUALIFIER detail::tmat3x3 shearY2D( - const detail::tmat3x3& m, - T s) - { - detail::tmat3x3 r(1); - r[1][0] = s; - return m * r; - } +template +GLM_FUNC_QUALIFIER detail::tmat3x3 shearY2D( + const detail::tmat3x3& m, + T s) +{ + detail::tmat3x3 r(1); + r[1][0] = s; + return m * r; +} - template - GLM_FUNC_QUALIFIER detail::tmat4x4 shearX3D( - const detail::tmat4x4& m, - T s, - T t) - { - detail::tmat4x4 r(1); - r[1][0] = s; - r[2][0] = t; - return m * r; - } +template +GLM_FUNC_QUALIFIER detail::tmat4x4 shearX3D( + const detail::tmat4x4& m, + T s, + T t) +{ + detail::tmat4x4 r(1); + r[1][0] = s; + r[2][0] = t; + return m * r; +} - template - GLM_FUNC_QUALIFIER detail::tmat4x4 shearY3D( - const detail::tmat4x4& m, - T s, - T t) - { - detail::tmat4x4 r(1); - r[0][1] = s; - r[2][1] = t; - return m * r; - } +template +GLM_FUNC_QUALIFIER detail::tmat4x4 shearY3D( + const detail::tmat4x4& m, + T s, + T t) +{ + detail::tmat4x4 r(1); + r[0][1] = s; + r[2][1] = t; + return m * r; +} - template - GLM_FUNC_QUALIFIER detail::tmat4x4 shearZ3D( - const detail::tmat4x4& m, - T s, - T t) - { - detail::tmat4x4 r(1); - r[0][2] = s; - r[1][2] = t; - return m * r; - } +template +GLM_FUNC_QUALIFIER detail::tmat4x4 shearZ3D( + const detail::tmat4x4& m, + T s, + T t) +{ + detail::tmat4x4 r(1); + r[0][2] = s; + r[1][2] = t; + return m * r; +} - template - GLM_FUNC_QUALIFIER detail::tmat3x3 reflect2D( - const detail::tmat3x3& m, - const detail::tvec3& normal) - { - detail::tmat3x3 r(1); - r[0][0] = 1 - 2 * normal.x * normal.x; - r[0][1] = -2 * normal.x * normal.y; - r[1][0] = -2 * normal.x * normal.y; - r[1][1] = 1 - 2 * normal.y * normal.y; - return m * r; - } +template +GLM_FUNC_QUALIFIER detail::tmat3x3 reflect2D( + const detail::tmat3x3& m, + const detail::tvec3& normal) +{ + detail::tmat3x3 r(1); + r[0][0] = 1 - 2 * normal.x * normal.x; + r[0][1] = -2 * normal.x * normal.y; + r[1][0] = -2 * normal.x * normal.y; + r[1][1] = 1 - 2 * normal.y * normal.y; + return m * r; +} - template - GLM_FUNC_QUALIFIER detail::tmat4x4 reflect3D( - const detail::tmat4x4& m, - const detail::tvec3& normal) - { - detail::tmat4x4 r(1); - r[0][0] = 1 - 2 * normal.x * normal.x; - r[0][1] = -2 * normal.x * normal.y; - r[0][2] = -2 * normal.x * normal.z; +template +GLM_FUNC_QUALIFIER detail::tmat4x4 reflect3D( + const detail::tmat4x4& m, + const detail::tvec3& normal) +{ + detail::tmat4x4 r(1); + r[0][0] = 1 - 2 * normal.x * normal.x; + r[0][1] = -2 * normal.x * normal.y; + r[0][2] = -2 * normal.x * normal.z; - r[1][0] = -2 * normal.x * normal.y; - r[1][1] = 1 - 2 * normal.y * normal.y; - r[1][2] = -2 * normal.y * normal.z; + r[1][0] = -2 * normal.x * normal.y; + r[1][1] = 1 - 2 * normal.y * normal.y; + r[1][2] = -2 * normal.y * normal.z; - r[2][0] = -2 * normal.x * normal.z; - r[2][1] = -2 * normal.y * normal.z; - r[2][2] = 1 - 2 * normal.z * normal.z; - return m * r; - } + r[2][0] = -2 * normal.x * normal.z; + r[2][1] = -2 * normal.y * normal.z; + r[2][2] = 1 - 2 * normal.z * normal.z; + return m * r; +} - template - GLM_FUNC_QUALIFIER detail::tmat3x3 proj2D( - const detail::tmat3x3& m, - const detail::tvec3& normal) - { - detail::tmat3x3 r(1); - r[0][0] = 1 - normal.x * normal.x; - r[0][1] = - normal.x * normal.y; - r[1][0] = - normal.x * normal.y; - r[1][1] = 1 - normal.y * normal.y; - return m * r; - } +template +GLM_FUNC_QUALIFIER detail::tmat3x3 proj2D( + const detail::tmat3x3& m, + const detail::tvec3& normal) +{ + detail::tmat3x3 r(1); + r[0][0] = 1 - normal.x * normal.x; + r[0][1] = - normal.x * normal.y; + r[1][0] = - normal.x * normal.y; + r[1][1] = 1 - normal.y * normal.y; + return m * r; +} - template - GLM_FUNC_QUALIFIER detail::tmat4x4 proj3D( - const detail::tmat4x4& m, - const detail::tvec3& normal) - { - detail::tmat4x4 r(1); - r[0][0] = 1 - normal.x * normal.x; - r[0][1] = - normal.x * normal.y; - r[0][2] = - normal.x * normal.z; - r[1][0] = - normal.x * normal.y; - r[1][1] = 1 - normal.y * normal.y; - r[1][2] = - normal.y * normal.z; - r[2][0] = - normal.x * normal.z; - r[2][1] = - normal.y * normal.z; - r[2][2] = 1 - normal.z * normal.z; - return m * r; - } +template +GLM_FUNC_QUALIFIER detail::tmat4x4 proj3D( + const detail::tmat4x4& m, + const detail::tvec3& normal) +{ + detail::tmat4x4 r(1); + r[0][0] = 1 - normal.x * normal.x; + r[0][1] = - normal.x * normal.y; + r[0][2] = - normal.x * normal.z; + r[1][0] = - normal.x * normal.y; + r[1][1] = 1 - normal.y * normal.y; + r[1][2] = - normal.y * normal.z; + r[2][0] = - normal.x * normal.z; + r[2][1] = - normal.y * normal.z; + r[2][2] = 1 - normal.z * normal.z; + return m * r; +} - template - GLM_FUNC_QUALIFIER detail::tmat4x4 scaleBias( - T scale, - T bias) - { - detail::tmat4x4 result; - result[3] = detail::tvec4(detail::tvec3(bias), T(1)); - result[0][0] = scale; - result[1][1] = scale; - result[2][2] = scale; - return result; - } +template +GLM_FUNC_QUALIFIER detail::tmat4x4 scaleBias( + T scale, + T bias) +{ + detail::tmat4x4 result; + result[3] = detail::tvec4(detail::tvec3(bias), T(1)); + result[0][0] = scale; + result[1][1] = scale; + result[2][2] = scale; + return result; +} - template - GLM_FUNC_QUALIFIER detail::tmat4x4 scaleBias( - const detail::tmat4x4& m, - T scale, - T bias) - { - return m * scaleBias(scale, bias); - } +template +GLM_FUNC_QUALIFIER detail::tmat4x4 scaleBias( + const detail::tmat4x4& m, + T scale, + T bias) +{ + return m * scaleBias(scale, bias); +} -}//namespace gtx }//namespace glm diff --git a/glm/gtx/ulp.hpp b/glm/gtx/ulp.hpp index b39786e6..a5d63f7b 100644 --- a/glm/gtx/ulp.hpp +++ b/glm/gtx/ulp.hpp @@ -46,8 +46,7 @@ # pragma message("GLM: GLM_GTX_ulp extension included") #endif -namespace glm{ -namespace gtx +namespace glm { /// @addtogroup gtx_ulp /// @{ @@ -83,7 +82,6 @@ namespace gtx vecType float_distance(vecType const & x, vecType const & y); /// @} -}// namespace gtx }// namespace glm #include "ulp.inl" diff --git a/glm/gtx/ulp.inl b/glm/gtx/ulp.inl index 063b6a75..1a85b5c4 100644 --- a/glm/gtx/ulp.inl +++ b/glm/gtx/ulp.inl @@ -177,219 +177,217 @@ namespace detail #endif namespace glm{ -namespace gtx{ - GLM_FUNC_QUALIFIER float next_float(float const & x) - { - return GLM_NEXT_AFTER_FLT(x, std::numeric_limits::max()); - } +GLM_FUNC_QUALIFIER float next_float(float const & x) +{ + return GLM_NEXT_AFTER_FLT(x, std::numeric_limits::max()); +} - GLM_FUNC_QUALIFIER double next_float(double const & x) - { - return GLM_NEXT_AFTER_DBL(x, std::numeric_limits::max()); - } +GLM_FUNC_QUALIFIER double next_float(double const & x) +{ + return GLM_NEXT_AFTER_DBL(x, std::numeric_limits::max()); +} - template class vecType> - GLM_FUNC_QUALIFIER vecType next_float(vecType const & x) - { - vecType Result; - for(std::size_t i = 0; i < Result.length(); ++i) - Result[i] = next_float(x[i]); - return Result; - } +template class vecType> +GLM_FUNC_QUALIFIER vecType next_float(vecType const & x) +{ + vecType Result; + for(std::size_t i = 0; i < Result.length(); ++i) + Result[i] = next_float(x[i]); + return Result; +} - GLM_FUNC_QUALIFIER float prev_float(float const & x) - { - return GLM_NEXT_AFTER_FLT(x, std::numeric_limits::min()); - } +GLM_FUNC_QUALIFIER float prev_float(float const & x) +{ + return GLM_NEXT_AFTER_FLT(x, std::numeric_limits::min()); +} - GLM_FUNC_QUALIFIER double prev_float(double const & x) - { - return GLM_NEXT_AFTER_DBL(x, std::numeric_limits::min()); - } +GLM_FUNC_QUALIFIER double prev_float(double const & x) +{ + return GLM_NEXT_AFTER_DBL(x, std::numeric_limits::min()); +} - template class vecType> - GLM_FUNC_QUALIFIER vecType prev_float(vecType const & x) - { - vecType Result; - for(std::size_t i = 0; i < Result.length(); ++i) - Result[i] = prev_float(x[i]); - return Result; - } +template class vecType> +GLM_FUNC_QUALIFIER vecType prev_float(vecType const & x) +{ + vecType Result; + for(std::size_t i = 0; i < Result.length(); ++i) + Result[i] = prev_float(x[i]); + return Result; +} - template - GLM_FUNC_QUALIFIER T next_float(T const & x, uint const & ulps) +template +GLM_FUNC_QUALIFIER T next_float(T const & x, uint const & ulps) +{ + T temp = x; + for(std::size_t i = 0; i < ulps; ++i) + temp = next_float(temp); + return temp; +} + +template class vecType> +GLM_FUNC_QUALIFIER vecType next_float(vecType const & x, vecType const & ulps) +{ + vecType Result; + for(std::size_t i = 0; i < Result.length(); ++i) + Result[i] = next_float(x[i], ulps[i]); + return Result; +} + +template +GLM_FUNC_QUALIFIER T prev_float(T const & x, uint const & ulps) +{ + T temp = x; + for(std::size_t i = 0; i < ulps; ++i) + temp = prev_float(temp); + return temp; +} + +template class vecType> +GLM_FUNC_QUALIFIER vecType prev_float(vecType const & x, vecType const & ulps) +{ + vecType Result; + for(std::size_t i = 0; i < Result.length(); ++i) + Result[i] = prev_float(x[i], ulps[i]); + return Result; +} + +template +GLM_FUNC_QUALIFIER uint float_distance(T const & x, T const & y) +{ + uint ulp = 0; + + if(x < y) { T temp = x; - for(std::size_t i = 0; i < ulps; ++i) + while(temp != y && ulp < std::numeric_limits::max()) + { + ++ulp; temp = next_float(temp); - return temp; - } - - template class vecType> - GLM_FUNC_QUALIFIER vecType next_float(vecType const & x, vecType const & ulps) - { - vecType Result; - for(std::size_t i = 0; i < Result.length(); ++i) - Result[i] = next_float(x[i], ulps[i]); - return Result; - } - - template - GLM_FUNC_QUALIFIER T prev_float(T const & x, uint const & ulps) - { - T temp = x; - for(std::size_t i = 0; i < ulps; ++i) - temp = prev_float(temp); - return temp; - } - - template class vecType> - GLM_FUNC_QUALIFIER vecType prev_float(vecType const & x, vecType const & ulps) - { - vecType Result; - for(std::size_t i = 0; i < Result.length(); ++i) - Result[i] = prev_float(x[i], ulps[i]); - return Result; - } - - template - GLM_FUNC_QUALIFIER uint float_distance(T const & x, T const & y) - { - uint ulp = 0; - - if(x < y) - { - T temp = x; - while(temp != y && ulp < std::numeric_limits::max()) - { - ++ulp; - temp = next_float(temp); - } } - else if(y < x) - { - T temp = y; - while(temp != x && ulp < std::numeric_limits::max()) - { - ++ulp; - temp = next_float(temp); - } - } - else // == - { - - } - - return ulp; } - - template class vecType> - GLM_FUNC_QUALIFIER vecType float_distance(vecType const & x, vecType const & y) + else if(y < x) { - vecType Result; - for(std::size_t i = 0; i < Result.length(); ++i) - Result[i] = float_distance(x[i], y[i]); - return Result; + T temp = y; + while(temp != x && ulp < std::numeric_limits::max()) + { + ++ulp; + temp = next_float(temp); + } } + else // == + { + + } + + return ulp; +} + +template class vecType> +GLM_FUNC_QUALIFIER vecType float_distance(vecType const & x, vecType const & y) +{ + vecType Result; + for(std::size_t i = 0; i < Result.length(); ++i) + Result[i] = float_distance(x[i], y[i]); + return Result; +} /* - inline std::size_t ulp - ( - detail::thalf const & a, - detail::thalf const & b - ) - { - std::size_t Count = 0; - float TempA(a); - float TempB(b); - //while((TempA = _nextafterf(TempA, TempB)) != TempB) - ++Count; - return Count; - } +inline std::size_t ulp +( + detail::thalf const & a, + detail::thalf const & b +) +{ + std::size_t Count = 0; + float TempA(a); + float TempB(b); + //while((TempA = _nextafterf(TempA, TempB)) != TempB) + ++Count; + return Count; +} - inline std::size_t ulp - ( - float const & a, - float const & b - ) - { - std::size_t Count = 0; - float Temp = a; - //while((Temp = _nextafterf(Temp, b)) != b) - { - std::cout << Temp << " " << b << std::endl; - ++Count; - } - return Count; - } +inline std::size_t ulp +( + float const & a, + float const & b +) +{ + std::size_t Count = 0; + float Temp = a; + //while((Temp = _nextafterf(Temp, b)) != b) + { + std::cout << Temp << " " << b << std::endl; + ++Count; + } + return Count; +} - inline std::size_t ulp - ( - double const & a, - double const & b - ) - { - std::size_t Count = 0; - double Temp = a; - //while((Temp = _nextafter(Temp, b)) != b) - { - std::cout << Temp << " " << b << std::endl; - ++Count; - } - return Count; - } +inline std::size_t ulp +( + double const & a, + double const & b +) +{ + std::size_t Count = 0; + double Temp = a; + //while((Temp = _nextafter(Temp, b)) != b) + { + std::cout << Temp << " " << b << std::endl; + ++Count; + } + return Count; +} - template - inline std::size_t ulp - ( - detail::tvec2 const & a, - detail::tvec2 const & b - ) - { - std::size_t ulps[] = - { - ulp(a[0], b[0]), - ulp(a[1], b[1]) - }; +template +inline std::size_t ulp +( + detail::tvec2 const & a, + detail::tvec2 const & b +) +{ + std::size_t ulps[] = + { + ulp(a[0], b[0]), + ulp(a[1], b[1]) + }; - return glm::max(ulps[0], ulps[1]); - } + return glm::max(ulps[0], ulps[1]); +} - template - inline std::size_t ulp - ( - detail::tvec3 const & a, - detail::tvec3 const & b - ) - { - std::size_t ulps[] = - { - ulp(a[0], b[0]), - ulp(a[1], b[1]), - ulp(a[2], b[2]) - }; +template +inline std::size_t ulp +( + detail::tvec3 const & a, + detail::tvec3 const & b +) +{ + std::size_t ulps[] = + { + ulp(a[0], b[0]), + ulp(a[1], b[1]), + ulp(a[2], b[2]) + }; - return glm::max(glm::max(ulps[0], ulps[1]), ulps[2]); - } + return glm::max(glm::max(ulps[0], ulps[1]), ulps[2]); +} - template - inline std::size_t ulp - ( - detail::tvec4 const & a, - detail::tvec4 const & b - ) - { - std::size_t ulps[] = - { - ulp(a[0], b[0]), - ulp(a[1], b[1]), - ulp(a[2], b[2]), - ulp(a[3], b[3]) - }; +template +inline std::size_t ulp +( + detail::tvec4 const & a, + detail::tvec4 const & b +) +{ + std::size_t ulps[] = + { + ulp(a[0], b[0]), + ulp(a[1], b[1]), + ulp(a[2], b[2]), + ulp(a[3], b[3]) + }; - return glm::max(glm::max(ulps[0], ulps[1]), glm::max(ulps[2], ulps[3])); - } + return glm::max(glm::max(ulps[0], ulps[1]), glm::max(ulps[2], ulps[3])); +} */ -}//namespace gtx }//namespace glm diff --git a/glm/gtx/unsigned_int.hpp b/glm/gtx/unsigned_int.hpp index 4fb2b342..bcfcd810 100644 --- a/glm/gtx/unsigned_int.hpp +++ b/glm/gtx/unsigned_int.hpp @@ -47,8 +47,7 @@ # pragma message("GLM: GLM_GTX_unsigned_int extension included") #endif -namespace glm{ -namespace gtx +namespace glm { /// @addtogroup gtx_unsigned_int /// @{ @@ -70,7 +69,6 @@ namespace gtx uint mod(uint x, uint y); /// @} -}//namespace gtx }//namespace glm #include "unsigned_int.inl" diff --git a/glm/gtx/unsigned_int.inl b/glm/gtx/unsigned_int.inl index 13f7171d..133a3022 100644 --- a/glm/gtx/unsigned_int.inl +++ b/glm/gtx/unsigned_int.inl @@ -8,7 +8,6 @@ /////////////////////////////////////////////////////////////////////////////////////////////////// namespace glm{ -namespace gtx{ GLM_FUNC_QUALIFIER uint pow(uint x, uint y) { @@ -39,5 +38,4 @@ GLM_FUNC_QUALIFIER uint mod(uint x, uint y) return x - y * (x / y); } -}//namespace gtx }//namespace glm diff --git a/glm/gtx/vec1.hpp b/glm/gtx/vec1.hpp index 1d04dc6c..b309aebe 100644 --- a/glm/gtx/vec1.hpp +++ b/glm/gtx/vec1.hpp @@ -45,8 +45,7 @@ # pragma message("GLM: GLM_GTX_vec1 extension included") #endif -namespace glm{ -namespace gtx +namespace glm { //! 1 component vector of high precision floating-point numbers. //! There is no guarantee on the actual precision. @@ -130,7 +129,6 @@ namespace gtx typedef mediump_uvec1 uvec1; #endif//GLM_PRECISION -}// namespace gtx }// namespace glm #include "vec1.inl" diff --git a/glm/gtx/vector_access.hpp b/glm/gtx/vector_access.hpp index f2b4e659..4bf4f931 100644 --- a/glm/gtx/vector_access.hpp +++ b/glm/gtx/vector_access.hpp @@ -45,8 +45,7 @@ # pragma message("GLM: GLM_GTX_vector_access extension included") #endif -namespace glm{ -namespace gtx +namespace glm { /// @addtogroup gtx_vector_access /// @{ @@ -79,7 +78,6 @@ namespace gtx valType const & w); /// @} -}//namespace gtx }//namespace glm #include "vector_access.inl" diff --git a/glm/gtx/vector_access.inl b/glm/gtx/vector_access.inl index 04b653bc..df55c15c 100644 --- a/glm/gtx/vector_access.inl +++ b/glm/gtx/vector_access.inl @@ -8,7 +8,6 @@ /////////////////////////////////////////////////////////////////////////////////////////////////// namespace glm{ -namespace gtx{ template GLM_FUNC_QUALIFIER void set @@ -52,5 +51,4 @@ GLM_FUNC_QUALIFIER void set v.w = w; } -}//namespace gtx }//namespace glm diff --git a/glm/gtx/vector_angle.hpp b/glm/gtx/vector_angle.hpp index fd2214cc..dd7fd0af 100644 --- a/glm/gtx/vector_angle.hpp +++ b/glm/gtx/vector_angle.hpp @@ -50,8 +50,7 @@ # pragma message("GLM: GLM_GTX_vector_angle extension included") #endif -namespace glm{ -namespace gtx +namespace glm { /// @addtogroup gtx_vector_angle /// @{ @@ -82,7 +81,6 @@ namespace gtx detail::tvec3 const & ref); /// @} -}// namespace gtx }// namespace glm #include "vector_angle.inl" diff --git a/glm/gtx/vector_angle.inl b/glm/gtx/vector_angle.inl index 097d3443..e40b61ce 100644 --- a/glm/gtx/vector_angle.inl +++ b/glm/gtx/vector_angle.inl @@ -8,7 +8,6 @@ /////////////////////////////////////////////////////////////////////////////////////////////////// namespace glm{ -namespace gtx{ template GLM_FUNC_QUALIFIER typename genType::value_type angle @@ -29,7 +28,7 @@ GLM_FUNC_QUALIFIER valType orientedAngle ) { valType Angle = glm::degrees(acos(dot(x, y))); - detail::tvec2 TransformedVector = glm::gtx::rotate(x, Angle); + detail::tvec2 TransformedVector = glm::rotate(x, Angle); if(all(equalEpsilon(y, TransformedVector, valType(0.01)))) return Angle; else @@ -52,5 +51,4 @@ GLM_FUNC_QUALIFIER valType orientedAngle return Angle; } -}//namespace gtx }//namespace glm diff --git a/glm/gtx/vector_query.hpp b/glm/gtx/vector_query.hpp index 19fe02e2..4e14dc48 100644 --- a/glm/gtx/vector_query.hpp +++ b/glm/gtx/vector_query.hpp @@ -47,8 +47,7 @@ # pragma message("GLM: GLM_GTX_vector_query extension included") #endif -namespace glm{ -namespace gtx +namespace glm { /// @addtogroup gtx_vector_query /// @{ @@ -108,7 +107,6 @@ namespace gtx typename genType::value_type const & epsilon = std::numeric_limits::epsilon()); /// @} -}// namespace gtx }// namespace glm #include "vector_query.inl" diff --git a/glm/gtx/vector_query.inl b/glm/gtx/vector_query.inl index fc5fb8c7..8d24ea41 100644 --- a/glm/gtx/vector_query.inl +++ b/glm/gtx/vector_query.inl @@ -13,160 +13,158 @@ #include namespace glm{ -namespace gtx{ - template - GLM_FUNC_QUALIFIER bool areCollinear - ( - detail::tvec2 const & v0, - detail::tvec2 const & v1, - T const & epsilon - ) - { - return length(cross(detail::tvec3(v0, T(0)), detail::tvec3(v1, T(0)))) < epsilon; - } +template +GLM_FUNC_QUALIFIER bool areCollinear +( + detail::tvec2 const & v0, + detail::tvec2 const & v1, + T const & epsilon +) +{ + return length(cross(detail::tvec3(v0, T(0)), detail::tvec3(v1, T(0)))) < epsilon; +} - template - GLM_FUNC_QUALIFIER bool areCollinear - ( - detail::tvec3 const & v0, - detail::tvec3 const & v1, - T const & epsilon - ) - { - return length(cross(v0, v1)) < epsilon; - } +template +GLM_FUNC_QUALIFIER bool areCollinear +( + detail::tvec3 const & v0, + detail::tvec3 const & v1, + T const & epsilon +) +{ + return length(cross(v0, v1)) < epsilon; +} - template - GLM_FUNC_QUALIFIER bool areCollinear - ( - detail::tvec4 const & v0, - detail::tvec4 const & v1, - T const & epsilon - ) - { - return length(cross(detail::tvec3(v0), detail::tvec3(v1))) < epsilon; - } +template +GLM_FUNC_QUALIFIER bool areCollinear +( + detail::tvec4 const & v0, + detail::tvec4 const & v1, + T const & epsilon +) +{ + return length(cross(detail::tvec3(v0), detail::tvec3(v1))) < epsilon; +} - template - GLM_FUNC_QUALIFIER bool areOpposite - ( - genType const & v0, - genType const & v1, - typename genType::value_type const & epsilon - ) - { - assert(isNormalized(v0) && isNormalized(v1)); - return((typename genType::value_type(1) + dot(v0, v1)) <= epsilon); - } +template +GLM_FUNC_QUALIFIER bool areOpposite +( + genType const & v0, + genType const & v1, + typename genType::value_type const & epsilon +) +{ + assert(isNormalized(v0) && isNormalized(v1)); + return((typename genType::value_type(1) + dot(v0, v1)) <= epsilon); +} - template - GLM_FUNC_QUALIFIER bool areOrthogonal - ( - genType const & v0, - genType const & v1, - typename genType::value_type const & epsilon - ) - { - return abs(dot(v0, v1)) <= max( +template +GLM_FUNC_QUALIFIER bool areOrthogonal +( + genType const & v0, + genType const & v1, + typename genType::value_type const & epsilon +) +{ + return abs(dot(v0, v1)) <= max( + typename genType::value_type(1), + length(v0)) * max( typename genType::value_type(1), - length(v0)) * max( - typename genType::value_type(1), - length(v1)) * epsilon; - } + length(v1)) * epsilon; +} - template - GLM_FUNC_QUALIFIER bool isNormalized - ( - genType const & v, - typename genType::value_type const & epsilon - ) - { - return abs(length(v) - typename genType::value_type(1)) <= typename genType::value_type(2) * epsilon; - } +template +GLM_FUNC_QUALIFIER bool isNormalized +( + genType const & v, + typename genType::value_type const & epsilon +) +{ + return abs(length(v) - typename genType::value_type(1)) <= typename genType::value_type(2) * epsilon; +} - template - GLM_FUNC_QUALIFIER bool isNull - ( - genType const & v, - typename genType::value_type const & epsilon - ) - { - return length(v) <= epsilon; - } +template +GLM_FUNC_QUALIFIER bool isNull +( + genType const & v, + typename genType::value_type const & epsilon +) +{ + return length(v) <= epsilon; +} - template - GLM_FUNC_QUALIFIER bool isCompNull - ( - T const & s, - T const & epsilon - ) - { - return abs(s) < epsilon; - } +template +GLM_FUNC_QUALIFIER bool isCompNull +( + T const & s, + T const & epsilon +) +{ + return abs(s) < epsilon; +} - template - GLM_FUNC_QUALIFIER detail::tvec2 isCompNull - ( - detail::tvec2 const & v, - T const & epsilon) - { - return detail::tvec2( - (abs(v.x) < epsilon), - (abs(v.y) < epsilon)); - } +template +GLM_FUNC_QUALIFIER detail::tvec2 isCompNull +( + detail::tvec2 const & v, + T const & epsilon) +{ + return detail::tvec2( + (abs(v.x) < epsilon), + (abs(v.y) < epsilon)); +} - template - GLM_FUNC_QUALIFIER detail::tvec3 isCompNull - ( - detail::tvec3 const & v, - T const & epsilon - ) - { - return detail::tvec3( - abs(v.x) < epsilon, - abs(v.y) < epsilon, - abs(v.z) < epsilon); - } +template +GLM_FUNC_QUALIFIER detail::tvec3 isCompNull +( + detail::tvec3 const & v, + T const & epsilon +) +{ + return detail::tvec3( + abs(v.x) < epsilon, + abs(v.y) < epsilon, + abs(v.z) < epsilon); +} - template - GLM_FUNC_QUALIFIER detail::tvec4 isCompNull - ( - detail::tvec4 const & v, - T const & epsilon - ) - { - return detail::tvec4( - abs(v.x) < epsilon, - abs(v.y) < epsilon, - abs(v.z) < epsilon, - abs(v.w) < epsilon); - } +template +GLM_FUNC_QUALIFIER detail::tvec4 isCompNull +( + detail::tvec4 const & v, + T const & epsilon +) +{ + return detail::tvec4( + abs(v.x) < epsilon, + abs(v.y) < epsilon, + abs(v.z) < epsilon, + abs(v.w) < epsilon); +} - template - GLM_FUNC_QUALIFIER bool areOrthonormal - ( - genType const & v0, - genType const & v1, - typename genType::value_type const & epsilon - ) - { - return isNormalized(v0, epsilon) && isNormalized(v1, epsilon) && (abs(dot(v0, v1)) <= epsilon); - } +template +GLM_FUNC_QUALIFIER bool areOrthonormal +( + genType const & v0, + genType const & v1, + typename genType::value_type const & epsilon +) +{ + return isNormalized(v0, epsilon) && isNormalized(v1, epsilon) && (abs(dot(v0, v1)) <= epsilon); +} - template - GLM_FUNC_QUALIFIER bool areSimilar - ( - genType const & v0, - genType const & v1, - typename genType::value_type const & epsilon - ) - { - bool similar = true; - for(typename genType::size_type i = 0; similar && i < genType::value_size(); i++) - similar = (abs(v0[i] - v1[i]) <= epsilon); - return similar; - } +template +GLM_FUNC_QUALIFIER bool areSimilar +( + genType const & v0, + genType const & v1, + typename genType::value_type const & epsilon +) +{ + bool similar = true; + for(typename genType::size_type i = 0; similar && i < genType::value_size(); i++) + similar = (abs(v0[i] - v1[i]) <= epsilon); + return similar; +} -}//namespace gtx }//namespace glm diff --git a/glm/gtx/verbose_operator.hpp b/glm/gtx/verbose_operator.hpp index c1486efc..f1dfa3f3 100644 --- a/glm/gtx/verbose_operator.hpp +++ b/glm/gtx/verbose_operator.hpp @@ -45,8 +45,7 @@ # pragma message("GLM: GLM_GTX_verbose_operator extension included") #endif -namespace glm{ -namespace gtx +namespace glm { /// @addtogroup gtx_verbose_operator /// @{ @@ -77,7 +76,6 @@ namespace gtx genTypeT mad(genTypeT const & a, genTypeU const & b, genTypeV const & c); /// @} -}// namespace gtx }// namespace glm #include "verbose_operator.inl" diff --git a/glm/gtx/verbose_operator.inl b/glm/gtx/verbose_operator.inl index 4557b40f..5c66f1c7 100644 --- a/glm/gtx/verbose_operator.inl +++ b/glm/gtx/verbose_operator.inl @@ -8,7 +8,6 @@ /////////////////////////////////////////////////////////////////////////////////////////////////// namespace glm{ -namespace gtx{ template GLM_FUNC_QUALIFIER genType add(genType const & a, genType const & b) @@ -123,5 +122,4 @@ GLM_FUNC_QUALIFIER genTypeT mad(genTypeT const & a, genTypeU const & b, genTypeV return a * b + c; } -}//namespace gtx }//namespace glm diff --git a/glm/gtx/wrap.hpp b/glm/gtx/wrap.hpp index 7e536e7e..d47cbaf2 100644 --- a/glm/gtx/wrap.hpp +++ b/glm/gtx/wrap.hpp @@ -45,8 +45,7 @@ # pragma message("GLM: GLM_GTX_wrap extension included") #endif -namespace glm{ -namespace gtx +namespace glm { /// @addtogroup gtx_wrap /// @{ @@ -67,7 +66,6 @@ namespace gtx genType mirrorRepeat(genType const & Texcoord); /// @} -}// namespace gtx }// namespace glm #include "wrap.inl" diff --git a/glm/gtx/wrap.inl b/glm/gtx/wrap.inl index c18ea67f..42c566cb 100644 --- a/glm/gtx/wrap.inl +++ b/glm/gtx/wrap.inl @@ -11,161 +11,156 @@ /////////////////////////////////////////////////////////////////////////////////////////////////// namespace glm{ -namespace gtx + +template +GLM_FUNC_QUALIFIER genType clamp +( + genType const & Texcoord +) { - //////////////////////// - // clamp + return glm::clamp(Texcoord, genType(0), genType(1)); +} - template - GLM_FUNC_QUALIFIER genType clamp - ( - genType const & Texcoord - ) - { - return glm::clamp(Texcoord, genType(0), genType(1)); - } +template +GLM_FUNC_QUALIFIER detail::tvec2 clamp +( + detail::tvec2 const & Texcoord +) +{ + detail::tvec2 Result; + for(typename detail::tvec2::size_type i = 0; i < detail::tvec2::value_size(); ++i) + Result[i] = clamp(Texcoord[i]); + return Result; +} - template - GLM_FUNC_QUALIFIER detail::tvec2 clamp - ( - detail::tvec2 const & Texcoord - ) - { - detail::tvec2 Result; - for(typename detail::tvec2::size_type i = 0; i < detail::tvec2::value_size(); ++i) - Result[i] = clamp(Texcoord[i]); - return Result; - } +template +GLM_FUNC_QUALIFIER detail::tvec3 clamp +( + detail::tvec3 const & Texcoord +) +{ + detail::tvec3 Result; + for(typename detail::tvec3::size_type i = 0; i < detail::tvec3::value_size(); ++i) + Result[i] = clamp(Texcoord[i]); + return Result; +} - template - GLM_FUNC_QUALIFIER detail::tvec3 clamp - ( - detail::tvec3 const & Texcoord - ) - { - detail::tvec3 Result; - for(typename detail::tvec3::size_type i = 0; i < detail::tvec3::value_size(); ++i) - Result[i] = clamp(Texcoord[i]); - return Result; - } +template +GLM_FUNC_QUALIFIER detail::tvec4 clamp +( + detail::tvec4 const & Texcoord +) +{ + detail::tvec4 Result; + for(typename detail::tvec4::size_type i = 0; i < detail::tvec4::value_size(); ++i) + Result[i] = clamp(Texcoord[i]); + return Result; +} - template - GLM_FUNC_QUALIFIER detail::tvec4 clamp - ( - detail::tvec4 const & Texcoord - ) - { - detail::tvec4 Result; - for(typename detail::tvec4::size_type i = 0; i < detail::tvec4::value_size(); ++i) - Result[i] = clamp(Texcoord[i]); - return Result; - } +//////////////////////// +// repeat - //////////////////////// - // repeat +template +GLM_FUNC_QUALIFIER genType repeat +( + genType const & Texcoord +) +{ + return glm::fract(Texcoord); +} - template - GLM_FUNC_QUALIFIER genType repeat - ( - genType const & Texcoord - ) - { - return glm::fract(Texcoord); - } +template +GLM_FUNC_QUALIFIER detail::tvec2 repeat +( + detail::tvec2 const & Texcoord +) +{ + detail::tvec2 Result; + for(typename detail::tvec2::size_type i = 0; i < detail::tvec2::value_size(); ++i) + Result[i] = repeat(Texcoord[i]); + return Result; +} - template - GLM_FUNC_QUALIFIER detail::tvec2 repeat - ( - detail::tvec2 const & Texcoord - ) - { - detail::tvec2 Result; - for(typename detail::tvec2::size_type i = 0; i < detail::tvec2::value_size(); ++i) - Result[i] = repeat(Texcoord[i]); - return Result; - } +template +GLM_FUNC_QUALIFIER detail::tvec3 repeat +( + detail::tvec3 const & Texcoord +) +{ + detail::tvec3 Result; + for(typename detail::tvec3::size_type i = 0; i < detail::tvec3::value_size(); ++i) + Result[i] = repeat(Texcoord[i]); + return Result; +} - template - GLM_FUNC_QUALIFIER detail::tvec3 repeat - ( - detail::tvec3 const & Texcoord - ) - { - detail::tvec3 Result; - for(typename detail::tvec3::size_type i = 0; i < detail::tvec3::value_size(); ++i) - Result[i] = repeat(Texcoord[i]); - return Result; - } +template +GLM_FUNC_QUALIFIER detail::tvec4 repeat +( + detail::tvec4 const & Texcoord +) +{ + detail::tvec4 Result; + for(typename detail::tvec4::size_type i = 0; i < detail::tvec4::value_size(); ++i) + Result[i] = repeat(Texcoord[i]); + return Result; +} - template - GLM_FUNC_QUALIFIER detail::tvec4 repeat - ( - detail::tvec4 const & Texcoord - ) - { - detail::tvec4 Result; - for(typename detail::tvec4::size_type i = 0; i < detail::tvec4::value_size(); ++i) - Result[i] = repeat(Texcoord[i]); - return Result; - } +//////////////////////// +// mirrorRepeat - //////////////////////// - // mirrorRepeat +template +GLM_FUNC_QUALIFIER genType mirrorRepeat +( + genType const & Texcoord +) +{ + genType const Clamp = genType(int(glm::floor(Texcoord)) % 2); + genType const Floor = glm::floor(Texcoord); + genType const Rest = Texcoord - Floor; + genType const Mirror = Clamp + Rest; - template - GLM_FUNC_QUALIFIER genType mirrorRepeat - ( - genType const & Texcoord - ) - { - genType const Clamp = genType(int(glm::floor(Texcoord)) % 2); - genType const Floor = glm::floor(Texcoord); - genType const Rest = Texcoord - Floor; - genType const Mirror = Clamp + Rest; + genType Out; + if(Mirror >= genType(1)) + Out = genType(1) - Rest; + else + Out = Rest; + return Out; +} - genType Out; - if(Mirror >= genType(1)) - Out = genType(1) - Rest; - else - Out = Rest; - return Out; - } +template +GLM_FUNC_QUALIFIER detail::tvec2 mirrorRepeat +( + detail::tvec2 const & Texcoord +) +{ + detail::tvec2 Result; + for(typename detail::tvec2::size_type i = 0; i < detail::tvec2::value_size(); ++i) + Result[i] = mirrorRepeat(Texcoord[i]); + return Result; +} - template - GLM_FUNC_QUALIFIER detail::tvec2 mirrorRepeat - ( - detail::tvec2 const & Texcoord - ) - { - detail::tvec2 Result; - for(typename detail::tvec2::size_type i = 0; i < detail::tvec2::value_size(); ++i) - Result[i] = mirrorRepeat(Texcoord[i]); - return Result; - } +template +GLM_FUNC_QUALIFIER detail::tvec3 mirrorRepeat +( + detail::tvec3 const & Texcoord +) +{ + detail::tvec3 Result; + for(typename detail::tvec3::size_type i = 0; i < detail::tvec3::value_size(); ++i) + Result[i] = mirrorRepeat(Texcoord[i]); + return Result; +} - template - GLM_FUNC_QUALIFIER detail::tvec3 mirrorRepeat - ( - detail::tvec3 const & Texcoord - ) - { - detail::tvec3 Result; - for(typename detail::tvec3::size_type i = 0; i < detail::tvec3::value_size(); ++i) - Result[i] = mirrorRepeat(Texcoord[i]); - return Result; - } +template +GLM_FUNC_QUALIFIER detail::tvec4 mirrorRepeat +( + detail::tvec4 const & Texcoord +) +{ + detail::tvec4 Result; + for(typename detail::tvec4::size_type i = 0; i < detail::tvec4::value_size(); ++i) + Result[i] = mirrorRepeat(Texcoord[i]); + return Result; +} - template - GLM_FUNC_QUALIFIER detail::tvec4 mirrorRepeat - ( - detail::tvec4 const & Texcoord - ) - { - detail::tvec4 Result; - for(typename detail::tvec4::size_type i = 0; i < detail::tvec4::value_size(); ++i) - Result[i] = mirrorRepeat(Texcoord[i]); - return Result; - } - -}//namespace gtx }//namespace glm diff --git a/glm/virtrev/xstream.hpp b/glm/virtrev/xstream.hpp index e60334b5..bbd834b5 100644 --- a/glm/virtrev/xstream.hpp +++ b/glm/virtrev/xstream.hpp @@ -47,120 +47,118 @@ # pragma message("GLM: GLM_VIRTREV_xstream extension included") #endif -namespace glm{ -namespace virtrev_glmext +namespace glm { - template - std::ostream & operator << (std::ostream & stream, glm::detail::tvec2 const & vec) - { - stream << ""; + template + std::ostream & operator << (std::ostream & stream, glm::detail::tvec2 const & vec) + { + stream << ""; - return stream; - } + return stream; + } - template - std::ostream & operator << (std::ostream & stream, glm::detail::tvec3 const & vec) - { - stream << ""; + template + std::ostream & operator << (std::ostream & stream, glm::detail::tvec3 const & vec) + { + stream << ""; - return stream; - } + return stream; + } - template - std::ostream & operator << (std::ostream & stream, glm::detail::tvec4 const & vec) - { - stream << ""; + template + std::ostream & operator << (std::ostream & stream, glm::detail::tvec4 const & vec) + { + stream << ""; - return stream; - } + return stream; + } - template - std::ostream & operator << (std::ostream & stream, glm::detail::tmat2x2 const & mat) - { - stream << "" << std::endl; - stream << "" << std::endl; - stream << "" << std::endl; - stream << ""; + template + std::ostream & operator << (std::ostream & stream, glm::detail::tmat2x2 const & mat) + { + stream << "" << std::endl; + stream << "" << std::endl; + stream << "" << std::endl; + stream << ""; - return stream; - } + return stream; + } - template - std::ostream & operator << (std::ostream & stream, glm::detail::tmat3x3 const & mat) - { - stream << "" << std::endl; - stream << "" << std::endl; - stream << "" << std::endl; - stream << "" << std::endl; - stream << ""; + template + std::ostream & operator << (std::ostream & stream, glm::detail::tmat3x3 const & mat) + { + stream << "" << std::endl; + stream << "" << std::endl; + stream << "" << std::endl; + stream << "" << std::endl; + stream << ""; - return stream; - } + return stream; + } - template - std::ostream & operator << (std::ostream & stream, glm::detail::tmat4x4 const & mat) - { - stream << "" << std::endl; - stream << "" << std::endl; - stream << "" << std::endl; - stream << "" << std::endl; - stream << "" << std::endl; - stream << ""; + template + std::ostream & operator << (std::ostream & stream, glm::detail::tmat4x4 const & mat) + { + stream << "" << std::endl; + stream << "" << std::endl; + stream << "" << std::endl; + stream << "" << std::endl; + stream << "" << std::endl; + stream << ""; - return stream; - } + return stream; + } -}//namespace virtrev_glmext }//namespace glm #endif//GLM_VIRTREV_XSTREAM_INCLUDED