diff options
author | Hans Goudey <h.goudey@me.com> | 2022-02-17 21:36:41 +0300 |
---|---|---|
committer | Hans Goudey <h.goudey@me.com> | 2022-02-17 21:36:41 +0300 |
commit | 48432c1c92824a0da4bb73b1ca7b45290a4b3aaf (patch) | |
tree | 8485d15a5f7d8b4941b34940bb3d9c02e3dac129 /source/blender/blenlib/BLI_math_vec_types.hh | |
parent | b6fe1b0c658f5068154f9e4a726de789f5ebb68a (diff) |
Fix: Debug build error with vector type division
The idea is to keep `is_any_zero` in the `blender::math` namespace,
so instead of trying to be clever, just move it there and expand the
function where it was used in the class.
Diffstat (limited to 'source/blender/blenlib/BLI_math_vec_types.hh')
-rw-r--r-- | source/blender/blenlib/BLI_math_vec_types.hh | 22 |
1 files changed, 9 insertions, 13 deletions
diff --git a/source/blender/blenlib/BLI_math_vec_types.hh b/source/blender/blenlib/BLI_math_vec_types.hh index b6b3d15aefe..389307e331d 100644 --- a/source/blender/blenlib/BLI_math_vec_types.hh +++ b/source/blender/blenlib/BLI_math_vec_types.hh @@ -64,16 +64,6 @@ template<typename T> uint64_t vector_hash(const T &vec) return result; } -template<typename T, int Size> inline bool is_any_zero(const vec_struct_base<T, Size> &a) -{ - for (int i = 0; i < Size; i++) { - if (a[i] == T(0)) { - return true; - } - } - return false; -} - } // namespace math template<typename T, int Size> struct vec_base : public vec_struct_base<T, Size> { @@ -353,7 +343,9 @@ template<typename T, int Size> struct vec_base : public vec_struct_base<T, Size> friend vec_base operator/(const vec_base &a, const vec_base &b) { - BLI_assert(!math::is_any_zero(b)); + for (int i = 0; i < Size; i++) { + BLI_assert(b[i] != T(0)); + } BLI_VEC_OP_IMPL(ret, i, ret[i] = a[i] / b[i]); } @@ -365,7 +357,9 @@ template<typename T, int Size> struct vec_base : public vec_struct_base<T, Size> friend vec_base operator/(T a, const vec_base &b) { - BLI_assert(!math::is_any_zero(b)); + for (int i = 0; i < Size; i++) { + BLI_assert(b[i] != T(0)); + } BLI_VEC_OP_IMPL(ret, i, ret[i] = a / b[i]); } @@ -509,7 +503,9 @@ template<typename T, int Size> struct vec_base : public vec_struct_base<T, Size> BLI_INT_OP(T) friend vec_base operator%(const vec_base &a, const vec_base &b) { - BLI_assert(!math::is_any_zero(b)); + for (int i = 0; i < Size; i++) { + BLI_assert(b[i] != T(0)); + } BLI_VEC_OP_IMPL(ret, i, ret[i] = a[i] % b[i]); } |