mirror of
https://github.com/g-truc/glm.git
synced 2024-11-12 21:31:47 +00:00
Fixed bitfieldExtract implementation
This commit is contained in:
parent
af2a12f1dc
commit
e74f71eb58
@ -258,14 +258,15 @@ namespace glm
|
|||||||
}
|
}
|
||||||
|
|
||||||
// bitfieldExtract
|
// bitfieldExtract
|
||||||
template <typename genIUType>
|
template <typename genIUType, typename sizeType>
|
||||||
genIUType bitfieldExtract
|
GLM_FUNC_QUALIFIER genIUType bitfieldExtract
|
||||||
(
|
(
|
||||||
genIUType const & Value,
|
genIUType const & Value,
|
||||||
int const & Offset,
|
sizeType const & Offset,
|
||||||
int const & Bits
|
sizeType const & Bits
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
|
/*
|
||||||
GLM_STATIC_ASSERT(std::numeric_limits<genIUType>::is_integer, "'bitfieldExtract' only accept integer values");
|
GLM_STATIC_ASSERT(std::numeric_limits<genIUType>::is_integer, "'bitfieldExtract' only accept integer values");
|
||||||
assert(Offset + Bits <= (sizeof(genIUType) << 3));
|
assert(Offset + Bits <= (sizeof(genIUType) << 3));
|
||||||
|
|
||||||
@ -278,6 +279,15 @@ namespace glm
|
|||||||
Mask |= (genIUType(1) << Bit);
|
Mask |= (genIUType(1) << Bit);
|
||||||
|
|
||||||
return Result | ((Mask & Value) >> Offset);
|
return Result | ((Mask & Value) >> Offset);
|
||||||
|
*/
|
||||||
|
sizeType GenSize = sizeof(genIUType) << sizeType(3);
|
||||||
|
|
||||||
|
assert(Offset + Bits <= GenSize);
|
||||||
|
|
||||||
|
genIUType ShiftLeft = Bits ? Value << (GenSize - (Bits + Offset)) : genIUType(0);
|
||||||
|
genIUType ShiftBack = ShiftLeft >> genIUType(GenSize - Bits);
|
||||||
|
|
||||||
|
return ShiftBack;
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
|
Loading…
Reference in New Issue
Block a user