diff --git a/doc/glm.docx b/doc/glm.docx index 553403c1..c23cad5b 100644 Binary files a/doc/glm.docx and b/doc/glm.docx differ diff --git a/glm/detail/type_mat2x2.hpp b/glm/detail/type_mat2x2.hpp index b4cb89d5..0f9c0b2f 100644 --- a/glm/detail/type_mat2x2.hpp +++ b/glm/detail/type_mat2x2.hpp @@ -92,8 +92,14 @@ namespace glm ////////////////////////////////////// // Matrix conversions - template - GLM_FUNC_DECL explicit tmat2x2(tmat2x2 const & m); + +# ifdef GLM_FORCE_EXPLICIT_CTOR + template + GLM_FUNC_DECL explicit tmat2x2(tmat2x2 const & m); +# else + template + GLM_FUNC_DECL tmat2x2(tmat2x2 const & m); +# endif GLM_FUNC_DECL explicit tmat2x2(tmat3x3 const & x); GLM_FUNC_DECL explicit tmat2x2(tmat4x4 const & x); diff --git a/glm/detail/type_mat2x3.hpp b/glm/detail/type_mat2x3.hpp index 53c5fa4a..8699a5b6 100644 --- a/glm/detail/type_mat2x3.hpp +++ b/glm/detail/type_mat2x3.hpp @@ -75,6 +75,7 @@ namespace glm ////////////////////////////////////// // Conversions + template GLM_FUNC_DECL tmat2x3( X1 const & x1, Y1 const & y1, Z1 const & z1, @@ -87,8 +88,14 @@ namespace glm ////////////////////////////////////// // Matrix conversion - template - GLM_FUNC_DECL explicit tmat2x3(tmat2x3 const & m); + +# ifdef GLM_FORCE_EXPLICIT_CTOR + template + GLM_FUNC_DECL explicit tmat2x3(tmat2x3 const & m); +# else + template + GLM_FUNC_DECL tmat2x3(tmat2x3 const & m); +# endif GLM_FUNC_DECL explicit tmat2x3(tmat2x2 const & x); GLM_FUNC_DECL explicit tmat2x3(tmat3x3 const & x); diff --git a/glm/detail/type_mat2x4.hpp b/glm/detail/type_mat2x4.hpp index 5f40ed5b..b97d1e91 100644 --- a/glm/detail/type_mat2x4.hpp +++ b/glm/detail/type_mat2x4.hpp @@ -89,8 +89,14 @@ namespace glm ////////////////////////////////////// // Matrix conversions - template - GLM_FUNC_DECL explicit tmat2x4(tmat2x4 const & m); + +# ifdef GLM_FORCE_EXPLICIT_CTOR + template + GLM_FUNC_DECL explicit tmat2x4(tmat2x4 const & m); +# else + template + GLM_FUNC_DECL tmat2x4(tmat2x4 const & m); +# endif GLM_FUNC_DECL explicit tmat2x4(tmat2x2 const & x); GLM_FUNC_DECL explicit tmat2x4(tmat3x3 const & x); diff --git a/glm/detail/type_mat3x2.hpp b/glm/detail/type_mat3x2.hpp index 762158bc..1a2b0c66 100644 --- a/glm/detail/type_mat3x2.hpp +++ b/glm/detail/type_mat3x2.hpp @@ -77,6 +77,7 @@ namespace glm ////////////////////////////////////// // Conversions + template< typename X1, typename Y1, typename X2, typename Y2, @@ -92,9 +93,16 @@ namespace glm tvec2 const & v2, tvec2 const & v3); + ////////////////////////////////////// // Matrix conversions - template - GLM_FUNC_DECL explicit tmat3x2(tmat3x2 const & m); + +# ifdef GLM_FORCE_EXPLICIT_CTOR + template + GLM_FUNC_DECL explicit tmat3x2(tmat3x2 const & m); +# else + template + GLM_FUNC_DECL tmat3x2(tmat3x2 const & m); +# endif GLM_FUNC_DECL explicit tmat3x2(tmat2x2 const & x); GLM_FUNC_DECL explicit tmat3x2(tmat3x3 const & x); diff --git a/glm/detail/type_mat3x3.hpp b/glm/detail/type_mat3x3.hpp index a7d1409f..97d1ed2e 100644 --- a/glm/detail/type_mat3x3.hpp +++ b/glm/detail/type_mat3x3.hpp @@ -81,6 +81,7 @@ namespace glm ////////////////////////////////////// // Conversions + template< typename X1, typename Y1, typename Z1, typename X2, typename Y2, typename Z2, @@ -96,9 +97,16 @@ namespace glm tvec3 const & v2, tvec3 const & v3); + ////////////////////////////////////// // Matrix conversions - template - GLM_FUNC_DECL explicit tmat3x3(tmat3x3 const & m); + +# ifdef GLM_FORCE_EXPLICIT_CTOR + template + GLM_FUNC_DECL explicit tmat3x3(tmat3x3 const & m); +# else + template + GLM_FUNC_DECL tmat3x3(tmat3x3 const & m); +# endif GLM_FUNC_DECL explicit tmat3x3(tmat2x2 const & x); GLM_FUNC_DECL explicit tmat3x3(tmat4x4 const & x); diff --git a/glm/detail/type_mat3x4.hpp b/glm/detail/type_mat3x4.hpp index 6c4c7cd5..4574f563 100644 --- a/glm/detail/type_mat3x4.hpp +++ b/glm/detail/type_mat3x4.hpp @@ -92,9 +92,16 @@ namespace glm tvec4 const & v2, tvec4 const & v3); + ////////////////////////////////////// // Matrix conversion - template - GLM_FUNC_DECL explicit tmat3x4(tmat3x4 const & m); + +# ifdef GLM_FORCE_EXPLICIT_CTOR + template + GLM_FUNC_DECL explicit tmat3x4(tmat3x4 const & m); +# else + template + GLM_FUNC_DECL tmat3x4(tmat3x4 const & m); +# endif GLM_FUNC_DECL explicit tmat3x4(tmat2x2 const & x); GLM_FUNC_DECL explicit tmat3x4(tmat3x3 const & x); diff --git a/glm/detail/type_mat4x2.hpp b/glm/detail/type_mat4x2.hpp index a84c83f2..6de10768 100644 --- a/glm/detail/type_mat4x2.hpp +++ b/glm/detail/type_mat4x2.hpp @@ -98,9 +98,16 @@ namespace glm tvec2 const & v3, tvec2 const & v4); + ////////////////////////////////////// // Matrix conversions - template - GLM_FUNC_DECL explicit tmat4x2(tmat4x2 const & m); + +# ifdef GLM_FORCE_EXPLICIT_CTOR + template + GLM_FUNC_DECL explicit tmat4x2(tmat4x2 const & m); +# else + template + GLM_FUNC_DECL tmat4x2(tmat4x2 const & m); +# endif GLM_FUNC_DECL explicit tmat4x2(tmat2x2 const & x); GLM_FUNC_DECL explicit tmat4x2(tmat3x3 const & x); diff --git a/glm/detail/type_mat4x3.hpp b/glm/detail/type_mat4x3.hpp index f108052b..a9210e7f 100644 --- a/glm/detail/type_mat4x3.hpp +++ b/glm/detail/type_mat4x3.hpp @@ -97,10 +97,17 @@ namespace glm tvec3 const & v3, tvec3 const & v4); + ////////////////////////////////////// // Matrix conversions - template - GLM_FUNC_DECL explicit tmat4x3(tmat4x3 const & m); - + +# ifdef GLM_FORCE_EXPLICIT_CTOR + template + GLM_FUNC_DECL explicit tmat4x3(tmat4x3 const & m); +# else + template + GLM_FUNC_DECL tmat4x3(tmat4x3 const & m); +# endif + GLM_FUNC_DECL explicit tmat4x3(tmat2x2 const & x); GLM_FUNC_DECL explicit tmat4x3(tmat3x3 const & x); GLM_FUNC_DECL explicit tmat4x3(tmat4x4 const & x); diff --git a/glm/detail/type_mat4x4.hpp b/glm/detail/type_mat4x4.hpp index 61e4e7bb..dcb2a6a7 100644 --- a/glm/detail/type_mat4x4.hpp +++ b/glm/detail/type_mat4x4.hpp @@ -95,17 +95,24 @@ namespace glm X2 const & x2, Y2 const & y2, Z2 const & z2, W2 const & w2, X3 const & x3, Y3 const & y3, Z3 const & z3, W3 const & w3, X4 const & x4, Y4 const & y4, Z4 const & z4, W4 const & w4); - + template GLM_FUNC_DECL tmat4x4( tvec4 const & v1, tvec4 const & v2, tvec4 const & v3, tvec4 const & v4); - + + ////////////////////////////////////// // Matrix conversions - template - GLM_FUNC_DECL explicit tmat4x4(tmat4x4 const & m); + +# ifdef GLM_FORCE_EXPLICIT_CTOR + template + GLM_FUNC_DECL explicit tmat4x4(tmat4x4 const & m); +# else + template + GLM_FUNC_DECL tmat4x4(tmat4x4 const & m); +# endif GLM_FUNC_DECL explicit tmat4x4(tmat2x2 const & x); GLM_FUNC_DECL explicit tmat4x4(tmat3x3 const & x); @@ -179,7 +186,7 @@ namespace glm template GLM_FUNC_DECL typename tmat4x4::row_type operator*(typename tmat4x4::col_type const & v, tmat4x4 const & m); - + template GLM_FUNC_DECL tmat2x4 operator*(tmat4x4 const & m1, tmat2x4 const & m2); diff --git a/glm/gtc/quaternion.hpp b/glm/gtc/quaternion.hpp index 5c8ed128..12730932 100644 --- a/glm/gtc/quaternion.hpp +++ b/glm/gtc/quaternion.hpp @@ -95,6 +95,14 @@ namespace glm ////////////////////////////////////// // Convertions +# ifdef GLM_FORCE_EXPLICIT_CTOR + template + GLM_FUNC_DECL explicit tquat(tquat const & q); +# else + template + GLM_FUNC_DECL tquat(tquat const & q); +# endif + /// Create a quaternion from two normalized axis /// /// @param u A first normalized axis @@ -102,6 +110,7 @@ namespace glm /// @see gtc_quaternion /// @see http://lolengine.net/blog/2013/09/18/beautiful-maths-quaternion-from-vectors GLM_FUNC_DECL explicit tquat(tvec3 const & u, tvec3 const & v); + /// Build a quaternion from euler angles (pitch, yaw, roll), in radians. GLM_FUNC_DECL explicit tquat(tvec3 const & eulerAngles); GLM_FUNC_DECL explicit tquat(tmat3x3 const & m); diff --git a/glm/gtc/quaternion.inl b/glm/gtc/quaternion.inl index f214eff3..70587b86 100644 --- a/glm/gtc/quaternion.inl +++ b/glm/gtc/quaternion.inl @@ -106,12 +106,21 @@ namespace detail template GLM_FUNC_QUALIFIER tquat::tquat(T const & w, T const & x, T const & y, T const & z) - : x(x), y(y), z(z), w(w) + : x(x), y(y), z(z), w(w) {} ////////////////////////////////////////////////////////////// // Conversions + template + template + GLM_FUNC_QUALIFIER tquat::tquat(tquat const & q) + : x(static_cast(q.x)) + , y(static_cast(q.y)) + , z(static_cast(q.z)) + , w(static_cast(q.w)) + {} + //template //GLM_FUNC_QUALIFIER tquat::tquat //( diff --git a/glm/gtx/dual_quaternion.hpp b/glm/gtx/dual_quaternion.hpp index 4e6b724e..c12af399 100644 --- a/glm/gtx/dual_quaternion.hpp +++ b/glm/gtx/dual_quaternion.hpp @@ -89,6 +89,14 @@ namespace glm ////////////////////////////////////////////////////////////// // tdualquat conversions +# ifdef GLM_FORCE_EXPLICIT_CTOR + template + GLM_FUNC_DECL explicit tdualquat(tdualquat const & q); +# else + template + GLM_FUNC_DECL tdualquat(tdualquat const & q); +# endif + GLM_FUNC_DECL explicit tdualquat(tmat2x4 const & holder_mat); GLM_FUNC_DECL explicit tdualquat(tmat3x4 const & aug_mat); diff --git a/glm/gtx/dual_quaternion.inl b/glm/gtx/dual_quaternion.inl index bde0b52d..83694716 100644 --- a/glm/gtx/dual_quaternion.inl +++ b/glm/gtx/dual_quaternion.inl @@ -56,7 +56,8 @@ namespace glm template template GLM_FUNC_QUALIFIER tdualquat::tdualquat(tdualquat const & d) - : real(d.real), dual(d.dual) + : real(d.real) + , dual(d.dual) {} ////////////////////////////////////// @@ -87,6 +88,14 @@ namespace glm ////////////////////////////////////////////////////////////// // tdualquat conversions + + template + template + GLM_FUNC_QUALIFIER tdualquat::tdualquat(tdualquat const & q) + : real(q.real) + , dual(q.dual) + {} + template GLM_FUNC_QUALIFIER tdualquat::tdualquat(tmat2x4 const & m) { diff --git a/readme.txt b/readme.txt index 6f7e6cb0..e6bd5ba8 100644 --- a/readme.txt +++ b/readme.txt @@ -57,6 +57,7 @@ Features: - Added GTC_bitfield extension, promoted GTX_bit - Added GTC_integer extension, promoted GTX_bit - Added GTC_round extension, promoted GTX_bit +- Added GLM_FORCE_EXPLICIT_CTOR to require explicit type conversions #269 Improvements: - Rely on C++11 to implement isinf and isnan diff --git a/test/core/core_func_common.cpp b/test/core/core_func_common.cpp index 528d665d..83fba5f6 100644 --- a/test/core/core_func_common.cpp +++ b/test/core/core_func_common.cpp @@ -7,6 +7,8 @@ // File : test/core/func_common.cpp /////////////////////////////////////////////////////////////////////////////////////////////////// +#define GLM_FORCE_EXPLICIT_CTOR +#include #include #include #include @@ -16,272 +18,293 @@ #include #include -int test_floor() +namespace floor_ { - int Error(0); - + int test() { - float A(1.1f); - float B = glm::floor(A); + int Error(0); + + { + float A(1.1f); + float B = glm::floor(A); + } + + { + double A(1.1f); + double B = glm::floor(A); + } + + { + glm::vec1 A(1.1f); + glm::vec1 B = glm::floor(A); + + Error += glm::all(glm::epsilonEqual(B, glm::vec1(1.0), 0.0001f)) ? 0 : 1; + } + + { + glm::dvec1 A(1.1f); + glm::dvec1 B = glm::floor(A); + + Error += glm::all(glm::epsilonEqual(B, glm::dvec1(1.0), 0.0001)) ? 0 : 1; + } + + { + glm::vec2 A(1.1f); + glm::vec2 B = glm::floor(A); + + Error += glm::all(glm::epsilonEqual(B, glm::vec2(1.0), 0.0001f)) ? 0 : 1; + } + + { + glm::dvec2 A(1.1f); + glm::dvec2 B = glm::floor(A); + + Error += glm::all(glm::epsilonEqual(B, glm::dvec2(1.0), 0.0001)) ? 0 : 1; + } + + { + glm::vec3 A(1.1f); + glm::vec3 B = glm::floor(A); + + Error += glm::all(glm::epsilonEqual(B, glm::vec3(1.0), 0.0001f)) ? 0 : 1; + } + + { + glm::dvec3 A(1.1f); + glm::dvec3 B = glm::floor(A); + + Error += glm::all(glm::epsilonEqual(B, glm::dvec3(1.0), 0.0001)) ? 0 : 1; + } + + { + glm::vec4 A(1.1f); + glm::vec4 B = glm::floor(A); + + Error += glm::all(glm::epsilonEqual(B, glm::vec4(1.0), 0.0001f)) ? 0 : 1; + } + + { + glm::dvec4 A(1.1f); + glm::dvec4 B = glm::floor(A); + + Error += glm::all(glm::epsilonEqual(B, glm::dvec4(1.0), 0.0001)) ? 0 : 1; + } + + return Error; } +}//namespace floor - { - double A(1.1f); - double B = glm::floor(A); - } - - { - glm::vec1 A(1.1f); - glm::vec1 B = glm::floor(A); - - Error += glm::all(glm::epsilonEqual(B, glm::vec1(1.0), 0.0001f)) ? 0 : 1; - } - - { - glm::dvec1 A(1.1f); - glm::dvec1 B = glm::floor(A); - - Error += glm::all(glm::epsilonEqual(B, glm::dvec1(1.0), 0.0001)) ? 0 : 1; - } - - { - glm::vec2 A(1.1f); - glm::vec2 B = glm::floor(A); - - Error += glm::all(glm::epsilonEqual(B, glm::vec2(1.0), 0.0001f)) ? 0 : 1; - } - - { - glm::dvec2 A(1.1f); - glm::dvec2 B = glm::floor(A); - - Error += glm::all(glm::epsilonEqual(B, glm::dvec2(1.0), 0.0001)) ? 0 : 1; - } - - { - glm::vec3 A(1.1f); - glm::vec3 B = glm::floor(A); - - Error += glm::all(glm::epsilonEqual(B, glm::vec3(1.0), 0.0001f)) ? 0 : 1; - } - - { - glm::dvec3 A(1.1f); - glm::dvec3 B = glm::floor(A); - - Error += glm::all(glm::epsilonEqual(B, glm::dvec3(1.0), 0.0001)) ? 0 : 1; - } - - { - glm::vec4 A(1.1f); - glm::vec4 B = glm::floor(A); - - Error += glm::all(glm::epsilonEqual(B, glm::vec4(1.0), 0.0001f)) ? 0 : 1; - } - - { - glm::dvec4 A(1.1f); - glm::dvec4 B = glm::floor(A); - - Error += glm::all(glm::epsilonEqual(B, glm::dvec4(1.0), 0.0001)) ? 0 : 1; - } - - return Error; -} - -int test_modf() +namespace modf_ { - int Error(0); - + int test() { - float X(1.5f); - float I(0.0f); - float A = glm::modf(X, I); + int Error(0); - Error += I == 1.0f ? 0 : 1; - Error += A == 0.5f ? 0 : 1; + { + float X(1.5f); + float I(0.0f); + float A = glm::modf(X, I); + + Error += I == 1.0f ? 0 : 1; + Error += A == 0.5f ? 0 : 1; + } + + { + glm::vec4 X(1.1f, 1.2f, 1.5f, 1.7f); + glm::vec4 I(0.0f); + glm::vec4 A = glm::modf(X, I); + + Error += I == glm::vec4(1.0f) ? 0 : 1; + Error += glm::all(glm::epsilonEqual(A, glm::vec4(0.1f, 0.2f, 0.5f, 0.7f), 0.00001f)) ? 0 : 1; + } + + { + glm::dvec4 X(1.1, 1.2, 1.5, 1.7); + glm::dvec4 I(0.0); + glm::dvec4 A = glm::modf(X, I); + + Error += I == glm::dvec4(1.0) ? 0 : 1; + Error += glm::all(glm::epsilonEqual(A, glm::dvec4(0.1, 0.2, 0.5, 0.7), 0.000000001)) ? 0 : 1; + } + + { + double X(1.5); + double I(0.0); + double A = glm::modf(X, I); + + Error += I == 1.0 ? 0 : 1; + Error += A == 0.5 ? 0 : 1; + } + + return Error; } +}//namespace modf - { - glm::vec4 X(1.1f, 1.2f, 1.5f, 1.7f); - glm::vec4 I(0.0f); - glm::vec4 A = glm::modf(X, I); - - Error += I == glm::vec4(1.0f) ? 0 : 1; - Error += glm::all(glm::epsilonEqual(A, glm::vec4(0.1f, 0.2f, 0.5f, 0.7f), 0.00001f)) ? 0 : 1; - } - - { - glm::dvec4 X(1.1, 1.2, 1.5, 1.7); - glm::dvec4 I(0.0); - glm::dvec4 A = glm::modf(X, I); - - Error += I == glm::dvec4(1.0) ? 0 : 1; - Error += glm::all(glm::epsilonEqual(A, glm::dvec4(0.1, 0.2, 0.5, 0.7), 0.000000001)) ? 0 : 1; - } - - { - double X(1.5); - double I(0.0); - double A = glm::modf(X, I); - - Error += I == 1.0 ? 0 : 1; - Error += A == 0.5 ? 0 : 1; - } - - return Error; -} - -int test_floatBitsToInt() +namespace floatBitsToInt { - int Error = 0; + int test() + { + int Error = 0; - { - float A = 1.0f; - int B = glm::floatBitsToInt(A); - float C = glm::intBitsToFloat(B); - int D = *(int*)&A; - Error += B == D ? 0 : 1; - Error += A == C ? 0 : 1; - } + { + float A = 1.0f; + int B = glm::floatBitsToInt(A); + float C = glm::intBitsToFloat(B); + int D = *(int*)&A; + Error += B == D ? 0 : 1; + Error += A == C ? 0 : 1; + } - { - glm::vec2 A(1.0f, 2.0f); - glm::ivec2 B = glm::floatBitsToInt(A); - glm::vec2 C = glm::intBitsToFloat(B); - Error += B.x == *(int*)&(A.x) ? 0 : 1; - Error += B.y == *(int*)&(A.y) ? 0 : 1; - Error += A == C? 0 : 1; - } + { + glm::vec2 A(1.0f, 2.0f); + glm::ivec2 B = glm::floatBitsToInt(A); + glm::vec2 C = glm::intBitsToFloat(B); + Error += B.x == *(int*)&(A.x) ? 0 : 1; + Error += B.y == *(int*)&(A.y) ? 0 : 1; + Error += A == C? 0 : 1; + } - { - glm::vec3 A(1.0f, 2.0f, 3.0f); - glm::ivec3 B = glm::floatBitsToInt(A); - glm::vec3 C = glm::intBitsToFloat(B); - Error += B.x == *(int*)&(A.x) ? 0 : 1; - Error += B.y == *(int*)&(A.y) ? 0 : 1; - Error += B.z == *(int*)&(A.z) ? 0 : 1; - Error += A == C? 0 : 1; - } + { + glm::vec3 A(1.0f, 2.0f, 3.0f); + glm::ivec3 B = glm::floatBitsToInt(A); + glm::vec3 C = glm::intBitsToFloat(B); + Error += B.x == *(int*)&(A.x) ? 0 : 1; + Error += B.y == *(int*)&(A.y) ? 0 : 1; + Error += B.z == *(int*)&(A.z) ? 0 : 1; + Error += A == C? 0 : 1; + } - { - glm::vec4 A(1.0f, 2.0f, 3.0f, 4.0f); - glm::ivec4 B = glm::floatBitsToInt(A); - glm::vec4 C = glm::intBitsToFloat(B); - Error += B.x == *(int*)&(A.x) ? 0 : 1; - Error += B.y == *(int*)&(A.y) ? 0 : 1; - Error += B.z == *(int*)&(A.z) ? 0 : 1; - Error += B.w == *(int*)&(A.w) ? 0 : 1; - Error += A == C? 0 : 1; - } + { + glm::vec4 A(1.0f, 2.0f, 3.0f, 4.0f); + glm::ivec4 B = glm::floatBitsToInt(A); + glm::vec4 C = glm::intBitsToFloat(B); + Error += B.x == *(int*)&(A.x) ? 0 : 1; + Error += B.y == *(int*)&(A.y) ? 0 : 1; + Error += B.z == *(int*)&(A.z) ? 0 : 1; + Error += B.w == *(int*)&(A.w) ? 0 : 1; + Error += A == C? 0 : 1; + } - return Error; -} + return Error; + } +}//namespace floatBitsToInt -int test_floatBitsToUint() +namespace floatBitsToUint { - int Error = 0; - + int test() { - float A = 1.0f; - glm::uint B = glm::floatBitsToUint(A); - float C = glm::intBitsToFloat(B); - Error += B == *(glm::uint*)&A ? 0 : 1; - Error += A == C? 0 : 1; - } + int Error = 0; - { - glm::vec2 A(1.0f, 2.0f); - glm::uvec2 B = glm::floatBitsToUint(A); - glm::vec2 C = glm::uintBitsToFloat(B); - Error += B.x == *(glm::uint*)&(A.x) ? 0 : 1; - Error += B.y == *(glm::uint*)&(A.y) ? 0 : 1; - Error += A == C ? 0 : 1; - } + { + float A = 1.0f; + glm::uint B = glm::floatBitsToUint(A); + float C = glm::intBitsToFloat(B); + Error += B == *(glm::uint*)&A ? 0 : 1; + Error += A == C? 0 : 1; + } - { - glm::vec3 A(1.0f, 2.0f, 3.0f); - glm::uvec3 B = glm::floatBitsToUint(A); - glm::vec3 C = glm::uintBitsToFloat(B); - Error += B.x == *(glm::uint*)&(A.x) ? 0 : 1; - Error += B.y == *(glm::uint*)&(A.y) ? 0 : 1; - Error += B.z == *(glm::uint*)&(A.z) ? 0 : 1; - Error += A == C? 0 : 1; - } + { + glm::vec2 A(1.0f, 2.0f); + glm::uvec2 B = glm::floatBitsToUint(A); + glm::vec2 C = glm::uintBitsToFloat(B); + Error += B.x == *(glm::uint*)&(A.x) ? 0 : 1; + Error += B.y == *(glm::uint*)&(A.y) ? 0 : 1; + Error += A == C ? 0 : 1; + } - { - glm::vec4 A(1.0f, 2.0f, 3.0f, 4.0f); - glm::uvec4 B = glm::floatBitsToUint(A); - glm::vec4 C = glm::uintBitsToFloat(B); - Error += B.x == *(glm::uint*)&(A.x) ? 0 : 1; - Error += B.y == *(glm::uint*)&(A.y) ? 0 : 1; - Error += B.z == *(glm::uint*)&(A.z) ? 0 : 1; - Error += B.w == *(glm::uint*)&(A.w) ? 0 : 1; - Error += A == C? 0 : 1; - } + { + glm::vec3 A(1.0f, 2.0f, 3.0f); + glm::uvec3 B = glm::floatBitsToUint(A); + glm::vec3 C = glm::uintBitsToFloat(B); + Error += B.x == *(glm::uint*)&(A.x) ? 0 : 1; + Error += B.y == *(glm::uint*)&(A.y) ? 0 : 1; + Error += B.z == *(glm::uint*)&(A.z) ? 0 : 1; + Error += A == C? 0 : 1; + } - return Error; -} + { + glm::vec4 A(1.0f, 2.0f, 3.0f, 4.0f); + glm::uvec4 B = glm::floatBitsToUint(A); + glm::vec4 C = glm::uintBitsToFloat(B); + Error += B.x == *(glm::uint*)&(A.x) ? 0 : 1; + Error += B.y == *(glm::uint*)&(A.y) ? 0 : 1; + Error += B.z == *(glm::uint*)&(A.z) ? 0 : 1; + Error += B.w == *(glm::uint*)&(A.w) ? 0 : 1; + Error += A == C? 0 : 1; + } + + return Error; + } +}//namespace floatBitsToUint -int test_min() +namespace min_ { - int Error = 0; + int test() + { + int Error = 0; - glm::vec1 A0 = glm::min(glm::vec1(1), glm::vec1(1)); + glm::vec1 A0 = glm::min(glm::vec1(1), glm::vec1(1)); - glm::vec2 B0 = glm::min(glm::vec2(1), glm::vec2(1)); - glm::vec2 B1 = glm::min(glm::vec2(1), 1.0f); - bool B2 = glm::all(glm::equal(B0, B1)); - Error += B2 ? 0 : 1; + glm::vec2 B0 = glm::min(glm::vec2(1), glm::vec2(1)); + glm::vec2 B1 = glm::min(glm::vec2(1), 1.0f); + bool B2 = glm::all(glm::equal(B0, B1)); + Error += B2 ? 0 : 1; - glm::vec3 C0 = glm::min(glm::vec3(1), glm::vec3(1)); - glm::vec3 C1 = glm::min(glm::vec3(1), 1.0f); - bool C2 = glm::all(glm::equal(C0, C1)); - Error += C2 ? 0 : 1; + glm::vec3 C0 = glm::min(glm::vec3(1), glm::vec3(1)); + glm::vec3 C1 = glm::min(glm::vec3(1), 1.0f); + bool C2 = glm::all(glm::equal(C0, C1)); + Error += C2 ? 0 : 1; - glm::vec4 D0 = glm::min(glm::vec4(1), glm::vec4(1)); - glm::vec4 D1 = glm::min(glm::vec4(1), 1.0f); - bool D2 = glm::all(glm::equal(D0, D1)); - Error += D2 ? 0 : 1; + glm::vec4 D0 = glm::min(glm::vec4(1), glm::vec4(1)); + glm::vec4 D1 = glm::min(glm::vec4(1), 1.0f); + bool D2 = glm::all(glm::equal(D0, D1)); + Error += D2 ? 0 : 1; - return Error; -} + return Error; + } +}//namespace min_ -int test_max() +namespace max_ { - int Error = 0; + int test() + { + int Error = 0; - glm::vec1 A0 = glm::max(glm::vec1(1), glm::vec1(1)); + glm::vec1 A0 = glm::max(glm::vec1(1), glm::vec1(1)); - glm::vec2 B0 = glm::max(glm::vec2(1), glm::vec2(1)); - glm::vec2 B1 = glm::max(glm::vec2(1), 1.0f); - bool B2 = glm::all(glm::equal(B0, B1)); - Error += B2 ? 0 : 1; + glm::vec2 B0 = glm::max(glm::vec2(1), glm::vec2(1)); + glm::vec2 B1 = glm::max(glm::vec2(1), 1.0f); + bool B2 = glm::all(glm::equal(B0, B1)); + Error += B2 ? 0 : 1; - glm::vec3 C0 = glm::max(glm::vec3(1), glm::vec3(1)); - glm::vec3 C1 = glm::max(glm::vec3(1), 1.0f); - bool C2 = glm::all(glm::equal(C0, C1)); - Error += C2 ? 0 : 1; + glm::vec3 C0 = glm::max(glm::vec3(1), glm::vec3(1)); + glm::vec3 C1 = glm::max(glm::vec3(1), 1.0f); + bool C2 = glm::all(glm::equal(C0, C1)); + Error += C2 ? 0 : 1; - glm::vec4 D0 = glm::max(glm::vec4(1), glm::vec4(1)); - glm::vec4 D1 = glm::max(glm::vec4(1), 1.0f); - bool D2 = glm::all(glm::equal(D0, D1)); - Error += D2 ? 0 : 1; + glm::vec4 D0 = glm::max(glm::vec4(1), glm::vec4(1)); + glm::vec4 D1 = glm::max(glm::vec4(1), 1.0f); + bool D2 = glm::all(glm::equal(D0, D1)); + Error += D2 ? 0 : 1; - return Error; -} + return Error; + } +}//namespace max_ -int test_clamp() +namespace clamp_ { - int Error = 0; + int test() + { + int Error = 0; - return Error; -} + return Error; + } +}//namespace clamp_ -namespace test_mix +namespace mix_ { template - struct test + struct entry { T x; T y; @@ -289,7 +312,7 @@ namespace test_mix T Result; }; - test TestBool[] = + entry TestBool[] = { {0.0f, 1.0f, false, 0.0f}, {0.0f, 1.0f, true, 1.0f}, @@ -297,7 +320,7 @@ namespace test_mix {-1.0f, 1.0f, true, 1.0f} }; - test TestFloat[] = + entry TestFloat[] = { {0.0f, 1.0f, 0.0f, 0.0f}, {0.0f, 1.0f, 1.0f, 1.0f}, @@ -305,7 +328,7 @@ namespace test_mix {-1.0f, 1.0f, 1.0f, 1.0f} }; - test TestVec2Bool[] = + entry TestVec2Bool[] = { {glm::vec2(0.0f), glm::vec2(1.0f), false, glm::vec2(0.0f)}, {glm::vec2(0.0f), glm::vec2(1.0f), true, glm::vec2(1.0f)}, @@ -313,7 +336,7 @@ namespace test_mix {glm::vec2(-1.0f), glm::vec2(1.0f), true, glm::vec2(1.0f)} }; - test TestBVec2[] = + entry TestBVec2[] = { {glm::vec2(0.0f), glm::vec2(1.0f), glm::bvec2(false), glm::vec2(0.0f)}, {glm::vec2(0.0f), glm::vec2(1.0f), glm::bvec2(true), glm::vec2(1.0f)}, @@ -322,7 +345,7 @@ namespace test_mix {glm::vec2(-1.0f), glm::vec2(1.0f), glm::bvec2(true, false), glm::vec2(1.0f, -1.0f)} }; - test TestVec3Bool[] = + entry TestVec3Bool[] = { {glm::vec3(0.0f), glm::vec3(1.0f), false, glm::vec3(0.0f)}, {glm::vec3(0.0f), glm::vec3(1.0f), true, glm::vec3(1.0f)}, @@ -330,7 +353,7 @@ namespace test_mix {glm::vec3(-1.0f), glm::vec3(1.0f), true, glm::vec3(1.0f)} }; - test TestBVec3[] = + entry TestBVec3[] = { {glm::vec3(0.0f), glm::vec3(1.0f), glm::bvec3(false), glm::vec3(0.0f)}, {glm::vec3(0.0f), glm::vec3(1.0f), glm::bvec3(true), glm::vec3(1.0f)}, @@ -339,7 +362,7 @@ namespace test_mix {glm::vec3(1.0f, 2.0f, 3.0f), glm::vec3(4.0f, 5.0f, 6.0f), glm::bvec3(true, false, true), glm::vec3(4.0f, 2.0f, 6.0f)} }; - test TestVec4Bool[] = + entry TestVec4Bool[] = { {glm::vec4(0.0f), glm::vec4(1.0f), false, glm::vec4(0.0f)}, {glm::vec4(0.0f), glm::vec4(1.0f), true, glm::vec4(1.0f)}, @@ -347,7 +370,7 @@ namespace test_mix {glm::vec4(-1.0f), glm::vec4(1.0f), true, glm::vec4(1.0f)} }; - test TestBVec4[] = + entry TestBVec4[] = { {glm::vec4(0.0f), glm::vec4(1.0f), glm::bvec4(false), glm::vec4(0.0f)}, {glm::vec4(0.0f), glm::vec4(1.0f), glm::bvec4(true), glm::vec4(1.0f)}, @@ -356,13 +379,13 @@ namespace test_mix {glm::vec4(1.0f, 2.0f, 3.0f, 4.0f), glm::vec4(5.0f, 6.0f, 7.0f, 8.0f), glm::bvec4(true, false, true, false), glm::vec4(5.0f, 2.0f, 7.0f, 4.0f)} }; - int run() + int test() { int Error = 0; // Float with bool { - for(std::size_t i = 0; i < sizeof(TestBool) / sizeof(test); ++i) + for(std::size_t i = 0; i < sizeof(TestBool) / sizeof(entry); ++i) { float Result = glm::mix(TestBool[i].x, TestBool[i].y, TestBool[i].a); Error += glm::epsilonEqual(Result, TestBool[i].Result, glm::epsilon()) ? 0 : 1; @@ -371,7 +394,7 @@ namespace test_mix // Float with float { - for(std::size_t i = 0; i < sizeof(TestFloat) / sizeof(test); ++i) + for(std::size_t i = 0; i < sizeof(TestFloat) / sizeof(entry); ++i) { float Result = glm::mix(TestFloat[i].x, TestFloat[i].y, TestFloat[i].a); Error += glm::epsilonEqual(Result, TestFloat[i].Result, glm::epsilon()) ? 0 : 1; @@ -380,7 +403,7 @@ namespace test_mix // vec2 with bool { - for(std::size_t i = 0; i < sizeof(TestVec2Bool) / sizeof(test); ++i) + for(std::size_t i = 0; i < sizeof(TestVec2Bool) / sizeof(entry); ++i) { glm::vec2 Result = glm::mix(TestVec2Bool[i].x, TestVec2Bool[i].y, TestVec2Bool[i].a); Error += glm::epsilonEqual(Result.x, TestVec2Bool[i].Result.x, glm::epsilon()) ? 0 : 1; @@ -390,7 +413,7 @@ namespace test_mix // vec2 with bvec2 { - for(std::size_t i = 0; i < sizeof(TestBVec2) / sizeof(test); ++i) + for(std::size_t i = 0; i < sizeof(TestBVec2) / sizeof(entry); ++i) { glm::vec2 Result = glm::mix(TestBVec2[i].x, TestBVec2[i].y, TestBVec2[i].a); Error += glm::epsilonEqual(Result.x, TestBVec2[i].Result.x, glm::epsilon()) ? 0 : 1; @@ -400,7 +423,7 @@ namespace test_mix // vec3 with bool { - for(std::size_t i = 0; i < sizeof(TestVec3Bool) / sizeof(test); ++i) + for(std::size_t i = 0; i < sizeof(TestVec3Bool) / sizeof(entry); ++i) { glm::vec3 Result = glm::mix(TestVec3Bool[i].x, TestVec3Bool[i].y, TestVec3Bool[i].a); Error += glm::epsilonEqual(Result.x, TestVec3Bool[i].Result.x, glm::epsilon()) ? 0 : 1; @@ -411,7 +434,7 @@ namespace test_mix // vec3 with bvec3 { - for(std::size_t i = 0; i < sizeof(TestBVec3) / sizeof(test); ++i) + for(std::size_t i = 0; i < sizeof(TestBVec3) / sizeof(entry); ++i) { glm::vec3 Result = glm::mix(TestBVec3[i].x, TestBVec3[i].y, TestBVec3[i].a); Error += glm::epsilonEqual(Result.x, TestBVec3[i].Result.x, glm::epsilon()) ? 0 : 1; @@ -422,7 +445,7 @@ namespace test_mix // vec4 with bool { - for(std::size_t i = 0; i < sizeof(TestVec4Bool) / sizeof(test); ++i) + for(std::size_t i = 0; i < sizeof(TestVec4Bool) / sizeof(entry); ++i) { glm::vec4 Result = glm::mix(TestVec4Bool[i].x, TestVec4Bool[i].y, TestVec4Bool[i].a); Error += glm::epsilonEqual(Result.x, TestVec4Bool[i].Result.x, glm::epsilon()) ? 0 : 1; @@ -434,7 +457,7 @@ namespace test_mix // vec4 with bvec4 { - for(std::size_t i = 0; i < sizeof(TestBVec4) / sizeof(test); ++i) + for(std::size_t i = 0; i < sizeof(TestBVec4) / sizeof(entry); ++i) { glm::vec4 Result = glm::mix(TestBVec4[i].x, TestBVec4[i].y, TestBVec4[i].a); Error += glm::epsilonEqual(Result.x, TestBVec4[i].Result.x, glm::epsilon()) ? 0 : 1; @@ -446,26 +469,26 @@ namespace test_mix return Error; } -}//namespace test_mix +}//namespace mix_ -namespace test_step +namespace step_ { template - struct test + struct entry { EDGE edge; VEC x; VEC result; }; - test TestVec4Scalar [] = + entry TestVec4Scalar [] = { { 0.0f, glm::vec4(1.0f, 2.0f, 3.0f, 4.0f), glm::vec4(1.0f) }, { 1.0f, glm::vec4(1.0f, 2.0f, 3.0f, 4.0f), glm::vec4(1.0f) }, { 0.0f, glm::vec4(-1.0f, -2.0f, -3.0f, -4.0f), glm::vec4(0.0f) } }; - test TestVec4Vector [] = + entry TestVec4Vector [] = { { glm::vec4(-1.0f, -2.0f, -3.0f, -4.0f), glm::vec4(-2.0f, -3.0f, -4.0f, -5.0f), glm::vec4(0.0f) }, { glm::vec4( 0.0f, 1.0f, 2.0f, 3.0f), glm::vec4( 1.0f, 2.0f, 3.0f, 4.0f), glm::vec4(1.0f) }, @@ -473,13 +496,13 @@ namespace test_step { glm::vec4( 0.0f, 1.0f, 2.0f, 3.0f), glm::vec4(-1.0f,-2.0f,-3.0f,-4.0f), glm::vec4(0.0f) } }; - int run() + int test() { int Error = 0; // vec4 and float { - for (std::size_t i = 0; i < sizeof(TestVec4Scalar) / sizeof(test); ++i) + for (std::size_t i = 0; i < sizeof(TestVec4Scalar) / sizeof(entry); ++i) { glm::vec4 Result = glm::step(TestVec4Scalar[i].edge, TestVec4Scalar[i].x); Error += glm::all(glm::epsilonEqual(Result, TestVec4Scalar[i].result, glm::epsilon())) ? 0 : 1; @@ -488,7 +511,7 @@ namespace test_step // vec4 and vec4 { - for (std::size_t i = 0; i < sizeof(TestVec4Vector) / sizeof(test); ++i) + for (std::size_t i = 0; i < sizeof(TestVec4Vector) / sizeof(entry); ++i) { glm::vec4 Result = glm::step(TestVec4Vector[i].edge, TestVec4Vector[i].x); Error += glm::all(glm::epsilonEqual(Result, TestVec4Vector[i].result, glm::epsilon())) ? 0 : 1; @@ -497,247 +520,259 @@ namespace test_step return Error; } -}//namespace test_step +}//namespace step_ -int test_round() +namespace round_ { - int Error = 0; - + int test() { - float A = glm::round(0.0f); - Error += A == 0.0f ? 0 : 1; - float B = glm::round(0.5f); - Error += B == 1.0f ? 0 : 1; - float C = glm::round(1.0f); - Error += C == 1.0f ? 0 : 1; - float D = glm::round(0.1f); - Error += D == 0.0f ? 0 : 1; - float E = glm::round(0.9f); - Error += E == 1.0f ? 0 : 1; - float F = glm::round(1.5f); - Error += F == 2.0f ? 0 : 1; - float G = glm::round(1.9f); - Error += G == 2.0f ? 0 : 1; - } + int Error = 0; - { - float A = glm::round(-0.0f); - Error += A == 0.0f ? 0 : 1; - float B = glm::round(-0.5f); - Error += B == -1.0f ? 0 : 1; - float C = glm::round(-1.0f); - Error += C == -1.0f ? 0 : 1; - float D = glm::round(-0.1f); - Error += D == 0.0f ? 0 : 1; - float E = glm::round(-0.9f); - Error += E == -1.0f ? 0 : 1; - float F = glm::round(-1.5f); - Error += F == -2.0f ? 0 : 1; - float G = glm::round(-1.9f); - Error += G == -2.0f ? 0 : 1; - } + { + float A = glm::round(0.0f); + Error += A == 0.0f ? 0 : 1; + float B = glm::round(0.5f); + Error += B == 1.0f ? 0 : 1; + float C = glm::round(1.0f); + Error += C == 1.0f ? 0 : 1; + float D = glm::round(0.1f); + Error += D == 0.0f ? 0 : 1; + float E = glm::round(0.9f); + Error += E == 1.0f ? 0 : 1; + float F = glm::round(1.5f); + Error += F == 2.0f ? 0 : 1; + float G = glm::round(1.9f); + Error += G == 2.0f ? 0 : 1; + } - return Error; -} + { + float A = glm::round(-0.0f); + Error += A == 0.0f ? 0 : 1; + float B = glm::round(-0.5f); + Error += B == -1.0f ? 0 : 1; + float C = glm::round(-1.0f); + Error += C == -1.0f ? 0 : 1; + float D = glm::round(-0.1f); + Error += D == 0.0f ? 0 : 1; + float E = glm::round(-0.9f); + Error += E == -1.0f ? 0 : 1; + float F = glm::round(-1.5f); + Error += F == -2.0f ? 0 : 1; + float G = glm::round(-1.9f); + Error += G == -2.0f ? 0 : 1; + } + + return Error; + } +}//namespace round_ -int test_roundEven() +namespace roundEven { - int Error = 0; - + int test() { - float A1 = glm::roundEven(-1.5f); - Error += glm::epsilonEqual(A1, -2.0f, 0.0001f) ? 0 : 1; + int Error = 0; - float A2 = glm::roundEven(1.5f); - Error += glm::epsilonEqual(A2, 2.0f, 0.0001f) ? 0 : 1; + { + float A1 = glm::roundEven(-1.5f); + Error += glm::epsilonEqual(A1, -2.0f, 0.0001f) ? 0 : 1; - float A5 = glm::roundEven(-2.5f); - Error += glm::epsilonEqual(A5, -2.0f, 0.0001f) ? 0 : 1; + float A2 = glm::roundEven(1.5f); + Error += glm::epsilonEqual(A2, 2.0f, 0.0001f) ? 0 : 1; - float A6 = glm::roundEven(2.5f); - Error += glm::epsilonEqual(A6, 2.0f, 0.0001f) ? 0 : 1; + float A5 = glm::roundEven(-2.5f); + Error += glm::epsilonEqual(A5, -2.0f, 0.0001f) ? 0 : 1; - float A3 = glm::roundEven(-3.5f); - Error += glm::epsilonEqual(A3, -4.0f, 0.0001f) ? 0 : 1; + float A6 = glm::roundEven(2.5f); + Error += glm::epsilonEqual(A6, 2.0f, 0.0001f) ? 0 : 1; - float A4 = glm::roundEven(3.5f); - Error += glm::epsilonEqual(A4, 4.0f, 0.0001f) ? 0 : 1; + float A3 = glm::roundEven(-3.5f); + Error += glm::epsilonEqual(A3, -4.0f, 0.0001f) ? 0 : 1; - float C7 = glm::roundEven(-4.5f); - Error += glm::epsilonEqual(C7, -4.0f, 0.0001f) ? 0 : 1; + float A4 = glm::roundEven(3.5f); + Error += glm::epsilonEqual(A4, 4.0f, 0.0001f) ? 0 : 1; - float C8 = glm::roundEven(4.5f); - Error += glm::epsilonEqual(C8, 4.0f, 0.0001f) ? 0 : 1; + float C7 = glm::roundEven(-4.5f); + Error += glm::epsilonEqual(C7, -4.0f, 0.0001f) ? 0 : 1; - float C1 = glm::roundEven(-5.5f); - Error += glm::epsilonEqual(C1, -6.0f, 0.0001f) ? 0 : 1; + float C8 = glm::roundEven(4.5f); + Error += glm::epsilonEqual(C8, 4.0f, 0.0001f) ? 0 : 1; - float C2 = glm::roundEven(5.5f); - Error += glm::epsilonEqual(C2, 6.0f, 0.0001f) ? 0 : 1; + float C1 = glm::roundEven(-5.5f); + Error += glm::epsilonEqual(C1, -6.0f, 0.0001f) ? 0 : 1; - float C3 = glm::roundEven(-6.5f); - Error += glm::epsilonEqual(C3, -6.0f, 0.0001f) ? 0 : 1; + float C2 = glm::roundEven(5.5f); + Error += glm::epsilonEqual(C2, 6.0f, 0.0001f) ? 0 : 1; - float C4 = glm::roundEven(6.5f); - Error += glm::epsilonEqual(C4, 6.0f, 0.0001f) ? 0 : 1; + float C3 = glm::roundEven(-6.5f); + Error += glm::epsilonEqual(C3, -6.0f, 0.0001f) ? 0 : 1; - float C5 = glm::roundEven(-7.5f); - Error += glm::epsilonEqual(C5, -8.0f, 0.0001f) ? 0 : 1; + float C4 = glm::roundEven(6.5f); + Error += glm::epsilonEqual(C4, 6.0f, 0.0001f) ? 0 : 1; - float C6 = glm::roundEven(7.5f); - Error += glm::epsilonEqual(C6, 8.0f, 0.0001f) ? 0 : 1; + float C5 = glm::roundEven(-7.5f); + Error += glm::epsilonEqual(C5, -8.0f, 0.0001f) ? 0 : 1; - Error += 0; - } + float C6 = glm::roundEven(7.5f); + Error += glm::epsilonEqual(C6, 8.0f, 0.0001f) ? 0 : 1; - { - float A7 = glm::roundEven(-2.4f); - Error += glm::epsilonEqual(A7, -2.0f, 0.0001f) ? 0 : 1; + Error += 0; + } - float A8 = glm::roundEven(2.4f); - Error += glm::epsilonEqual(A8, 2.0f, 0.0001f) ? 0 : 1; + { + float A7 = glm::roundEven(-2.4f); + Error += glm::epsilonEqual(A7, -2.0f, 0.0001f) ? 0 : 1; - float B1 = glm::roundEven(-2.6f); - Error += glm::epsilonEqual(B1, -3.0f, 0.0001f) ? 0 : 1; + float A8 = glm::roundEven(2.4f); + Error += glm::epsilonEqual(A8, 2.0f, 0.0001f) ? 0 : 1; - float B2 = glm::roundEven(2.6f); - Error += glm::epsilonEqual(B2, 3.0f, 0.0001f) ? 0 : 1; + float B1 = glm::roundEven(-2.6f); + Error += glm::epsilonEqual(B1, -3.0f, 0.0001f) ? 0 : 1; - float B3 = glm::roundEven(-2.0f); - Error += glm::epsilonEqual(B3, -2.0f, 0.0001f) ? 0 : 1; + float B2 = glm::roundEven(2.6f); + Error += glm::epsilonEqual(B2, 3.0f, 0.0001f) ? 0 : 1; - float B4 = glm::roundEven(2.0f); - Error += glm::epsilonEqual(B4, 2.0f, 0.0001f) ? 0 : 1; + float B3 = glm::roundEven(-2.0f); + Error += glm::epsilonEqual(B3, -2.0f, 0.0001f) ? 0 : 1; - Error += 0; - } + float B4 = glm::roundEven(2.0f); + Error += glm::epsilonEqual(B4, 2.0f, 0.0001f) ? 0 : 1; - { - float A = glm::roundEven(0.0f); - Error += A == 0.0f ? 0 : 1; - float B = glm::roundEven(0.5f); - Error += B == 0.0f ? 0 : 1; - float C = glm::roundEven(1.0f); - Error += C == 1.0f ? 0 : 1; - float D = glm::roundEven(0.1f); - Error += D == 0.0f ? 0 : 1; - float E = glm::roundEven(0.9f); - Error += E == 1.0f ? 0 : 1; - float F = glm::roundEven(1.5f); - Error += F == 2.0f ? 0 : 1; - float G = glm::roundEven(1.9f); - Error += G == 2.0f ? 0 : 1; - } + Error += 0; + } - { - float A = glm::roundEven(-0.0f); - Error += A == 0.0f ? 0 : 1; - float B = glm::roundEven(-0.5f); - Error += B == -0.0f ? 0 : 1; - float C = glm::roundEven(-1.0f); - Error += C == -1.0f ? 0 : 1; - float D = glm::roundEven(-0.1f); - Error += D == 0.0f ? 0 : 1; - float E = glm::roundEven(-0.9f); - Error += E == -1.0f ? 0 : 1; - float F = glm::roundEven(-1.5f); - Error += F == -2.0f ? 0 : 1; - float G = glm::roundEven(-1.9f); - Error += G == -2.0f ? 0 : 1; - } + { + float A = glm::roundEven(0.0f); + Error += A == 0.0f ? 0 : 1; + float B = glm::roundEven(0.5f); + Error += B == 0.0f ? 0 : 1; + float C = glm::roundEven(1.0f); + Error += C == 1.0f ? 0 : 1; + float D = glm::roundEven(0.1f); + Error += D == 0.0f ? 0 : 1; + float E = glm::roundEven(0.9f); + Error += E == 1.0f ? 0 : 1; + float F = glm::roundEven(1.5f); + Error += F == 2.0f ? 0 : 1; + float G = glm::roundEven(1.9f); + Error += G == 2.0f ? 0 : 1; + } - { - float A = glm::roundEven(1.5f); - Error += A == 2.0f ? 0 : 1; - float B = glm::roundEven(2.5f); - Error += B == 2.0f ? 0 : 1; - float C = glm::roundEven(3.5f); - Error += C == 4.0f ? 0 : 1; - float D = glm::roundEven(4.5f); - Error += D == 4.0f ? 0 : 1; - float E = glm::roundEven(5.5f); - Error += E == 6.0f ? 0 : 1; - float F = glm::roundEven(6.5f); - Error += F == 6.0f ? 0 : 1; - float G = glm::roundEven(7.5f); - Error += G == 8.0f ? 0 : 1; - } + { + float A = glm::roundEven(-0.0f); + Error += A == 0.0f ? 0 : 1; + float B = glm::roundEven(-0.5f); + Error += B == -0.0f ? 0 : 1; + float C = glm::roundEven(-1.0f); + Error += C == -1.0f ? 0 : 1; + float D = glm::roundEven(-0.1f); + Error += D == 0.0f ? 0 : 1; + float E = glm::roundEven(-0.9f); + Error += E == -1.0f ? 0 : 1; + float F = glm::roundEven(-1.5f); + Error += F == -2.0f ? 0 : 1; + float G = glm::roundEven(-1.9f); + Error += G == -2.0f ? 0 : 1; + } + + { + float A = glm::roundEven(1.5f); + Error += A == 2.0f ? 0 : 1; + float B = glm::roundEven(2.5f); + Error += B == 2.0f ? 0 : 1; + float C = glm::roundEven(3.5f); + Error += C == 4.0f ? 0 : 1; + float D = glm::roundEven(4.5f); + Error += D == 4.0f ? 0 : 1; + float E = glm::roundEven(5.5f); + Error += E == 6.0f ? 0 : 1; + float F = glm::roundEven(6.5f); + Error += F == 6.0f ? 0 : 1; + float G = glm::roundEven(7.5f); + Error += G == 8.0f ? 0 : 1; + } - { - float A = glm::roundEven(-1.5f); - Error += A == -2.0f ? 0 : 1; - float B = glm::roundEven(-2.5f); - Error += B == -2.0f ? 0 : 1; - float C = glm::roundEven(-3.5f); - Error += C == -4.0f ? 0 : 1; - float D = glm::roundEven(-4.5f); - Error += D == -4.0f ? 0 : 1; - float E = glm::roundEven(-5.5f); - Error += E == -6.0f ? 0 : 1; - float F = glm::roundEven(-6.5f); - Error += F == -6.0f ? 0 : 1; - float G = glm::roundEven(-7.5f); - Error += G == -8.0f ? 0 : 1; + { + float A = glm::roundEven(-1.5f); + Error += A == -2.0f ? 0 : 1; + float B = glm::roundEven(-2.5f); + Error += B == -2.0f ? 0 : 1; + float C = glm::roundEven(-3.5f); + Error += C == -4.0f ? 0 : 1; + float D = glm::roundEven(-4.5f); + Error += D == -4.0f ? 0 : 1; + float E = glm::roundEven(-5.5f); + Error += E == -6.0f ? 0 : 1; + float F = glm::roundEven(-6.5f); + Error += F == -6.0f ? 0 : 1; + float G = glm::roundEven(-7.5f); + Error += G == -8.0f ? 0 : 1; + } + + return Error; } +}//namespace roundEven - return Error; -} - -int test_isnan() +namespace isnan_ { - int Error = 0; - - float Zero_f = 0.0; - double Zero_d = 0.0; - + int test() { - Error += true == glm::isnan(0.0/Zero_d) ? 0 : 1; - Error += true == glm::any(glm::isnan(glm::dvec2(0.0 / Zero_d))) ? 0 : 1; - Error += true == glm::any(glm::isnan(glm::dvec3(0.0 / Zero_d))) ? 0 : 1; - Error += true == glm::any(glm::isnan(glm::dvec4(0.0 / Zero_d))) ? 0 : 1; - } + int Error = 0; - { - Error += true == glm::isnan(0.0f/Zero_f) ? 0 : 1; - Error += true == glm::any(glm::isnan(glm::vec2(0.0f/Zero_f))) ? 0 : 1; - Error += true == glm::any(glm::isnan(glm::vec3(0.0f/Zero_f))) ? 0 : 1; - Error += true == glm::any(glm::isnan(glm::vec4(0.0f/Zero_f))) ? 0 : 1; - } + float Zero_f = 0.0; + double Zero_d = 0.0; - return Error; -} - -int test_isinf() + { + Error += true == glm::isnan(0.0/Zero_d) ? 0 : 1; + Error += true == glm::any(glm::isnan(glm::dvec2(0.0 / Zero_d))) ? 0 : 1; + Error += true == glm::any(glm::isnan(glm::dvec3(0.0 / Zero_d))) ? 0 : 1; + Error += true == glm::any(glm::isnan(glm::dvec4(0.0 / Zero_d))) ? 0 : 1; + } + + { + Error += true == glm::isnan(0.0f/Zero_f) ? 0 : 1; + Error += true == glm::any(glm::isnan(glm::vec2(0.0f/Zero_f))) ? 0 : 1; + Error += true == glm::any(glm::isnan(glm::vec3(0.0f/Zero_f))) ? 0 : 1; + Error += true == glm::any(glm::isnan(glm::vec4(0.0f/Zero_f))) ? 0 : 1; + } + + return Error; + } +}//namespace isnan_ + +namespace isinf_ { - int Error = 0; - - float Zero_f = 0.0; - double Zero_d = 0.0; + int test() + { + int Error = 0; - { - Error += true == glm::isinf( 1.0/Zero_d) ? 0 : 1; - Error += true == glm::isinf(-1.0/Zero_d) ? 0 : 1; - Error += true == glm::any(glm::isinf(glm::dvec2( 1.0/Zero_d))) ? 0 : 1; - Error += true == glm::any(glm::isinf(glm::dvec2(-1.0/Zero_d))) ? 0 : 1; - Error += true == glm::any(glm::isinf(glm::dvec3( 1.0/Zero_d))) ? 0 : 1; - Error += true == glm::any(glm::isinf(glm::dvec3(-1.0/Zero_d))) ? 0 : 1; - Error += true == glm::any(glm::isinf(glm::dvec4( 1.0/Zero_d))) ? 0 : 1; - Error += true == glm::any(glm::isinf(glm::dvec4(-1.0/Zero_d))) ? 0 : 1; + float Zero_f = 0.0; + double Zero_d = 0.0; + + { + Error += true == glm::isinf( 1.0/Zero_d) ? 0 : 1; + Error += true == glm::isinf(-1.0/Zero_d) ? 0 : 1; + Error += true == glm::any(glm::isinf(glm::dvec2( 1.0/Zero_d))) ? 0 : 1; + Error += true == glm::any(glm::isinf(glm::dvec2(-1.0/Zero_d))) ? 0 : 1; + Error += true == glm::any(glm::isinf(glm::dvec3( 1.0/Zero_d))) ? 0 : 1; + Error += true == glm::any(glm::isinf(glm::dvec3(-1.0/Zero_d))) ? 0 : 1; + Error += true == glm::any(glm::isinf(glm::dvec4( 1.0/Zero_d))) ? 0 : 1; + Error += true == glm::any(glm::isinf(glm::dvec4(-1.0/Zero_d))) ? 0 : 1; + } + + { + Error += true == glm::isinf( 1.0f/Zero_f) ? 0 : 1; + Error += true == glm::isinf(-1.0f/Zero_f) ? 0 : 1; + Error += true == glm::any(glm::isinf(glm::vec2( 1.0f/Zero_f))) ? 0 : 1; + Error += true == glm::any(glm::isinf(glm::vec2(-1.0f/Zero_f))) ? 0 : 1; + Error += true == glm::any(glm::isinf(glm::vec3( 1.0f/Zero_f))) ? 0 : 1; + Error += true == glm::any(glm::isinf(glm::vec3(-1.0f/Zero_f))) ? 0 : 1; + Error += true == glm::any(glm::isinf(glm::vec4( 1.0f/Zero_f))) ? 0 : 1; + Error += true == glm::any(glm::isinf(glm::vec4(-1.0f/Zero_f))) ? 0 : 1; + } + + return Error; } - - { - Error += true == glm::isinf( 1.0f/Zero_f) ? 0 : 1; - Error += true == glm::isinf(-1.0f/Zero_f) ? 0 : 1; - Error += true == glm::any(glm::isinf(glm::vec2( 1.0f/Zero_f))) ? 0 : 1; - Error += true == glm::any(glm::isinf(glm::vec2(-1.0f/Zero_f))) ? 0 : 1; - Error += true == glm::any(glm::isinf(glm::vec3( 1.0f/Zero_f))) ? 0 : 1; - Error += true == glm::any(glm::isinf(glm::vec3(-1.0f/Zero_f))) ? 0 : 1; - Error += true == glm::any(glm::isinf(glm::vec4( 1.0f/Zero_f))) ? 0 : 1; - Error += true == glm::any(glm::isinf(glm::vec4(-1.0f/Zero_f))) ? 0 : 1; - } - - return Error; -} +}//namespace isinf_ namespace sign { @@ -1018,18 +1053,18 @@ int main() int Error(0); Error += sign::test(); - Error += test_floor(); - Error += test_modf(); - Error += test_floatBitsToInt(); - Error += test_floatBitsToUint(); - Error += test_step::run(); - Error += test_max(); - Error += test_min(); - Error += test_mix::run(); - Error += test_round(); - Error += test_roundEven(); - Error += test_isnan(); - Error += test_isinf(); + Error += floor_::test(); + Error += modf_::test(); + Error += floatBitsToInt::test(); + Error += floatBitsToUint::test(); + Error += step_::test(); + Error += max_::test(); + Error += min_::test(); + Error += mix_::test(); + Error += round_::test(); + Error += roundEven::test(); + Error += isnan_::test(); + Error += isinf_::test(); # ifdef GLM_TEST_ENABLE_PERF Error += sign::perf(); diff --git a/test/core/core_type_mat4x4.cpp b/test/core/core_type_mat4x4.cpp index d9396c37..cd1239a7 100644 --- a/test/core/core_type_mat4x4.cpp +++ b/test/core/core_type_mat4x4.cpp @@ -13,16 +13,9 @@ #include #include -void print(glm::dmat4 const & Mat0) -{ - printf("mat4(\n"); - printf("\tvec4(%2.9f, %2.9f, %2.9f, %2.9f)\n", Mat0[0][0], Mat0[0][1], Mat0[0][2], Mat0[0][3]); - printf("\tvec4(%2.9f, %2.9f, %2.9f, %2.9f)\n", Mat0[1][0], Mat0[1][1], Mat0[1][2], Mat0[1][3]); - printf("\tvec4(%2.9f, %2.9f, %2.9f, %2.9f)\n", Mat0[2][0], Mat0[2][1], Mat0[2][2], Mat0[2][3]); - printf("\tvec4(%2.9f, %2.9f, %2.9f, %2.9f))\n\n", Mat0[3][0], Mat0[3][1], Mat0[3][2], Mat0[3][3]); -} -void print(glm::mat4 const & Mat0) +template +void print(genType const & Mat0) { printf("mat4(\n"); printf("\tvec4(%2.9f, %2.9f, %2.9f, %2.9f)\n", Mat0[0][0], Mat0[0][1], Mat0[0][2], Mat0[0][3]);