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