Browse Source

Moved bounded function to GTX_common from EXT_vector_relational as there are quite new

Christophe Riccio 7 years ago
parent
commit
4d4dbcade6

+ 1 - 0
glm/ext.hpp

@@ -13,6 +13,7 @@
 #	pragma message("GLM: All extensions included (not recommended)")
 #endif//GLM_MESSAGES
 
+#include "./ext/vec1.hpp"
 #include "./ext/vector_relational.hpp"
 
 #include "./gtc/bitfield.hpp"

+ 63 - 0
glm/ext/vec1.hpp

@@ -390,6 +390,69 @@ namespace glm
 	template <typename T, qualifier Q = defaultp> using tvec1 = vec<1, T, Q>;
 #endif//GLM_HAS_TEMPLATE_ALIASES
 
+	//////////////////////////
+	// vec1 definition
+
+#if(defined(GLM_PRECISION_HIGHP_BOOL))
+	typedef highp_bvec1				bvec1;
+#elif(defined(GLM_PRECISION_MEDIUMP_BOOL))
+	typedef mediump_bvec1			bvec1;
+#elif(defined(GLM_PRECISION_LOWP_BOOL))
+	typedef lowp_bvec1				bvec1;
+#else
+	/// 1 component vector of boolean.
+	/// @see gtc_vec1 extension.
+	typedef highp_bvec1				bvec1;
+#endif//GLM_PRECISION
+
+#if(defined(GLM_PRECISION_HIGHP_FLOAT))
+	typedef highp_vec1				vec1;
+#elif(defined(GLM_PRECISION_MEDIUMP_FLOAT))
+	typedef mediump_vec1			vec1;
+#elif(defined(GLM_PRECISION_LOWP_FLOAT))
+	typedef lowp_vec1				vec1;
+#else
+	/// 1 component vector of floating-point numbers.
+	/// @see gtc_vec1 extension.
+	typedef highp_vec1				vec1;
+#endif//GLM_PRECISION
+
+#if(defined(GLM_PRECISION_HIGHP_DOUBLE))
+	typedef highp_dvec1				dvec1;
+#elif(defined(GLM_PRECISION_MEDIUMP_DOUBLE))
+	typedef mediump_dvec1			dvec1;
+#elif(defined(GLM_PRECISION_LOWP_DOUBLE))
+	typedef lowp_dvec1				dvec1;
+#else
+	/// 1 component vector of floating-point numbers.
+	/// @see gtc_vec1 extension.
+	typedef highp_dvec1				dvec1;
+#endif//GLM_PRECISION
+
+#if(defined(GLM_PRECISION_HIGHP_INT))
+	typedef highp_ivec1			ivec1;
+#elif(defined(GLM_PRECISION_MEDIUMP_INT))
+	typedef mediump_ivec1		ivec1;
+#elif(defined(GLM_PRECISION_LOWP_INT))
+	typedef lowp_ivec1			ivec1;
+#else
+	/// 1 component vector of signed integer numbers.
+	/// @see gtc_vec1 extension.
+	typedef highp_ivec1			ivec1;
+#endif//GLM_PRECISION
+
+#if(defined(GLM_PRECISION_HIGHP_UINT))
+	typedef highp_uvec1			uvec1;
+#elif(defined(GLM_PRECISION_MEDIUMP_UINT))
+	typedef mediump_uvec1		uvec1;
+#elif(defined(GLM_PRECISION_LOWP_UINT))
+	typedef lowp_uvec1			uvec1;
+#else
+	/// 1 component vector of unsigned integer numbers.
+	/// @see gtc_vec1 extension.
+	typedef highp_uvec1			uvec1;
+#endif//GLM_PRECISION
+
 	/// @}
 }//namespace glm
 

+ 0 - 20
glm/ext/vector_relational.hpp

@@ -87,26 +87,6 @@ namespace glm
 	template<typename genType>
 	GLM_FUNC_DECL bool notEqual(genType const& x, genType const& y, genType const& epsilon);
 
-	/// Returns whether vector components values are within an interval. A open interval excludes its endpoints, and is denoted with square brackets.
-	///
-	/// @tparam L Integer between 1 and 4 included that qualify the dimension of the vector
-	/// @tparam T Floating-point or integer scalar types
-	/// @tparam Q Value from qualifier enum
-	///
-	/// @see ext_vector_relational
-	template <length_t L, typename T, qualifier Q>
-	GLM_FUNC_DECL vec<L, bool, Q> openBounded(vec<L, T, Q> const& Value, vec<L, T, Q> const& Min, vec<L, T, Q> const& Max);
-
-	/// Returns whether vector components values are within an interval. A closed interval includes its endpoints, and is denoted with square brackets.
-	///
-	/// @tparam L Integer between 1 and 4 included that qualify the dimension of the vector
-	/// @tparam T Floating-point or integer scalar types
-	/// @tparam Q Value from qualifier enum
-	///
-	/// @see ext_vector_relational
-	template <length_t L, typename T, qualifier Q>
-	GLM_FUNC_DECL vec<L, bool, Q> closeBounded(vec<L, T, Q> const& Value, vec<L, T, Q> const& Min, vec<L, T, Q> const& Max);
-
 	/// @}
 }//namespace glm
 

+ 0 - 12
glm/ext/vector_relational.inl

@@ -43,16 +43,4 @@ namespace glm
 	{
 		return greaterThanEqual(abs(x - y), epsilon);
 	}
-
-	template <length_t L, typename T, qualifier Q>
-	GLM_FUNC_QUALIFIER vec<L, bool, Q> openBounded(vec<L, T, Q> const& Value, vec<L, T, Q> const& Min, vec<L, T, Q> const& Max)
-	{
-		return greaterThan(Value, Min) && lessThan(Value, Max);
-	}
-
-	template <length_t L, typename T, qualifier Q>
-	GLM_FUNC_QUALIFIER vec<L, bool, Q> closeBounded(vec<L, T, Q> const& Value, vec<L, T, Q> const& Min, vec<L, T, Q> const& Max)
-	{
-		return greaterThanEqual(Value, Min) && lessThanEqual(Value, Max);
-	}
 }//namespace glm

+ 11 - 2
glm/glm.hpp

@@ -49,11 +49,20 @@
 ///
 /// @ingroup core
 ///
-/// @defgroup gtc Stable extensions
+/// @defgroup ext Stable extensions
 ///
 /// @brief Additional features not specified by GLSL specification.
 ///
-/// GTC extensions aim to be stable.
+/// EXT extensions are fully tested and documented.
+///
+/// Even if it's highly unrecommended, it's possible to include all the extensions at once by
+/// including <glm/ext.hpp>. Otherwise, each extension needs to be included  a specific file.
+///
+/// @defgroup gtc Recommended extensions
+///
+/// @brief Additional features not specified by GLSL specification.
+///
+/// GTC extensions aim to be stable with tests and documentation.
 ///
 /// Even if it's highly unrecommended, it's possible to include all the extensions at once by
 /// including <glm/ext.hpp>. Otherwise, each extension needs to be included  a specific file.

+ 0 - 67
glm/gtc/vec1.hpp

@@ -19,71 +19,4 @@
 #	pragma message("GLM: GLM_GTC_vec1 extension included")
 #endif
 
-namespace glm
-{
-	//////////////////////////
-	// vec1 definition
-
-#if(defined(GLM_PRECISION_HIGHP_BOOL))
-	typedef highp_bvec1				bvec1;
-#elif(defined(GLM_PRECISION_MEDIUMP_BOOL))
-	typedef mediump_bvec1			bvec1;
-#elif(defined(GLM_PRECISION_LOWP_BOOL))
-	typedef lowp_bvec1				bvec1;
-#else
-	/// 1 component vector of boolean.
-	/// @see gtc_vec1 extension.
-	typedef highp_bvec1				bvec1;
-#endif//GLM_PRECISION
-
-#if(defined(GLM_PRECISION_HIGHP_FLOAT))
-	typedef highp_vec1				vec1;
-#elif(defined(GLM_PRECISION_MEDIUMP_FLOAT))
-	typedef mediump_vec1			vec1;
-#elif(defined(GLM_PRECISION_LOWP_FLOAT))
-	typedef lowp_vec1				vec1;
-#else
-	/// 1 component vector of floating-point numbers.
-	/// @see gtc_vec1 extension.
-	typedef highp_vec1				vec1;
-#endif//GLM_PRECISION
-
-#if(defined(GLM_PRECISION_HIGHP_DOUBLE))
-	typedef highp_dvec1				dvec1;
-#elif(defined(GLM_PRECISION_MEDIUMP_DOUBLE))
-	typedef mediump_dvec1			dvec1;
-#elif(defined(GLM_PRECISION_LOWP_DOUBLE))
-	typedef lowp_dvec1				dvec1;
-#else
-	/// 1 component vector of floating-point numbers.
-	/// @see gtc_vec1 extension.
-	typedef highp_dvec1				dvec1;
-#endif//GLM_PRECISION
-
-#if(defined(GLM_PRECISION_HIGHP_INT))
-	typedef highp_ivec1			ivec1;
-#elif(defined(GLM_PRECISION_MEDIUMP_INT))
-	typedef mediump_ivec1		ivec1;
-#elif(defined(GLM_PRECISION_LOWP_INT))
-	typedef lowp_ivec1			ivec1;
-#else
-	/// 1 component vector of signed integer numbers.
-	/// @see gtc_vec1 extension.
-	typedef highp_ivec1			ivec1;
-#endif//GLM_PRECISION
-
-#if(defined(GLM_PRECISION_HIGHP_UINT))
-	typedef highp_uvec1			uvec1;
-#elif(defined(GLM_PRECISION_MEDIUMP_UINT))
-	typedef mediump_uvec1		uvec1;
-#elif(defined(GLM_PRECISION_LOWP_UINT))
-	typedef lowp_uvec1			uvec1;
-#else
-	/// 1 component vector of unsigned integer numbers.
-	/// @see gtc_vec1 extension.
-	typedef highp_uvec1			uvec1;
-#endif//GLM_PRECISION
-
-}// namespace glm
-
 #include "vec1.inl"

+ 20 - 0
glm/gtx/common.hpp

@@ -50,6 +50,26 @@ namespace glm
 	template<length_t L, typename T, qualifier Q>
 	GLM_FUNC_DECL vec<L, T, Q> fmod(vec<L, T, Q> const& v);
 
+	/// Returns whether vector components values are within an interval. A open interval excludes its endpoints, and is denoted with square brackets.
+	///
+	/// @tparam L Integer between 1 and 4 included that qualify the dimension of the vector
+	/// @tparam T Floating-point or integer scalar types
+	/// @tparam Q Value from qualifier enum
+	///
+	/// @see ext_vector_relational
+	template <length_t L, typename T, qualifier Q>
+	GLM_FUNC_DECL vec<L, bool, Q> openBounded(vec<L, T, Q> const& Value, vec<L, T, Q> const& Min, vec<L, T, Q> const& Max);
+
+	/// Returns whether vector components values are within an interval. A closed interval includes its endpoints, and is denoted with square brackets.
+	///
+	/// @tparam L Integer between 1 and 4 included that qualify the dimension of the vector
+	/// @tparam T Floating-point or integer scalar types
+	/// @tparam Q Value from qualifier enum
+	///
+	/// @see ext_vector_relational
+	template <length_t L, typename T, qualifier Q>
+	GLM_FUNC_DECL vec<L, bool, Q> closeBounded(vec<L, T, Q> const& Value, vec<L, T, Q> const& Min, vec<L, T, Q> const& Max);
+
 	/// @}
 }//namespace glm
 

+ 12 - 0
glm/gtx/common.inl

@@ -111,4 +111,16 @@ namespace detail
 	{
 		return detail::compute_fmod<L, T, Q, std::numeric_limits<T>::is_iec559>::call(x, y);
 	}
+
+	template <length_t L, typename T, qualifier Q>
+	GLM_FUNC_QUALIFIER vec<L, bool, Q> openBounded(vec<L, T, Q> const& Value, vec<L, T, Q> const& Min, vec<L, T, Q> const& Max)
+	{
+		return greaterThan(Value, Min) && lessThan(Value, Max);
+	}
+
+	template <length_t L, typename T, qualifier Q>
+	GLM_FUNC_QUALIFIER vec<L, bool, Q> closeBounded(vec<L, T, Q> const& Value, vec<L, T, Q> const& Min, vec<L, T, Q> const& Max)
+	{
+		return greaterThanEqual(Value, Min) && lessThanEqual(Value, Max);
+	}
 }//namespace glm

+ 4 - 1
glm/gtx/easing.hpp

@@ -200,14 +200,17 @@ namespace glm{
 	template <typename genType>
 	GLM_FUNC_DECL genType backEaseInOut(genType const& a, genType const& o);
 
+	/// @see gtx_easing
 	template <typename genType>
 	GLM_FUNC_DECL genType bounceEaseIn(genType const& a);
 
+	/// @see gtx_easing
 	template <typename genType>
 	GLM_FUNC_DECL genType bounceEaseOut(genType const& a);
 
+	/// @see gtx_easing
 	template <typename genType>
-	GLM_FUNC_DECL genType bounceEaseInOut(genType const& a, genType);
+	GLM_FUNC_DECL genType bounceEaseInOut(genType const& a);
 
 	/// @}
 }//namespace glm

+ 140 - 0
test/ext/ext_vec1.cpp

@@ -1,8 +1,148 @@
+#define GLM_FORCE_SWIZZLE
+#include <glm/vector_relational.hpp>
 #include <glm/ext/vec1.hpp>
+#include <vector>
+
+static glm::vec1 g1;
+static glm::vec1 g2(1);
+
+int test_vec1_operators()
+{
+	int Error(0);
+
+	glm::vec1 A(1.0f);
+	glm::vec1 B(1.0f);
+	{
+		bool R = A != B;
+		bool S = A == B;
+
+		Error += (S && !R) ? 0 : 1;
+	}
+
+	{
+		A *= 1.0f;
+		B *= 1.0;
+		A += 1.0f;
+		B += 1.0;
+
+		bool R = A != B;
+		bool S = A == B;
+
+		Error += (S && !R) ? 0 : 1;
+	}
+
+	return Error;
+}
+
+int test_vec1_ctor()
+{
+	int Error = 0;
+
+#	if GLM_HAS_TRIVIAL_QUERIES
+	//	Error += std::is_trivially_default_constructible<glm::vec1>::value ? 0 : 1;
+	//	Error += std::is_trivially_copy_assignable<glm::vec1>::value ? 0 : 1;
+		Error += std::is_trivially_copyable<glm::vec1>::value ? 0 : 1;
+		Error += std::is_trivially_copyable<glm::dvec1>::value ? 0 : 1;
+		Error += std::is_trivially_copyable<glm::ivec1>::value ? 0 : 1;
+		Error += std::is_trivially_copyable<glm::uvec1>::value ? 0 : 1;
+
+		Error += std::is_copy_constructible<glm::vec1>::value ? 0 : 1;
+#	endif
+
+
+	{
+		glm::ivec1 A = glm::vec1(2.0f);
+
+		glm::ivec1 E(glm::dvec1(2.0));
+		Error += A == E ? 0 : 1;
+
+		glm::ivec1 F(glm::ivec1(2));
+		Error += A == F ? 0 : 1;
+	}
+
+	return Error;
+}
+
+int test_vec1_size()
+{
+	int Error = 0;
+
+	Error += sizeof(glm::vec1) == sizeof(glm::mediump_vec1) ? 0 : 1;
+	Error += 4 == sizeof(glm::mediump_vec1) ? 0 : 1;
+	Error += sizeof(glm::dvec1) == sizeof(glm::highp_dvec1) ? 0 : 1;
+	Error += 8 == sizeof(glm::highp_dvec1) ? 0 : 1;
+	Error += glm::vec1().length() == 1 ? 0 : 1;
+	Error += glm::dvec1().length() == 1 ? 0 : 1;
+	Error += glm::vec1::length() == 1 ? 0 : 1;
+	Error += glm::dvec1::length() == 1 ? 0 : 1;
+
+#	if GLM_HAS_CONSTEXPR_PARTIAL
+	constexpr std::size_t Length = glm::vec1::length();
+	Error += Length == 1 ? 0 : 1;
+#	endif
+
+	return Error;
+}
+
+int test_vec1_operator_increment()
+{
+	int Error(0);
+
+	glm::ivec1 v0(1);
+	glm::ivec1 v1(v0);
+	glm::ivec1 v2(v0);
+	glm::ivec1 v3 = ++v1;
+	glm::ivec1 v4 = v2++;
+
+	Error += glm::all(glm::equal(v0, v4)) ? 0 : 1;
+	Error += glm::all(glm::equal(v1, v2)) ? 0 : 1;
+	Error += glm::all(glm::equal(v1, v3)) ? 0 : 1;
+
+	int i0(1);
+	int i1(i0);
+	int i2(i0);
+	int i3 = ++i1;
+	int i4 = i2++;
+
+	Error += i0 == i4 ? 0 : 1;
+	Error += i1 == i2 ? 0 : 1;
+	Error += i1 == i3 ? 0 : 1;
+
+	return Error;
+}
+
+static int test_bvec1_ctor()
+{
+	int Error = 0;
+
+	glm::bvec1 const A(true);
+	glm::bvec1 const B(true);
+	glm::bvec1 const C(false);
+	glm::bvec1 const D = A && B;
+	glm::bvec1 const E = A && C;
+	glm::bvec1 const F = A || C;
+
+	Error += D == glm::bvec1(true) ? 0 : 1;
+	Error += E == glm::bvec1(false) ? 0 : 1;
+	Error += F == glm::bvec1(true) ? 0 : 1;
+
+	bool const G = A == C;
+	bool const H = A != C;
+	Error += !G ? 0 : 1;
+	Error += H ? 0 : 1;
+
+	return Error;
+}
 
 int main()
 {
 	int Error = 0;
 
+	Error += test_vec1_size();
+	Error += test_vec1_ctor();
+	Error += test_bvec1_ctor();
+	Error += test_vec1_operators();
+	Error += test_vec1_operator_increment();
+	
 	return Error;
 }

+ 0 - 24
test/ext/ext_vector_relational.cpp

@@ -31,36 +31,12 @@ int test_notEqual()
 	return Error;
 }
 
-int test_openBounded()
-{
-	int Error = 0;
-
-	Error += glm::all(glm::openBounded(glm::ivec2(2), glm::ivec2(1), glm::ivec2(3))) ? 0 : 1;
-	Error += !glm::all(glm::openBounded(glm::ivec2(1), glm::ivec2(1), glm::ivec2(3))) ? 0 : 1;
-	Error += !glm::all(glm::openBounded(glm::ivec2(3), glm::ivec2(1), glm::ivec2(3))) ? 0 : 1;
-
-	return Error;
-}
-
-int test_closeBounded()
-{
-	int Error = 0;
-
-	Error += glm::all(glm::closeBounded(glm::ivec2(2), glm::ivec2(1), glm::ivec2(3))) ? 0 : 1;
-	Error += glm::all(glm::closeBounded(glm::ivec2(1), glm::ivec2(1), glm::ivec2(3))) ? 0 : 1;
-	Error += glm::all(glm::closeBounded(glm::ivec2(3), glm::ivec2(1), glm::ivec2(3))) ? 0 : 1;
-
-	return Error;
-}
-
 int main()
 {
 	int Error = 0;
 
 	Error += test_equal();
 	Error += test_notEqual();
-	Error += test_openBounded();
-	Error += test_closeBounded();
 
 	return Error;
 }

+ 24 - 0
test/gtx/gtx_common.cpp

@@ -126,12 +126,36 @@ int test_isdenormal()
 	return Error;
 }
 
+int test_openBounded()
+{
+	int Error = 0;
+
+	Error += glm::all(glm::openBounded(glm::ivec2(2), glm::ivec2(1), glm::ivec2(3))) ? 0 : 1;
+	Error += !glm::all(glm::openBounded(glm::ivec2(1), glm::ivec2(1), glm::ivec2(3))) ? 0 : 1;
+	Error += !glm::all(glm::openBounded(glm::ivec2(3), glm::ivec2(1), glm::ivec2(3))) ? 0 : 1;
+
+	return Error;
+}
+
+int test_closeBounded()
+{
+	int Error = 0;
+
+	Error += glm::all(glm::closeBounded(glm::ivec2(2), glm::ivec2(1), glm::ivec2(3))) ? 0 : 1;
+	Error += glm::all(glm::closeBounded(glm::ivec2(1), glm::ivec2(1), glm::ivec2(3))) ? 0 : 1;
+	Error += glm::all(glm::closeBounded(glm::ivec2(3), glm::ivec2(1), glm::ivec2(3))) ? 0 : 1;
+
+	return Error;
+}
+
 int main()
 {
 	int Error = 0;
 
 	Error += test_isdenormal();
 	Error += ::fmod_::test();
+	Error += test_openBounded();
+	Error += test_closeBounded();
 
 	return Error;
 }