Merge 0.9.7
This commit is contained in:
parent
79643cf4fa
commit
b3cae39ea6
@ -30,8 +30,9 @@
|
|||||||
/// @author Christophe Riccio
|
/// @author Christophe Riccio
|
||||||
///////////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
namespace glm
|
#include "../detail/func_integer.hpp"
|
||||||
{
|
|
||||||
|
namespace glm{
|
||||||
namespace detail
|
namespace detail
|
||||||
{
|
{
|
||||||
template <typename T, precision P, template <typename, precision> class vecType, bool compute = false>
|
template <typename T, precision P, template <typename, precision> class vecType, bool compute = false>
|
||||||
@ -275,7 +276,7 @@ namespace detail
|
|||||||
template <typename genType>
|
template <typename genType>
|
||||||
GLM_FUNC_QUALIFIER genType floorPowerOfTwo(genType value)
|
GLM_FUNC_QUALIFIER genType floorPowerOfTwo(genType value)
|
||||||
{
|
{
|
||||||
return isPowerOfTwo(value) ? value : highestBitValue(value);
|
return isPowerOfTwo(value) ? value : static_cast<genType>(1) << findMSB(value);
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename T, precision P, template <typename, precision> class vecType>
|
template <typename T, precision P, template <typename, precision> class vecType>
|
||||||
@ -293,8 +294,8 @@ namespace detail
|
|||||||
if(isPowerOfTwo(value))
|
if(isPowerOfTwo(value))
|
||||||
return value;
|
return value;
|
||||||
|
|
||||||
genIUType const prev = highestBitValue(value);
|
genIUType const prev = static_cast<genIUType>(1) << findMSB(value);
|
||||||
genIUType const next = prev << 1;
|
genIUType const next = prev << static_cast<genIUType>(1);
|
||||||
return (next - value) < (value - prev) ? next : prev;
|
return (next - value) < (value - prev) ? next : prev;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -79,6 +79,7 @@ glm::mat4 camera(float Translate, glm::vec2 const & Rotate)
|
|||||||
#### [GLM 0.9.7.5](https://github.com/g-truc/glm/tree/0.9.7) - 2016-0X-XX
|
#### [GLM 0.9.7.5](https://github.com/g-truc/glm/tree/0.9.7) - 2016-0X-XX
|
||||||
##### Fixes:
|
##### Fixes:
|
||||||
- Fixed uaddCarry warning #497
|
- Fixed uaddCarry warning #497
|
||||||
|
- Fixed roundPowerOfTwo and floorPowerOfTwo #503
|
||||||
|
|
||||||
#### [GLM 0.9.7.4](https://github.com/g-truc/glm/releases/tag/0.9.7.4) - 2016-03-19
|
#### [GLM 0.9.7.4](https://github.com/g-truc/glm/releases/tag/0.9.7.4) - 2016-03-19
|
||||||
##### Fixes:
|
##### Fixes:
|
||||||
|
@ -174,7 +174,7 @@ namespace isPowerOfTwo
|
|||||||
}
|
}
|
||||||
}//isPowerOfTwo
|
}//isPowerOfTwo
|
||||||
|
|
||||||
namespace ceilPowerOfTwo
|
namespace ceilPowerOfTwo_advanced
|
||||||
{
|
{
|
||||||
template <typename genIUType>
|
template <typename genIUType>
|
||||||
GLM_FUNC_QUALIFIER genIUType highestBitValue(genIUType Value)
|
GLM_FUNC_QUALIFIER genIUType highestBitValue(genIUType Value)
|
||||||
@ -290,6 +290,72 @@ namespace ceilPowerOfTwo
|
|||||||
Error += test_int32();
|
Error += test_int32();
|
||||||
Error += test_uint32();
|
Error += test_uint32();
|
||||||
|
|
||||||
|
return Error;
|
||||||
|
}
|
||||||
|
}//namespace ceilPowerOfTwo_advanced
|
||||||
|
|
||||||
|
namespace roundPowerOfTwo
|
||||||
|
{
|
||||||
|
int test()
|
||||||
|
{
|
||||||
|
int Error = 0;
|
||||||
|
|
||||||
|
glm::uint32 const A = glm::roundPowerOfTwo(7u);
|
||||||
|
Error += A == 8u ? 0 : 1;
|
||||||
|
|
||||||
|
glm::uint32 const B = glm::roundPowerOfTwo(15u);
|
||||||
|
Error += B == 16u ? 0 : 1;
|
||||||
|
|
||||||
|
glm::uint32 const C = glm::roundPowerOfTwo(31u);
|
||||||
|
Error += C == 32u ? 0 : 1;
|
||||||
|
|
||||||
|
glm::uint32 const D = glm::roundPowerOfTwo(9u);
|
||||||
|
Error += D == 8u ? 0 : 1;
|
||||||
|
|
||||||
|
glm::uint32 const E = glm::roundPowerOfTwo(17u);
|
||||||
|
Error += E == 16u ? 0 : 1;
|
||||||
|
|
||||||
|
glm::uint32 const F = glm::roundPowerOfTwo(33u);
|
||||||
|
Error += F == 32u ? 0 : 1;
|
||||||
|
|
||||||
|
return Error;
|
||||||
|
}
|
||||||
|
}//namespace roundPowerOfTwo
|
||||||
|
|
||||||
|
namespace floorPowerOfTwo
|
||||||
|
{
|
||||||
|
int test()
|
||||||
|
{
|
||||||
|
int Error = 0;
|
||||||
|
|
||||||
|
glm::uint32 const A = glm::floorPowerOfTwo(7u);
|
||||||
|
Error += A == 4u ? 0 : 1;
|
||||||
|
|
||||||
|
glm::uint32 const B = glm::floorPowerOfTwo(15u);
|
||||||
|
Error += B == 8u ? 0 : 1;
|
||||||
|
|
||||||
|
glm::uint32 const C = glm::floorPowerOfTwo(31u);
|
||||||
|
Error += C == 16u ? 0 : 1;
|
||||||
|
|
||||||
|
return Error;
|
||||||
|
}
|
||||||
|
}//namespace floorPowerOfTwo
|
||||||
|
|
||||||
|
namespace ceilPowerOfTwo
|
||||||
|
{
|
||||||
|
int test()
|
||||||
|
{
|
||||||
|
int Error = 0;
|
||||||
|
|
||||||
|
glm::uint32 const A = glm::ceilPowerOfTwo(7u);
|
||||||
|
Error += A == 8u ? 0 : 1;
|
||||||
|
|
||||||
|
glm::uint32 const B = glm::ceilPowerOfTwo(15u);
|
||||||
|
Error += B == 16u ? 0 : 1;
|
||||||
|
|
||||||
|
glm::uint32 const C = glm::ceilPowerOfTwo(31u);
|
||||||
|
Error += C == 32u ? 0 : 1;
|
||||||
|
|
||||||
return Error;
|
return Error;
|
||||||
}
|
}
|
||||||
}//namespace ceilPowerOfTwo
|
}//namespace ceilPowerOfTwo
|
||||||
@ -406,8 +472,11 @@ int main()
|
|||||||
int Error(0);
|
int Error(0);
|
||||||
|
|
||||||
Error += isPowerOfTwo::test();
|
Error += isPowerOfTwo::test();
|
||||||
|
Error += floorPowerOfTwo::test();
|
||||||
|
Error += roundPowerOfTwo::test();
|
||||||
Error += ceilPowerOfTwo::test();
|
Error += ceilPowerOfTwo::test();
|
||||||
|
Error += ceilPowerOfTwo_advanced::test();
|
||||||
|
|
||||||
# ifdef NDEBUG
|
# ifdef NDEBUG
|
||||||
Error += ceilPowerOfTwo::perf();
|
Error += ceilPowerOfTwo::perf();
|
||||||
# endif//NDEBUG
|
# endif//NDEBUG
|
||||||
|
Loading…
x
Reference in New Issue
Block a user