|
|
|
@ -245,21 +245,26 @@ namespace detail |
|
|
|
|
} |
|
|
|
|
}//namespace detail |
|
|
|
|
|
|
|
|
|
GLM_FUNC_QUALIFIER int mask(int Bits) |
|
|
|
|
template <typename genType> |
|
|
|
|
GLM_FUNC_QUALIFIER genType mask(genType Bits) |
|
|
|
|
{ |
|
|
|
|
return Bits >= sizeof(Bits) * 8 ? ~static_cast<int>(0) : (static_cast<int>(1) << Bits) - static_cast<int>(1); |
|
|
|
|
GLM_STATIC_ASSERT(std::numeric_limits<genIType>::is_integer, "'mask' accepts only integer values"); |
|
|
|
|
|
|
|
|
|
return ~((~static_cast<genType>(0)) << Bits); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
template <precision P, template <typename, precision> class vecType> |
|
|
|
|
GLM_FUNC_QUALIFIER vecType<int, P> mask(vecType<int, P> const & v) |
|
|
|
|
template <typename T, precision P, template <typename, precision> class vecType> |
|
|
|
|
GLM_FUNC_QUALIFIER vecType<T, P> mask(vecType<T, P> const & v) |
|
|
|
|
{ |
|
|
|
|
return detail::functor1<int, int, P, vecType>::call(mask, v); |
|
|
|
|
GLM_STATIC_ASSERT(std::numeric_limits<T>::is_integer, "'mask' accepts only integer values"); |
|
|
|
|
|
|
|
|
|
return ~((~static_cast<T>(0)) << v); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
template <typename genIType> |
|
|
|
|
GLM_FUNC_QUALIFIER genIType bitfieldRotateRight(genIType In, int Shift) |
|
|
|
|
{ |
|
|
|
|
GLM_STATIC_ASSERT(std::numeric_limits<genIType>::is_integer, "'bitfieldRotateRight' only accept integer values"); |
|
|
|
|
GLM_STATIC_ASSERT(std::numeric_limits<genIType>::is_integer, "'bitfieldRotateRight' accepts only integer values"); |
|
|
|
|
|
|
|
|
|
int const BitSize = static_cast<genIType>(sizeof(genIType) * 8); |
|
|
|
|
return (In << static_cast<genIType>(Shift)) | (In >> static_cast<genIType>(BitSize - Shift)); |
|
|
|
@ -268,7 +273,7 @@ namespace detail |
|
|
|
|
template <typename T, precision P, template <typename, precision> class vecType> |
|
|
|
|
GLM_FUNC_QUALIFIER vecType<T, P> bitfieldRotateRight(vecType<T, P> const & In, int Shift) |
|
|
|
|
{ |
|
|
|
|
GLM_STATIC_ASSERT(std::numeric_limits<T>::is_integer, "'bitfieldRotateRight' only accept integer values"); |
|
|
|
|
GLM_STATIC_ASSERT(std::numeric_limits<T>::is_integer, "'bitfieldRotateRight' accepts only integer values"); |
|
|
|
|
|
|
|
|
|
int const BitSize = static_cast<int>(sizeof(T) * 8); |
|
|
|
|
return (In << static_cast<T>(Shift)) | (In >> static_cast<T>(BitSize - Shift)); |
|
|
|
@ -277,7 +282,7 @@ namespace detail |
|
|
|
|
template <typename genIType> |
|
|
|
|
GLM_FUNC_QUALIFIER genIType bitfieldRotateLeft(genIType In, int Shift) |
|
|
|
|
{ |
|
|
|
|
GLM_STATIC_ASSERT(std::numeric_limits<genIType>::is_integer, "'bitfieldRotateLeft' only accept integer values"); |
|
|
|
|
GLM_STATIC_ASSERT(std::numeric_limits<genIType>::is_integer, "'bitfieldRotateLeft' accepts only integer values"); |
|
|
|
|
|
|
|
|
|
int const BitSize = static_cast<genIType>(sizeof(genIType) * 8); |
|
|
|
|
return (In >> static_cast<genIType>(Shift)) | (In << static_cast<genIType>(BitSize - Shift)); |
|
|
|
@ -286,7 +291,7 @@ namespace detail |
|
|
|
|
template <typename T, precision P, template <typename, precision> class vecType> |
|
|
|
|
GLM_FUNC_QUALIFIER vecType<T, P> bitfieldRotateLeft(vecType<T, P> const & In, int Shift) |
|
|
|
|
{ |
|
|
|
|
GLM_STATIC_ASSERT(std::numeric_limits<T>::is_integer, "'bitfieldRotateLeft' only accept integer values"); |
|
|
|
|
GLM_STATIC_ASSERT(std::numeric_limits<T>::is_integer, "'bitfieldRotateLeft' accepts only integer values"); |
|
|
|
|
|
|
|
|
|
int const BitSize = static_cast<int>(sizeof(T) * 8); |
|
|
|
|
return (In >> static_cast<T>(Shift)) | (In << static_cast<T>(BitSize - Shift)); |
|
|
|
|