From 64da6d3da344ee76699c5e096f7e4578d102d5e8 Mon Sep 17 00:00:00 2001 From: Christophe Riccio Date: Tue, 22 Nov 2011 16:36:09 +0000 Subject: [PATCH] Remove value_size() from vectors --- glm/core/func_vector_relational.inl | 24 +++++++++++++++--------- glm/core/type_vec1.hpp | 1 - glm/core/type_vec1.inl | 6 ------ glm/core/type_vec2.hpp | 1 - glm/core/type_vec2.inl | 6 ------ glm/core/type_vec3.hpp | 1 - glm/core/type_vec3.inl | 6 ------ glm/core/type_vec4.hpp | 1 - glm/core/type_vec4.inl | 6 ------ glm/gtx/component_wise.inl | 8 ++++---- 10 files changed, 19 insertions(+), 41 deletions(-) diff --git a/glm/core/func_vector_relational.inl b/glm/core/func_vector_relational.inl index b378b3ba..a797063f 100644 --- a/glm/core/func_vector_relational.inl +++ b/glm/core/func_vector_relational.inl @@ -39,9 +39,10 @@ namespace glm "Invalid template instantiation of 'lessThan', GLM vector types required"); GLM_STATIC_ASSERT(detail::is_bool::_NO, "Invalid template instantiation of 'lessThan', GLM vector types required floating-point or integer value types vectors"); + assert(x.length() == y.length()); typename vecType::bool_type Result(vecType::null); - for(typename vecType::size_type i = 0; i < vecType::value_size(); ++i) + for(typename vecType::size_type i = 0; i < x.length(); ++i) Result[i] = x[i] < y[i]; return Result; @@ -58,9 +59,10 @@ namespace glm "Invalid template instantiation of 'lessThanEqual', GLM vector types required"); GLM_STATIC_ASSERT(detail::is_bool::_NO, "Invalid template instantiation of 'lessThanEqual', GLM vector types required floating-point or integer value types vectors"); + assert(x.length() == y.length()); typename vecType::bool_type Result(vecType::null); - for(typename vecType::size_type i = 0; i < vecType::value_size(); ++i) + for(typename vecType::size_type i = 0; i < x.length(); ++i) Result[i] = x[i] <= y[i]; return Result; } @@ -76,9 +78,10 @@ namespace glm "Invalid template instantiation of 'greaterThan', GLM vector types required"); GLM_STATIC_ASSERT(detail::is_bool::_NO, "Invalid template instantiation of 'greaterThan', GLM vector types required floating-point or integer value types vectors"); + assert(x.length() == y.length()); typename vecType::bool_type Result(vecType::null); - for(typename vecType::size_type i = 0; i < vecType::value_size(); ++i) + for(typename vecType::size_type i = 0; i < x.length(); ++i) Result[i] = x[i] > y[i]; return Result; } @@ -94,9 +97,10 @@ namespace glm "Invalid template instantiation of 'greaterThanEqual', GLM vector types required"); GLM_STATIC_ASSERT(detail::is_bool::_NO, "Invalid template instantiation of 'greaterThanEqual', GLM vector types required floating-point or integer value types vectors"); + assert(x.length() == y.length()); typename vecType::bool_type Result(vecType::null); - for(typename vecType::size_type i = 0; i < vecType::value_size(); ++i) + for(typename vecType::size_type i = 0; i < x.length(); ++i) Result[i] = x[i] >= y[i]; return Result; } @@ -110,9 +114,10 @@ namespace glm { GLM_STATIC_ASSERT(detail::is_vector >::_YES, "Invalid template instantiation of 'equal', GLM vector types required"); + assert(x.length() == y.length()); typename vecType::bool_type Result(vecType::null); - for(typename vecType::size_type i = 0; i < vecType::value_size(); ++i) + for(typename vecType::size_type i = 0; i < x.length(); ++i) Result[i] = x[i] == y[i]; return Result; } @@ -126,9 +131,10 @@ namespace glm { GLM_STATIC_ASSERT(detail::is_vector >::_YES, "Invalid template instantiation of 'notEqual', GLM vector types required"); + assert(x.length() == y.length()); typename vecType::bool_type Result(vecType::null); - for(typename vecType::size_type i = 0; i < vecType::value_size(); ++i) + for(typename vecType::size_type i = 0; i < x.length(); ++i) Result[i] = x[i] != y[i]; return Result; } @@ -140,7 +146,7 @@ namespace glm "Invalid template instantiation of 'any', GLM boolean vector types required"); bool Result = false; - for(typename vecType::size_type i = 0; i < vecType::value_size(); ++i) + for(typename vecType::size_type i = 0; i < v.length(); ++i) Result = Result || v[i]; return Result; } @@ -152,7 +158,7 @@ namespace glm "Invalid template instantiation of 'all', GLM boolean vector types required"); bool Result = true; - for(typename vecType::size_type i = 0; i < vecType::value_size(); ++i) + for(typename vecType::size_type i = 0; i < v.length(); ++i) Result = Result && v[i]; return Result; } @@ -164,7 +170,7 @@ namespace glm "Invalid template instantiation of 'not_', GLM vector types required"); typename vecType::bool_type Result(vecType::null); - for(typename vecType::size_type i = 0; i < vecType::value_size(); ++i) + for(typename vecType::size_type i = 0; i < v.length(); ++i) Result[i] = !v[i]; return Result; } diff --git a/glm/core/type_vec1.hpp b/glm/core/type_vec1.hpp index 6d1f89ad..f0393ab1 100644 --- a/glm/core/type_vec1.hpp +++ b/glm/core/type_vec1.hpp @@ -55,7 +55,6 @@ namespace detail typedef T value_type; typedef std::size_t size_type; GLM_FUNC_DECL size_type length() const; - static GLM_FUNC_DECL size_type value_size(); typedef tvec1 type; typedef tvec1 bool_type; diff --git a/glm/core/type_vec1.inl b/glm/core/type_vec1.inl index 5528cd38..07433aaf 100644 --- a/glm/core/type_vec1.inl +++ b/glm/core/type_vec1.inl @@ -35,12 +35,6 @@ namespace detail return 1; } - template - GLM_FUNC_QUALIFIER typename tvec1::size_type tvec1::value_size() - { - return 1; - } - ////////////////////////////////////// // Accesses diff --git a/glm/core/type_vec2.hpp b/glm/core/type_vec2.hpp index 701138fb..e06a2218 100644 --- a/glm/core/type_vec2.hpp +++ b/glm/core/type_vec2.hpp @@ -54,7 +54,6 @@ namespace detail typedef T value_type; typedef std::size_t size_type; GLM_FUNC_DECL size_type length() const; - static GLM_FUNC_DECL size_type value_size(); typedef tvec2 type; typedef tvec2 bool_type; diff --git a/glm/core/type_vec2.inl b/glm/core/type_vec2.inl index 8c00216e..3ffb7b71 100644 --- a/glm/core/type_vec2.inl +++ b/glm/core/type_vec2.inl @@ -35,12 +35,6 @@ namespace detail return 2; } - template - GLM_FUNC_QUALIFIER typename tvec2::size_type tvec2::value_size() - { - return 2; - } - ////////////////////////////////////// // Accesses diff --git a/glm/core/type_vec3.hpp b/glm/core/type_vec3.hpp index 4b19b706..9179791b 100644 --- a/glm/core/type_vec3.hpp +++ b/glm/core/type_vec3.hpp @@ -54,7 +54,6 @@ namespace detail typedef T value_type; typedef std::size_t size_type; GLM_FUNC_DECL size_type length() const; - static GLM_FUNC_DECL size_type value_size(); typedef tvec3 type; typedef tvec3 bool_type; diff --git a/glm/core/type_vec3.inl b/glm/core/type_vec3.inl index 75d72e5e..6628ebd1 100644 --- a/glm/core/type_vec3.inl +++ b/glm/core/type_vec3.inl @@ -35,12 +35,6 @@ namespace detail return 3; } - template - GLM_FUNC_QUALIFIER typename tvec3::size_type tvec3::value_size() - { - return 3; - } - ////////////////////////////////////// // Accesses diff --git a/glm/core/type_vec4.hpp b/glm/core/type_vec4.hpp index 78d20097..b795a9b2 100644 --- a/glm/core/type_vec4.hpp +++ b/glm/core/type_vec4.hpp @@ -54,7 +54,6 @@ namespace detail typedef T value_type; typedef std::size_t size_type; GLM_FUNC_DECL size_type length() const; - static GLM_FUNC_DECL size_type value_size(); typedef tvec4 type; typedef tvec4 bool_type; diff --git a/glm/core/type_vec4.inl b/glm/core/type_vec4.inl index 8bbaac29..c4c0a26f 100644 --- a/glm/core/type_vec4.inl +++ b/glm/core/type_vec4.inl @@ -35,12 +35,6 @@ namespace detail return 4; } - template - GLM_FUNC_QUALIFIER typename tvec4::size_type tvec4::value_size() - { - return 4; - } - ////////////////////////////////////// // Accesses diff --git a/glm/gtx/component_wise.inl b/glm/gtx/component_wise.inl index 9e484f92..699dafc5 100644 --- a/glm/gtx/component_wise.inl +++ b/glm/gtx/component_wise.inl @@ -13,7 +13,7 @@ namespace glm GLM_FUNC_QUALIFIER typename genType::value_type compAdd(genType const & v) { typename genType::size_type result = typename genType::value_type(0); - for(typename genType::size_type i = 0; i < genType::value_size(); ++i) + for(typename genType::size_type i = 0; i < v.length(); ++i) result += v[i]; return result; } @@ -22,7 +22,7 @@ namespace glm GLM_FUNC_QUALIFIER typename genType::value_type compMul(genType const & v) { typename genType::value_type result = typename genType::value_type(1); - for(typename genType::size_type i = 0; i < genType::value_size(); ++i) + for(typename genType::size_type i = 0; i < v.length(); ++i) result *= v[i]; return result; } @@ -31,7 +31,7 @@ namespace glm GLM_FUNC_QUALIFIER typename genType::value_type compMin(genType const & v) { typename genType::value_type result = typename genType::value_type(v[0]); - for(typename genType::size_type i = 1; i < genType::value_size(); ++i) + for(typename genType::size_type i = 1; i < v.length(); ++i) result = min(result, v[i]); return result; } @@ -40,7 +40,7 @@ namespace glm GLM_FUNC_QUALIFIER typename genType::value_type compMax(genType const & v) { typename genType::value_type result = typename genType::value_type(v[0]); - for(typename genType::size_type i = 1; i < genType::value_size(); ++i) + for(typename genType::size_type i = 1; i < v.length(); ++i) result = max(result, v[i]); return result; }