glm/glm/gtx/bit.inl

744 lines
16 KiB
Plaintext
Raw Normal View History

2010-04-29 10:54:07 +00:00
///////////////////////////////////////////////////////////////////////////////////////////////////
2011-01-20 11:40:14 +00:00
// OpenGL Mathematics Copyright (c) 2005 - 2011 G-Truc Creation (www.g-truc.net)
2010-04-29 10:54:07 +00:00
///////////////////////////////////////////////////////////////////////////////////////////////////
// Created : 2007-03-14
// Updated : 2008-11-14
// Licence : This source is under MIT License
// File : glm/gtx/bit.inl
///////////////////////////////////////////////////////////////////////////////////////////////////
#include "../core/_detail.hpp"
namespace glm{
namespace gtx{
namespace bit{
template <typename genIType>
2011-04-09 08:44:32 +00:00
GLM_FUNC_QUALIFIER genIType mask
2010-04-29 10:54:07 +00:00
(
genIType const & count
)
{
return ((genIType(1) << (count)) - genIType(1));
}
template <typename valIType>
2011-04-09 08:44:32 +00:00
GLM_FUNC_QUALIFIER detail::tvec2<valIType> mask
2010-04-29 10:54:07 +00:00
(
detail::tvec2<valIType> const & count
)
{
return detail::tvec2<valIType>(
mask(count[0]),
mask(count[1]));
}
template <typename valIType>
2011-04-09 08:44:32 +00:00
GLM_FUNC_QUALIFIER detail::tvec3<valIType> mask
2010-04-29 10:54:07 +00:00
(
detail::tvec3<valIType> const & count
)
{
return detail::tvec3<valIType>(
mask(count[0]),
mask(count[1]),
mask(count[2]));
}
template <typename valIType>
2011-04-09 08:44:32 +00:00
GLM_FUNC_QUALIFIER detail::tvec4<valIType> mask
2010-04-29 10:54:07 +00:00
(
detail::tvec4<valIType> const & count
)
{
return detail::tvec4<valIType>(
mask(count[0]),
mask(count[1]),
mask(count[2]),
mask(count[3]));
}
// extractField
template <typename genIType>
2011-04-09 08:44:32 +00:00
GLM_FUNC_QUALIFIER genIType extractField
2010-04-29 10:54:07 +00:00
(
gtc::half_float::half const & value,
genIType const & first,
genIType const & count
)
{
assert(first + count < sizeof(gtc::half_float::half));
return (value._data() << first) >> ((sizeof(gtc::half_float::half) << 3) - count);
}
template <typename genIType>
2011-04-09 08:44:32 +00:00
GLM_FUNC_QUALIFIER genIType extractField
2010-04-29 10:54:07 +00:00
(
float const & value,
genIType const & first,
genIType const & count
)
{
assert(first + count < sizeof(float));
return (detail::uif32(value).i << first) >> ((sizeof(float) << 3) - count);
}
template <typename genIType>
2011-04-09 08:44:32 +00:00
GLM_FUNC_QUALIFIER genIType extractField
2010-04-29 10:54:07 +00:00
(
double const & value,
genIType const & first,
genIType const & count
)
{
assert(first + count < sizeof(double));
2010-10-05 22:52:59 +00:00
return (detail::uif64(value).i << first) >> ((sizeof(double) << genIType(3)) - count);
2010-04-29 10:54:07 +00:00
}
2010-10-05 22:52:59 +00:00
template <typename genIUType, typename sizeType>
2011-04-09 08:44:32 +00:00
GLM_FUNC_QUALIFIER genIUType extractField
2010-04-29 10:54:07 +00:00
(
2010-10-05 22:52:59 +00:00
genIUType const & Value,
sizeType const & First,
sizeType const & Count
2010-04-29 10:54:07 +00:00
)
{
2010-10-05 22:52:59 +00:00
sizeType GenSize = sizeof(genIUType) << 3;
assert(First + Count <= GenSize);
genIUType ShiftLeft = Count ? Value << (GenSize - (Count + First)) : 0;
genIUType ShiftBack = ShiftLeft >> genIUType(GenSize - Count);
return ShiftBack;
2010-04-29 10:54:07 +00:00
}
2010-10-05 22:52:59 +00:00
template <typename genIUType, typename sizeType>
2011-04-09 08:44:32 +00:00
GLM_FUNC_QUALIFIER detail::tvec2<genIUType> extractField
2010-04-29 10:54:07 +00:00
(
2010-10-05 22:52:59 +00:00
detail::tvec2<genIUType> const & value,
sizeType const & first,
sizeType const & count
2010-04-29 10:54:07 +00:00
)
{
2010-10-05 22:52:59 +00:00
return detail::tvec2<genIUType>(
2010-04-29 10:54:07 +00:00
extractField(value[0], first, count),
extractField(value[1], first, count));
}
2010-10-05 22:52:59 +00:00
template <typename genIUType, typename sizeType>
2011-04-09 08:44:32 +00:00
GLM_FUNC_QUALIFIER detail::tvec3<genIUType> extractField
2010-04-29 10:54:07 +00:00
(
2010-10-05 22:52:59 +00:00
detail::tvec3<genIUType> const & value,
sizeType const & first,
sizeType const & count
2010-04-29 10:54:07 +00:00
)
{
2010-10-05 22:52:59 +00:00
return detail::tvec3<genIUType>(
2010-04-29 10:54:07 +00:00
extractField(value[0], first, count),
extractField(value[1], first, count),
extractField(value[2], first, count));
}
2010-10-05 22:52:59 +00:00
template <typename genIUType, typename sizeType>
2011-04-09 08:44:32 +00:00
GLM_FUNC_QUALIFIER detail::tvec4<genIUType> extractField
2010-04-29 10:54:07 +00:00
(
2010-10-05 22:52:59 +00:00
detail::tvec4<genIUType> const & value,
sizeType const & first,
sizeType const & count
2010-04-29 10:54:07 +00:00
)
{
2010-10-05 22:52:59 +00:00
return detail::tvec4<genIUType>(
2010-04-29 10:54:07 +00:00
extractField(value[0], first, count),
extractField(value[1], first, count),
extractField(value[2], first, count),
extractField(value[3], first, count));
}
2010-10-05 22:52:59 +00:00
template <typename genIUType, typename sizeType>
2011-04-09 08:44:32 +00:00
GLM_FUNC_QUALIFIER detail::tvec2<genIUType> extractField
2010-04-29 10:54:07 +00:00
(
2010-10-05 22:52:59 +00:00
detail::tvec2<genIUType> const & value,
detail::tvec2<sizeType> const & first,
detail::tvec2<sizeType> const & count
2010-04-29 10:54:07 +00:00
)
{
2010-10-05 22:52:59 +00:00
return detail::tvec2<genIUType>(
2010-04-29 10:54:07 +00:00
extractField(value[0], first[0], count[0]),
extractField(value[1], first[1], count[1]));
}
2010-10-05 22:52:59 +00:00
template <typename genIUType, typename sizeType>
2011-04-09 08:44:32 +00:00
GLM_FUNC_QUALIFIER detail::tvec3<genIUType> extractField
2010-04-29 10:54:07 +00:00
(
2010-10-05 22:52:59 +00:00
detail::tvec3<genIUType> const & value,
detail::tvec3<sizeType> const & first,
detail::tvec3<sizeType> const & count
2010-04-29 10:54:07 +00:00
)
{
2010-10-05 22:52:59 +00:00
return detail::tvec3<genIUType>(
2010-04-29 10:54:07 +00:00
extractField(value[0], first[0], count[0]),
extractField(value[1], first[1], count[1]),
extractField(value[2], first[2], count[2]));
}
2010-10-05 22:52:59 +00:00
template <typename genIUType, typename sizeType>
2011-04-09 08:44:32 +00:00
GLM_FUNC_QUALIFIER detail::tvec4<genIUType> extractField
2010-04-29 10:54:07 +00:00
(
2010-10-05 22:52:59 +00:00
detail::tvec4<genIUType> const & value,
detail::tvec4<sizeType> const & first,
detail::tvec4<sizeType> const & count
2010-04-29 10:54:07 +00:00
)
{
2010-10-05 22:52:59 +00:00
return detail::tvec4<genIUType>(
2010-04-29 10:54:07 +00:00
extractField(value[0], first[0], count[0]),
extractField(value[1], first[1], count[1]),
extractField(value[2], first[2], count[2]),
extractField(value[3], first[3], count[3]));
}
2010-10-05 22:52:59 +00:00
template <typename genIUType, typename sizeType>
2011-04-09 08:44:32 +00:00
GLM_FUNC_QUALIFIER detail::tvec2<genIUType> extractField
2010-04-29 10:54:07 +00:00
(
2010-10-05 22:52:59 +00:00
genIUType const & value,
detail::tvec2<sizeType> const & first,
detail::tvec2<sizeType> const & count
2010-04-29 10:54:07 +00:00
)
{
2010-10-05 22:52:59 +00:00
return detail::tvec2<genIUType>(
2010-04-29 10:54:07 +00:00
extractField(value, first[0], count[0]),
extractField(value, first[1], count[1]));
}
2010-10-05 22:52:59 +00:00
template <typename genIUType, typename sizeType>
2011-04-09 08:44:32 +00:00
GLM_FUNC_QUALIFIER detail::tvec3<genIUType> extractField
2010-04-29 10:54:07 +00:00
(
2010-10-05 22:52:59 +00:00
genIUType const & value,
detail::tvec3<sizeType> const & first,
detail::tvec3<sizeType> const & count
2010-04-29 10:54:07 +00:00
)
{
2010-10-05 22:52:59 +00:00
return detail::tvec3<genIUType>(
2010-04-29 10:54:07 +00:00
extractField(value, first[0], count[0]),
extractField(value, first[1], count[1]),
extractField(value, first[2], count[2]));
}
2010-10-05 22:52:59 +00:00
template <typename genIUType, typename sizeType>
2011-04-09 08:44:32 +00:00
GLM_FUNC_QUALIFIER detail::tvec4<genIUType> extractField
2010-04-29 10:54:07 +00:00
(
2010-10-05 22:52:59 +00:00
genIUType const & value,
detail::tvec4<sizeType> const & first,
detail::tvec4<sizeType> const & count
2010-04-29 10:54:07 +00:00
)
{
2010-10-05 22:52:59 +00:00
return detail::tvec4<genIUType>(
2010-04-29 10:54:07 +00:00
extractField(value, first[0], count[0]),
extractField(value, first[1], count[1]),
extractField(value, first[2], count[2]),
extractField(value, first[3], count[3]));
}
// lowestBit
template <typename genType>
2011-04-09 08:44:32 +00:00
GLM_FUNC_QUALIFIER int lowestBit
2010-04-29 10:54:07 +00:00
(
genType const & Value
)
{
2010-04-29 10:56:52 +00:00
assert(Value != genType(0)); // not valid call
2010-04-29 10:54:07 +00:00
genType Bit;
for(Bit = genType(0); !(Value & (1 << Bit)); ++Bit){}
return Bit;
}
template <typename valType>
2011-04-09 08:44:32 +00:00
GLM_FUNC_QUALIFIER detail::tvec2<int> lowestBit
2010-04-29 10:54:07 +00:00
(
detail::tvec2<valType> const & value
)
{
return detail::tvec2<int>(
lowestBit(value[0]),
lowestBit(value[1]));
}
template <typename valType>
2011-04-09 08:44:32 +00:00
GLM_FUNC_QUALIFIER detail::tvec3<int> lowestBit
2010-04-29 10:54:07 +00:00
(
detail::tvec3<valType> const & value
)
{
return detail::tvec3<int>(
lowestBit(value[0]),
lowestBit(value[1]),
lowestBit(value[2]));
}
template <typename valType>
2011-04-09 08:44:32 +00:00
GLM_FUNC_QUALIFIER detail::tvec4<int> lowestBit
2010-04-29 10:54:07 +00:00
(
detail::tvec4<valType> const & value
)
{
return detail::tvec4<int>(
lowestBit(value[0]),
lowestBit(value[1]),
lowestBit(value[2]),
lowestBit(value[3]));
}
// highestBit
template <typename genType>
2011-04-09 08:44:32 +00:00
GLM_FUNC_QUALIFIER int highestBit
2010-04-29 10:54:07 +00:00
(
genType const & value
)
{
2010-04-29 10:56:52 +00:00
assert(value != genType(0)); // not valid call
2010-04-29 10:54:07 +00:00
genType bit = genType(-1);
for(genType tmp = value; tmp; tmp >>= 1, ++bit){}
return bit;
}
//template <>
2011-04-09 08:44:32 +00:00
//GLM_FUNC_QUALIFIER int highestBit<int>
2010-04-29 10:54:07 +00:00
//(
// int value
//)
//{
// int bit = -1;
// for(int tmp = value; tmp; tmp >>= 1, ++bit);
// return bit;
//}
template <typename valType>
2011-04-09 08:44:32 +00:00
GLM_FUNC_QUALIFIER detail::tvec2<int> highestBit
2010-04-29 10:54:07 +00:00
(
detail::tvec2<valType> const & value
)
{
return detail::tvec2<int>(
highestBit(value[0]),
highestBit(value[1]));
}
template <typename valType>
2011-04-09 08:44:32 +00:00
GLM_FUNC_QUALIFIER detail::tvec3<int> highestBit
2010-04-29 10:54:07 +00:00
(
detail::tvec3<valType> const & value
)
{
return detail::tvec3<int>(
highestBit(value[0]),
highestBit(value[1]),
highestBit(value[2]));
}
template <typename valType>
2011-04-09 08:44:32 +00:00
GLM_FUNC_QUALIFIER detail::tvec4<int> highestBit
2010-04-29 10:54:07 +00:00
(
detail::tvec4<valType> const & value
)
{
return detail::tvec4<int>(
highestBit(value[0]),
highestBit(value[1]),
highestBit(value[2]),
highestBit(value[3]));
}
// highestBitValue
template <typename genType>
2011-04-09 08:44:32 +00:00
GLM_FUNC_QUALIFIER genType highestBitValue
2010-04-29 10:54:07 +00:00
(
genType const & value
)
{
genType tmp = value;
genType result = genType(0);
while(tmp)
{
result = (tmp & (~tmp + 1)); // grab lowest bit
tmp &= ~result; // clear lowest bit
}
return result;
}
template <typename valType>
2011-04-09 08:44:32 +00:00
GLM_FUNC_QUALIFIER detail::tvec2<int> highestBitValue
2010-04-29 10:54:07 +00:00
(
detail::tvec2<valType> const & value
)
{
return detail::tvec2<int>(
highestBitValue(value[0]),
highestBitValue(value[1]));
}
template <typename valType>
2011-04-09 08:44:32 +00:00
GLM_FUNC_QUALIFIER detail::tvec3<int> highestBitValue
2010-04-29 10:54:07 +00:00
(
detail::tvec3<valType> const & value
)
{
return detail::tvec3<int>(
highestBitValue(value[0]),
highestBitValue(value[1]),
highestBitValue(value[2]));
}
template <typename valType>
2011-04-09 08:44:32 +00:00
GLM_FUNC_QUALIFIER detail::tvec4<int> highestBitValue
2010-04-29 10:54:07 +00:00
(
detail::tvec4<valType> const & value
)
{
return detail::tvec4<int>(
highestBitValue(value[0]),
highestBitValue(value[1]),
highestBitValue(value[2]),
highestBitValue(value[3]));
}
// isPowerOfTwo
template <typename genType>
2011-04-09 08:44:32 +00:00
GLM_FUNC_QUALIFIER bool isPowerOfTwo(genType const & Value)
2010-04-29 10:54:07 +00:00
{
//detail::If<std::numeric_limits<genType>::is_signed>::apply(abs, Value);
//return !(Value & (Value - 1));
// For old complier?
genType Result = Value;
if(std::numeric_limits<genType>::is_signed)
Result = abs(Result);
return !(Result & (Result - 1));
}
template <typename valType>
2011-04-09 08:44:32 +00:00
GLM_FUNC_QUALIFIER detail::tvec2<bool> isPowerOfTwo
2010-04-29 10:54:07 +00:00
(
detail::tvec2<valType> const & value
)
{
return detail::tvec2<bool>(
isPowerOfTwo(value[0]),
isPowerOfTwo(value[1]));
}
template <typename valType>
2011-04-09 08:44:32 +00:00
GLM_FUNC_QUALIFIER detail::tvec3<bool> isPowerOfTwo
2010-04-29 10:54:07 +00:00
(
detail::tvec3<valType> const & value
)
{
return detail::tvec3<bool>(
isPowerOfTwo(value[0]),
isPowerOfTwo(value[1]),
isPowerOfTwo(value[2]));
}
template <typename valType>
2011-04-09 08:44:32 +00:00
GLM_FUNC_QUALIFIER detail::tvec4<bool> isPowerOfTwo
2010-04-29 10:54:07 +00:00
(
detail::tvec4<valType> const & value
)
{
return detail::tvec4<bool>(
isPowerOfTwo(value[0]),
isPowerOfTwo(value[1]),
isPowerOfTwo(value[2]),
isPowerOfTwo(value[3]));
}
// powerOfTwoAbove
template <typename genType>
2011-04-09 08:44:32 +00:00
GLM_FUNC_QUALIFIER genType powerOfTwoAbove(genType const & value)
2010-04-29 10:54:07 +00:00
{
return isPowerOfTwo(value) ? value : highestBitValue(value) << 1;
}
template <typename valType>
2011-04-09 08:44:32 +00:00
GLM_FUNC_QUALIFIER detail::tvec2<valType> powerOfTwoAbove
2010-04-29 10:54:07 +00:00
(
detail::tvec2<valType> const & value
)
{
return detail::tvec2<valType>(
powerOfTwoAbove(value[0]),
powerOfTwoAbove(value[1]));
}
template <typename valType>
2011-04-09 08:44:32 +00:00
GLM_FUNC_QUALIFIER detail::tvec3<valType> powerOfTwoAbove
2010-04-29 10:54:07 +00:00
(
detail::tvec3<valType> const & value
)
{
return detail::tvec3<valType>(
powerOfTwoAbove(value[0]),
powerOfTwoAbove(value[1]),
powerOfTwoAbove(value[2]));
}
template <typename valType>
2011-04-09 08:44:32 +00:00
GLM_FUNC_QUALIFIER detail::tvec4<valType> powerOfTwoAbove
2010-04-29 10:54:07 +00:00
(
detail::tvec4<valType> const & value
)
{
return detail::tvec4<valType>(
powerOfTwoAbove(value[0]),
powerOfTwoAbove(value[1]),
powerOfTwoAbove(value[2]),
powerOfTwoAbove(value[3]));
}
// powerOfTwoBelow
template <typename genType>
2011-04-09 08:44:32 +00:00
GLM_FUNC_QUALIFIER genType powerOfTwoBelow
2010-04-29 10:54:07 +00:00
(
genType const & value
)
{
return isPowerOfTwo(value) ? value : highestBitValue(value);
}
template <typename valType>
2011-04-09 08:44:32 +00:00
GLM_FUNC_QUALIFIER detail::tvec2<valType> powerOfTwoBelow
2010-04-29 10:54:07 +00:00
(
detail::tvec2<valType> const & value
)
{
return detail::tvec2<valType>(
powerOfTwoBelow(value[0]),
powerOfTwoBelow(value[1]));
}
template <typename valType>
2011-04-09 08:44:32 +00:00
GLM_FUNC_QUALIFIER detail::tvec3<valType> powerOfTwoBelow
2010-04-29 10:54:07 +00:00
(
detail::tvec3<valType> const & value
)
{
return detail::tvec3<valType>(
powerOfTwoBelow(value[0]),
powerOfTwoBelow(value[1]),
powerOfTwoBelow(value[2]));
}
template <typename valType>
2011-04-09 08:44:32 +00:00
GLM_FUNC_QUALIFIER detail::tvec4<valType> powerOfTwoBelow
2010-04-29 10:54:07 +00:00
(
detail::tvec4<valType> const & value
)
{
return detail::tvec4<valType>(
powerOfTwoBelow(value[0]),
powerOfTwoBelow(value[1]),
powerOfTwoBelow(value[2]),
powerOfTwoBelow(value[3]));
}
// powerOfTwoNearest
template <typename genType>
2011-04-09 08:44:32 +00:00
GLM_FUNC_QUALIFIER genType powerOfTwoNearest
2010-04-29 10:54:07 +00:00
(
genType const & value
)
{
if(isPowerOfTwo(value))
return value;
genType prev = highestBitValue(value);
genType next = prev << 1;
return (next - value) < (value - prev) ? next : prev;
}
template <typename valType>
2011-04-09 08:44:32 +00:00
GLM_FUNC_QUALIFIER detail::tvec2<valType> powerOfTwoNearest
2010-04-29 10:54:07 +00:00
(
detail::tvec2<valType> const & value
)
{
return detail::tvec2<valType>(
powerOfTwoNearest(value[0]),
powerOfTwoNearest(value[1]));
}
template <typename valType>
2011-04-09 08:44:32 +00:00
GLM_FUNC_QUALIFIER detail::tvec3<valType> powerOfTwoNearest
2010-04-29 10:54:07 +00:00
(
detail::tvec3<valType> const & value
)
{
return detail::tvec3<valType>(
powerOfTwoNearest(value[0]),
powerOfTwoNearest(value[1]),
powerOfTwoNearest(value[2]));
}
template <typename valType>
2011-04-09 08:44:32 +00:00
GLM_FUNC_QUALIFIER detail::tvec4<valType> powerOfTwoNearest
2010-04-29 10:54:07 +00:00
(
detail::tvec4<valType> const & value
)
{
return detail::tvec4<valType>(
powerOfTwoNearest(value[0]),
powerOfTwoNearest(value[1]),
powerOfTwoNearest(value[2]),
powerOfTwoNearest(value[3]));
}
template <typename genType>
2011-04-09 08:44:32 +00:00
GLM_FUNC_QUALIFIER genType bitRevert(genType const & In)
2010-04-29 10:54:07 +00:00
{
2010-11-12 18:58:55 +00:00
GLM_STATIC_ASSERT(std::numeric_limits<genType>::is_integer, "'bitRevert' only accept integer values");
2010-04-29 10:54:07 +00:00
genType Out = 0;
std::size_t BitSize = sizeof(genType) * 8;
for(std::size_t i = 0; i < BitSize; ++i)
2011-03-18 01:50:40 +00:00
if(In & (genType(1) << i))
Out |= genType(1) << (BitSize - 1 - i);
2010-04-29 10:54:07 +00:00
return Out;
}
template <typename valType>
2011-04-09 08:44:32 +00:00
GLM_FUNC_QUALIFIER detail::tvec2<valType> bitRevert
2010-04-29 10:54:07 +00:00
(
detail::tvec2<valType> const & Value
)
{
return detail::tvec2<valType>(
bitRevert(Value[0]),
bitRevert(Value[1]));
}
template <typename valType>
2011-04-09 08:44:32 +00:00
GLM_FUNC_QUALIFIER detail::tvec3<valType> bitRevert
2010-04-29 10:54:07 +00:00
(
detail::tvec3<valType> const & Value
)
{
return detail::tvec3<valType>(
bitRevert(Value[0]),
bitRevert(Value[1]),
bitRevert(Value[2]));
}
template <typename valType>
2011-04-09 08:44:32 +00:00
GLM_FUNC_QUALIFIER detail::tvec4<valType> bitRevert
2010-04-29 10:54:07 +00:00
(
detail::tvec4<valType> const & Value
)
{
return detail::tvec4<valType>(
bitRevert(Value[0]),
bitRevert(Value[1]),
bitRevert(Value[2]),
bitRevert(Value[3]));
}
template <typename genType>
2011-04-09 08:44:32 +00:00
GLM_FUNC_QUALIFIER genType bitRotateRight(genType const & In, std::size_t Shift)
2010-04-29 10:54:07 +00:00
{
2010-11-12 18:58:55 +00:00
GLM_STATIC_ASSERT(std::numeric_limits<genType>::is_integer, "'bitRotateRight' only accept integer values");
2010-04-29 10:54:07 +00:00
std::size_t BitSize = sizeof(genType) * 8;
return (In << Shift) | (In >> (BitSize - Shift));
}
template <typename valType>
2011-04-09 08:44:32 +00:00
GLM_FUNC_QUALIFIER detail::tvec2<valType> bitRotateRight
2010-04-29 10:54:07 +00:00
(
detail::tvec2<valType> const & Value,
std::size_t Shift
)
{
return detail::tvec2<valType>(
bitRotateRight(Value[0], Shift),
bitRotateRight(Value[1], Shift));
}
template <typename valType>
2011-04-09 08:44:32 +00:00
GLM_FUNC_QUALIFIER detail::tvec3<valType> bitRotateRight
2010-04-29 10:54:07 +00:00
(
detail::tvec3<valType> const & Value,
std::size_t Shift
)
{
return detail::tvec3<valType>(
bitRotateRight(Value[0], Shift),
bitRotateRight(Value[1], Shift),
bitRotateRight(Value[2], Shift));
}
template <typename valType>
2011-04-09 08:44:32 +00:00
GLM_FUNC_QUALIFIER detail::tvec4<valType> bitRotateRight
2010-04-29 10:54:07 +00:00
(
detail::tvec4<valType> const & Value,
std::size_t Shift
)
{
return detail::tvec4<valType>(
bitRotateRight(Value[0], Shift),
bitRotateRight(Value[1], Shift),
bitRotateRight(Value[2], Shift),
bitRotateRight(Value[3], Shift));
}
template <typename genType>
2011-04-09 08:44:32 +00:00
GLM_FUNC_QUALIFIER genType bitRotateLeft(genType const & In, std::size_t Shift)
2010-04-29 10:54:07 +00:00
{
2010-11-12 18:58:55 +00:00
GLM_STATIC_ASSERT(std::numeric_limits<genType>::is_integer, "'bitRotateLeft' only accept integer values");
2010-04-29 10:54:07 +00:00
std::size_t BitSize = sizeof(genType) * 8;
return (In >> Shift) | (In << (BitSize - Shift));
}
template <typename valType>
2011-04-09 08:44:32 +00:00
GLM_FUNC_QUALIFIER detail::tvec2<valType> bitRotateLeft
2010-04-29 10:54:07 +00:00
(
detail::tvec2<valType> const & Value,
std::size_t Shift
)
{
return detail::tvec2<valType>(
bitRotateLeft(Value[0], Shift),
bitRotateLeft(Value[1], Shift));
}
template <typename valType>
2011-04-09 08:44:32 +00:00
GLM_FUNC_QUALIFIER detail::tvec3<valType> bitRotateLeft
2010-04-29 10:54:07 +00:00
(
detail::tvec3<valType> const & Value,
std::size_t Shift
)
{
return detail::tvec3<valType>(
bitRotateLeft(Value[0], Shift),
bitRotateLeft(Value[1], Shift),
bitRotateLeft(Value[2], Shift));
}
template <typename valType>
2011-04-09 08:44:32 +00:00
GLM_FUNC_QUALIFIER detail::tvec4<valType> bitRotateLeft
2010-04-29 10:54:07 +00:00
(
detail::tvec4<valType> const & Value,
std::size_t Shift
)
{
return detail::tvec4<valType>(
bitRotateLeft(Value[0], Shift),
bitRotateLeft(Value[1], Shift),
bitRotateLeft(Value[2], Shift),
bitRotateLeft(Value[3], Shift));
}
}//namespace bit
}//namespace gtx
}//namespace glm