Browse Source

Added lowestBitValue to GTX_bit #536

Christophe Riccio 9 years ago
parent
commit
4db0dfcb19
3 changed files with 20 additions and 0 deletions
  1. 4 0
      glm/gtx/bit.hpp
  2. 15 0
      glm/gtx/bit.inl
  3. 1 0
      readme.md

+ 4 - 0
glm/gtx/bit.hpp

@@ -29,6 +29,10 @@ namespace glm
 	template <typename genIUType>
 	GLM_FUNC_DECL genIUType highestBitValue(genIUType Value);
 
+	/// @see gtx_bit
+	template <typename genIUType>
+	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

+ 15 - 0
glm/gtx/bit.inl

@@ -25,6 +25,21 @@ namespace glm
 		return detail::functor1<T, T, P, vecType>::call(highestBitValue, v);
 	}
 
+	///////////////////
+	// lowestBitValue
+
+	template <typename genIUType>
+	GLM_FUNC_QUALIFIER genIUType lowestBitValue(genIUType Value)
+	{
+		return (Value & (~Value + 1));
+	}
+
+	template <typename T, precision P, template <typename, precision> class vecType>
+	GLM_FUNC_QUALIFIER vecType<T, P> lowestBitValue(vecType<T, P> const & v)
+	{
+		return detail::functor1<T, T, P, vecType>::call(lowestBitValue, v);
+	}
+
 	///////////////////
 	// powerOfTwoAbove
 

+ 1 - 0
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