From 07ec8c95b225b54ddf603c1657a35e455925a66d Mon Sep 17 00:00:00 2001 From: Christophe Riccio Date: Wed, 1 Jun 2011 00:58:31 +0100 Subject: [PATCH 01/22] Fixed a bunch of warnings --- glm/core/intrinsic_common.inl | 4 ++++ glm/core/intrinsic_matrix.inl | 5 +++-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/glm/core/intrinsic_common.inl b/glm/core/intrinsic_common.inl index 5905b3b5..47935d29 100644 --- a/glm/core/intrinsic_common.inl +++ b/glm/core/intrinsic_common.inl @@ -205,10 +205,12 @@ GLM_FUNC_QUALIFIER __m128 sse_mod_ps(__m128 x, __m128 y) } /// TODO +/* GLM_FUNC_QUALIFIER __m128 sse_modf_ps(__m128 x, __m128i & i) { return __m128(); } +*/ //GLM_FUNC_QUALIFIER __m128 _mm_min_ps(__m128 x, __m128 y) @@ -252,6 +254,7 @@ GLM_FUNC_QUALIFIER __m128 sse_ssp_ps(__m128 edge0, __m128 edge1, __m128 x) return mul2; } +/* TODO GLM_FUNC_QUALIFIER __m128 sse_nan_ps(__m128 x) { @@ -261,6 +264,7 @@ GLM_FUNC_QUALIFIER __m128 sse_inf_ps(__m128 x) { } +*/ // SSE scalar reciprocal sqrt using rsqrt op, plus one Newton-Rhaphson iteration // By Elan Ruskin, http://assemblyrequired.crashworks.org/ diff --git a/glm/core/intrinsic_matrix.inl b/glm/core/intrinsic_matrix.inl index 1246a744..7350488f 100644 --- a/glm/core/intrinsic_matrix.inl +++ b/glm/core/intrinsic_matrix.inl @@ -10,8 +10,9 @@ namespace glm{ namespace detail{ -static const __m128 _m128_rad_ps = _mm_set_ps1(3.141592653589793238462643383279f / 180.f); -static const __m128 _m128_deg_ps = _mm_set_ps1(180.f / 3.141592653589793238462643383279f); +/// \todo +//static const __m128 _m128_rad_ps = _mm_set_ps1(3.141592653589793238462643383279f / 180.f); +//static const __m128 _m128_deg_ps = _mm_set_ps1(180.f / 3.141592653589793238462643383279f); template GLM_FUNC_QUALIFIER matType sse_comp_mul_ps From 35ed096cc831c1ec71106be20878895ebcffa429 Mon Sep 17 00:00:00 2001 From: Christophe Riccio Date: Wed, 1 Jun 2011 10:02:02 +0100 Subject: [PATCH 02/22] Added declarations for missing constructors --- glm/core/type_mat2x2.hpp | 12 ++++++------ glm/core/type_mat2x2.inl | 22 +++++++++++----------- glm/core/type_mat2x3.hpp | 20 +++++++++++++++++++- glm/core/type_mat2x4.hpp | 25 +++++++++++++++++++++++-- glm/core/type_mat3x2.hpp | 25 ++++++++++++++++++++++++- glm/core/type_mat3x3.hpp | 23 +++++++++++++++++++++++ glm/core/type_mat3x4.hpp | 25 ++++++++++++++++++++++++- glm/core/type_mat4x2.hpp | 28 +++++++++++++++++++++++++++- glm/core/type_mat4x3.hpp | 30 +++++++++++++++++++++++++++--- glm/core/type_mat4x4.hpp | 24 ++++++++++++++++++++++++ 10 files changed, 208 insertions(+), 26 deletions(-) diff --git a/glm/core/type_mat2x2.hpp b/glm/core/type_mat2x2.hpp index 7f0df2c7..9ae7cd13 100644 --- a/glm/core/type_mat2x2.hpp +++ b/glm/core/type_mat2x2.hpp @@ -79,7 +79,7 @@ namespace glm col_type const & v2); ////////////////////////////////////// - // Convertion constructors + // Conversions template GLM_FUNC_DECL explicit tmat2x2( U const & x); @@ -89,13 +89,13 @@ namespace glm U const & x1, V const & y1, M const & x2, N const & y2); - //template - //GLM_FUNC_DECL explicit tmat2x2( - // tvec2 const & v1, - // tvec2 const & v2); + template + GLM_FUNC_DECL explicit tmat2x2( + tvec2 const & v1, + tvec2 const & v2); ////////////////////////////////////// - // Conversions + // Matrix conversions template GLM_FUNC_DECL explicit tmat2x2(tmat2x2 const & m); diff --git a/glm/core/type_mat2x2.inl b/glm/core/type_mat2x2.inl index 11a3f11c..77638dbb 100644 --- a/glm/core/type_mat2x2.inl +++ b/glm/core/type_mat2x2.inl @@ -133,17 +133,17 @@ namespace detail this->value[1] = col_type(value_type(x2), value_type(y2)); } - //template - //template - //GLM_FUNC_DECL tmat2x2::tmat2x2 - //( - // tvec2 const & v1, - // tvec2 const & v2 - //) - //{ - // this->value[0] = col_type(v1); - // this->value[1] = col_type(v2); - //} + template + template + GLM_FUNC_DECL tmat2x2::tmat2x2 + ( + tvec2 const & v1, + tvec2 const & v2 + ) + { + this->value[0] = col_type(v1); + this->value[1] = col_type(v2); + } ////////////////////////////////////////////////////////////// // mat2x2 conversions diff --git a/glm/core/type_mat2x3.hpp b/glm/core/type_mat2x3.hpp index ed87f9e2..4ff621e1 100644 --- a/glm/core/type_mat2x3.hpp +++ b/glm/core/type_mat2x3.hpp @@ -71,7 +71,25 @@ namespace glm col_type const & v0, col_type const & v1); - // Conversion + + ////////////////////////////////////// + // Conversions + template + GLM_FUNC_DECL explicit tmat2x3( + U const & x); + + template + GLM_FUNC_DECL explicit tmat2x3( + X1 const & x1, Y1 const & y1, Z1 const & z1, + X2 const & x2, Y2 const & y2, Z2 const & z2); + + template + GLM_FUNC_DECL explicit tmat2x3( + tvec3 const & v1, + tvec3 const & v2); + + ////////////////////////////////////// + // Matrix conversion template GLM_FUNC_DECL explicit tmat2x3(tmat2x3 const & m); diff --git a/glm/core/type_mat2x4.hpp b/glm/core/type_mat2x4.hpp index a14cc033..8eee4105 100644 --- a/glm/core/type_mat2x4.hpp +++ b/glm/core/type_mat2x4.hpp @@ -70,8 +70,29 @@ namespace glm GLM_FUNC_DECL explicit tmat2x4( col_type const & v0, col_type const & v1); - - // Conversion + + ////////////////////////////////////// + // Conversions + template + GLM_FUNC_DECL explicit tmat2x4( + U const & x); + + template + < + typename X1, typename Y1, typename Z1, typename W1, + typename X2, typename Y2, typename Z2, typename W2 + > + GLM_FUNC_DECL explicit tmat2x4( + X1 const & x1, Y1 const & y1, Z1 const & z1, W1 const & w1, + X2 const & x2, Y2 const & y2, Z2 const & z2, W2 const & w2,); + + template + GLM_FUNC_DECL explicit tmat2x4( + tvec4 const & v1, + tvec4 const & v2); + + ////////////////////////////////////// + // Matrix conversions template GLM_FUNC_DECL explicit tmat2x4(tmat2x4 const & m); diff --git a/glm/core/type_mat3x2.hpp b/glm/core/type_mat3x2.hpp index 3457b72f..70c0795a 100644 --- a/glm/core/type_mat3x2.hpp +++ b/glm/core/type_mat3x2.hpp @@ -73,7 +73,30 @@ namespace glm col_type const & v1, col_type const & v2); - // Conversion + ////////////////////////////////////// + // Conversions + template + GLM_FUNC_DECL explicit tmat3x2( + U const & x); + + template + < + typename X1, typename Y1, + typename X2, typename Y2, + typename X3, typename Y3 + > + GLM_FUNC_DECL explicit tmat3x2( + X1 const & x1, Y1 const & y1, + X2 const & x2, Y2 const & y2, + X3 const & x3, Y3 const & y3); + + template + GLM_FUNC_DECL explicit tmat3x2( + tvec2 const & v1, + tvec2 const & v2, + tvec2 const & v3); + + // Matrix conversions template GLM_FUNC_DECL explicit tmat3x2(tmat3x2 const & m); diff --git a/glm/core/type_mat3x3.hpp b/glm/core/type_mat3x3.hpp index 3f4725dc..4f47eb7a 100644 --- a/glm/core/type_mat3x3.hpp +++ b/glm/core/type_mat3x3.hpp @@ -77,8 +77,31 @@ namespace glm col_type const & v1, col_type const & v2); + ////////////////////////////////////// // Conversions template + GLM_FUNC_DECL explicit tmat3x3( + U const & x); + + template + < + typename X1, typename Y1, typename Z1, + typename X2, typename Y2, typename Z2, + typename X3, typename Y3, typename Z3 + > + GLM_FUNC_DECL explicit tmat3x3( + X1 const & x1, Y1 const & y1, Z1 const & z1, + X2 const & x2, Y2 const & y2, Z2 const & z2, + X3 const & x3, Y3 const & y3, Z3 const & z3); + + template + GLM_FUNC_DECL explicit tmat3x3( + tvec3 const & v1, + tvec3 const & v2, + tvec3 const & v3); + + // Matrix conversions + template GLM_FUNC_DECL explicit tmat3x3(tmat3x3 const & m); GLM_FUNC_DECL explicit tmat3x3(tmat2x2 const & x); diff --git a/glm/core/type_mat3x4.hpp b/glm/core/type_mat3x4.hpp index 1f84ec7b..7978361e 100644 --- a/glm/core/type_mat3x4.hpp +++ b/glm/core/type_mat3x4.hpp @@ -73,7 +73,30 @@ namespace glm col_type const & v1, col_type const & v2); - // Conversion + ////////////////////////////////////// + // Conversions + template + GLM_FUNC_DECL explicit tmat3x4( + U const & x); + + template + < + typename X1, typename Y1, typename Z1, typename W1, + typename X2, typename Y2, typename Z2, typename W2, + typename X3, typename Y3, typename Z3, typename W3 + > + GLM_FUNC_DECL explicit tmat3x4( + X1 const & x1, Y1 const & y1, Z1 const & z1, W1 const & w1, + X2 const & x2, Y2 const & y2, Z2 const & z2, W2 const & w2, + X3 const & x3, Y3 const & y3, Z3 const & z3, W3 const & w3); + + template + GLM_FUNC_DECL explicit tmat3x4( + tvec4 const & v1, + tvec4 const & v2, + tvec4 const & v3); + + // Matrix conversion template GLM_FUNC_DECL explicit tmat3x4(tmat3x4 const & m); diff --git a/glm/core/type_mat4x2.hpp b/glm/core/type_mat4x2.hpp index 3354ce8e..67c5b2b2 100644 --- a/glm/core/type_mat4x2.hpp +++ b/glm/core/type_mat4x2.hpp @@ -74,9 +74,35 @@ namespace glm col_type const & v1, col_type const & v2, col_type const & v3); - + + ////////////////////////////////////// // Conversions template + GLM_FUNC_DECL explicit tmat4x2( + U const & x); + + template + < + typename X1, typename Y1, + typename X2, typename Y2, + typename X3, typename Y3, + typename X4, typename Y4 + > + GLM_FUNC_DECL explicit tmat4x2( + X1 const & x1, Y1 const & y1, + X2 const & x2, Y2 const & y2, + X3 const & x3, Y3 const & y3, + X4 const & x4, Y4 const & y4); + + template + GLM_FUNC_DECL explicit tmat4x2( + tvec2 const & v1, + tvec2 const & v2, + tvec2 const & v3, + tvec2 const & v4); + + // Matrix conversions + template GLM_FUNC_DECL explicit tmat4x2(tmat4x2 const & m); GLM_FUNC_DECL explicit tmat4x2(tmat2x2 const & x); diff --git a/glm/core/type_mat4x3.hpp b/glm/core/type_mat4x3.hpp index b15a3c30..3876150b 100644 --- a/glm/core/type_mat4x3.hpp +++ b/glm/core/type_mat4x3.hpp @@ -73,9 +73,33 @@ namespace glm col_type const & v0, col_type const & v1, col_type const & v2, - col_type const & v3); - - // Conversion + col_type const & v3); + + ////////////////////////////////////// + // Conversions + template + GLM_FUNC_DECL explicit tmat4x3( + U const & x); + + template < + typename X1, typename Y1, typename Z1, + typename X2, typename Y2, typename Z2, + typename X3, typename Y3, typename Z3, + typename X4, typename Y4, typename Z4> + GLM_FUNC_DECL explicit tmat4x3( + X1 const & x1, Y1 const & y1, Z1 const & z1, + X2 const & x2, Y2 const & y2, Z2 const & z2, + X3 const & x3, Y3 const & y3, Z3 const & z3, + X4 const & x4, Y4 const & y4, Z4 const & z4); + + template + GLM_FUNC_DECL explicit tmat4x3( + tvec3 const & v1, + tvec3 const & v2, + tvec3 const & v3, + tvec3 const & v4); + + // Matrix conversions template GLM_FUNC_DECL explicit tmat4x3(tmat4x3 const & m); diff --git a/glm/core/type_mat4x4.hpp b/glm/core/type_mat4x4.hpp index e992ddaf..a470f34a 100644 --- a/glm/core/type_mat4x4.hpp +++ b/glm/core/type_mat4x4.hpp @@ -79,8 +79,32 @@ namespace glm col_type const & v2, col_type const & v3); + ////////////////////////////////////// // Conversions template + GLM_FUNC_DECL explicit tmat4x4( + U const & x); + + template < + typename X1, typename Y1, typename Z1, + typename X2, typename Y2, typename Z2, + typename X3, typename Y3, typename Z3, + typename X4, typename Y4, typename Z4> + GLM_FUNC_DECL explicit tmat4x4( + X1 const & x1, Y1 const & y1, Z1 const & z1, W1 const & w1, + 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 explicit tmat4x4( + tvec4 const & v1, + tvec4 const & v2, + tvec4 const & v3, + tvec4 const & v4); + + // Matrix conversions + template GLM_FUNC_DECL explicit tmat4x4(tmat4x4 const & m); GLM_FUNC_DECL explicit tmat4x4(tmat2x2 const & x); From b049cae5f28a17bb5da6ea067b0b2da3dc185004 Mon Sep 17 00:00:00 2001 From: Christophe Riccio Date: Wed, 1 Jun 2011 10:45:24 +0100 Subject: [PATCH 03/22] Updated random tests --- glm/gtx/random.inl | 2 +- test/gtx/CMakeLists.txt | 1 + test/gtx/gtx_noise.cpp | 25 +++++++++++++++++++++++- test/gtx/gtx_random.cpp | 42 +++++++++++++++++++++++++++++++++++++++++ 4 files changed, 68 insertions(+), 2 deletions(-) create mode 100644 test/gtx/gtx_random.cpp diff --git a/glm/gtx/random.inl b/glm/gtx/random.inl index f325d61d..77edea44 100644 --- a/glm/gtx/random.inl +++ b/glm/gtx/random.inl @@ -17,7 +17,7 @@ namespace random template <> GLM_FUNC_QUALIFIER float signedRand1() { - #if(GLM_COMPILER & GLM_COMPILER_VC) + #if(GLM_COMPILER & GLM_COMPILER_VC)// && (GLM_COMPILER < GLM_COMPILER_VC2010) #define RAND_SHIFT_NUM 5 #else #define RAND_SHIFT_NUM 0 diff --git a/test/gtx/CMakeLists.txt b/test/gtx/CMakeLists.txt index 48258987..38387f78 100644 --- a/test/gtx/CMakeLists.txt +++ b/test/gtx/CMakeLists.txt @@ -1,6 +1,7 @@ glmCreateTestGTC(gtx_bit) glmCreateTestGTC(gtx_noise) glmCreateTestGTC(gtx_quaternion) +glmCreateTestGTC(gtx_random) glmCreateTestGTC(gtx_rotate_vector) glmCreateTestGTC(gtx_simd_vec4) glmCreateTestGTC(gtx_simd_mat4) diff --git a/test/gtx/gtx_noise.cpp b/test/gtx/gtx_noise.cpp index 624ca022..8acaaaf4 100644 --- a/test/gtx/gtx_noise.cpp +++ b/test/gtx/gtx_noise.cpp @@ -11,17 +11,40 @@ #include #include -int main() +int test_simplex() { float ValueSNoise2D = glm::simplex(glm::vec2(0.5f)); float ValueSNoise3D = glm::simplex(glm::vec3(0.5f)); float ValueSNoise4D = glm::simplex(glm::vec4(0.5f)); + return 0; +} + +int test_perlin() +{ float ValueCNoise2D = glm::perlin(glm::vec2(0.5f)); float ValueCNoise3D = glm::perlin(glm::vec3(0.5f)); float ValueCNoise4D = glm::perlin(glm::vec4(0.5f)); + return 0; +} + +int test_perlin_pedioric() +{ float ValuePNoise2D = glm::perlin(glm::vec2(0.5f), glm::vec2(0.5f)); float ValuePNoise3D = glm::perlin(glm::vec3(0.5f), glm::vec3(0.5f)); float ValuePNoise4D = glm::perlin(glm::vec4(0.5f), glm::vec4(0.5f)); + + return 0; +} + +int main() +{ + int Error = 0; + + Error += test_simplex(); + Error += test_perlin(); + Error += test_perlin_pedioric(); + + return Error; } diff --git a/test/gtx/gtx_random.cpp b/test/gtx/gtx_random.cpp new file mode 100644 index 00000000..00ef2614 --- /dev/null +++ b/test/gtx/gtx_random.cpp @@ -0,0 +1,42 @@ +/////////////////////////////////////////////////////////////////////////////////////////////////// +// OpenGL Mathematics Copyright (c) 2005 - 2011 G-Truc Creation (www.g-truc.net) +/////////////////////////////////////////////////////////////////////////////////////////////////// +// Created : 2011-05-31 +// Updated : 2011-05-31 +// Licence : This source is under MIT licence +// File : test/gtx/random.cpp +/////////////////////////////////////////////////////////////////////////////////////////////////// + +#include +#include +#include +#include + +int test_signedRand1() +{ + int Error = 0; + + { + float ResultFloat = 0.0f; + double ResultDouble = 0.0f; + for(std::size_t i = 0; i < 100000; ++i) + { + ResultFloat += glm::signedRand1(); + ResultDouble += glm::signedRand1(); + } + + Error += glm::equalEpsilon(ResultFloat, 0.0f, 0.0001f); + Error += glm::equalEpsilon(ResultDouble, 0.0, 0.0001); + } + + return Error; +} + +int main() +{ + int Error = 0; + + Error += test_signedRand1(); + + return Error; +} From 5375fbbc9777c3fe8c6eda18848524ba66cb4f1b Mon Sep 17 00:00:00 2001 From: Christophe Riccio Date: Wed, 1 Jun 2011 11:57:43 +0100 Subject: [PATCH 04/22] Added random tests --- test/gtx/gtx_random.cpp | 56 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 56 insertions(+) diff --git a/test/gtx/gtx_random.cpp b/test/gtx/gtx_random.cpp index 00ef2614..859faa52 100644 --- a/test/gtx/gtx_random.cpp +++ b/test/gtx/gtx_random.cpp @@ -32,11 +32,67 @@ int test_signedRand1() return Error; } +int test_normalizedRand2() +{ + int Error = 0; + + { + std::size_t Max = 100000; + float ResultFloat = 0.0f; + double ResultDouble = 0.0f; + for(std::size_t i = 0; i < Max; ++i) + { + ResultFloat += glm::length(glm::normalizedRand2()); + ResultDouble += glm::length(glm::normalizedRand2()); + } + + Error += glm::equalEpsilon(ResultFloat, float(Max), 0.0001f); + Error += glm::equalEpsilon(ResultDouble, double(Max), 0.0001); + } + + return Error; +} + +int test_normalizedRand3() +{ + int Error = 0; + + { + std::size_t Max = 100000; + float ResultFloatA = 0.0f; + float ResultFloatB = 0.0f; + float ResultFloatC = 0.0f; + double ResultDoubleA = 0.0f; + double ResultDoubleB = 0.0f; + double ResultDoubleC = 0.0f; + for(std::size_t i = 0; i < Max; ++i) + { + ResultFloatA += glm::length(glm::normalizedRand3()); + ResultDoubleA += glm::length(glm::normalizedRand3()); + ResultFloatB += glm::length(glm::normalizedRand3(2.0f, 2.0f)); + ResultDoubleB += glm::length(glm::normalizedRand3(2.0, 2.0)); + ResultFloatC += glm::length(glm::normalizedRand3(1.0f, 3.0f)); + ResultDoubleC += glm::length(glm::normalizedRand3(1.0, 3.0)); + } + + Error += glm::equalEpsilon(ResultFloatA, float(Max), 0.0001f) ? 0 : 1; + Error += glm::equalEpsilon(ResultDoubleA, double(Max), 0.0001) ? 0 : 1; + Error += glm::equalEpsilon(ResultFloatB, float(Max * 2), 0.0001f) ? 0 : 1; + Error += glm::equalEpsilon(ResultDoubleB, double(Max * 2), 0.0001) ? 0 : 1; + Error += (ResultFloatC >= float(Max) && ResultFloatC <= float(Max * 3)) ? 0 : 1; + Error += (ResultDoubleC >= double(Max) && ResultDoubleC <= double(Max * 3)) ? 0 : 1; + } + + return Error; +} + int main() { int Error = 0; Error += test_signedRand1(); + Error += test_normalizedRand2(); + Error += test_normalizedRand3(); return Error; } From 54e8df2ff374518d408548d4913287bd396aaea6 Mon Sep 17 00:00:00 2001 From: Christophe Riccio Date: Wed, 1 Jun 2011 16:09:20 +0100 Subject: [PATCH 05/22] Fixed compiler detection between GCC, LLVM and Clang; fixed MinGW build --- glm/core/intrinsic_common.inl | 8 ++++---- glm/core/setup.hpp | 8 ++++---- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/glm/core/intrinsic_common.inl b/glm/core/intrinsic_common.inl index 5905b3b5..fdaac0c8 100644 --- a/glm/core/intrinsic_common.inl +++ b/glm/core/intrinsic_common.inl @@ -205,10 +205,10 @@ GLM_FUNC_QUALIFIER __m128 sse_mod_ps(__m128 x, __m128 y) } /// TODO -GLM_FUNC_QUALIFIER __m128 sse_modf_ps(__m128 x, __m128i & i) -{ - return __m128(); -} +//GLM_FUNC_QUALIFIER __m128 sse_modf_ps(__m128 x, __m128i & i) +//{ +// return __m128(); +//} //GLM_FUNC_QUALIFIER __m128 _mm_min_ps(__m128 x, __m128 y) diff --git a/glm/core/setup.hpp b/glm/core/setup.hpp index 01075f3c..70ad1576 100644 --- a/glm/core/setup.hpp +++ b/glm/core/setup.hpp @@ -43,8 +43,8 @@ // GCC defines #define GLM_COMPILER_GCC 0x02000000 -#define GLM_COMPILER_GCC_LLVM 0x02000000 -#define GLM_COMPILER_GCC_CLANG 0x02000000 +#define GLM_COMPILER_GCC_LLVM 0x02000001 +#define GLM_COMPILER_GCC_CLANG 0x02000002 #define GLM_COMPILER_GCC30 0x02000010 #define GLM_COMPILER_GCC31 0x02000020 #define GLM_COMPILER_GCC32 0x02000030 @@ -214,9 +214,9 @@ # elif(GLM_COMPILER & GLM_COMPILER_LLVM_GCC) # pragma message("GLM: LLVM GCC compiler detected") # elif(GLM_COMPILER & GLM_COMPILER_GCC) -# if(GLM_COMPILER & GLM_COMPILER_GCC_LLVM) +# if(GLM_COMPILER == GLM_COMPILER_GCC_LLVM) # pragma message("GLM: LLVM GCC compiler detected") -# elif(GLM_COMPILER & GLM_COMPILER_GCC_CLANG) +# elif(GLM_COMPILER == GLM_COMPILER_GCC_CLANG) # pragma message("GLM: CLANG compiler detected") # else # pragma message("GLM: GCC compiler detected") From 6c9364c2e847876caaba06d95434aaef61630c4d Mon Sep 17 00:00:00 2001 From: Christophe Riccio Date: Wed, 1 Jun 2011 16:17:45 +0100 Subject: [PATCH 06/22] Fixed ticket #104, dependence between GTX_epsilon and GTC_quaternion --- glm/gtx/epsilon.hpp | 4 +++- glm/gtx/epsilon.inl | 30 ++++++++++++++++++++++++++++++ 2 files changed, 33 insertions(+), 1 deletion(-) diff --git a/glm/gtx/epsilon.hpp b/glm/gtx/epsilon.hpp index 7df2cb7d..3ee7f418 100644 --- a/glm/gtx/epsilon.hpp +++ b/glm/gtx/epsilon.hpp @@ -8,7 +8,8 @@ /////////////////////////////////////////////////////////////////////////////////////////////////// // Dependency: // - GLM core -// - GLM_GTX_half +// - GLM_GTC_half_float +// - GLM_GTC_quaternion /////////////////////////////////////////////////////////////////////////////////////////////////// #ifndef glm_gtx_epsilon @@ -17,6 +18,7 @@ // Dependency: #include "../glm.hpp" #include "../gtc/half_float.hpp" +#include "../gtc/quaternion.hpp" #if(defined(GLM_MESSAGES) && !defined(glm_ext)) # pragma message("GLM: GLM_GTX_epsilon extension included") diff --git a/glm/gtx/epsilon.inl b/glm/gtx/epsilon.inl index 1e424127..4eab9103 100644 --- a/glm/gtx/epsilon.inl +++ b/glm/gtx/epsilon.inl @@ -157,6 +157,21 @@ GLM_FUNC_QUALIFIER detail::tvec4 equalEpsilon abs(x.w - y.w) < epsilon.w); } +template +GLM_FUNC_QUALIFIER detail::tvec4 equalEpsilon +( + detail::tquat const & x, + detail::tquat const & y, + detail::tquat const & epsilon +) +{ + return detail::tvec4( + abs(x.x - y.x) < epsilon.x, + abs(x.y - y.y) < epsilon.y, + abs(x.z - y.z) < epsilon.z, + abs(x.w - y.w) < epsilon.w); +} + template GLM_FUNC_QUALIFIER detail::tvec2 notEqualEpsilon ( @@ -199,6 +214,21 @@ GLM_FUNC_QUALIFIER detail::tvec4 notEqualEpsilon abs(x.w - y.w) >= epsilon.w); } +template +GLM_FUNC_QUALIFIER detail::tvec4 notEqualEpsilon +( + detail::tquat const & x, + detail::tquat const & y, + detail::tquat const & epsilon +) +{ + return detail::tvec4( + abs(x.x - y.x) >= epsilon.x, + abs(x.y - y.y) >= epsilon.y, + abs(x.z - y.z) >= epsilon.z, + abs(x.w - y.w) >= epsilon.w); +} + }//namespace epsilon }//namespace gtx }//namespace glm From 2500be6bcba7d606f3f14df61a52eb0c56574bc4 Mon Sep 17 00:00:00 2001 From: Christophe Riccio Date: Wed, 1 Jun 2011 16:27:50 +0100 Subject: [PATCH 07/22] Fixed #95, shortMix implementation --- glm/gtx/quaternion.inl | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/glm/gtx/quaternion.inl b/glm/gtx/quaternion.inl index ec713c8d..b63e6c0f 100644 --- a/glm/gtx/quaternion.inl +++ b/glm/gtx/quaternion.inl @@ -256,7 +256,7 @@ namespace quaternion if(a <= typename detail::tquat::value_type(0)) return x; if(a >= typename detail::tquat::value_type(1)) return y; - float fCos = dot(x, y); + detail::tquat::value_type fCos = dot(x, y); detail::tquat y2(y); //BUG!!! tquat y2; if(fCos < typename detail::tquat::value_type(0)) { @@ -265,7 +265,7 @@ namespace quaternion } //if(fCos > 1.0f) // problem - float k0, k1; + detail::tquat::value_type k0, k1; if(fCos > typename detail::tquat::value_type(0.9999)) { k0 = typename detail::tquat::value_type(1) - a; @@ -295,7 +295,7 @@ namespace quaternion T const & a ) { - return glm::normalize(x * (1 - a) + (y * a)); + return glm::normalize(x * (detail::tquat::value_type(1) - a) + (y * a)); } }//namespace quaternion From 39580d05f001eb9646cab2b6d6ecd4d99e55723f Mon Sep 17 00:00:00 2001 From: Christophe Riccio Date: Wed, 1 Jun 2011 16:46:04 +0100 Subject: [PATCH 08/22] Fixed quaternion tests --- test/gtx/gtx_quaternion.cpp | 45 +++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) diff --git a/test/gtx/gtx_quaternion.cpp b/test/gtx/gtx_quaternion.cpp index 5fb5ebd2..287dc1df 100644 --- a/test/gtx/gtx_quaternion.cpp +++ b/test/gtx/gtx_quaternion.cpp @@ -11,6 +11,23 @@ #include #include +int test_quat_mix() +{ + int Error = 0; + + glm::quat A = glm::angleAxis(0.0f, glm::vec3(0, 0, 1)); + glm::quat B = glm::angleAxis(90.0f, glm::vec3(0, 0, 1)); + glm::quat C = glm::mix(A, B, 0.5f); + glm::quat D = glm::angleAxis(45.0f, glm::vec3(0, 0, 1)); + + Error += glm::equalEpsilon(C.x, D.x, 0.01f) ? 0 : 1; + Error += glm::equalEpsilon(C.y, D.y, 0.01f) ? 0 : 1; + Error += glm::equalEpsilon(C.z, D.z, 0.01f) ? 0 : 1; + Error += glm::equalEpsilon(C.w, D.w, 0.01f) ? 0 : 1; + + return Error; +} + int test_quat_fastMix() { int Error = 0; @@ -94,14 +111,42 @@ int test_quat_angle() return Error; } +int test_quat_normalize() +{ + int Error = 0; + + { + glm::quat Q = glm::angleAxis(45.0f, glm::vec3(0, 0, 1)); + glm::quat N = glm::normalize(Q); + float L = glm::length(N); + Error += glm::equalEpsilon(L, 1.0f, 0.000001f) ? 0 : 1; + } + { + glm::quat Q = glm::angleAxis(45.0f, glm::vec3(0, 0, 2)); + glm::quat N = glm::normalize(Q); + float L = glm::length(N); + Error += glm::equalEpsilon(L, 1.0f, 0.000001f) ? 0 : 1; + } + { + glm::quat Q = glm::angleAxis(45.0f, glm::vec3(1, 2, 3)); + glm::quat N = glm::normalize(Q); + float L = glm::length(N); + Error += glm::equalEpsilon(L, 1.0f, 0.000001f) ? 0 : 1; + } + + return Error; +} + int main() { int Error = 0; Error += test_quat_angle(); Error += test_quat_angleAxis(); + Error += test_quat_mix(); Error += test_quat_fastMix(); Error += test_quat_shortMix(); + Error += test_quat_normalize(); return Error; } From e43633dbe6084b912fbcf1b640bdd5ed0a43f622 Mon Sep 17 00:00:00 2001 From: Christophe Riccio Date: Wed, 1 Jun 2011 17:00:20 +0100 Subject: [PATCH 09/22] Moved test to GTX tests --- glm/virtrev/xstream.hpp | 6 ++-- test/gtc/gtc_quaternion.cpp | 55 ------------------------------------- 2 files changed, 3 insertions(+), 58 deletions(-) diff --git a/glm/virtrev/xstream.hpp b/glm/virtrev/xstream.hpp index 1f19dae2..cf13ffbe 100644 --- a/glm/virtrev/xstream.hpp +++ b/glm/virtrev/xstream.hpp @@ -1,6 +1,3 @@ -#ifndef GLM_EXT_VIRTREV_XSTREAM_HPP -#define GLM_EXT_VIRTREV_XSTREAM_HPP - /////////////////////////////////////////////////////////////////////////////////////////////////// // OpenGL Mathematics Copyright (c) 2005 - 2011 G-Truc Creation (www.g-truc.net) // Virtrev SDK copyright matrem (matrem84.free.fr) @@ -15,6 +12,9 @@ // - GLM_GTX_matrix_selection /////////////////////////////////////////////////////////////////////////////////////////////////// +#ifndef GLM_EXT_VIRTREV_XSTREAM_HPP +#define GLM_EXT_VIRTREV_XSTREAM_HPP + #include "../glm.hpp" #include "../gtc/matrix_access.hpp" #include diff --git a/test/gtc/gtc_quaternion.cpp b/test/gtc/gtc_quaternion.cpp index a84b03be..d59fb1a3 100644 --- a/test/gtc/gtc_quaternion.cpp +++ b/test/gtc/gtc_quaternion.cpp @@ -29,67 +29,12 @@ int test_quat_type() return 0; } -int test_quat_slerp() -{ - int Error = 0; - - glm::quat A(glm::vec3(0, 0, 1)); - glm::quat B(glm::vec3(0, 1, 0)); - glm::quat C = glm::mix(A, B, 0.5f); - glm::quat D(glm::normalize(glm::vec3(0, 1, 1))); - - Error += C == D ? 0 : 1; - - return Error; -} - -int test_quat_length() -{ - int Error = 0; - - float A = glm::length(glm::quat(45.0f, glm::vec3(0, 0, 1))); - Error += A == 1.0f ? 0 : 1; - float B = glm::length(glm::quat(90.0f, glm::vec3(0, 0, 2))); - Error += B == 2.0f ? 0 : 1; - - return Error; -} - -int test_quat_normalize() -{ - int Error = 0; - - { - glm::quat Q(45.0f, glm::vec3(0, 0, 1)); - glm::quat N = glm::normalize(Q); - float L = glm::length(N); - Error += L == 1.0f ? 0 : 1; - } - { - glm::quat Q(45.0f, glm::vec3(0, 0, 2)); - glm::quat N = glm::normalize(Q); - float L = glm::length(N); - Error += L == 1.0f ? 0 : 1; - } - { - glm::quat Q(45.0f, glm::vec3(1, 2, 3)); - glm::quat N = glm::normalize(Q); - float L = glm::length(N); - Error += L == 1.0f ? 0 : 1; - } - - return Error; -} - int main() { int Error = 0; Error += test_quat_precision(); Error += test_quat_type(); - Error += test_quat_slerp(); - Error += test_quat_length(); - Error += test_quat_normalize(); return Error; } From 92d3fc5b6a665b31fc6ac796f057ce962058bcef Mon Sep 17 00:00:00 2001 From: Christophe Riccio Date: Wed, 1 Jun 2011 17:22:15 +0100 Subject: [PATCH 10/22] Fixed #102, removed GCC warnings --- glm/core/intrinsic_common.inl | 194 +++++++++++++++++----------------- glm/core/intrinsic_matrix.inl | 8 +- glm/core/setup.hpp | 6 ++ 3 files changed, 109 insertions(+), 99 deletions(-) diff --git a/glm/core/intrinsic_common.inl b/glm/core/intrinsic_common.inl index fdaac0c8..cda40420 100644 --- a/glm/core/intrinsic_common.inl +++ b/glm/core/intrinsic_common.inl @@ -21,107 +21,107 @@ namespace detail{ ieee754_QNAN() : f(0.0)/*, mantissa(0x7FFFFF), exp(0xFF), sign(0x0)*/ {} }; - static const __m128 zero = _mm_setzero_ps(); - static const __m128 one = _mm_set_ps1(1.0f); - static const __m128 minus_one = _mm_set_ps1(-1.0f); - static const __m128 two = _mm_set_ps1(2.0f); - static const __m128 three = _mm_set_ps1(3.0f); - static const __m128 pi = _mm_set_ps1(3.1415926535897932384626433832795f); - static const __m128 hundred_eighty = _mm_set_ps1(180.f); - static const __m128 pi_over_hundred_eighty = _mm_set_ps1(0.017453292519943295769236907684886f); - static const __m128 hundred_eighty_over_pi = _mm_set_ps1(57.295779513082320876798154814105f); + static const __m128 GLM_VAR_USED zero = _mm_setzero_ps(); + static const __m128 GLM_VAR_USED one = _mm_set_ps1(1.0f); + static const __m128 GLM_VAR_USED minus_one = _mm_set_ps1(-1.0f); + static const __m128 GLM_VAR_USED two = _mm_set_ps1(2.0f); + static const __m128 GLM_VAR_USED three = _mm_set_ps1(3.0f); + static const __m128 GLM_VAR_USED pi = _mm_set_ps1(3.1415926535897932384626433832795f); + static const __m128 GLM_VAR_USED hundred_eighty = _mm_set_ps1(180.f); + static const __m128 GLM_VAR_USED pi_over_hundred_eighty = _mm_set_ps1(0.017453292519943295769236907684886f); + static const __m128 GLM_VAR_USED hundred_eighty_over_pi = _mm_set_ps1(57.295779513082320876798154814105f); static const ieee754_QNAN absMask; - static const __m128 abs4Mask = _mm_set_ps1(absMask.f); + static const __m128 GLM_VAR_USED abs4Mask = _mm_set_ps1(absMask.f); - static const __m128 _epi32_sign_mask = _mm_castsi128_ps(_mm_set1_epi32(0x80000000)); - //static const __m128 _epi32_inv_sign_mask = _mm_castsi128_ps(_mm_set1_epi32(0x7FFFFFFF)); - //static const __m128 _epi32_mant_mask = _mm_castsi128_ps(_mm_set1_epi32(0x7F800000)); - //static const __m128 _epi32_inv_mant_mask = _mm_castsi128_ps(_mm_set1_epi32(0x807FFFFF)); - //static const __m128 _epi32_min_norm_pos = _mm_castsi128_ps(_mm_set1_epi32(0x00800000)); - static const __m128 _epi32_0 = _mm_set_ps1(0); - static const __m128 _epi32_1 = _mm_set_ps1(1); - static const __m128 _epi32_2 = _mm_set_ps1(2); - static const __m128 _epi32_3 = _mm_set_ps1(3); - static const __m128 _epi32_4 = _mm_set_ps1(4); - static const __m128 _epi32_5 = _mm_set_ps1(5); - static const __m128 _epi32_6 = _mm_set_ps1(6); - static const __m128 _epi32_7 = _mm_set_ps1(7); - static const __m128 _epi32_8 = _mm_set_ps1(8); - static const __m128 _epi32_9 = _mm_set_ps1(9); - static const __m128 _epi32_127 = _mm_set_ps1(127); - //static const __m128 _epi32_ninf = _mm_castsi128_ps(_mm_set1_epi32(0xFF800000)); - //static const __m128 _epi32_pinf = _mm_castsi128_ps(_mm_set1_epi32(0x7F800000)); + static const __m128 GLM_VAR_USED _epi32_sign_mask = _mm_castsi128_ps(_mm_set1_epi32(0x80000000)); + //static const __m128 GLM_VAR_USED _epi32_inv_sign_mask = _mm_castsi128_ps(_mm_set1_epi32(0x7FFFFFFF)); + //static const __m128 GLM_VAR_USED _epi32_mant_mask = _mm_castsi128_ps(_mm_set1_epi32(0x7F800000)); + //static const __m128 GLM_VAR_USED _epi32_inv_mant_mask = _mm_castsi128_ps(_mm_set1_epi32(0x807FFFFF)); + //static const __m128 GLM_VAR_USED _epi32_min_norm_pos = _mm_castsi128_ps(_mm_set1_epi32(0x00800000)); + static const __m128 GLM_VAR_USED _epi32_0 = _mm_set_ps1(0); + static const __m128 GLM_VAR_USED _epi32_1 = _mm_set_ps1(1); + static const __m128 GLM_VAR_USED _epi32_2 = _mm_set_ps1(2); + static const __m128 GLM_VAR_USED _epi32_3 = _mm_set_ps1(3); + static const __m128 GLM_VAR_USED _epi32_4 = _mm_set_ps1(4); + static const __m128 GLM_VAR_USED _epi32_5 = _mm_set_ps1(5); + static const __m128 GLM_VAR_USED _epi32_6 = _mm_set_ps1(6); + static const __m128 GLM_VAR_USED _epi32_7 = _mm_set_ps1(7); + static const __m128 GLM_VAR_USED _epi32_8 = _mm_set_ps1(8); + static const __m128 GLM_VAR_USED _epi32_9 = _mm_set_ps1(9); + static const __m128 GLM_VAR_USED _epi32_127 = _mm_set_ps1(127); + //static const __m128 GLM_VAR_USED _epi32_ninf = _mm_castsi128_ps(_mm_set1_epi32(0xFF800000)); + //static const __m128 GLM_VAR_USED _epi32_pinf = _mm_castsi128_ps(_mm_set1_epi32(0x7F800000)); - static const __m128 _ps_1_3 = _mm_set_ps1(0.33333333333333333333333333333333f); - static const __m128 _ps_0p5 = _mm_set_ps1(0.5f); - static const __m128 _ps_1 = _mm_set_ps1(1.0f); - static const __m128 _ps_m1 = _mm_set_ps1(-1.0f); - static const __m128 _ps_2 = _mm_set_ps1(2.0f); - static const __m128 _ps_3 = _mm_set_ps1(3.0f); - static const __m128 _ps_127 = _mm_set_ps1(127.0f); - static const __m128 _ps_255 = _mm_set_ps1(255.0f); - static const __m128 _ps_2pow23 = _mm_set_ps1(8388608.0f); + static const __m128 GLM_VAR_USED _ps_1_3 = _mm_set_ps1(0.33333333333333333333333333333333f); + static const __m128 GLM_VAR_USED _ps_0p5 = _mm_set_ps1(0.5f); + static const __m128 GLM_VAR_USED _ps_1 = _mm_set_ps1(1.0f); + static const __m128 GLM_VAR_USED _ps_m1 = _mm_set_ps1(-1.0f); + static const __m128 GLM_VAR_USED _ps_2 = _mm_set_ps1(2.0f); + static const __m128 GLM_VAR_USED _ps_3 = _mm_set_ps1(3.0f); + static const __m128 GLM_VAR_USED _ps_127 = _mm_set_ps1(127.0f); + static const __m128 GLM_VAR_USED _ps_255 = _mm_set_ps1(255.0f); + static const __m128 GLM_VAR_USED _ps_2pow23 = _mm_set_ps1(8388608.0f); - static const __m128 _ps_1_0_0_0 = _mm_set_ps(1.0f, 0.0f, 0.0f, 0.0f); - static const __m128 _ps_0_1_0_0 = _mm_set_ps(0.0f, 1.0f, 0.0f, 0.0f); - static const __m128 _ps_0_0_1_0 = _mm_set_ps(0.0f, 0.0f, 1.0f, 0.0f); - static const __m128 _ps_0_0_0_1 = _mm_set_ps(0.0f, 0.0f, 0.0f, 1.0f); + static const __m128 GLM_VAR_USED _ps_1_0_0_0 = _mm_set_ps(1.0f, 0.0f, 0.0f, 0.0f); + static const __m128 GLM_VAR_USED _ps_0_1_0_0 = _mm_set_ps(0.0f, 1.0f, 0.0f, 0.0f); + static const __m128 GLM_VAR_USED _ps_0_0_1_0 = _mm_set_ps(0.0f, 0.0f, 1.0f, 0.0f); + static const __m128 GLM_VAR_USED _ps_0_0_0_1 = _mm_set_ps(0.0f, 0.0f, 0.0f, 1.0f); - static const __m128 _ps_pi = _mm_set_ps1(3.1415926535897932384626433832795f); - static const __m128 _ps_pi2 = _mm_set_ps1(6.283185307179586476925286766560f); - static const __m128 _ps_2_pi = _mm_set_ps1(0.63661977236758134307553505349006f); - static const __m128 _ps_pi_2 = _mm_set_ps1(1.5707963267948966192313216916398f); - static const __m128 _ps_4_pi = _mm_set_ps1(1.2732395447351626861510701069801f); - static const __m128 _ps_pi_4 = _mm_set_ps1(0.78539816339744830961566084581988f); + static const __m128 GLM_VAR_USED _ps_pi = _mm_set_ps1(3.1415926535897932384626433832795f); + static const __m128 GLM_VAR_USED _ps_pi2 = _mm_set_ps1(6.283185307179586476925286766560f); + static const __m128 GLM_VAR_USED _ps_2_pi = _mm_set_ps1(0.63661977236758134307553505349006f); + static const __m128 GLM_VAR_USED _ps_pi_2 = _mm_set_ps1(1.5707963267948966192313216916398f); + static const __m128 GLM_VAR_USED _ps_4_pi = _mm_set_ps1(1.2732395447351626861510701069801f); + static const __m128 GLM_VAR_USED _ps_pi_4 = _mm_set_ps1(0.78539816339744830961566084581988f); - static const __m128 _ps_sincos_p0 = _mm_set_ps1(0.15707963267948963959e1f); - static const __m128 _ps_sincos_p1 = _mm_set_ps1(-0.64596409750621907082e0f); - static const __m128 _ps_sincos_p2 = _mm_set_ps1(0.7969262624561800806e-1f); - static const __m128 _ps_sincos_p3 = _mm_set_ps1(-0.468175413106023168e-2f); - static const __m128 _ps_tan_p0 = _mm_set_ps1(-1.79565251976484877988e7f); - static const __m128 _ps_tan_p1 = _mm_set_ps1(1.15351664838587416140e6f); - static const __m128 _ps_tan_p2 = _mm_set_ps1(-1.30936939181383777646e4f); - static const __m128 _ps_tan_q0 = _mm_set_ps1(-5.38695755929454629881e7f); - static const __m128 _ps_tan_q1 = _mm_set_ps1(2.50083801823357915839e7f); - static const __m128 _ps_tan_q2 = _mm_set_ps1(-1.32089234440210967447e6f); - static const __m128 _ps_tan_q3 = _mm_set_ps1(1.36812963470692954678e4f); - static const __m128 _ps_tan_poleval = _mm_set_ps1(3.68935e19f); - static const __m128 _ps_atan_t0 = _mm_set_ps1(-0.91646118527267623468e-1f); - static const __m128 _ps_atan_t1 = _mm_set_ps1(-0.13956945682312098640e1f); - static const __m128 _ps_atan_t2 = _mm_set_ps1(-0.94393926122725531747e2f); - static const __m128 _ps_atan_t3 = _mm_set_ps1(0.12888383034157279340e2f); - static const __m128 _ps_atan_s0 = _mm_set_ps1(0.12797564625607904396e1f); - static const __m128 _ps_atan_s1 = _mm_set_ps1(0.21972168858277355914e1f); - static const __m128 _ps_atan_s2 = _mm_set_ps1(0.68193064729268275701e1f); - static const __m128 _ps_atan_s3 = _mm_set_ps1(0.28205206687035841409e2f); + static const __m128 GLM_VAR_USED _ps_sincos_p0 = _mm_set_ps1(0.15707963267948963959e1f); + static const __m128 GLM_VAR_USED _ps_sincos_p1 = _mm_set_ps1(-0.64596409750621907082e0f); + static const __m128 GLM_VAR_USED _ps_sincos_p2 = _mm_set_ps1(0.7969262624561800806e-1f); + static const __m128 GLM_VAR_USED _ps_sincos_p3 = _mm_set_ps1(-0.468175413106023168e-2f); + static const __m128 GLM_VAR_USED _ps_tan_p0 = _mm_set_ps1(-1.79565251976484877988e7f); + static const __m128 GLM_VAR_USED _ps_tan_p1 = _mm_set_ps1(1.15351664838587416140e6f); + static const __m128 GLM_VAR_USED _ps_tan_p2 = _mm_set_ps1(-1.30936939181383777646e4f); + static const __m128 GLM_VAR_USED _ps_tan_q0 = _mm_set_ps1(-5.38695755929454629881e7f); + static const __m128 GLM_VAR_USED _ps_tan_q1 = _mm_set_ps1(2.50083801823357915839e7f); + static const __m128 GLM_VAR_USED _ps_tan_q2 = _mm_set_ps1(-1.32089234440210967447e6f); + static const __m128 GLM_VAR_USED _ps_tan_q3 = _mm_set_ps1(1.36812963470692954678e4f); + static const __m128 GLM_VAR_USED _ps_tan_poleval = _mm_set_ps1(3.68935e19f); + static const __m128 GLM_VAR_USED _ps_atan_t0 = _mm_set_ps1(-0.91646118527267623468e-1f); + static const __m128 GLM_VAR_USED _ps_atan_t1 = _mm_set_ps1(-0.13956945682312098640e1f); + static const __m128 GLM_VAR_USED _ps_atan_t2 = _mm_set_ps1(-0.94393926122725531747e2f); + static const __m128 GLM_VAR_USED _ps_atan_t3 = _mm_set_ps1(0.12888383034157279340e2f); + static const __m128 GLM_VAR_USED _ps_atan_s0 = _mm_set_ps1(0.12797564625607904396e1f); + static const __m128 GLM_VAR_USED _ps_atan_s1 = _mm_set_ps1(0.21972168858277355914e1f); + static const __m128 GLM_VAR_USED _ps_atan_s2 = _mm_set_ps1(0.68193064729268275701e1f); + static const __m128 GLM_VAR_USED _ps_atan_s3 = _mm_set_ps1(0.28205206687035841409e2f); - static const __m128 _ps_exp_hi = _mm_set_ps1(88.3762626647949f); - static const __m128 _ps_exp_lo = _mm_set_ps1(-88.3762626647949f); - static const __m128 _ps_exp_rln2 = _mm_set_ps1(1.4426950408889634073599f); - static const __m128 _ps_exp_p0 = _mm_set_ps1(1.26177193074810590878e-4f); - static const __m128 _ps_exp_p1 = _mm_set_ps1(3.02994407707441961300e-2f); - static const __m128 _ps_exp_q0 = _mm_set_ps1(3.00198505138664455042e-6f); - static const __m128 _ps_exp_q1 = _mm_set_ps1(2.52448340349684104192e-3f); - static const __m128 _ps_exp_q2 = _mm_set_ps1(2.27265548208155028766e-1f); - static const __m128 _ps_exp_q3 = _mm_set_ps1(2.00000000000000000009e0f); - static const __m128 _ps_exp_c1 = _mm_set_ps1(6.93145751953125e-1f); - static const __m128 _ps_exp_c2 = _mm_set_ps1(1.42860682030941723212e-6f); - static const __m128 _ps_exp2_hi = _mm_set_ps1(127.4999961853f); - static const __m128 _ps_exp2_lo = _mm_set_ps1(-127.4999961853f); - static const __m128 _ps_exp2_p0 = _mm_set_ps1(2.30933477057345225087e-2f); - static const __m128 _ps_exp2_p1 = _mm_set_ps1(2.02020656693165307700e1f); - static const __m128 _ps_exp2_p2 = _mm_set_ps1(1.51390680115615096133e3f); - static const __m128 _ps_exp2_q0 = _mm_set_ps1(2.33184211722314911771e2f); - static const __m128 _ps_exp2_q1 = _mm_set_ps1(4.36821166879210612817e3f); - static const __m128 _ps_log_p0 = _mm_set_ps1(-7.89580278884799154124e-1f); - static const __m128 _ps_log_p1 = _mm_set_ps1(1.63866645699558079767e1f); - static const __m128 _ps_log_p2 = _mm_set_ps1(-6.41409952958715622951e1f); - static const __m128 _ps_log_q0 = _mm_set_ps1(-3.56722798256324312549e1f); - static const __m128 _ps_log_q1 = _mm_set_ps1(3.12093766372244180303e2f); - static const __m128 _ps_log_q2 = _mm_set_ps1(-7.69691943550460008604e2f); - static const __m128 _ps_log_c0 = _mm_set_ps1(0.693147180559945f); - static const __m128 _ps_log2_c0 = _mm_set_ps1(1.44269504088896340735992f); + static const __m128 GLM_VAR_USED _ps_exp_hi = _mm_set_ps1(88.3762626647949f); + static const __m128 GLM_VAR_USED _ps_exp_lo = _mm_set_ps1(-88.3762626647949f); + static const __m128 GLM_VAR_USED _ps_exp_rln2 = _mm_set_ps1(1.4426950408889634073599f); + static const __m128 GLM_VAR_USED _ps_exp_p0 = _mm_set_ps1(1.26177193074810590878e-4f); + static const __m128 GLM_VAR_USED _ps_exp_p1 = _mm_set_ps1(3.02994407707441961300e-2f); + static const __m128 GLM_VAR_USED _ps_exp_q0 = _mm_set_ps1(3.00198505138664455042e-6f); + static const __m128 GLM_VAR_USED _ps_exp_q1 = _mm_set_ps1(2.52448340349684104192e-3f); + static const __m128 GLM_VAR_USED _ps_exp_q2 = _mm_set_ps1(2.27265548208155028766e-1f); + static const __m128 GLM_VAR_USED _ps_exp_q3 = _mm_set_ps1(2.00000000000000000009e0f); + static const __m128 GLM_VAR_USED _ps_exp_c1 = _mm_set_ps1(6.93145751953125e-1f); + static const __m128 GLM_VAR_USED _ps_exp_c2 = _mm_set_ps1(1.42860682030941723212e-6f); + static const __m128 GLM_VAR_USED _ps_exp2_hi = _mm_set_ps1(127.4999961853f); + static const __m128 GLM_VAR_USED _ps_exp2_lo = _mm_set_ps1(-127.4999961853f); + static const __m128 GLM_VAR_USED _ps_exp2_p0 = _mm_set_ps1(2.30933477057345225087e-2f); + static const __m128 GLM_VAR_USED _ps_exp2_p1 = _mm_set_ps1(2.02020656693165307700e1f); + static const __m128 GLM_VAR_USED _ps_exp2_p2 = _mm_set_ps1(1.51390680115615096133e3f); + static const __m128 GLM_VAR_USED _ps_exp2_q0 = _mm_set_ps1(2.33184211722314911771e2f); + static const __m128 GLM_VAR_USED _ps_exp2_q1 = _mm_set_ps1(4.36821166879210612817e3f); + static const __m128 GLM_VAR_USED _ps_log_p0 = _mm_set_ps1(-7.89580278884799154124e-1f); + static const __m128 GLM_VAR_USED _ps_log_p1 = _mm_set_ps1(1.63866645699558079767e1f); + static const __m128 GLM_VAR_USED _ps_log_p2 = _mm_set_ps1(-6.41409952958715622951e1f); + static const __m128 GLM_VAR_USED _ps_log_q0 = _mm_set_ps1(-3.56722798256324312549e1f); + static const __m128 GLM_VAR_USED _ps_log_q1 = _mm_set_ps1(3.12093766372244180303e2f); + static const __m128 GLM_VAR_USED _ps_log_q2 = _mm_set_ps1(-7.69691943550460008604e2f); + static const __m128 GLM_VAR_USED _ps_log_c0 = _mm_set_ps1(0.693147180559945f); + static const __m128 GLM_VAR_USED _ps_log2_c0 = _mm_set_ps1(1.44269504088896340735992f); GLM_FUNC_QUALIFIER __m128 sse_abs_ps(__m128 x) { @@ -252,14 +252,18 @@ GLM_FUNC_QUALIFIER __m128 sse_ssp_ps(__m128 edge0, __m128 edge1, __m128 x) return mul2; } +/// \todo GLM_FUNC_QUALIFIER __m128 sse_nan_ps(__m128 x) { - + __m128 empty; + return empty; } +/// \todo GLM_FUNC_QUALIFIER __m128 sse_inf_ps(__m128 x) { - + __m128 empty; + return empty; } // SSE scalar reciprocal sqrt using rsqrt op, plus one Newton-Rhaphson iteration diff --git a/glm/core/intrinsic_matrix.inl b/glm/core/intrinsic_matrix.inl index 1246a744..c3ec68a7 100644 --- a/glm/core/intrinsic_matrix.inl +++ b/glm/core/intrinsic_matrix.inl @@ -10,8 +10,8 @@ namespace glm{ namespace detail{ -static const __m128 _m128_rad_ps = _mm_set_ps1(3.141592653589793238462643383279f / 180.f); -static const __m128 _m128_deg_ps = _mm_set_ps1(180.f / 3.141592653589793238462643383279f); +static const __m128 GLM_VAR_USED _m128_rad_ps = _mm_set_ps1(3.141592653589793238462643383279f / 180.f); +static const __m128 GLM_VAR_USED _m128_deg_ps = _mm_set_ps1(180.f / 3.141592653589793238462643383279f); template GLM_FUNC_QUALIFIER matType sse_comp_mul_ps @@ -968,7 +968,7 @@ GLM_FUNC_QUALIFIER void sse_inverse_fast_ps(__m128 const in[4], __m128 out[4]) out[2] = _mm_mul_ps(Inv2, Rcp0); out[3] = _mm_mul_ps(Inv3, Rcp0); } - +/* GLM_FUNC_QUALIFIER void sse_rotate_ps(__m128 const in[4], float Angle, float const v[3], __m128 out[4]) { float a = glm::radians(Angle); @@ -1038,7 +1038,7 @@ GLM_FUNC_QUALIFIER void sse_rotate_ps(__m128 const in[4], float Angle, float con //return Result; sse_mul_ps(in, Result, out); } - +*/ GLM_FUNC_QUALIFIER void sse_outer_ps(__m128 const & c, __m128 const & r, __m128 out[4]) { out[0] = _mm_mul_ps(c, _mm_shuffle_ps(r, r, _MM_SHUFFLE(0, 0, 0, 0))); diff --git a/glm/core/setup.hpp b/glm/core/setup.hpp index 70ad1576..28a89b52 100644 --- a/glm/core/setup.hpp +++ b/glm/core/setup.hpp @@ -441,6 +441,12 @@ # define GLM_CUDA_FUNC_DECL #endif +#if GLM_COMPILER & GLM_COMPILER_GCC +#define GLM_VAR_USED __attribute__ ((unused)) +#else +#define GLM_VAR_USED +#endif + #if(defined(GLM_FORCE_INLINE)) # if((GLM_COMPILER & GLM_COMPILER_VC) && (GLM_COMPILER >= GLM_COMPILER_VC2005)) # define GLM_INLINE __forceinline From d373c85b676bf28e721f3b30fd3fb0b1ceadd0d2 Mon Sep 17 00:00:00 2001 From: Christophe Riccio Date: Wed, 1 Jun 2011 19:01:44 +0100 Subject: [PATCH 11/22] Updated documentation for 0.9.2.2 release --- doc/src/data.xml | 62 ++++++++++++++++++++++++++++++++++++++++-------- readme.txt | 23 +++++++++++------- 2 files changed, 67 insertions(+), 18 deletions(-) diff --git a/doc/src/data.xml b/doc/src/data.xml index e0ba3945..fdfaa64a 100644 --- a/doc/src/data.xml +++ b/doc/src/data.xml @@ -3,16 +3,17 @@
- - - - - - - - - - + + + + + + + + + + + @@ -64,6 +65,7 @@
+ @@ -152,6 +154,46 @@ + + + The main improvement of this version comes from the extented number of matrix contructors so that a programmer can used diffent scalar types for each parameter. + + + + #include + <glm/glm.hpp> + + + + + + // Create an identity matrix + + + glm::mat3 m( + + + 1, 0.0, 0, + + + 0.0, 1.0, 0.0f, + + + 0, 0.0, 1.0f); + + + + The quaternion implementation has been updated as well, fixing the various slerp implementation flavour (mix, shortMix and fastMix) and providing more completeness: Added interaction with GLM_GTX_epsilon and missing lowp_quat, mediump_quat and highp_quat but also none square matrix equivalents. + + + Finally, some efforts have been put to remove warnings across all supported compilers. + + + GLM 0.9.2.2 (zip) + GLM 0.9.2.2 (7z) + Submit a bug report + + GLM 0.9.2.1 significantly improves compiler detection which allows CUDA to be automatically recognized when GLM is used inside a CUDA kernel. diff --git a/readme.txt b/readme.txt index 50157d1a..33f5726a 100644 --- a/readme.txt +++ b/readme.txt @@ -37,7 +37,14 @@ More informations in GLM manual: http://glm.g-truc.net/glm-0.9.2.pdf ================================================================================ -GLM 0.9.2.1: 2010-05-24 +GLM 0.9.2.2: 2011-06-XX +-------------------------------------------------------------------------------- +- Expend matrix constructors flexibility +- Improved quaternion implementation +- Fixed many warnings across platforms and compilers + +================================================================================ +GLM 0.9.2.1: 2011-05-24 -------------------------------------------------------------------------------- - Automatically detect CUDA support - Improved compiler detection @@ -46,7 +53,7 @@ GLM 0.9.2.1: 2010-05-24 - Fixed and tested GLM_GTX_rotate_vector ================================================================================ -GLM 0.9.2.0: 2010-05-09 +GLM 0.9.2.0: 2011-05-09 -------------------------------------------------------------------------------- - Added CUDA support - Added CTest test suite @@ -56,27 +63,27 @@ GLM 0.9.2.0: 2010-05-09 - Updated quaternion slerp interpolation ================================================================================ -GLM 0.9.1.3: 2010-05-07 +GLM 0.9.1.3: 2011-05-07 -------------------------------------------------------------------------------- - Fixed bugs ================================================================================ -GLM 0.9.1.2: 2010-04-15 +GLM 0.9.1.2: 2011-04-15 -------------------------------------------------------------------------------- - Fixed bugs ================================================================================ -GLM 0.9.1.1: 2010-03-17 +GLM 0.9.1.1: 2011-03-17 -------------------------------------------------------------------------------- - Fixed bugs ================================================================================ -GLM 0.9.1.0: 2010-03-03 +GLM 0.9.1.0: 2011-03-03 -------------------------------------------------------------------------------- - Fixed bugs ================================================================================ -GLM 0.9.1.B: 2010-02-13 +GLM 0.9.1.B: 2011-02-13 -------------------------------------------------------------------------------- - Updated API documentation - Improved SIMD implementation @@ -89,7 +96,7 @@ GLM 0.9.0.8: 2011-02-13 - Clarify that GLM is a header only library. ================================================================================ -GLM 0.9.1.A: 2010-01-31 +GLM 0.9.1.A: 2011-01-31 -------------------------------------------------------------------------------- - Added SIMD support - Added new swizzle functions From f9dd517d0c08ab99b39be295d3775fcc50ad264b Mon Sep 17 00:00:00 2001 From: Christophe Riccio Date: Wed, 1 Jun 2011 20:17:23 +0100 Subject: [PATCH 12/22] Added implementation of missing matrix constructor --- glm/core/type_mat2x2.inl | 14 +++++------ glm/core/type_mat2x3.inl | 44 ++++++++++++++++++++++++++++++++++- glm/core/type_mat2x4.inl | 44 ++++++++++++++++++++++++++++++++++- glm/core/type_mat3x2.inl | 50 +++++++++++++++++++++++++++++++++++++++- glm/core/type_mat3x3.inl | 46 ++++++++++++++++++++++++++++++++++++ glm/core/type_mat3x4.inl | 46 ++++++++++++++++++++++++++++++++++++ glm/core/type_mat4x2.inl | 48 ++++++++++++++++++++++++++++++++++++++ 7 files changed, 282 insertions(+), 10 deletions(-) diff --git a/glm/core/type_mat2x2.inl b/glm/core/type_mat2x2.inl index 77638dbb..f7fced77 100644 --- a/glm/core/type_mat2x2.inl +++ b/glm/core/type_mat2x2.inl @@ -122,11 +122,11 @@ namespace detail } template - template + template GLM_FUNC_DECL tmat2x2::tmat2x2 ( - U const & x1, V const & y1, - M const & x2, N const & y2 + X1 const & x1, Y1 const & y1, + X2 const & x2, Y2 const & y2 ) { this->value[0] = col_type(value_type(x1), value_type(y1)); @@ -134,11 +134,11 @@ namespace detail } template - template + template GLM_FUNC_DECL tmat2x2::tmat2x2 ( - tvec2 const & v1, - tvec2 const & v2 + tvec2 const & v1, + tvec2 const & v2 ) { this->value[0] = col_type(v1); @@ -146,7 +146,7 @@ namespace detail } ////////////////////////////////////////////////////////////// - // mat2x2 conversions + // mat2x2 matrix conversions template template diff --git a/glm/core/type_mat2x3.inl b/glm/core/type_mat2x3.inl index 83e8b2e3..79d9c423 100644 --- a/glm/core/type_mat2x3.inl +++ b/glm/core/type_mat2x3.inl @@ -106,7 +106,49 @@ namespace detail this->value[1] = v1; } - // Conversion + ////////////////////////////////////// + // Convertion constructors + template + template + GLM_FUNC_DECL tmat2x3::tmat2x3 + ( + U const & s + ) + { + value_type const Zero(0); + this->value[0] = tvec3(value_type(s), Zero, Zero); + this->value[1] = tvec3(Zero, value_type(s), Zero); + } + + template + template < + typename X1, typename Y1, typename Z1, + typename X2, typename Y2, typename Z2> + GLM_FUNC_DECL tmat2x3::tmat2x3 + ( + X1 const & x1, Y1 const & y1, Z1 const & z1, + X2 const & x2, Y2 const & y2, Z2 const & z2 + ) + { + this->value[0] = col_type(value_type(x1), value_type(y1), value_type(z1)); + this->value[1] = col_type(value_type(x2), value_type(y2), value_type(z2)); + } + + template + template + GLM_FUNC_DECL tmat2x3::tmat2x3 + ( + tvec3 const & v1, + tvec3 const & v2 + ) + { + this->value[0] = col_type(v1); + this->value[1] = col_type(v2); + } + + ////////////////////////////////////// + // Matrix conversions + template template GLM_FUNC_QUALIFIER tmat2x3::tmat2x3 diff --git a/glm/core/type_mat2x4.inl b/glm/core/type_mat2x4.inl index b19193f6..0a644d99 100644 --- a/glm/core/type_mat2x4.inl +++ b/glm/core/type_mat2x4.inl @@ -109,7 +109,49 @@ namespace detail this->value[1] = v1; } - // Conversion + ////////////////////////////////////// + // Convertion constructors + template + template + GLM_FUNC_DECL tmat2x4::tmat2x4 + ( + U const & s + ) + { + value_type const Zero(0); + this->value[0] = tvec4(value_type(s), Zero, Zero, Zero); + this->value[1] = tvec4(Zero, value_type(s), Zero, Zero); + } + + template + template < + typename X1, typename Y1, typename Z1, typename W1 + typename X2, typename Y2, typename Z2, typename W2> + GLM_FUNC_DECL tmat2x4::tmat2x4 + ( + X1 const & x1, Y1 const & y1, Z1 const & z1, W1 const & w1, + X2 const & x2, Y2 const & y2, Z2 const & z2, W2 const & w2, + ) + { + this->value[0] = col_type(value_type(x1), value_type(y1), value_type(z1), value_type(w1)); + this->value[1] = col_type(value_type(x2), value_type(y2), value_type(z2), value_type(w2)); + } + + template + template + GLM_FUNC_DECL tmat2x4::tmat2x4 + ( + tvec4 const & v1, + tvec4 const & v2 + ) + { + this->value[0] = col_type(v1); + this->value[1] = col_type(v2); + } + + ////////////////////////////////////// + // Matrix conversions + template template GLM_FUNC_QUALIFIER tmat2x4::tmat2x4 diff --git a/glm/core/type_mat3x2.inl b/glm/core/type_mat3x2.inl index 5fddb4c1..4138208f 100644 --- a/glm/core/type_mat3x2.inl +++ b/glm/core/type_mat3x2.inl @@ -113,7 +113,55 @@ namespace detail this->value[2] = v2; } - // Conversion + ////////////////////////////////////// + // Convertion constructors + template + template + GLM_FUNC_DECL tmat3x2::tmat3x2 + ( + U const & s + ) + { + value_type const Zero(0); + this->value[0] = tvec2(value_type(s), Zero); + this->value[1] = tvec2(Zero, value_type(s)); + this->value[2] = tvec2(Zero); + } + + template + template < + typename X1, typename Y1, + typename X2, typename Y2, + typename X3, typename Y3> + GLM_FUNC_DECL tmat3x2::tmat3x2 + ( + X1 const & x1, Y1 const & y1, + X2 const & x2, Y2 const & y2, + X3 const & x3, Y3 const & y3 + ) + { + this->value[0] = col_type(value_type(x1), value_type(y1)); + this->value[1] = col_type(value_type(x2), value_type(y2)); + this->value[2] = col_type(value_type(x3), value_type(y3)); + } + + template + template + GLM_FUNC_DECL tmat3x2::tmat3x2 + ( + tvec2 const & v1, + tvec2 const & v2, + tvec2 const & v3 + ) + { + this->value[0] = col_type(v1); + this->value[1] = col_type(v2); + this->value[2] = col_type(v3); + } + + ////////////////////////////////////////////////////////////// + // mat3x2 matrix conversions + template template GLM_FUNC_QUALIFIER tmat3x2::tmat3x2 diff --git a/glm/core/type_mat3x3.inl b/glm/core/type_mat3x3.inl index 667f2235..3aeeaeb9 100644 --- a/glm/core/type_mat3x3.inl +++ b/glm/core/type_mat3x3.inl @@ -116,6 +116,52 @@ namespace detail this->value[2] = v2; } + ////////////////////////////////////// + // Convertion constructors + template + template + GLM_FUNC_DECL tmat3x3::tmat3x3 + ( + U const & s + ) + { + value_type const Zero(0); + this->value[0] = tvec3(value_type(s), Zero, Zero); + this->value[1] = tvec3(Zero, value_type(s), Zero); + this->value[2] = tvec3(Zero, Zero, value_type(s)); + } + + template + template < + typename X1, typename Y1, typename Z1, + typename X2, typename Y2, typename Z2, + typename X3, typename Y3, typename Z3> + GLM_FUNC_DECL tmat3x3::tmat3x3 + ( + X1 const & x1, Y1 const & y1, Z1 const & z1, + X2 const & x2, Y2 const & y2, Z2 const & z2, + X3 const & x3, Y3 const & y3, Z3 const & z3 + ) + { + this->value[0] = col_type(value_type(x1), value_type(y1), value_type(z1)); + this->value[1] = col_type(value_type(x2), value_type(y2), value_type(z2)); + this->value[2] = col_type(value_type(x3), value_type(y3), value_type(z3)); + } + + template + template + GLM_FUNC_DECL tmat3x3::tmat3x3 + ( + tvec3 const & v1, + tvec3 const & v2, + tvec3 const & v3 + ) + { + this->value[0] = col_type(v1); + this->value[1] = col_type(v2); + this->value[2] = col_type(v3); + } + ////////////////////////////////////////////////////////////// // Conversions diff --git a/glm/core/type_mat3x4.inl b/glm/core/type_mat3x4.inl index 1a0b8499..8502dacd 100644 --- a/glm/core/type_mat3x4.inl +++ b/glm/core/type_mat3x4.inl @@ -114,6 +114,52 @@ namespace detail this->value[2] = v2; } + ////////////////////////////////////// + // Convertion constructors + template + template + GLM_FUNC_DECL tmat3x4::tmat3x4 + ( + U const & s + ) + { + value_type const Zero(0); + this->value[0] = tvec4(value_type(s), Zero, Zero, Zero); + this->value[1] = tvec4(Zero, value_type(s), Zero, Zero); + this->value[2] = tvec4(Zero, Zero, value_type(s), Zero); + } + + template + template < + typename X1, typename Y1, typename Z1, typename W1, + typename X2, typename Y2, typename Z2, typename W2, + typename X3, typename Y3, typename Z3, typename W3> + GLM_FUNC_DECL tmat3x4::tmat3x4 + ( + X1 const & x1, Y1 const & y1, Z1 const & z1, W1 const & w1, + X2 const & x2, Y2 const & y2, Z2 const & z2, W2 const & w2, + X3 const & x3, Y3 const & y3, Z3 const & z3, W3 const & w3 + ) + { + this->value[0] = col_type(value_type(x1), value_type(y1), value_type(z1), value_type(w1)); + this->value[1] = col_type(value_type(x2), value_type(y2), value_type(z2), value_type(w2)); + this->value[2] = col_type(value_type(x3), value_type(y3), value_type(z3), value_type(w3)); + } + + template + template + GLM_FUNC_DECL tmat3x4::tmat3x4 + ( + tvec4 const & v1, + tvec4 const & v2, + tvec4 const & v3 + ) + { + this->value[0] = col_type(v1); + this->value[1] = col_type(v2); + this->value[2] = col_type(v3); + } + // Conversion template template diff --git a/glm/core/type_mat4x2.inl b/glm/core/type_mat4x2.inl index cb30a98c..60c54df9 100644 --- a/glm/core/type_mat4x2.inl +++ b/glm/core/type_mat4x2.inl @@ -123,6 +123,54 @@ namespace detail this->value[3] = v3; } + ////////////////////////////////////// + // Convertion constructors + template + template + GLM_FUNC_DECL tmat4x2::tmat4x2 + ( + U const & s + ) + { + value_type const Zero(0); + this->value[0] = tvec4(value_type(s), Zero); + this->value[1] = tvec4(Zero, value_type(s)); + this->value[2] = tvec4(Zero, Zero); + this->value[3] = tvec4(Zero, Zero); + } + + template + template < + typename X1, typename Y1, + typename X2, typename Y2, + typename X3, typename Y3, + typename X4, typename Y4> + GLM_FUNC_DECL tmat4x2::tmat4x2 + ( + X1 const & x1, Y1 const & y1, Z1 const & z1, W1 const & w1, + X2 const & x2, Y2 const & y2, Z2 const & z2, W2 const & w2, + X3 const & x3, Y3 const & y3, Z3 const & z3, W3 const & w3 + ) + { + this->value[0] = col_type(value_type(x1), value_type(y1), value_type(z1), value_type(w1)); + this->value[1] = col_type(value_type(x2), value_type(y2), value_type(z2), value_type(w2)); + this->value[2] = col_type(value_type(x3), value_type(y3), value_type(z3), value_type(w3)); + } + + template + template + GLM_FUNC_DECL tmat4x2::tmat4x2 + ( + tvec4 const & v1, + tvec4 const & v2, + tvec4 const & v3 + ) + { + this->value[0] = col_type(v1); + this->value[1] = col_type(v2); + this->value[2] = col_type(v3); + } + // Conversion template template From a0256b5946cd5ebfa3c9762bc7f55f8c6a0845f1 Mon Sep 17 00:00:00 2001 From: Christophe Riccio Date: Thu, 2 Jun 2011 09:58:20 +0100 Subject: [PATCH 13/22] Fixed build on Visual C++, completed extended matrix cast #105 --- glm/core/intrinsic_common.inl | 12 +----- glm/core/type_mat2x4.hpp | 8 ++-- glm/core/type_mat2x4.inl | 4 +- glm/core/type_mat3x2.inl | 2 +- glm/core/type_mat4x2.inl | 32 ++++++++------ glm/core/type_mat4x3.inl | 54 ++++++++++++++++++++++- glm/core/type_mat4x4.hpp | 8 ++-- glm/core/type_mat4x4.inl | 81 +++++++++++++++++++++++++++++++++++ 8 files changed, 164 insertions(+), 37 deletions(-) diff --git a/glm/core/intrinsic_common.inl b/glm/core/intrinsic_common.inl index b4cccd35..8080bb35 100644 --- a/glm/core/intrinsic_common.inl +++ b/glm/core/intrinsic_common.inl @@ -205,19 +205,11 @@ GLM_FUNC_QUALIFIER __m128 sse_mod_ps(__m128 x, __m128 y) } /// TODO -<<<<<<< HEAD -/* GLM_FUNC_QUALIFIER __m128 sse_modf_ps(__m128 x, __m128i & i) { - return __m128(); + __m128 empty; + return empty; } -*/ -======= -//GLM_FUNC_QUALIFIER __m128 sse_modf_ps(__m128 x, __m128i & i) -//{ -// return __m128(); -//} ->>>>>>> d373c85b676bf28e721f3b30fd3fb0b1ceadd0d2 //GLM_FUNC_QUALIFIER __m128 _mm_min_ps(__m128 x, __m128 y) diff --git a/glm/core/type_mat2x4.hpp b/glm/core/type_mat2x4.hpp index 8eee4105..cf21c6f8 100644 --- a/glm/core/type_mat2x4.hpp +++ b/glm/core/type_mat2x4.hpp @@ -77,14 +77,12 @@ namespace glm GLM_FUNC_DECL explicit tmat2x4( U const & x); - template - < + template < typename X1, typename Y1, typename Z1, typename W1, - typename X2, typename Y2, typename Z2, typename W2 - > + typename X2, typename Y2, typename Z2, typename W2> GLM_FUNC_DECL explicit tmat2x4( X1 const & x1, Y1 const & y1, Z1 const & z1, W1 const & w1, - X2 const & x2, Y2 const & y2, Z2 const & z2, W2 const & w2,); + X2 const & x2, Y2 const & y2, Z2 const & z2, W2 const & w2); template GLM_FUNC_DECL explicit tmat2x4( diff --git a/glm/core/type_mat2x4.inl b/glm/core/type_mat2x4.inl index 0a644d99..2c12df43 100644 --- a/glm/core/type_mat2x4.inl +++ b/glm/core/type_mat2x4.inl @@ -125,12 +125,12 @@ namespace detail template template < - typename X1, typename Y1, typename Z1, typename W1 + typename X1, typename Y1, typename Z1, typename W1, typename X2, typename Y2, typename Z2, typename W2> GLM_FUNC_DECL tmat2x4::tmat2x4 ( X1 const & x1, Y1 const & y1, Z1 const & z1, W1 const & w1, - X2 const & x2, Y2 const & y2, Z2 const & z2, W2 const & w2, + X2 const & x2, Y2 const & y2, Z2 const & z2, W2 const & w2 ) { this->value[0] = col_type(value_type(x1), value_type(y1), value_type(z1), value_type(w1)); diff --git a/glm/core/type_mat3x2.inl b/glm/core/type_mat3x2.inl index 4138208f..1c45e58a 100644 --- a/glm/core/type_mat3x2.inl +++ b/glm/core/type_mat3x2.inl @@ -146,7 +146,7 @@ namespace detail } template - template + template GLM_FUNC_DECL tmat3x2::tmat3x2 ( tvec2 const & v1, diff --git a/glm/core/type_mat4x2.inl b/glm/core/type_mat4x2.inl index 60c54df9..4cd8b063 100644 --- a/glm/core/type_mat4x2.inl +++ b/glm/core/type_mat4x2.inl @@ -133,10 +133,10 @@ namespace detail ) { value_type const Zero(0); - this->value[0] = tvec4(value_type(s), Zero); - this->value[1] = tvec4(Zero, value_type(s)); - this->value[2] = tvec4(Zero, Zero); - this->value[3] = tvec4(Zero, Zero); + this->value[0] = tvec2(value_type(s), Zero); + this->value[1] = tvec2(Zero, value_type(s)); + this->value[2] = tvec2(Zero, Zero); + this->value[3] = tvec2(Zero, Zero); } template @@ -147,28 +147,32 @@ namespace detail typename X4, typename Y4> GLM_FUNC_DECL tmat4x2::tmat4x2 ( - X1 const & x1, Y1 const & y1, Z1 const & z1, W1 const & w1, - X2 const & x2, Y2 const & y2, Z2 const & z2, W2 const & w2, - X3 const & x3, Y3 const & y3, Z3 const & z3, W3 const & w3 + X1 const & x1, Y1 const & y1, + X2 const & x2, Y2 const & y2, + X3 const & x3, Y3 const & y3, + X4 const & x4, Y4 const & y4 ) { - this->value[0] = col_type(value_type(x1), value_type(y1), value_type(z1), value_type(w1)); - this->value[1] = col_type(value_type(x2), value_type(y2), value_type(z2), value_type(w2)); - this->value[2] = col_type(value_type(x3), value_type(y3), value_type(z3), value_type(w3)); + this->value[0] = col_type(value_type(x1), value_type(y1)); + this->value[1] = col_type(value_type(x2), value_type(y2)); + this->value[2] = col_type(value_type(x3), value_type(y3)); + this->value[3] = col_type(value_type(x4), value_type(y4)); } template - template + template GLM_FUNC_DECL tmat4x2::tmat4x2 ( - tvec4 const & v1, - tvec4 const & v2, - tvec4 const & v3 + tvec2 const & v1, + tvec2 const & v2, + tvec2 const & v3, + tvec2 const & v4 ) { this->value[0] = col_type(v1); this->value[1] = col_type(v2); this->value[2] = col_type(v3); + this->value[3] = col_type(v4); } // Conversion diff --git a/glm/core/type_mat4x3.inl b/glm/core/type_mat4x3.inl index b882af27..87e3dcea 100644 --- a/glm/core/type_mat4x3.inl +++ b/glm/core/type_mat4x3.inl @@ -123,8 +123,60 @@ namespace detail this->value[3] = v3; } + ////////////////////////////////////// + // Convertion constructors + template + template + GLM_FUNC_DECL tmat4x3::tmat4x3 + ( + U const & s + ) + { + value_type const Zero(0); + this->value[0] = tvec3(value_type(s), Zero, Zero); + this->value[1] = tvec3(Zero, value_type(s), Zero); + this->value[2] = tvec3(Zero, Zero, value_type(s)); + this->value[3] = tvec3(Zero, Zero, Zero); + } + + template + template < + typename X1, typename Y1, typename Z1, + typename X2, typename Y2, typename Z2, + typename X3, typename Y3, typename Z3, + typename X4, typename Y4, typename Z4> + GLM_FUNC_DECL tmat4x3::tmat4x3 + ( + X1 const & x1, Y1 const & y1, Z1 const & z1, + X2 const & x2, Y2 const & y2, Z2 const & z2, + X3 const & x3, Y3 const & y3, Z3 const & z3, + X4 const & x4, Y4 const & y4, Z4 const & z4 + ) + { + this->value[0] = col_type(value_type(x1), value_type(y1), value_type(z1)); + this->value[1] = col_type(value_type(x2), value_type(y2), value_type(z2)); + this->value[2] = col_type(value_type(x3), value_type(y3), value_type(z3)); + this->value[3] = col_type(value_type(x4), value_type(y4), value_type(z4)); + } + + template + template + GLM_FUNC_DECL tmat4x3::tmat4x3 + ( + tvec3 const & v1, + tvec3 const & v2, + tvec3 const & v3, + tvec3 const & v4 + ) + { + this->value[0] = col_type(v1); + this->value[1] = col_type(v2); + this->value[2] = col_type(v3); + this->value[3] = col_type(v4); + } + ////////////////////////////////////////////////////////////// - // Conversions + // Matrix conversions template template diff --git a/glm/core/type_mat4x4.hpp b/glm/core/type_mat4x4.hpp index a470f34a..4ff29db9 100644 --- a/glm/core/type_mat4x4.hpp +++ b/glm/core/type_mat4x4.hpp @@ -86,10 +86,10 @@ namespace glm U const & x); template < - typename X1, typename Y1, typename Z1, - typename X2, typename Y2, typename Z2, - typename X3, typename Y3, typename Z3, - typename X4, typename Y4, typename Z4> + typename X1, typename Y1, typename Z1, typename W1, + typename X2, typename Y2, typename Z2, typename W2, + typename X3, typename Y3, typename Z3, typename W3, + typename X4, typename Y4, typename Z4, typename W4> GLM_FUNC_DECL explicit tmat4x4( X1 const & x1, Y1 const & y1, Z1 const & z1, W1 const & w1, X2 const & x2, Y2 const & y2, Z2 const & z2, W2 const & w2, diff --git a/glm/core/type_mat4x4.inl b/glm/core/type_mat4x4.inl index 8df4b062..765491b7 100644 --- a/glm/core/type_mat4x4.inl +++ b/glm/core/type_mat4x4.inl @@ -136,6 +136,87 @@ namespace detail this->value[3] = col_type(m[3]); } + ////////////////////////////////////// + // Convertion constructors + template + template + GLM_FUNC_DECL tmat4x4::tmat4x4 + ( + U const & s + ) + { + GLM_STATIC_ASSERT(detail::type::is_float || std::numeric_limits::is_integer, "*mat4x4 constructor only takes float and integer types"); + + value_type const Zero(0); + this->value[0] = tvec4(value_type(s), Zero, Zero, Zero); + this->value[1] = tvec4(Zero, value_type(s), Zero, Zero); + this->value[2] = tvec4(Zero, Zero, value_type(s), Zero); + this->value[3] = tvec4(Zero, Zero, Zero, value_type(s)); + } + + template + template < + typename X1, typename Y1, typename Z1, typename W1, + typename X2, typename Y2, typename Z2, typename W2, + typename X3, typename Y3, typename Z3, typename W3, + typename X4, typename Y4, typename Z4, typename W4> + GLM_FUNC_DECL tmat4x4::tmat4x4 + ( + X1 const & x1, Y1 const & y1, Z1 const & z1, W1 const & w1, + 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 + ) + { + GLM_STATIC_ASSERT(detail::type::is_float || std::numeric_limits::is_integer, "*mat4x4 constructor only takes float and integer types, 1st parameter type invalid."); + GLM_STATIC_ASSERT(detail::type::is_float || std::numeric_limits::is_integer, "*mat4x4 constructor only takes float and integer types, 2nd parameter type invalid."); + GLM_STATIC_ASSERT(detail::type::is_float || std::numeric_limits::is_integer, "*mat4x4 constructor only takes float and integer types, 3rd parameter type invalid."); + GLM_STATIC_ASSERT(detail::type::is_float || std::numeric_limits::is_integer, "*mat4x4 constructor only takes float and integer types, 4th parameter type invalid."); + + GLM_STATIC_ASSERT(detail::type::is_float || std::numeric_limits::is_integer, "*mat4x4 constructor only takes float and integer types, 5th parameter type invalid."); + GLM_STATIC_ASSERT(detail::type::is_float || std::numeric_limits::is_integer, "*mat4x4 constructor only takes float and integer types, 6th parameter type invalid."); + GLM_STATIC_ASSERT(detail::type::is_float || std::numeric_limits::is_integer, "*mat4x4 constructor only takes float and integer types, 7th parameter type invalid."); + GLM_STATIC_ASSERT(detail::type::is_float || std::numeric_limits::is_integer, "*mat4x4 constructor only takes float and integer types, 8th parameter type invalid."); + + GLM_STATIC_ASSERT(detail::type::is_float || std::numeric_limits::is_integer, "*mat4x4 constructor only takes float and integer types, 9th parameter type invalid."); + GLM_STATIC_ASSERT(detail::type::is_float || std::numeric_limits::is_integer, "*mat4x4 constructor only takes float and integer types, 10th parameter type invalid."); + GLM_STATIC_ASSERT(detail::type::is_float || std::numeric_limits::is_integer, "*mat4x4 constructor only takes float and integer types, 11th parameter type invalid."); + GLM_STATIC_ASSERT(detail::type::is_float || std::numeric_limits::is_integer, "*mat4x4 constructor only takes float and integer types, 12th parameter type invalid."); + + GLM_STATIC_ASSERT(detail::type::is_float || std::numeric_limits::is_integer, "*mat4x4 constructor only takes float and integer types, 13th parameter type invalid."); + GLM_STATIC_ASSERT(detail::type::is_float || std::numeric_limits::is_integer, "*mat4x4 constructor only takes float and integer types, 14th parameter type invalid."); + GLM_STATIC_ASSERT(detail::type::is_float || std::numeric_limits::is_integer, "*mat4x4 constructor only takes float and integer types, 15th parameter type invalid."); + GLM_STATIC_ASSERT(detail::type::is_float || std::numeric_limits::is_integer, "*mat4x4 constructor only takes float and integer types, 16th parameter type invalid."); + + this->value[0] = col_type(value_type(x1), value_type(y1), value_type(z1), value_type(w1)); + this->value[1] = col_type(value_type(x2), value_type(y2), value_type(z2), value_type(w2)); + this->value[2] = col_type(value_type(x3), value_type(y3), value_type(z3), value_type(w3)); + this->value[3] = col_type(value_type(x4), value_type(y4), value_type(z4), value_type(w4)); + } + + template + template + GLM_FUNC_DECL tmat4x4::tmat4x4 + ( + tvec4 const & v1, + tvec4 const & v2, + tvec4 const & v3, + tvec4 const & v4 + ) + { + GLM_STATIC_ASSERT(detail::type::is_float || std::numeric_limits::is_integer, "*mat4x4 constructor only takes float and integer types, 1st parameter type invalid."); + GLM_STATIC_ASSERT(detail::type::is_float || std::numeric_limits::is_integer, "*mat4x4 constructor only takes float and integer types, 2nd parameter type invalid."); + GLM_STATIC_ASSERT(detail::type::is_float || std::numeric_limits::is_integer, "*mat4x4 constructor only takes float and integer types, 3rd parameter type invalid."); + GLM_STATIC_ASSERT(detail::type::is_float || std::numeric_limits::is_integer, "*mat4x4 constructor only takes float and integer types, 4th parameter type invalid."); + + this->value[0] = col_type(v1); + this->value[1] = col_type(v2); + this->value[2] = col_type(v3); + this->value[3] = col_type(v4); + } + + ////////////////////////////////////// + // Matrix convertion constructors template GLM_FUNC_QUALIFIER tmat4x4::tmat4x4 ( From 40f3e519a80e6d2ab27afc80c00c2182880f7a30 Mon Sep 17 00:00:00 2001 From: Christophe Riccio Date: Thu, 2 Jun 2011 10:08:44 +0100 Subject: [PATCH 14/22] Fixed build on MinGW --- glm/gtx/quaternion.inl | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/glm/gtx/quaternion.inl b/glm/gtx/quaternion.inl index b63e6c0f..910cdd78 100644 --- a/glm/gtx/quaternion.inl +++ b/glm/gtx/quaternion.inl @@ -256,28 +256,28 @@ namespace quaternion if(a <= typename detail::tquat::value_type(0)) return x; if(a >= typename detail::tquat::value_type(1)) return y; - detail::tquat::value_type fCos = dot(x, y); + T fCos = dot(x, y); detail::tquat y2(y); //BUG!!! tquat y2; - if(fCos < typename detail::tquat::value_type(0)) + if(fCos < T(0)) { y2 = -y; fCos = -fCos; } //if(fCos > 1.0f) // problem - detail::tquat::value_type k0, k1; - if(fCos > typename detail::tquat::value_type(0.9999)) + T k0, k1; + if(fCos > T(0.9999)) { - k0 = typename detail::tquat::value_type(1) - a; - k1 = typename detail::tquat::value_type(0) + a; //BUG!!! 1.0f + a; + k0 = T(1) - a; + k1 = T(0) + a; //BUG!!! 1.0f + a; } else { - typename detail::tquat::value_type fSin = sqrt(T(1) - fCos * fCos); - typename detail::tquat::value_type fAngle = atan(fSin, fCos); - typename detail::tquat::value_type fOneOverSin = T(1) / fSin; - k0 = sin((typename detail::tquat::value_type(1) - a) * fAngle) * fOneOverSin; - k1 = sin((typename detail::tquat::value_type(0) + a) * fAngle) * fOneOverSin; + T fSin = sqrt(T(1) - fCos * fCos); + T fAngle = atan(fSin, fCos); + T fOneOverSin = T(1) / fSin; + k0 = sin((T(1) - a) * fAngle) * fOneOverSin; + k1 = sin((T(0) + a) * fAngle) * fOneOverSin; } return detail::tquat( @@ -295,7 +295,7 @@ namespace quaternion T const & a ) { - return glm::normalize(x * (detail::tquat::value_type(1) - a) + (y * a)); + return glm::normalize(x * (T(1) - a) + (y * a)); } }//namespace quaternion From b1b8b18256cf38a710b736acbbbdb22fa0a49dce Mon Sep 17 00:00:00 2001 From: Christophe Riccio Date: Thu, 2 Jun 2011 10:47:25 +0100 Subject: [PATCH 15/22] Added doc for GLM 0.9.2.2 release --- doc/about.html | 4 +- doc/code.html | 4 +- doc/download.html | 30 ++++++------ doc/glm-0.9.2.pdf | Bin 362163 -> 363472 bytes doc/goodies.html | 4 +- doc/index.html | 116 ++++++++++++++++++++++++++-------------------- doc/src/data.xml | 10 ++-- doc/src/news.xsl | 5 +- doc/src/util.xsl | 30 ++++++------ 9 files changed, 109 insertions(+), 94 deletions(-) diff --git a/doc/about.html b/doc/about.html index 3ba3953d..126961e9 100644 --- a/doc/about.html +++ b/doc/about.html @@ -11,8 +11,8 @@ ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js'; var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s); })(); -
OpenGL Mathematics
GLSL + Optional features = OpenGL Mathematics (GLM)
A C++ mathematics library for graphics programming


+
OpenGL Mathematics
GLSL + Optional features = OpenGL Mathematics (GLM)
A C++ mathematics library for graphics programming


OpenGL Mathematics (GLM) is a header only C++ mathematics library for graphics software based on the OpenGL Shading Language (GLSL) specification.

diff --git a/doc/code.html b/doc/code.html index 5a742173..bd08be2e 100644 --- a/doc/code.html +++ b/doc/code.html @@ -11,8 +11,8 @@ ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js'; var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s); })(); -
OpenGL Mathematics
GLSL + Optional features = OpenGL Mathematics (GLM)
A C++ mathematics library for graphics programming


Compute a triangle normal: