diff --git a/glm/detail/type_vec1.hpp b/glm/detail/type_vec1.hpp index 3550d032..f5d9d6c3 100644 --- a/glm/detail/type_vec1.hpp +++ b/glm/detail/type_vec1.hpp @@ -8,14 +8,14 @@ /// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell /// copies of the Software, and to permit persons to whom the Software is /// furnished to do so, subject to the following conditions: -/// +/// /// The above copyright notice and this permission notice shall be included in /// all copies or substantial portions of the Software. -/// +/// /// Restrictions: /// By making use of the Software for military purposes, you choose to make /// a Bunny unhappy. -/// +/// /// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR /// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, /// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE @@ -54,7 +54,13 @@ namespace glm typedef tvec1 type; typedef tvec1 bool_type; typedef T value_type; - +# if GLM_HAS_CONSTEXPR + static GLM_CONSTEXPR length_t components = 1; + static GLM_CONSTEXPR precision prec = P; +# else + static const length_t components = 1; + static const precision prec = P; +# endif ////////////////////////////////////// // Data @@ -120,7 +126,7 @@ namespace glm ////////////////////////////////////// // Conversion vector constructors - + //! Explicit conversions (From section 5.4.1 Conversion and scalar constructors of GLSL 1.30.08 specification) template GLM_FUNC_DECL explicit tvec1(tvec2 const & v); @@ -157,23 +163,23 @@ namespace glm GLM_FUNC_DECL tvec1 & operator=(tvec1 const & v); - template + template GLM_FUNC_DECL tvec1 & operator=(tvec1 const & v); - template + template GLM_FUNC_DECL tvec1 & operator+=(U const & s); - template + template GLM_FUNC_DECL tvec1 & operator+=(tvec1 const & v); - template + template GLM_FUNC_DECL tvec1 & operator-=(U const & s); - template + template GLM_FUNC_DECL tvec1 & operator-=(tvec1 const & v); - template + template GLM_FUNC_DECL tvec1 & operator*=(U const & s); - template + template GLM_FUNC_DECL tvec1 & operator*=(tvec1 const & v); - template + template GLM_FUNC_DECL tvec1 & operator/=(U const & s); - template + template GLM_FUNC_DECL tvec1 & operator/=(tvec1 const & v); ////////////////////////////////////// @@ -187,29 +193,29 @@ namespace glm ////////////////////////////////////// // Unary bit operators - template + template GLM_FUNC_DECL tvec1 & operator%=(U const & s); - template + template GLM_FUNC_DECL tvec1 & operator%=(tvec1 const & v); - template + template GLM_FUNC_DECL tvec1 & operator&=(U const & s); - template + template GLM_FUNC_DECL tvec1 & operator&=(tvec1 const & v); - template + template GLM_FUNC_DECL tvec1 & operator|=(U const & s); - template + template GLM_FUNC_DECL tvec1 & operator|=(tvec1 const & v); - template + template GLM_FUNC_DECL tvec1 & operator^=(U const & s); - template + template GLM_FUNC_DECL tvec1 & operator^=(tvec1 const & v); - template + template GLM_FUNC_DECL tvec1 & operator<<=(U const & s); - template + template GLM_FUNC_DECL tvec1 & operator<<=(tvec1 const & v); - template + template GLM_FUNC_DECL tvec1 & operator>>=(U const & s); - template + template GLM_FUNC_DECL tvec1 & operator>>=(tvec1 const & v); }; @@ -313,7 +319,7 @@ namespace glm template GLM_FUNC_DECL tvec1 operator>>(tvec1 const & v1, tvec1 const & v2); - template + template GLM_FUNC_DECL tvec1 operator~(tvec1 const & v); }//namespace glm diff --git a/glm/detail/type_vec2.hpp b/glm/detail/type_vec2.hpp index 29cfa092..8b2a8ba6 100644 --- a/glm/detail/type_vec2.hpp +++ b/glm/detail/type_vec2.hpp @@ -54,6 +54,13 @@ namespace glm typedef tvec2 type; typedef tvec2 bool_type; typedef T value_type; +# if GLM_HAS_CONSTEXPR + static GLM_CONSTEXPR length_t components = 2; + static GLM_CONSTEXPR precision prec = P; +# else + static const length_t components = 2; + static const precision prec = P; +# endif ////////////////////////////////////// // Data diff --git a/glm/detail/type_vec3.hpp b/glm/detail/type_vec3.hpp index 5f0673bf..2aef6ef7 100644 --- a/glm/detail/type_vec3.hpp +++ b/glm/detail/type_vec3.hpp @@ -54,6 +54,13 @@ namespace glm typedef tvec3 type; typedef tvec3 bool_type; typedef T value_type; +# if GLM_HAS_CONSTEXPR + static GLM_CONSTEXPR length_t components = 3; + static GLM_CONSTEXPR precision prec = P; +# else + static const length_t components = 3; + static const precision prec = P; +# endif ////////////////////////////////////// // Data diff --git a/glm/detail/type_vec4.hpp b/glm/detail/type_vec4.hpp index 8189d6f0..31ae1a8d 100644 --- a/glm/detail/type_vec4.hpp +++ b/glm/detail/type_vec4.hpp @@ -108,6 +108,13 @@ namespace detail typedef tvec4 type; typedef tvec4 bool_type; typedef T value_type; +# if GLM_HAS_CONSTEXPR + static GLM_CONSTEXPR length_t components = 4; + static GLM_CONSTEXPR precision prec = P; +# else + static const length_t components = 4; + static const precision prec = P; +# endif ////////////////////////////////////// // Data diff --git a/glm/gtc/quaternion.hpp b/glm/gtc/quaternion.hpp index 812b5b00..a50e31b3 100644 --- a/glm/gtc/quaternion.hpp +++ b/glm/gtc/quaternion.hpp @@ -64,6 +64,13 @@ namespace glm { typedef tquat type; typedef T value_type; +# if GLM_HAS_CONSTEXPR + static GLM_CONSTEXPR length_t components = 4; + static GLM_CONSTEXPR precision prec = P; +# else + static const length_t components = 4; + static const precision prec = P; +# endif public: T x, y, z, w; diff --git a/glm/gtx/dual_quaternion.hpp b/glm/gtx/dual_quaternion.hpp index a8005cb8..392a0005 100644 --- a/glm/gtx/dual_quaternion.hpp +++ b/glm/gtx/dual_quaternion.hpp @@ -15,7 +15,7 @@ /// Restrictions: /// By making use of the Software for military purposes, you choose to make /// a Bunny unhappy. -/// +/// /// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR /// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, /// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE @@ -63,10 +63,17 @@ namespace glm { typedef T value_type; typedef glm::tquat part_type; - +# if GLM_HAS_CONSTEXPR + static GLM_CONSTEXPR length_t components = 8; + static GLM_CONSTEXPR precision prec = P; +# else + static const length_t components = 8; + static const precision prec = P; +# endif + public: glm::tquat real, dual; - + ////////////////////////////////////// // Component accesses @@ -115,7 +122,7 @@ namespace glm GLM_FUNC_DECL explicit tdualquat(tmat2x4 const & holder_mat); GLM_FUNC_DECL explicit tdualquat(tmat3x4 const & aug_mat); - + // Operators GLM_FUNC_DECL tdualquat & operator=(tdualquat const & m); @@ -126,51 +133,51 @@ namespace glm template GLM_FUNC_DECL tdualquat & operator/=(U s); }; - + template GLM_FUNC_DECL tquat operator- ( tquat const & q); - + template GLM_FUNC_DECL tdualquat operator+ ( tdualquat const & q, tdualquat const & p); - + template GLM_FUNC_DECL tdualquat operator* ( tdualquat const & q, tdualquat const & p); - + template GLM_FUNC_DECL tvec3 operator* ( tquat const & q, tvec3 const & v); - + template GLM_FUNC_DECL tvec3 operator* ( tvec3 const & v, tquat const & q); - + template GLM_FUNC_DECL tvec4 operator* ( tquat const & q, tvec4 const & v); - + template GLM_FUNC_DECL tvec4 operator* ( tvec4 const & v, tquat const & q); - + template GLM_FUNC_DECL tdualquat operator* ( tdualquat const & q, T const & s); - + template GLM_FUNC_DECL tdualquat operator* ( T const & s, tdualquat const & q); - + template GLM_FUNC_DECL tdualquat operator/ ( tdualquat const & q, @@ -227,17 +234,17 @@ namespace glm GLM_FUNC_DECL tdualquat dualquat_cast( tmat3x4 const & x); - + /// Dual-quaternion of low single-precision floating-point numbers. /// /// @see gtx_dual_quaternion typedef tdualquat lowp_dualquat; - + /// Dual-quaternion of medium single-precision floating-point numbers. /// /// @see gtx_dual_quaternion typedef tdualquat mediump_dualquat; - + /// Dual-quaternion of high single-precision floating-point numbers. /// /// @see gtx_dual_quaternion @@ -248,40 +255,40 @@ namespace glm /// /// @see gtx_dual_quaternion typedef tdualquat lowp_fdualquat; - + /// Dual-quaternion of medium single-precision floating-point numbers. /// /// @see gtx_dual_quaternion typedef tdualquat mediump_fdualquat; - + /// Dual-quaternion of high single-precision floating-point numbers. /// /// @see gtx_dual_quaternion typedef tdualquat highp_fdualquat; - - + + /// Dual-quaternion of low double-precision floating-point numbers. /// /// @see gtx_dual_quaternion typedef tdualquat lowp_ddualquat; - + /// Dual-quaternion of medium double-precision floating-point numbers. /// /// @see gtx_dual_quaternion typedef tdualquat mediump_ddualquat; - + /// Dual-quaternion of high double-precision floating-point numbers. /// /// @see gtx_dual_quaternion typedef tdualquat highp_ddualquat; - + #if(!defined(GLM_PRECISION_HIGHP_FLOAT) && !defined(GLM_PRECISION_MEDIUMP_FLOAT) && !defined(GLM_PRECISION_LOWP_FLOAT)) /// Dual-quaternion of floating-point numbers. /// /// @see gtx_dual_quaternion typedef highp_fdualquat dualquat; - + /// Dual-quaternion of single-precision floating-point numbers. /// /// @see gtx_dual_quaternion @@ -298,7 +305,7 @@ namespace glm #else # error "GLM error: multiple default precision requested for single-precision floating-point types" #endif - + #if(!defined(GLM_PRECISION_HIGHP_DOUBLE) && !defined(GLM_PRECISION_MEDIUMP_DOUBLE) && !defined(GLM_PRECISION_LOWP_DOUBLE)) /// Dual-quaternion of default double-precision floating-point numbers. diff --git a/glm/gtx/simd_quat.hpp b/glm/gtx/simd_quat.hpp index 810ce30c..177d0401 100644 --- a/glm/gtx/simd_quat.hpp +++ b/glm/gtx/simd_quat.hpp @@ -75,6 +75,13 @@ namespace detail typedef fquatSIMD type; typedef tquat bool_type; +# if GLM_HAS_CONSTEXPR + static GLM_CONSTEXPR length_t components = 1; + static GLM_CONSTEXPR precision prec = defaultp; +# else + static const length_t components = 1; + static const precision prec = defaultp; +# endif #ifdef GLM_SIMD_ENABLE_XYZW_UNION union diff --git a/glm/gtx/simd_vec4.hpp b/glm/gtx/simd_vec4.hpp index 2d836a41..3a263323 100644 --- a/glm/gtx/simd_vec4.hpp +++ b/glm/gtx/simd_vec4.hpp @@ -98,6 +98,13 @@ namespace detail typedef fvec4SIMD type; typedef tvec4 bool_type; +# if GLM_HAS_CONSTEXPR + static GLM_CONSTEXPR length_t components = 1; + static GLM_CONSTEXPR precision prec = defaultp; +# else + static const length_t components = 1; + static const precision prec = defaultp; +# endif #ifdef GLM_SIMD_ENABLE_XYZW_UNION union diff --git a/test/core/core_type_vec1.cpp b/test/core/core_type_vec1.cpp index 24d1796a..76d808ce 100644 --- a/test/core/core_type_vec1.cpp +++ b/test/core/core_type_vec1.cpp @@ -131,6 +131,7 @@ int test_vec1_size() Error += 8 == sizeof(glm::highp_dvec1) ? 0 : 1; Error += glm::vec1().length() == 1 ? 0 : 1; Error += glm::dvec1().length() == 1 ? 0 : 1; + Error += glm::vec1::components == 1 ? 0 : 1; return Error; } @@ -168,6 +169,7 @@ int main() glm::vec1 v; assert(v.length() == 1); + assert(glm::vec1::components == 1); Error += test_vec1_size(); Error += test_vec1_ctor(); diff --git a/test/core/core_type_vec2.cpp b/test/core/core_type_vec2.cpp index 1b545c43..590ad3f0 100644 --- a/test/core/core_type_vec2.cpp +++ b/test/core/core_type_vec2.cpp @@ -8,14 +8,14 @@ /// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell /// copies of the Software, and to permit persons to whom the Software is /// furnished to do so, subject to the following conditions: -/// +/// /// The above copyright notice and this permission notice shall be included in /// all copies or substantial portions of the Software. -/// +/// /// Restrictions: /// By making use of the Software for military purposes, you choose to make /// a Bunny unhappy. -/// +/// /// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR /// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, /// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE @@ -102,81 +102,81 @@ int test_vec2_operators() { glm::vec2 A(1.0f, 2.0f); glm::vec2 B(4.0f, 5.0f); - + glm::vec2 C = A + B; Error += C == glm::vec2(5, 7) ? 0 : 1; - + glm::vec2 D = B - A; Error += D == glm::vec2(3, 3) ? 0 : 1; - + glm::vec2 E = A * B; Error += E == glm::vec2(4, 10) ? 0 : 1; - + glm::vec2 F = B / A; Error += F == glm::vec2(4, 2.5) ? 0 : 1; - + glm::vec2 G = A + 1.0f; Error += G == glm::vec2(2, 3) ? 0 : 1; - + glm::vec2 H = B - 1.0f; Error += H == glm::vec2(3, 4) ? 0 : 1; - + glm::vec2 I = A * 2.0f; Error += I == glm::vec2(2, 4) ? 0 : 1; - + glm::vec2 J = B / 2.0f; Error += J == glm::vec2(2, 2.5) ? 0 : 1; - + glm::vec2 K = 1.0f + A; Error += K == glm::vec2(2, 3) ? 0 : 1; - + glm::vec2 L = 1.0f - B; Error += L == glm::vec2(-3, -4) ? 0 : 1; - + glm::vec2 M = 2.0f * A; Error += M == glm::vec2(2, 4) ? 0 : 1; - + glm::vec2 N = 2.0f / B; Error += N == glm::vec2(0.5, 2.0 / 5.0) ? 0 : 1; } - + { glm::vec2 A(1.0f, 2.0f); glm::vec2 B(4.0f, 5.0f); - + A += B; Error += A == glm::vec2(5, 7) ? 0 : 1; - + A += 1.0f; Error += A == glm::vec2(6, 8) ? 0 : 1; } { glm::vec2 A(1.0f, 2.0f); glm::vec2 B(4.0f, 5.0f); - + B -= A; Error += B == glm::vec2(3, 3) ? 0 : 1; - + B -= 1.0f; Error += B == glm::vec2(2, 2) ? 0 : 1; } { glm::vec2 A(1.0f, 2.0f); glm::vec2 B(4.0f, 5.0f); - + A *= B; Error += A == glm::vec2(4, 10) ? 0 : 1; - + A *= 2.0f; Error += A == glm::vec2(8, 20) ? 0 : 1; } { glm::vec2 A(1.0f, 2.0f); glm::vec2 B(4.0f, 5.0f); - + B /= A; Error += B == glm::vec2(4, 2.5) ? 0 : 1; - + B /= 2.0f; Error += B == glm::vec2(2, 1.25) ? 0 : 1; } @@ -186,39 +186,39 @@ int test_vec2_operators() B /= B.y; Error += B == glm::vec2(1.0f) ? 0 : 1; } - + { glm::vec2 A(1.0f, 2.0f); glm::vec2 B = -A; Error += B == glm::vec2(-1.0f, -2.0f) ? 0 : 1; } - + { glm::vec2 A(1.0f, 2.0f); glm::vec2 B = --A; Error += B == glm::vec2(0.0f, 1.0f) ? 0 : 1; } - + { glm::vec2 A(1.0f, 2.0f); glm::vec2 B = A--; Error += B == glm::vec2(1.0f, 2.0f) ? 0 : 1; Error += A == glm::vec2(0.0f, 1.0f) ? 0 : 1; } - + { glm::vec2 A(1.0f, 2.0f); glm::vec2 B = ++A; Error += B == glm::vec2(2.0f, 3.0f) ? 0 : 1; } - + { glm::vec2 A(1.0f, 2.0f); glm::vec2 B = A++; Error += B == glm::vec2(1.0f, 2.0f) ? 0 : 1; Error += A == glm::vec2(2.0f, 3.0f) ? 0 : 1; } - + return Error; } @@ -283,14 +283,15 @@ int test_vec2_ctor() int test_vec2_size() { int Error = 0; - + Error += sizeof(glm::vec2) == sizeof(glm::mediump_vec2) ? 0 : 1; Error += 8 == sizeof(glm::mediump_vec2) ? 0 : 1; Error += sizeof(glm::dvec2) == sizeof(glm::highp_dvec2) ? 0 : 1; Error += 16 == sizeof(glm::highp_dvec2) ? 0 : 1; Error += glm::vec2().length() == 2 ? 0 : 1; Error += glm::dvec2().length() == 2 ? 0 : 1; - + Error += glm::vec2::components == 2 ? 0 : 1; + return Error; } @@ -327,6 +328,7 @@ int main() glm::vec2 v; assert(v.length() == 2); + assert(glm::vec2::components == 2); Error += test_vec2_size(); Error += test_vec2_ctor(); diff --git a/test/core/core_type_vec3.cpp b/test/core/core_type_vec3.cpp index 81d8ed35..cdd5f6d3 100644 --- a/test/core/core_type_vec3.cpp +++ b/test/core/core_type_vec3.cpp @@ -263,7 +263,7 @@ int test_vec3_size() Error += 24 == sizeof(glm::highp_dvec3) ? 0 : 1; Error += glm::vec3().length() == 3 ? 0 : 1; Error += glm::dvec3().length() == 3 ? 0 : 1; - + Error += glm::vec3::components == 3 ? 0 : 1; return Error; } @@ -494,6 +494,10 @@ int main() { int Error = 0; + glm::vec3 v; + assert(v.length() == 3); + assert(glm::vec3::components == 3); + Error += test_vec3_ctor(); Error += test_vec3_operators(); Error += test_vec3_size(); diff --git a/test/core/core_type_vec4.cpp b/test/core/core_type_vec4.cpp index fa724399..89ee0a6a 100644 --- a/test/core/core_type_vec4.cpp +++ b/test/core/core_type_vec4.cpp @@ -446,9 +446,12 @@ int main() { int Error(0); - std::size_t const Size(1000000); + glm::vec4 v; + assert(v.length() == 4); + assert(glm::vec4::components == 4); # ifdef NDEBUG + std::size_t const Size(1000000); Error += test_vec4_perf_AoS(Size); Error += test_vec4_perf_SoA(Size); # endif//NDEBUG diff --git a/test/gtc/gtc_quaternion.cpp b/test/gtc/gtc_quaternion.cpp index 8818827e..6a8d344b 100644 --- a/test/gtc/gtc_quaternion.cpp +++ b/test/gtc/gtc_quaternion.cpp @@ -8,14 +8,14 @@ /// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell /// copies of the Software, and to permit persons to whom the Software is /// furnished to do so, subject to the following conditions: -/// +/// /// The above copyright notice and this permission notice shall be included in /// all copies or substantial portions of the Software. -/// +/// /// Restrictions: /// By making use of the Software for military purposes, you choose to make /// a Bunny unhappy. -/// +/// /// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR /// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, /// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE @@ -324,6 +324,8 @@ int main() { int Error(0); + assert(glm::quat::components == 4); + Error += test_quat_ctr(); Error += test_quat_mul_vec(); Error += test_quat_two_axis_ctr();