From 79f6d92c8ae9e4f430a47da21ef333aaa0f8278f Mon Sep 17 00:00:00 2001 From: Christophe R Date: Sun, 9 Aug 2015 10:50:29 +0200 Subject: [PATCH 01/94] Added GLM_SIMD to enable automatic SIMD code generation for generic GLM types #235 #370 --- glm/detail/type_vec4.hpp | 6 ++++-- glm/detail/type_vec4.inl | 2 +- readme.md | 4 ++++ test/core/core_type_mat4x4.cpp | 1 + 4 files changed, 10 insertions(+), 3 deletions(-) diff --git a/glm/detail/type_vec4.hpp b/glm/detail/type_vec4.hpp index c2d9f60e..94583f1f 100644 --- a/glm/detail/type_vec4.hpp +++ b/glm/detail/type_vec4.hpp @@ -114,14 +114,16 @@ namespace detail // -- Data -- -# if GLM_HAS_ANONYMOUS_UNION +# if GLM_HAS_ANONYMOUS_UNION && GLM_NOT_BUGGY_VC32BITS union { struct { T x, y, z, w;}; struct { T r, g, b, a; }; struct { T s, t, p, q; }; - typename detail::simd::type data; +# ifdef GLM_SIMD + typename detail::simd::type data; +# endif # ifdef GLM_SWIZZLE _GLM_SWIZZLE4_2_MEMBERS(T, P, tvec2, x, y, z, w) diff --git a/glm/detail/type_vec4.inl b/glm/detail/type_vec4.inl index 7518748e..27391693 100644 --- a/glm/detail/type_vec4.inl +++ b/glm/detail/type_vec4.inl @@ -1104,7 +1104,7 @@ namespace glm } }//namespace glm -#if GLM_HAS_ANONYMOUS_UNION && GLM_NOT_BUGGY_VC32BITS +#if GLM_HAS_ANONYMOUS_UNION && defined(GLM_SIMD) && GLM_NOT_BUGGY_VC32BITS #if GLM_ARCH & GLM_ARCH_SSE2 # include "type_vec4_sse2.inl" #endif diff --git a/readme.md b/readme.md index fe0a37f8..d899dd8c 100644 --- a/readme.md +++ b/readme.md @@ -50,6 +50,10 @@ glm::mat4 camera(float Translate, glm::vec2 const & Rotate) ## Release notes +#### [GLM 0.9.7.1](https://github.com/g-truc/glm/releases/latest) - 2015-XX-XX +##### Features: +- Added GLM_SIMD to enable automatic SIMD code generation for generic GLM types #235 #370 + #### [GLM 0.9.7.0](https://github.com/g-truc/glm/releases/tag/0.9.7.0) - 2015-08-02 ##### Features: - Added GTC_color_space: convertLinearToSRGB and convertSRGBToLinear functions diff --git a/test/core/core_type_mat4x4.cpp b/test/core/core_type_mat4x4.cpp index 9e16c53d..6b7b36e3 100644 --- a/test/core/core_type_mat4x4.cpp +++ b/test/core/core_type_mat4x4.cpp @@ -29,6 +29,7 @@ /// @author Christophe Riccio /////////////////////////////////////////////////////////////////////////////////// +#define GLM_SIMD #include #include #include From 6f128f598336a1395a8951e280e1301fcb862c39 Mon Sep 17 00:00:00 2001 From: Bryce Mehring Date: Wed, 12 Aug 2015 22:44:32 -0500 Subject: [PATCH 02/94] Fixed C++11 standard library error message When including glm/gtx/hash.hpp before any other glm header files, the error "GLM_GTX_hash requires C++11 standard library support" is thrown because GLM_HAS_CXX11_STL is not yet defined. --- glm/gtx/hash.hpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/glm/gtx/hash.hpp b/glm/gtx/hash.hpp index cd44028c..1d9e5572 100644 --- a/glm/gtx/hash.hpp +++ b/glm/gtx/hash.hpp @@ -41,10 +41,6 @@ #pragma once -#if !GLM_HAS_CXX11_STL -# error "GLM_GTX_hash requires C++11 standard library support" -#endif - #include #include "../vec2.hpp" @@ -67,6 +63,10 @@ #include "../mat4x3.hpp" #include "../mat4x4.hpp" +#if !GLM_HAS_CXX11_STL +# error "GLM_GTX_hash requires C++11 standard library support" +#endif + namespace std { template From 497da9a7cd405c31b1a0d7baa2115842bd092294 Mon Sep 17 00:00:00 2001 From: Morgan Bengtsson Date: Fri, 28 Aug 2015 22:13:05 +0200 Subject: [PATCH 03/94] Update matrix_decompose.hpp Changed documentation to show correct include file. --- glm/gtx/matrix_decompose.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/glm/gtx/matrix_decompose.hpp b/glm/gtx/matrix_decompose.hpp index 735b4288..e7fc83e2 100644 --- a/glm/gtx/matrix_decompose.hpp +++ b/glm/gtx/matrix_decompose.hpp @@ -36,7 +36,7 @@ /// /// @brief Decomposes a model matrix to translations, rotation and scale components /// -/// need to be included to use these functionalities. +/// need to be included to use these functionalities. /////////////////////////////////////////////////////////////////////////////////// #pragma once From be983bd7cba6746765e34627c0c9eaff61a7519f Mon Sep 17 00:00:00 2001 From: Christophe Riccio Date: Mon, 31 Aug 2015 17:33:22 +0200 Subject: [PATCH 04/94] Added test --- doc/man.doxy | 2 +- test/core/core_type_vec2.cpp | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/doc/man.doxy b/doc/man.doxy index d0379e34..faa82852 100644 --- a/doc/man.doxy +++ b/doc/man.doxy @@ -51,7 +51,7 @@ PROJECT_BRIEF = # pixels and the maximum width should not exceed 200 pixels. Doxygen will copy # the logo to the output directory. -PROJECT_LOGO = E:/Source/G-Truc/glm/doc/logo.png +PROJECT_LOGO = D:/Source/G-Truc/glm/doc/logo.png # The OUTPUT_DIRECTORY tag is used to specify the (relative or absolute) path # into which the generated documentation will be written. If a relative path is diff --git a/test/core/core_type_vec2.cpp b/test/core/core_type_vec2.cpp index 4730e9b8..69b5957e 100644 --- a/test/core/core_type_vec2.cpp +++ b/test/core/core_type_vec2.cpp @@ -229,6 +229,12 @@ int test_vec2_ctor() { int Error = 0; + { + glm::vec2 A(1); + glm::vec2 B(A); + Error += A == B ? 0 : 1; + } + # if GLM_HAS_TRIVIAL_QUERIES // Error += std::is_trivially_default_constructible::value ? 0 : 1; // Error += std::is_trivially_copy_assignable::value ? 0 : 1; From debed281495682b5f1900cc4aad4e68b573472c0 Mon Sep 17 00:00:00 2001 From: Christophe Riccio Date: Mon, 31 Aug 2015 18:01:51 +0200 Subject: [PATCH 05/94] Fixed link errors on compilers not supported default function #377 --- glm/detail/setup.hpp | 4 ++-- readme.md | 3 +++ test/gtx/gtx_common.cpp | 2 +- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/glm/detail/setup.hpp b/glm/detail/setup.hpp index b91a77ee..2210dc68 100644 --- a/glm/detail/setup.hpp +++ b/glm/detail/setup.hpp @@ -617,10 +617,10 @@ #elif GLM_LANG & GLM_LANG_CXX11_FLAG # define GLM_HAS_DEFAULTED_FUNCTIONS 1 #else -# define GLM_HAS_DEFAULTED_FUNCTIONS (GLM_LANG & GLM_LANG_CXX0X_FLAG) && (\ +# define GLM_HAS_DEFAULTED_FUNCTIONS ((GLM_LANG & GLM_LANG_CXX0X_FLAG) && (\ ((GLM_COMPILER & GLM_COMPILER_GCC) && (GLM_COMPILER >= GLM_COMPILER_GCC44)) || \ ((GLM_COMPILER & GLM_COMPILER_VC) && (GLM_COMPILER >= GLM_COMPILER_VC2013)) || \ - ((GLM_COMPILER & GLM_COMPILER_INTEL) && (GLM_COMPILER >= GLM_COMPILER_INTEL12))) + ((GLM_COMPILER & GLM_COMPILER_INTEL) && (GLM_COMPILER >= GLM_COMPILER_INTEL12)))) #endif // N2118 diff --git a/readme.md b/readme.md index d899dd8c..d7fe262c 100644 --- a/readme.md +++ b/readme.md @@ -54,6 +54,9 @@ glm::mat4 camera(float Translate, glm::vec2 const & Rotate) ##### Features: - Added GLM_SIMD to enable automatic SIMD code generation for generic GLM types #235 #370 +##### Fixes: +- Fixed link errors on compilers not supported default function #377 + #### [GLM 0.9.7.0](https://github.com/g-truc/glm/releases/tag/0.9.7.0) - 2015-08-02 ##### Features: - Added GTC_color_space: convertLinearToSRGB and convertSRGBToLinear functions diff --git a/test/gtx/gtx_common.cpp b/test/gtx/gtx_common.cpp index 37819aa5..1ffb5c52 100644 --- a/test/gtx/gtx_common.cpp +++ b/test/gtx/gtx_common.cpp @@ -40,7 +40,7 @@ namespace fmod_ template GLM_FUNC_QUALIFIER genType modTrunc(genType a, genType b) { - return a - b * trunc(a / b); + return a - b * glm::trunc(a / b); } int test() From 70234afb492eff3b428785cc9511dd3a0d9a1818 Mon Sep 17 00:00:00 2001 From: Christophe Riccio Date: Mon, 31 Aug 2015 18:12:26 +0200 Subject: [PATCH 06/94] Fixed warnings --- test/gtx/gtx_type_aligned.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/test/gtx/gtx_type_aligned.cpp b/test/gtx/gtx_type_aligned.cpp index b69a6307..2521518f 100644 --- a/test/gtx/gtx_type_aligned.cpp +++ b/test/gtx/gtx_type_aligned.cpp @@ -47,7 +47,7 @@ int test_decl() glm::vec4 B; }; - printf("vec4 - Aligned: %ld, unaligned: %ld\n", sizeof(S1), sizeof(S2)); + printf("vec4 - Aligned: %d, unaligned: %d\n", static_cast(sizeof(S1)), static_cast(sizeof(S2))); Error += sizeof(S1) >= sizeof(S2) ? 0 : 1; } @@ -65,7 +65,7 @@ int test_decl() glm::aligned_vec3 B; }; - printf("vec3: %ld, aligned: %ld\n", sizeof(S1), sizeof(S2)); + printf("vec3 - Aligned: %d, unaligned: %d\n", static_cast(sizeof(S1)), static_cast(sizeof(S2))); Error += sizeof(S1) <= sizeof(S2) ? 0 : 1; } @@ -83,7 +83,7 @@ int test_decl() glm::vec4 B; }; - printf("vec4 - Aligned: %ld, unaligned: %ld\n", sizeof(S1), sizeof(S2)); + printf("vec4 - Aligned: %d, unaligned: %d\n", static_cast(sizeof(S1)), static_cast(sizeof(S2))); Error += sizeof(S1) >= sizeof(S2) ? 0 : 1; } @@ -101,7 +101,7 @@ int test_decl() glm::dvec4 B; }; - printf("dvec4 - Aligned: %ld, unaligned: %ld\n", sizeof(S1), sizeof(S2)); + printf("dvec4 - Aligned: %d, unaligned: %d\n", static_cast(sizeof(S1)), static_cast(sizeof(S2))); Error += sizeof(S1) >= sizeof(S2) ? 0 : 1; } From 6aabe5a07dff7046970ab7bb32fd20dad385f664 Mon Sep 17 00:00:00 2001 From: Christophe Riccio Date: Mon, 31 Aug 2015 18:13:46 +0200 Subject: [PATCH 07/94] Fixed warnings --- glm/detail/type_vec4.inl | 20 ++++++++++---------- readme.md | 1 + 2 files changed, 11 insertions(+), 10 deletions(-) diff --git a/glm/detail/type_vec4.inl b/glm/detail/type_vec4.inl index 27391693..8b680dd4 100644 --- a/glm/detail/type_vec4.inl +++ b/glm/detail/type_vec4.inl @@ -341,12 +341,12 @@ namespace glm template template - GLM_FUNC_QUALIFIER tvec4 & tvec4::operator*=(U s) + GLM_FUNC_QUALIFIER tvec4 & tvec4::operator*=(U v) { - this->x *= static_cast(s); - this->y *= static_cast(s); - this->z *= static_cast(s); - this->w *= static_cast(s); + this->x *= static_cast(v); + this->y *= static_cast(v); + this->z *= static_cast(v); + this->w *= static_cast(v); return *this; } @@ -374,12 +374,12 @@ namespace glm template template - GLM_FUNC_QUALIFIER tvec4 & tvec4::operator/=(U s) + GLM_FUNC_QUALIFIER tvec4 & tvec4::operator/=(U v) { - this->x /= static_cast(s); - this->y /= static_cast(s); - this->z /= static_cast(s); - this->w /= static_cast(s); + this->x /= static_cast(v); + this->y /= static_cast(v); + this->z /= static_cast(v); + this->w /= static_cast(v); return *this; } diff --git a/readme.md b/readme.md index d7fe262c..f90bb5cb 100644 --- a/readme.md +++ b/readme.md @@ -56,6 +56,7 @@ glm::mat4 camera(float Translate, glm::vec2 const & Rotate) ##### Fixes: - Fixed link errors on compilers not supported default function #377 +- Fixed compilation warnings in vec4 #### [GLM 0.9.7.0](https://github.com/g-truc/glm/releases/tag/0.9.7.0) - 2015-08-02 ##### Features: From 2f4338269d90f50e1a493592c6d423bead7084c5 Mon Sep 17 00:00:00 2001 From: Christophe Riccio Date: Mon, 31 Aug 2015 18:14:54 +0200 Subject: [PATCH 08/94] Fixed reliability issue of GLM_HAS caps #377 --- glm/detail/setup.hpp | 42 +++++++++++++++++++++--------------------- 1 file changed, 21 insertions(+), 21 deletions(-) diff --git a/glm/detail/setup.hpp b/glm/detail/setup.hpp index 2210dc68..d28568c1 100644 --- a/glm/detail/setup.hpp +++ b/glm/detail/setup.hpp @@ -561,9 +561,9 @@ #elif GLM_LANG & GLM_LANG_CXX11_FLAG # define GLM_HAS_STATIC_ASSERT 1 #else -# define GLM_HAS_STATIC_ASSERT (GLM_LANG & GLM_LANG_CXX0X_FLAG) && (\ +# define GLM_HAS_STATIC_ASSERT ((GLM_LANG & GLM_LANG_CXX0X_FLAG) && (\ ((GLM_COMPILER & GLM_COMPILER_GCC) && (GLM_COMPILER >= GLM_COMPILER_GCC43)) || \ - ((GLM_COMPILER & GLM_COMPILER_VC) && (GLM_COMPILER >= GLM_COMPILER_VC2010))) + ((GLM_COMPILER & GLM_COMPILER_VC) && (GLM_COMPILER >= GLM_COMPILER_VC2010)))) #endif // N1988 @@ -585,9 +585,9 @@ # define GLM_HAS_CONSTEXPR 1 # define GLM_HAS_CONSTEXPR_PARTIAL GLM_HAS_CONSTEXPR #else -# define GLM_HAS_CONSTEXPR (GLM_LANG & GLM_LANG_CXX0X_FLAG) && (\ - ((GLM_COMPILER & GLM_COMPILER_GCC) && (GLM_COMPILER >= GLM_COMPILER_GCC46))) -# define GLM_HAS_CONSTEXPR_PARTIAL GLM_HAS_CONSTEXPR || ((GLM_COMPILER & GLM_COMPILER_VC) && (GLM_COMPILER >= GLM_COMPILER_VC2015)) +# define GLM_HAS_CONSTEXPR ((GLM_LANG & GLM_LANG_CXX0X_FLAG) && (\ + ((GLM_COMPILER & GLM_COMPILER_GCC) && (GLM_COMPILER >= GLM_COMPILER_GCC46)))) +# define GLM_HAS_CONSTEXPR_PARTIAL (GLM_HAS_CONSTEXPR || ((GLM_COMPILER & GLM_COMPILER_VC) && (GLM_COMPILER >= GLM_COMPILER_VC2015))) #endif // N2672 @@ -596,9 +596,9 @@ #elif GLM_LANG & GLM_LANG_CXX11_FLAG # define GLM_HAS_INITIALIZER_LISTS 1 #else -# define GLM_HAS_INITIALIZER_LISTS (GLM_LANG & GLM_LANG_CXX0X_FLAG) && (\ +# define GLM_HAS_INITIALIZER_LISTS ((GLM_LANG & GLM_LANG_CXX0X_FLAG) && (\ ((GLM_COMPILER & GLM_COMPILER_GCC) && (GLM_COMPILER >= GLM_COMPILER_GCC44)) || \ - ((GLM_COMPILER & GLM_COMPILER_VC) && (GLM_COMPILER >= GLM_COMPILER_VC2013))) + ((GLM_COMPILER & GLM_COMPILER_VC) && (GLM_COMPILER >= GLM_COMPILER_VC2013)))) #endif // N2544 Unrestricted unions @@ -629,9 +629,9 @@ #elif GLM_LANG & GLM_LANG_CXX11_FLAG # define GLM_HAS_RVALUE_REFERENCES 1 #else -# define GLM_HAS_RVALUE_REFERENCES (GLM_LANG & GLM_LANG_CXX0X_FLAG) && (\ +# define GLM_HAS_RVALUE_REFERENCES ((GLM_LANG & GLM_LANG_CXX0X_FLAG) && (\ ((GLM_COMPILER & GLM_COMPILER_GCC) && (GLM_COMPILER >= GLM_COMPILER_GCC43)) || \ - ((GLM_COMPILER & GLM_COMPILER_VC) && (GLM_COMPILER >= GLM_COMPILER_VC2012))) + ((GLM_COMPILER & GLM_COMPILER_VC) && (GLM_COMPILER >= GLM_COMPILER_VC2012)))) #endif // N2437 http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2007/n2437.pdf @@ -640,10 +640,10 @@ #elif GLM_LANG & GLM_LANG_CXX11_FLAG # define GLM_HAS_EXPLICIT_CONVERSION_OPERATORS 1 #else -# define GLM_HAS_EXPLICIT_CONVERSION_OPERATORS (GLM_LANG & GLM_LANG_CXX0X_FLAG) && (\ +# define GLM_HAS_EXPLICIT_CONVERSION_OPERATORS ((GLM_LANG & GLM_LANG_CXX0X_FLAG) && (\ ((GLM_COMPILER & GLM_COMPILER_GCC) && (GLM_COMPILER >= GLM_COMPILER_GCC45)) || \ ((GLM_COMPILER & GLM_COMPILER_INTEL) && (GLM_COMPILER >= GLM_COMPILER_INTEL14)) || \ - ((GLM_COMPILER & GLM_COMPILER_VC) && (GLM_COMPILER >= GLM_COMPILER_VC2013))) + ((GLM_COMPILER & GLM_COMPILER_VC) && (GLM_COMPILER >= GLM_COMPILER_VC2013)))) #endif // N2258 http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2007/n2258.pdf @@ -652,10 +652,10 @@ #elif GLM_LANG & GLM_LANG_CXX11_FLAG # define GLM_HAS_TEMPLATE_ALIASES 1 #else -# define GLM_HAS_TEMPLATE_ALIASES (GLM_LANG & GLM_LANG_CXX0X_FLAG) && (\ +# define GLM_HAS_TEMPLATE_ALIASES ((GLM_LANG & GLM_LANG_CXX0X_FLAG) && (\ ((GLM_COMPILER & GLM_COMPILER_INTEL) && (GLM_COMPILER >= GLM_COMPILER_INTEL12_1)) || \ ((GLM_COMPILER & GLM_COMPILER_GCC) && (GLM_COMPILER >= GLM_COMPILER_GCC47)) || \ - ((GLM_COMPILER & GLM_COMPILER_VC) && (GLM_COMPILER >= GLM_COMPILER_VC2013))) + ((GLM_COMPILER & GLM_COMPILER_VC) && (GLM_COMPILER >= GLM_COMPILER_VC2013)))) #endif // N2930 http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2009/n2930.html @@ -664,18 +664,18 @@ #elif GLM_LANG & GLM_LANG_CXX11_FLAG # define GLM_HAS_RANGE_FOR 1 #else -# define GLM_HAS_RANGE_FOR (GLM_LANG & GLM_LANG_CXX0X_FLAG) && (\ +# define GLM_HAS_RANGE_FOR ((GLM_LANG & GLM_LANG_CXX0X_FLAG) && (\ ((GLM_COMPILER & GLM_COMPILER_GCC) && (GLM_COMPILER >= GLM_COMPILER_GCC46)) || \ ((GLM_COMPILER & GLM_COMPILER_INTEL) && (GLM_COMPILER >= GLM_COMPILER_INTEL13)) || \ - ((GLM_COMPILER & GLM_COMPILER_VC) && (GLM_COMPILER >= GLM_COMPILER_VC2012))) + ((GLM_COMPILER & GLM_COMPILER_VC) && (GLM_COMPILER >= GLM_COMPILER_VC2012)))) #endif // #if GLM_LANG & GLM_LANG_CXX11_FLAG # define GLM_HAS_ASSIGNABLE 1 #else -# define GLM_HAS_ASSIGNABLE (GLM_LANG & GLM_LANG_CXX0X_FLAG) && (\ - ((GLM_COMPILER & GLM_COMPILER_GCC) && (GLM_COMPILER >= GLM_COMPILER_GCC49))) +# define GLM_HAS_ASSIGNABLE ((GLM_LANG & GLM_LANG_CXX0X_FLAG) && (\ + ((GLM_COMPILER & GLM_COMPILER_GCC) && (GLM_COMPILER >= GLM_COMPILER_GCC49)))) #endif // @@ -685,16 +685,16 @@ #if GLM_LANG & GLM_LANG_CXX11_FLAG # define GLM_HAS_MAKE_SIGNED 1 #else -# define GLM_HAS_MAKE_SIGNED (GLM_LANG & GLM_LANG_CXX0X_FLAG) && (\ - ((GLM_COMPILER & GLM_COMPILER_VC) && (GLM_COMPILER >= GLM_COMPILER_VC2013))) +# define GLM_HAS_MAKE_SIGNED ((GLM_LANG & GLM_LANG_CXX0X_FLAG) && (\ + ((GLM_COMPILER & GLM_COMPILER_VC) && (GLM_COMPILER >= GLM_COMPILER_VC2013)))) #endif // #if GLM_ARCH == GLM_ARCH_PURE # define GLM_HAS_BITSCAN_WINDOWS 0 #else -# define GLM_HAS_BITSCAN_WINDOWS (GLM_PLATFORM & GLM_PLATFORM_WINDOWS) && (\ - (GLM_COMPILER & (GLM_COMPILER_VC | GLM_COMPILER_LLVM | GLM_COMPILER_INTEL)) +# define GLM_HAS_BITSCAN_WINDOWS ((GLM_PLATFORM & GLM_PLATFORM_WINDOWS) && (\ + (GLM_COMPILER & (GLM_COMPILER_VC | GLM_COMPILER_LLVM | GLM_COMPILER_INTEL))) #endif // OpenMP From c10df14b5855e8b0b7c4ad47968e828462ddf12e Mon Sep 17 00:00:00 2001 From: Christophe Riccio Date: Mon, 31 Aug 2015 18:55:45 +0200 Subject: [PATCH 09/94] Fixed strict alignment warnings #235 #370 --- glm/detail/precision.hpp | 1 + glm/detail/type_vec4.hpp | 20 ++++++------- glm/detail/type_vec4.inl | 2 +- glm/detail/type_vec4_sse2.inl | 53 ++++------------------------------- glm/gtc/matrix_transform.hpp | 1 - readme.md | 4 +-- 6 files changed, 18 insertions(+), 63 deletions(-) diff --git a/glm/detail/precision.hpp b/glm/detail/precision.hpp index 2be5e238..c657d031 100644 --- a/glm/detail/precision.hpp +++ b/glm/detail/precision.hpp @@ -39,6 +39,7 @@ namespace glm highp, mediump, lowp, + simd, defaultp = highp }; }//namespace glm diff --git a/glm/detail/type_vec4.hpp b/glm/detail/type_vec4.hpp index 94583f1f..58868ef6 100644 --- a/glm/detail/type_vec4.hpp +++ b/glm/detail/type_vec4.hpp @@ -46,8 +46,8 @@ namespace glm{ namespace detail { - template - struct simd + template + struct simd_data { typedef T type[4]; }; @@ -56,19 +56,19 @@ namespace detail # if (GLM_ARCH & GLM_ARCH_SSE2) && GLM_NOT_BUGGY_VC32BITS template <> - struct simd + struct simd_data { typedef __m128 type; }; template <> - struct simd + struct simd_data { typedef __m128i type; }; template <> - struct simd + struct simd_data { typedef __m128i type; }; @@ -76,7 +76,7 @@ namespace detail # if (GLM_ARCH & GLM_ARCH_AVX) && GLM_NOT_BUGGY_VC32BITS template <> - struct simd + struct simd_data { typedef __m256d type; }; @@ -84,13 +84,13 @@ namespace detail # if (GLM_ARCH & GLM_ARCH_AVX2) && GLM_NOT_BUGGY_VC32BITS template <> - struct simd + struct simd_data { typedef __m256i type; }; template <> - struct simd + struct simd_data { typedef __m256i type; }; @@ -121,9 +121,7 @@ namespace detail struct { T r, g, b, a; }; struct { T s, t, p, q; }; -# ifdef GLM_SIMD - typename detail::simd::type data; -# endif + typename detail::simd_data::type data; # ifdef GLM_SWIZZLE _GLM_SWIZZLE4_2_MEMBERS(T, P, tvec2, x, y, z, w) diff --git a/glm/detail/type_vec4.inl b/glm/detail/type_vec4.inl index 8b680dd4..62d59d11 100644 --- a/glm/detail/type_vec4.inl +++ b/glm/detail/type_vec4.inl @@ -1104,7 +1104,7 @@ namespace glm } }//namespace glm -#if GLM_HAS_ANONYMOUS_UNION && defined(GLM_SIMD) && GLM_NOT_BUGGY_VC32BITS +#if GLM_HAS_ANONYMOUS_UNION && GLM_NOT_BUGGY_VC32BITS #if GLM_ARCH & GLM_ARCH_SSE2 # include "type_vec4_sse2.inl" #endif diff --git a/glm/detail/type_vec4_sse2.inl b/glm/detail/type_vec4_sse2.inl index 623db81a..968e9fed 100644 --- a/glm/detail/type_vec4_sse2.inl +++ b/glm/detail/type_vec4_sse2.inl @@ -34,14 +34,7 @@ namespace glm{ # if !GLM_HAS_DEFAULTED_FUNCTIONS template <> - GLM_FUNC_QUALIFIER tvec4::tvec4() -# ifndef GLM_FORCE_NO_CTOR_INIT - : data(_mm_setzero_ps()) -# endif - {} - - template <> - GLM_FUNC_QUALIFIER tvec4::tvec4() + GLM_FUNC_QUALIFIER tvec4::tvec4() # ifndef GLM_FORCE_NO_CTOR_INIT : data(_mm_setzero_ps()) # endif @@ -49,28 +42,18 @@ namespace glm{ # endif//!GLM_HAS_DEFAULTED_FUNCTIONS template <> - GLM_FUNC_QUALIFIER tvec4::tvec4(float s) : - data(_mm_set1_ps(s)) - {} - - template <> - GLM_FUNC_QUALIFIER tvec4::tvec4(float s) : + GLM_FUNC_QUALIFIER tvec4::tvec4(float s) : data(_mm_set1_ps(s)) {} template <> - GLM_FUNC_QUALIFIER tvec4::tvec4(float a, float b, float c, float d) : - data(_mm_set_ps(d, c, b, a)) - {} - - template <> - GLM_FUNC_QUALIFIER tvec4::tvec4(float a, float b, float c, float d) : + GLM_FUNC_QUALIFIER tvec4::tvec4(float a, float b, float c, float d) : data(_mm_set_ps(d, c, b, a)) {} template <> template - GLM_FUNC_QUALIFIER tvec4 & tvec4::operator+=(U scalar) + GLM_FUNC_QUALIFIER tvec4 & tvec4::operator+=(U scalar) { this->data = _mm_add_ps(this->data, _mm_set_ps1(static_cast(scalar))); return *this; @@ -78,7 +61,7 @@ namespace glm{ template <> template <> - GLM_FUNC_QUALIFIER tvec4 & tvec4::operator+=(float scalar) + GLM_FUNC_QUALIFIER tvec4 & tvec4::operator+=(float scalar) { this->data = _mm_add_ps(this->data, _mm_set_ps1(scalar)); return *this; @@ -86,31 +69,7 @@ namespace glm{ template <> template - GLM_FUNC_QUALIFIER tvec4 & tvec4::operator+=(U scalar) - { - this->data = _mm_add_ps(this->data, _mm_set_ps1(static_cast(scalar))); - return *this; - } - - template <> - template <> - GLM_FUNC_QUALIFIER tvec4 & tvec4::operator+=(float scalar) - { - this->data = _mm_add_ps(this->data, _mm_set_ps1(scalar)); - return *this; - } - - template <> - template - GLM_FUNC_QUALIFIER tvec4 & tvec4::operator+=(tvec1 const & v) - { - this->data = _mm_add_ps(this->data, _mm_set_ps1(static_cast(v.x))); - return *this; - } - - template <> - template - GLM_FUNC_QUALIFIER tvec4 & tvec4::operator+=(tvec1 const & v) + GLM_FUNC_QUALIFIER tvec4 & tvec4::operator+=(tvec1 const & v) { this->data = _mm_add_ps(this->data, _mm_set_ps1(static_cast(v.x))); return *this; diff --git a/glm/gtc/matrix_transform.hpp b/glm/gtc/matrix_transform.hpp index d4ff3cfe..b9f8098c 100644 --- a/glm/gtc/matrix_transform.hpp +++ b/glm/gtc/matrix_transform.hpp @@ -186,7 +186,6 @@ namespace glm T near, T far); - /// Creates a matrix for a right handed, symetric perspective-view frustum. /// /// @param fovy Specifies the field of view angle, in degrees, in the y direction. Expressed in radians. diff --git a/readme.md b/readme.md index f90bb5cb..26a36c7e 100644 --- a/readme.md +++ b/readme.md @@ -51,10 +51,8 @@ glm::mat4 camera(float Translate, glm::vec2 const & Rotate) ## Release notes #### [GLM 0.9.7.1](https://github.com/g-truc/glm/releases/latest) - 2015-XX-XX -##### Features: -- Added GLM_SIMD to enable automatic SIMD code generation for generic GLM types #235 #370 - ##### Fixes: +- Fixed strict alignment warnings #235 #370 - Fixed link errors on compilers not supported default function #377 - Fixed compilation warnings in vec4 From f92c1219edec83dafd5085dfeca07b61a35c07fb Mon Sep 17 00:00:00 2001 From: Christophe Riccio Date: Mon, 31 Aug 2015 21:56:34 +0200 Subject: [PATCH 10/94] Fixed non-identity quaternions for equal vectors #234 --- glm/gtx/quaternion.inl | 3 +++ readme.md | 1 + 2 files changed, 4 insertions(+) diff --git a/glm/gtx/quaternion.inl b/glm/gtx/quaternion.inl index 7467b42d..b405cc5e 100644 --- a/glm/gtx/quaternion.inl +++ b/glm/gtx/quaternion.inl @@ -249,6 +249,9 @@ namespace glm T cosTheta = dot(orig, dest); tvec3 rotationAxis; + if(cosTheta >= static_cast(1) - epsilon()) + return quat(); + if(cosTheta < static_cast(-1) + epsilon()) { // special case when vectors in opposite directions : diff --git a/readme.md b/readme.md index 26a36c7e..9e06527e 100644 --- a/readme.md +++ b/readme.md @@ -55,6 +55,7 @@ glm::mat4 camera(float Translate, glm::vec2 const & Rotate) - Fixed strict alignment warnings #235 #370 - Fixed link errors on compilers not supported default function #377 - Fixed compilation warnings in vec4 +- Fixed non-identity quaternions for equal vectors #234 #### [GLM 0.9.7.0](https://github.com/g-truc/glm/releases/tag/0.9.7.0) - 2015-08-02 ##### Features: From 1d266efe200ef7e40da1fc24e7a5a419c2fbf725 Mon Sep 17 00:00:00 2001 From: Christophe Riccio Date: Mon, 31 Aug 2015 22:14:45 +0200 Subject: [PATCH 11/94] - Improved constexpr for constant functions coverage #198 --- glm/detail/func_trigonometric.hpp | 4 +-- glm/detail/func_trigonometric.inl | 4 +-- glm/gtc/constants.hpp | 58 +++++++++++++++---------------- glm/gtc/constants.inl | 56 ++++++++++++++--------------- readme.md | 3 ++ 5 files changed, 64 insertions(+), 61 deletions(-) diff --git a/glm/detail/func_trigonometric.hpp b/glm/detail/func_trigonometric.hpp index d43961ba..24434977 100644 --- a/glm/detail/func_trigonometric.hpp +++ b/glm/detail/func_trigonometric.hpp @@ -58,7 +58,7 @@ namespace glm /// @see GLSL radians man page /// @see GLSL 4.20.8 specification, section 8.1 Angle and Trigonometry Functions template class vecType> - GLM_FUNC_DECL vecType radians(vecType const & degrees); + GLM_FUNC_DECL GLM_CONSTEXPR vecType radians(vecType const & degrees); /// Converts radians to degrees and returns the result. /// @@ -67,7 +67,7 @@ namespace glm /// @see GLSL degrees man page /// @see GLSL 4.20.8 specification, section 8.1 Angle and Trigonometry Functions template class vecType> - GLM_FUNC_DECL vecType degrees(vecType const & radians); + GLM_FUNC_DECL GLM_CONSTEXPR vecType degrees(vecType const & radians); /// The standard trigonometric sine function. /// The values returned by this function will range from [-1, 1]. diff --git a/glm/detail/func_trigonometric.inl b/glm/detail/func_trigonometric.inl index a7105250..ad738499 100644 --- a/glm/detail/func_trigonometric.inl +++ b/glm/detail/func_trigonometric.inl @@ -38,7 +38,7 @@ namespace glm { // radians template - GLM_FUNC_QUALIFIER genType radians(genType degrees) + GLM_FUNC_QUALIFIER GLM_CONSTEXPR genType radians(genType degrees) { GLM_STATIC_ASSERT(std::numeric_limits::is_iec559, "'radians' only accept floating-point input"); @@ -46,7 +46,7 @@ namespace glm } template class vecType> - GLM_FUNC_QUALIFIER vecType radians(vecType const & v) + GLM_FUNC_QUALIFIER GLM_CONSTEXPR vecType radians(vecType const & v) { return detail::functor1::call(radians, v); } diff --git a/glm/gtc/constants.hpp b/glm/gtc/constants.hpp index ae1fb622..786467ad 100644 --- a/glm/gtc/constants.hpp +++ b/glm/gtc/constants.hpp @@ -57,147 +57,147 @@ namespace glm /// Return the epsilon constant for floating point types. /// @see gtc_constants template - GLM_FUNC_DECL genType epsilon(); + GLM_FUNC_DECL GLM_CONSTEXPR genType epsilon(); /// Return 0. /// @see gtc_constants template - GLM_FUNC_DECL genType zero(); + GLM_FUNC_DECL GLM_CONSTEXPR genType zero(); /// Return 1. /// @see gtc_constants template - GLM_FUNC_DECL genType one(); + GLM_FUNC_DECL GLM_CONSTEXPR genType one(); /// Return the pi constant. /// @see gtc_constants template - GLM_FUNC_DECL genType pi(); + GLM_FUNC_DECL GLM_CONSTEXPR genType pi(); /// Return pi * 2. /// @see gtc_constants template - GLM_FUNC_DECL genType two_pi(); + GLM_FUNC_DECL GLM_CONSTEXPR genType two_pi(); /// Return square root of pi. /// @see gtc_constants template - GLM_FUNC_DECL genType root_pi(); + GLM_FUNC_DECL GLM_CONSTEXPR genType root_pi(); /// Return pi / 2. /// @see gtc_constants template - GLM_FUNC_DECL genType half_pi(); + GLM_FUNC_DECL GLM_CONSTEXPR genType half_pi(); /// Return pi / 2 * 3. /// @see gtc_constants template - GLM_FUNC_DECL genType three_over_two_pi(); + GLM_FUNC_DECL GLM_CONSTEXPR genType three_over_two_pi(); /// Return pi / 4. /// @see gtc_constants template - GLM_FUNC_DECL genType quarter_pi(); + GLM_FUNC_DECL GLM_CONSTEXPR genType quarter_pi(); /// Return 1 / pi. /// @see gtc_constants template - GLM_FUNC_DECL genType one_over_pi(); + GLM_FUNC_DECL GLM_CONSTEXPR genType one_over_pi(); /// Return 1 / (pi * 2). /// @see gtc_constants template - GLM_FUNC_DECL genType one_over_two_pi(); + GLM_FUNC_DECL GLM_CONSTEXPR genType one_over_two_pi(); /// Return 2 / pi. /// @see gtc_constants template - GLM_FUNC_DECL genType two_over_pi(); + GLM_FUNC_DECL GLM_CONSTEXPR genType two_over_pi(); /// Return 4 / pi. /// @see gtc_constants template - GLM_FUNC_DECL genType four_over_pi(); + GLM_FUNC_DECL GLM_CONSTEXPR genType four_over_pi(); /// Return 2 / sqrt(pi). /// @see gtc_constants template - GLM_FUNC_DECL genType two_over_root_pi(); + GLM_FUNC_DECL GLM_CONSTEXPR genType two_over_root_pi(); /// Return 1 / sqrt(2). /// @see gtc_constants template - GLM_FUNC_DECL genType one_over_root_two(); + GLM_FUNC_DECL GLM_CONSTEXPR genType one_over_root_two(); /// Return sqrt(pi / 2). /// @see gtc_constants template - GLM_FUNC_DECL genType root_half_pi(); + GLM_FUNC_DECL GLM_CONSTEXPR genType root_half_pi(); /// Return sqrt(2 * pi). /// @see gtc_constants template - GLM_FUNC_DECL genType root_two_pi(); + GLM_FUNC_DECL GLM_CONSTEXPR genType root_two_pi(); /// Return sqrt(ln(4)). /// @see gtc_constants template - GLM_FUNC_DECL genType root_ln_four(); + GLM_FUNC_DECL GLM_CONSTEXPR genType root_ln_four(); /// Return e constant. /// @see gtc_constants template - GLM_FUNC_DECL genType e(); + GLM_FUNC_DECL GLM_CONSTEXPR genType e(); /// Return Euler's constant. /// @see gtc_constants template - GLM_FUNC_DECL genType euler(); + GLM_FUNC_DECL GLM_CONSTEXPR genType euler(); /// Return sqrt(2). /// @see gtc_constants template - GLM_FUNC_DECL genType root_two(); + GLM_FUNC_DECL GLM_CONSTEXPR genType root_two(); /// Return sqrt(3). /// @see gtc_constants template - GLM_FUNC_DECL genType root_three(); + GLM_FUNC_DECL GLM_CONSTEXPR genType root_three(); /// Return sqrt(5). /// @see gtc_constants template - GLM_FUNC_DECL genType root_five(); + GLM_FUNC_DECL GLM_CONSTEXPR genType root_five(); /// Return ln(2). /// @see gtc_constants template - GLM_FUNC_DECL genType ln_two(); + GLM_FUNC_DECL GLM_CONSTEXPR genType ln_two(); /// Return ln(10). /// @see gtc_constants template - GLM_FUNC_DECL genType ln_ten(); + GLM_FUNC_DECL GLM_CONSTEXPR genType ln_ten(); /// Return ln(ln(2)). /// @see gtc_constants template - GLM_FUNC_DECL genType ln_ln_two(); + GLM_FUNC_DECL GLM_CONSTEXPR genType ln_ln_two(); /// Return 1 / 3. /// @see gtc_constants template - GLM_FUNC_DECL genType third(); + GLM_FUNC_DECL GLM_CONSTEXPR genType third(); /// Return 2 / 3. /// @see gtc_constants template - GLM_FUNC_DECL genType two_thirds(); + GLM_FUNC_DECL GLM_CONSTEXPR genType two_thirds(); /// Return the golden ratio constant. /// @see gtc_constants template - GLM_FUNC_DECL genType golden_ratio(); + GLM_FUNC_DECL GLM_CONSTEXPR genType golden_ratio(); /// @} } //namespace glm diff --git a/glm/gtc/constants.inl b/glm/gtc/constants.inl index a5de153b..0023f449 100644 --- a/glm/gtc/constants.inl +++ b/glm/gtc/constants.inl @@ -35,151 +35,151 @@ namespace glm { template - GLM_FUNC_QUALIFIER genType epsilon() + GLM_FUNC_QUALIFIER GLM_CONSTEXPR genType epsilon() { return std::numeric_limits::epsilon(); } template - GLM_FUNC_QUALIFIER genType zero() + GLM_FUNC_QUALIFIER GLM_CONSTEXPR genType zero() { return genType(0); } template - GLM_FUNC_QUALIFIER genType one() + GLM_FUNC_QUALIFIER GLM_CONSTEXPR genType one() { return genType(1); } template - GLM_FUNC_QUALIFIER genType pi() + GLM_FUNC_QUALIFIER GLM_CONSTEXPR genType pi() { return genType(3.14159265358979323846264338327950288); } template - GLM_FUNC_QUALIFIER genType two_pi() + GLM_FUNC_QUALIFIER GLM_CONSTEXPR genType two_pi() { return genType(6.28318530717958647692528676655900576); } template - GLM_FUNC_QUALIFIER genType root_pi() + GLM_FUNC_QUALIFIER GLM_CONSTEXPR genType root_pi() { return genType(1.772453850905516027); } template - GLM_FUNC_QUALIFIER genType half_pi() + GLM_FUNC_QUALIFIER GLM_CONSTEXPR genType half_pi() { return genType(1.57079632679489661923132169163975144); } template - GLM_FUNC_QUALIFIER genType three_over_two_pi() + GLM_FUNC_QUALIFIER GLM_CONSTEXPR genType three_over_two_pi() { return genType(4.71238898038468985769396507491925432); } template - GLM_FUNC_QUALIFIER genType quarter_pi() + GLM_FUNC_QUALIFIER GLM_CONSTEXPR genType quarter_pi() { return genType(0.785398163397448309615660845819875721); } template - GLM_FUNC_QUALIFIER genType one_over_pi() + GLM_FUNC_QUALIFIER GLM_CONSTEXPR genType one_over_pi() { return genType(0.318309886183790671537767526745028724); } template - GLM_FUNC_QUALIFIER genType one_over_two_pi() + GLM_FUNC_QUALIFIER GLM_CONSTEXPR genType one_over_two_pi() { return genType(0.159154943091895335768883763372514362); } template - GLM_FUNC_QUALIFIER genType two_over_pi() + GLM_FUNC_QUALIFIER GLM_CONSTEXPR genType two_over_pi() { return genType(0.636619772367581343075535053490057448); } template - GLM_FUNC_QUALIFIER genType four_over_pi() + GLM_FUNC_QUALIFIER GLM_CONSTEXPR genType four_over_pi() { return genType(1.273239544735162686151070106980114898); } template - GLM_FUNC_QUALIFIER genType two_over_root_pi() + GLM_FUNC_QUALIFIER GLM_CONSTEXPR genType two_over_root_pi() { return genType(1.12837916709551257389615890312154517); } template - GLM_FUNC_QUALIFIER genType one_over_root_two() + GLM_FUNC_QUALIFIER GLM_CONSTEXPR genType one_over_root_two() { return genType(0.707106781186547524400844362104849039); } template - GLM_FUNC_QUALIFIER genType root_half_pi() + GLM_FUNC_QUALIFIER GLM_CONSTEXPR genType root_half_pi() { return genType(1.253314137315500251); } template - GLM_FUNC_QUALIFIER genType root_two_pi() + GLM_FUNC_QUALIFIER GLM_CONSTEXPR genType root_two_pi() { return genType(2.506628274631000502); } template - GLM_FUNC_QUALIFIER genType root_ln_four() + GLM_FUNC_QUALIFIER GLM_CONSTEXPR genType root_ln_four() { return genType(1.17741002251547469); } template - GLM_FUNC_QUALIFIER genType e() + GLM_FUNC_QUALIFIER GLM_CONSTEXPR genType e() { return genType(2.71828182845904523536); } template - GLM_FUNC_QUALIFIER genType euler() + GLM_FUNC_QUALIFIER GLM_CONSTEXPR genType euler() { return genType(0.577215664901532860606); } template - GLM_FUNC_QUALIFIER genType root_two() + GLM_FUNC_QUALIFIER GLM_CONSTEXPR genType root_two() { return genType(1.41421356237309504880168872420969808); } template - GLM_FUNC_QUALIFIER genType root_three() + GLM_FUNC_QUALIFIER GLM_CONSTEXPR genType root_three() { return genType(1.73205080756887729352744634150587236); } template - GLM_FUNC_QUALIFIER genType root_five() + GLM_FUNC_QUALIFIER GLM_CONSTEXPR genType root_five() { return genType(2.23606797749978969640917366873127623); } template - GLM_FUNC_QUALIFIER genType ln_two() + GLM_FUNC_QUALIFIER GLM_CONSTEXPR genType ln_two() { return genType(0.693147180559945309417232121458176568); } template - GLM_FUNC_QUALIFIER genType ln_ten() + GLM_FUNC_QUALIFIER GLM_CONSTEXPR genType ln_ten() { return genType(2.30258509299404568401799145468436421); } @@ -191,19 +191,19 @@ namespace glm } template - GLM_FUNC_QUALIFIER genType third() + GLM_FUNC_QUALIFIER GLM_CONSTEXPR genType third() { return genType(0.3333333333333333333333333333333333333333); } template - GLM_FUNC_QUALIFIER genType two_thirds() + GLM_FUNC_QUALIFIER GLM_CONSTEXPR genType two_thirds() { return genType(0.666666666666666666666666666666666666667); } template - GLM_FUNC_QUALIFIER genType golden_ratio() + GLM_FUNC_QUALIFIER GLM_CONSTEXPR genType golden_ratio() { return genType(1.61803398874989484820458683436563811); } diff --git a/readme.md b/readme.md index 9e06527e..c1795df9 100644 --- a/readme.md +++ b/readme.md @@ -51,6 +51,9 @@ glm::mat4 camera(float Translate, glm::vec2 const & Rotate) ## Release notes #### [GLM 0.9.7.1](https://github.com/g-truc/glm/releases/latest) - 2015-XX-XX +##### Improvements: +- Improved constexpr for constant functions coverage #198 + ##### Fixes: - Fixed strict alignment warnings #235 #370 - Fixed link errors on compilers not supported default function #377 From 3356896a3aa6fb8894991d0d7dff13c5ee644349 Mon Sep 17 00:00:00 2001 From: Christophe Riccio Date: Mon, 31 Aug 2015 22:21:03 +0200 Subject: [PATCH 12/94] Fixed build --- glm/detail/func_trigonometric.inl | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/glm/detail/func_trigonometric.inl b/glm/detail/func_trigonometric.inl index ad738499..f723de47 100644 --- a/glm/detail/func_trigonometric.inl +++ b/glm/detail/func_trigonometric.inl @@ -53,7 +53,7 @@ namespace glm // degrees template - GLM_FUNC_QUALIFIER genType degrees(genType radians) + GLM_FUNC_QUALIFIER GLM_CONSTEXPR genType degrees(genType radians) { GLM_STATIC_ASSERT(std::numeric_limits::is_iec559, "'degrees' only accept floating-point input"); @@ -61,7 +61,7 @@ namespace glm } template class vecType> - GLM_FUNC_QUALIFIER vecType degrees(vecType const & v) + GLM_FUNC_QUALIFIER GLM_CONSTEXPR vecType degrees(vecType const & v) { return detail::functor1::call(degrees, v); } From d8f7b080d0ad70b77e23b11f7f856538c58ee59d Mon Sep 17 00:00:00 2001 From: Christophe Riccio Date: Mon, 31 Aug 2015 22:25:12 +0200 Subject: [PATCH 13/94] Fixed build --- glm/gtc/constants.inl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/glm/gtc/constants.inl b/glm/gtc/constants.inl index 0023f449..8214f606 100644 --- a/glm/gtc/constants.inl +++ b/glm/gtc/constants.inl @@ -185,7 +185,7 @@ namespace glm } template - GLM_FUNC_QUALIFIER genType ln_ln_two() + GLM_FUNC_QUALIFIER GLM_CONSTEXPR genType ln_ln_two() { return genType(-0.3665129205816643); } From bf30816e363b196805c99ef06c41ec1560005040 Mon Sep 17 00:00:00 2001 From: Christophe Riccio Date: Mon, 31 Aug 2015 22:34:14 +0200 Subject: [PATCH 14/94] - Added to_string for quat and dual_quat in GTX_string_cast #375 --- glm/gtx/string_cast.hpp | 2 ++ glm/gtx/string_cast.inl | 32 ++++++++++++++++++++++++++++++++ readme.md | 1 + 3 files changed, 35 insertions(+) diff --git a/glm/gtx/string_cast.hpp b/glm/gtx/string_cast.hpp index e04320c0..c292efd1 100644 --- a/glm/gtx/string_cast.hpp +++ b/glm/gtx/string_cast.hpp @@ -48,6 +48,8 @@ // Dependency: #include "../glm.hpp" #include "../gtc/type_precision.hpp" +#include "../gtc/quaternion.hpp" +#include "../gtx/dual_quaternion.hpp" #include #if(GLM_COMPILER & GLM_COMPILER_CUDA) diff --git a/glm/gtx/string_cast.inl b/glm/gtx/string_cast.inl index fb70ebc0..c21fa75f 100644 --- a/glm/gtx/string_cast.inl +++ b/glm/gtx/string_cast.inl @@ -444,6 +444,38 @@ namespace detail x[3][0], x[3][1], x[3][2], x[3][3]); } }; + + + template + struct compute_to_string + { + GLM_FUNC_QUALIFIER static std::string call(tquat const & x) + { + char const * PrefixStr = prefix::value(); + char const * LiteralStr = literal::is_iec559>::value(); + std::string FormatStr(detail::format("%squat(%s, %s, %s, %s)", + PrefixStr, + LiteralStr, LiteralStr, LiteralStr, LiteralStr)); + + return detail::format(FormatStr.c_str(), x[0], x[1], x[2], x[3]); + } + }; + + template + struct compute_to_string + { + GLM_FUNC_QUALIFIER static std::string call(tdualquat const & x) + { + char const * PrefixStr = prefix::value(); + char const * LiteralStr = literal::is_iec559>::value(); + std::string FormatStr(detail::format("%sdualquat((%s, %s, %s, %s), (%s, %s, %s, %s))", + PrefixStr, + LiteralStr, LiteralStr, LiteralStr, LiteralStr)); + + return detail::format(FormatStr.c_str(), x.real[0], x.real[1], x.real[2], x.real[3], x.dual[0], x.dual[1], x.dual[2], x.dual[3]); + } + }; + }//namespace detail template