diff --git a/glm/gtx/bit.hpp b/glm/gtx/bit.hpp index d97974e7..b07b4b65 100644 --- a/glm/gtx/bit.hpp +++ b/glm/gtx/bit.hpp @@ -29,6 +29,10 @@ namespace glm template GLM_FUNC_DECL genIUType highestBitValue(genIUType Value); + /// @see gtx_bit + template + GLM_FUNC_DECL genIUType lowestBitValue(genIUType Value); + /// Find the highest bit set to 1 in a integer variable and return its value. /// /// @see gtx_bit diff --git a/glm/gtx/bit.inl b/glm/gtx/bit.inl index d97a42c7..10d5f7fa 100644 --- a/glm/gtx/bit.inl +++ b/glm/gtx/bit.inl @@ -25,6 +25,21 @@ namespace glm return detail::functor1::call(highestBitValue, v); } + /////////////////// + // lowestBitValue + + template + GLM_FUNC_QUALIFIER genIUType lowestBitValue(genIUType Value) + { + return (Value & (~Value + 1)); + } + + template class vecType> + GLM_FUNC_QUALIFIER vecType lowestBitValue(vecType const & v) + { + return detail::functor1::call(lowestBitValue, v); + } + /////////////////// // powerOfTwoAbove diff --git a/readme.md b/readme.md index 3a568186..e83ed772 100644 --- a/readme.md +++ b/readme.md @@ -67,6 +67,7 @@ glm::mat4 camera(float Translate, glm::vec2 const & Rotate) - Added GTC_type_aligned with aligned *vec* types - Added GTC_functions extension - Added quaternion version of isnan and isinf #521 +- Added lowestBitValue to GTX_bit #536 ##### Improvements: - Improved SIMD and swizzle operators interactions with GCC and Clang #474