Browse Source

Fixed conflict with Boost, ticket #158

Christophe Riccio 14 years ago
parent
commit
040ea3ce7e
4 changed files with 30 additions and 17 deletions
  1. 11 8
      glm/core/func_exponential.inl
  2. 10 2
      glm/gtc/random.inl
  3. 5 4
      glm/gtx/integer.inl
  4. 4 3
      test/core/core_func_common.cpp

+ 11 - 8
glm/core/func_exponential.inl

@@ -87,29 +87,32 @@ namespace glm
 
 	VECTORIZE_VEC(exp2)
 
-namespace detail
+namespace _detail
 {
-	template <int PATH = float_or_int_value::GLM_ERROR>
-	struct compute_log2
+	template <int _PATH = detail::float_or_int_value::GLM_ERROR>
+	struct _compute_log2
 	{
 		template <typename T>
-		T operator() (T const & Value) const
+		T operator() (T const & Value) const;
+/*
 		{
 			GLM_STATIC_ASSERT(0, "'log2' parameter has an invalid template parameter type. GLM core features only supports floating-point types, include <glm/gtx/integer.hpp> for integer types support. Others types are not supported.");
 			return Value;
 		}
+*/
 	};
 
 	template <>
-	struct compute_log2<float_or_int_value::GLM_FLOAT>
+	struct _compute_log2<detail::float_or_int_value::GLM_FLOAT>
 	{
 		template <typename T>
 		T operator() (T const & Value) const
 		{
-			return ::std::log(Value) / T(0.69314718055994530941723212145818);
+			return T(::std::log(Value)) / T(0.69314718055994530941723212145818);
 		}
 	};
-}//namespace detail
+    
+}//namespace _detail
 
     // log2, ln2 = 0.69314718055994530941723212145818f
     template <typename genType>
@@ -119,7 +122,7 @@ namespace detail
 	)
     {
 		assert(x > genType(0)); // log2 is only defined on the range (0, inf]
-		return detail::compute_log2<detail::float_or_int_trait<genType>::ID>()(x);
+		return _detail::_compute_log2<detail::float_or_int_trait<genType>::ID>()(x);
     }
 
 	VECTORIZE_VEC(log2)

+ 10 - 2
glm/gtc/random.inl

@@ -17,13 +17,15 @@ namespace detail
 	struct compute_linearRand
 	{
 		template <typename T>
-		GLM_FUNC_QUALIFIER T operator() (T const & Min, T const & Max) const
+		GLM_FUNC_QUALIFIER T operator() (T const & Min, T const & Max) const;
+/*
 		{
 			GLM_STATIC_ASSERT(0, "'linearRand' invalid template parameter type. GLM_GTC_random only supports floating-point template types.");
 			return Min;
 		}
+*/
 	};
-
+    
 	template <>
 	GLM_FUNC_QUALIFIER half compute_linearRand::operator()<half> (half const & Min, half const & Max) const
 	{
@@ -41,6 +43,12 @@ namespace detail
 	{
 		return double(std::rand()) / double(RAND_MAX) * (Max - Min) + Min;
 	}
+    
+	template <>
+	GLM_FUNC_QUALIFIER long double compute_linearRand::operator()<long double> (long double const & Min, long double const & Max) const
+	{
+		return (long double)(std::rand()) / (long double)(RAND_MAX) * (Max - Min) + Min;
+	}
 }//namespace detail
 
 	template <typename genType> 

+ 5 - 4
glm/gtx/integer.inl

@@ -38,7 +38,7 @@ namespace glm
 	}
 
 // Henry Gordon Dietz: http://aggregate.org/MAGIC/
-namespace detail
+namespace _detail
 {
 	GLM_FUNC_QUALIFIER unsigned int ones32(unsigned int x)
 	{
@@ -55,7 +55,7 @@ namespace detail
 	}
 
 	template <>
-	struct compute_log2<float_or_int_value::GLM_INT>
+	struct _compute_log2<detail::float_or_int_value::GLM_INT>
 	{
 		template <typename T>
 		T operator() (T const & Value) const
@@ -67,7 +67,8 @@ namespace detail
 #endif
 		}
 	};
-}//namespace detail
+
+}//namespace _detail
 
 	// Henry Gordon Dietz: http://aggregate.org/MAGIC/
 	unsigned int floor_log2(unsigned int x)
@@ -78,7 +79,7 @@ namespace detail
 		x |= (x >> 8);
 		x |= (x >> 16);
 
-		return(detail::ones32(x) - 1);
+		return(_detail::ones32(x) - 1);
 	}
 
 	// mod

+ 4 - 3
test/core/core_func_common.cpp

@@ -7,12 +7,13 @@
 // File    : test/core/func_common.cpp
 ///////////////////////////////////////////////////////////////////////////////////////////////////
 
-#include <glm/glm.hpp>
-#include <glm/gtx/epsilon.hpp>
-#include <cstdio>
 #include <boost/array.hpp>
 #include <boost/date_time/posix_time/posix_time.hpp>
 #include <boost/thread/thread.hpp>
+#include <glm/glm.hpp>
+#include <glm/ext.hpp>
+#include <glm/gtx/epsilon.hpp>
+#include <cstdio>
 
 int test_modf()
 {