Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorClément Foucault <foucault.clem@gmail.com>2022-01-10 17:38:06 +0300
committerClément Foucault <foucault.clem@gmail.com>2022-01-10 20:21:05 +0300
commit88498ab9b5fad61fa0d3a82c5e5ae4c57466516f (patch)
treebee4c4100bc3edbd614aab707bb1e99cb4a30cc5
parentfd2653323bb7c15ec963b0e192febb312c7b33ca (diff)
BLI_math_vector: Remove old implementation
-rw-r--r--source/blender/blenlib/BLI_math_vector.hh1169
1 files changed, 0 insertions, 1169 deletions
diff --git a/source/blender/blenlib/BLI_math_vector.hh b/source/blender/blenlib/BLI_math_vector.hh
index 7be6fafdc50..5eb1d63e22a 100644
--- a/source/blender/blenlib/BLI_math_vector.hh
+++ b/source/blender/blenlib/BLI_math_vector.hh
@@ -791,1175 +791,6 @@ template<typename T, int Size> struct vec_base : public vec_struct_base<T, Size>
}
};
-template<typename bT> struct vec2_base {
-
- static constexpr int type_length = 2;
-
- typedef bT base_type;
- typedef vec2_base<as_uint_type<bT>> uint_type;
-
- bT x, y;
-
- vec2_base() = default;
-
- explicit vec2_base(uint value) : x(value), y(value)
- {
- }
-
- explicit vec2_base(int value) : x(value), y(value)
- {
- }
-
- explicit vec2_base(float value) : x(value), y(value)
- {
- }
-
- explicit vec2_base(double value) : x(value), y(value)
- {
- }
-
- vec2_base(bT x, bT y) : x(x), y(y)
- {
- }
-
- /** Conversion from pointers (from C-style vectors). */
-
- vec2_base(const bT *ptr) : x(ptr[0]), y(ptr[1])
- {
- }
-
- vec2_base(const bT (*ptr)[2]) : vec2_base(static_cast<const bT *>(ptr[0]))
- {
- }
-
- /** Conversion from other vec2 types. */
-
- template<typename T>
- explicit vec2_base(const vec2_base<T> &vec)
- : x(static_cast<bT>(vec.x)), y(static_cast<bT>(vec.y))
- {
- }
-
- /** C-style pointer dereference. */
-
- operator const bT *() const
- {
- return &x;
- }
-
- operator bT *()
- {
- return &x;
- }
-
- /** Array access. */
-
- const bT &operator[](int index) const
- {
- BLI_assert(index < type_length);
- return (&x)[index];
- }
-
- bT &operator[](int index)
- {
- BLI_assert(index < type_length);
- return (&x)[index];
- }
-
- /** Arithmetic. */
-
- friend vec2_base operator+(const vec2_base &a, const vec2_base &b)
- {
- return {a.x + b.x, a.y + b.y};
- }
-
- friend vec2_base operator+(const vec2_base &a, const bT &b)
- {
- return {a.x + b, a.y + b};
- }
-
- friend vec2_base operator+(const bT &a, const vec2_base &b)
- {
- return b + a;
- }
-
- vec2_base &operator+=(const vec2_base &b)
- {
- x += b.x;
- y += b.y;
- return *this;
- }
-
- vec2_base &operator+=(const bT &b)
- {
- x += b;
- y += b;
- return *this;
- }
-
- friend vec2_base operator-(const vec2_base &a)
- {
- return {-a.x, -a.y};
- }
-
- friend vec2_base operator-(const vec2_base &a, const vec2_base &b)
- {
- return {a.x - b.x, a.y - b.y};
- }
-
- friend vec2_base operator-(const vec2_base &a, const bT &b)
- {
- return {a.x - b, a.y - b};
- }
-
- friend vec2_base operator-(const bT &a, const vec2_base &b)
- {
- return {a - b.x, a - b.y};
- }
-
- vec2_base &operator-=(const vec2_base &b)
- {
- x -= b.x;
- y -= b.y;
- return *this;
- }
-
- vec2_base &operator-=(const bT &b)
- {
- x -= b;
- y -= b;
- return *this;
- }
-
- friend vec2_base operator*(const vec2_base &a, const vec2_base &b)
- {
- return {a.x * b.x, a.y * b.y};
- }
-
- friend vec2_base operator*(const vec2_base &a, bT b)
- {
- return {a.x * b, a.y * b};
- }
-
- friend vec2_base operator*(bT a, const vec2_base &b)
- {
- return b * a;
- }
-
- vec2_base &operator*=(bT b)
- {
- x *= b;
- y *= b;
- return *this;
- }
-
- vec2_base &operator*=(const vec2_base &b)
- {
- x *= b.x;
- y *= b.y;
- return *this;
- }
-
- friend vec2_base operator/(const vec2_base &a, const vec2_base &b)
- {
- BLI_assert(b.x != bT(0) && b.y != bT(0));
- return {a.x / b.x, a.y / b.y};
- }
-
- friend vec2_base operator/(const vec2_base &a, bT b)
- {
- BLI_assert(b != bT(0));
- return {a.x / b, a.y / b};
- }
-
- friend vec2_base operator/(bT a, const vec2_base &b)
- {
- BLI_assert(b.x != bT(0) && b.y != bT(0));
- return {a / b.x, a / b.y};
- }
-
- vec2_base &operator/=(bT b)
- {
- BLI_assert(b != bT(0));
- x /= b;
- y /= b;
- return *this;
- }
-
- vec2_base &operator/=(const vec2_base &b)
- {
- BLI_assert(b.x != bT(0) && b.y != bT(0));
- x /= b.x;
- y /= b.y;
- return *this;
- }
-
- /** Binary operator. */
-
- INTEGRAL_OP friend vec2_base operator&(const vec2_base &a, const vec2_base &b)
- {
- return {a.x & b.x, a.y & b.y};
- }
-
- INTEGRAL_OP friend vec2_base operator&(const vec2_base &a, bT b)
- {
- return {a.x & b, a.y & b};
- }
-
- INTEGRAL_OP friend vec2_base operator&(bT a, const vec2_base &b)
- {
- return b & a;
- }
-
- INTEGRAL_OP vec2_base &operator&=(bT b)
- {
- x &= b;
- y &= b;
- return *this;
- }
-
- INTEGRAL_OP vec2_base &operator&=(const vec2_base &b)
- {
- x &= b.x;
- y &= b.y;
- return *this;
- }
-
- INTEGRAL_OP friend vec2_base operator|(const vec2_base &a, const vec2_base &b)
- {
- return {a.x | b.x, a.y | b.y};
- }
-
- INTEGRAL_OP friend vec2_base operator|(const vec2_base &a, bT b)
- {
- return {a.x | b, a.y | b};
- }
-
- INTEGRAL_OP friend vec2_base operator|(bT a, const vec2_base &b)
- {
- return b | a;
- }
-
- INTEGRAL_OP vec2_base &operator|=(bT b)
- {
- x |= b;
- y |= b;
- return *this;
- }
-
- INTEGRAL_OP vec2_base &operator|=(const vec2_base &b)
- {
- x |= b.x;
- y |= b.y;
- return *this;
- }
-
- INTEGRAL_OP friend vec2_base operator^(const vec2_base &a, const vec2_base &b)
- {
- return {a.x ^ b.x, a.y ^ b.y};
- }
-
- INTEGRAL_OP friend vec2_base operator^(const vec2_base &a, bT b)
- {
- return {a.x ^ b, a.y ^ b};
- }
-
- INTEGRAL_OP friend vec2_base operator^(bT a, const vec2_base &b)
- {
- return b ^ a;
- }
-
- INTEGRAL_OP vec2_base &operator^=(bT b)
- {
- x ^= b;
- y ^= b;
- return *this;
- }
-
- INTEGRAL_OP vec2_base &operator^=(const vec2_base &b)
- {
- x ^= b.x;
- y ^= b.y;
- return *this;
- }
-
- INTEGRAL_OP friend vec2_base operator~(const vec2_base &a)
- {
- return {~a.x, ~a.y};
- }
-
- /** Modulo operator. */
-
- INTEGRAL_OP friend vec2_base operator%(const vec2_base &a, const vec2_base &b)
- {
- return {a.x % b.x, a.y % b.y};
- }
-
- INTEGRAL_OP friend vec2_base operator%(const vec2_base &a, bT b)
- {
- return {a.x % b, a.y % b};
- }
-
- INTEGRAL_OP friend vec2_base operator%(bT a, const vec2_base &b)
- {
- return {a % b.x, a % b.y};
- }
-
- /** Compare. */
-
- friend bool operator==(const vec2_base &a, const vec2_base &b)
- {
- return a.x == b.x && a.y == b.y;
- }
-
- friend bool operator!=(const vec2_base &a, const vec2_base &b)
- {
- return !(a == b);
- }
-
- bool is_zero() const
- {
- return x == 0 && y == 0;
- }
-
- uint64_t hash() const
- {
- return math::vector_hash(*this);
- }
-
- /** Print. */
-
- friend std::ostream &operator<<(std::ostream &stream, const vec2_base &v)
- {
- stream << "(" << v.x << ", " << v.y << ")";
- return stream;
- }
-};
-
-template<typename bT> struct vec3_base {
-
- static constexpr int type_length = 3;
-
- typedef bT base_type;
- typedef vec3_base<as_uint_type<bT>> uint_type;
-
- bT x, y, z;
-
- vec3_base() = default;
-
- explicit vec3_base(uint value) : x(value), y(value), z(value)
- {
- }
-
- explicit vec3_base(int value) : x(value), y(value), z(value)
- {
- }
-
- explicit vec3_base(float value) : x(value), y(value), z(value)
- {
- }
-
- explicit vec3_base(double value) : x(value), y(value), z(value)
- {
- }
-
- vec3_base(bT x, bT y, bT z) : x(x), y(y), z(z)
- {
- }
-
- /** Conversion from pointers (from C-style vectors). */
-
- vec3_base(const bT *ptr) : x(ptr[0]), y(ptr[1]), z(ptr[2])
- {
- }
-
- vec3_base(const bT (*ptr)[3]) : vec3_base(static_cast<const bT *>(ptr[0]))
- {
- }
-
- /** Conversion from other vec3 types. */
-
- template<typename T>
- explicit vec3_base(const vec3_base<T> &vec)
- : x(static_cast<bT>(vec.x)), y(static_cast<bT>(vec.y)), z(static_cast<bT>(vec.z))
- {
- }
-
- /** Mixed scalar-vector constructors. */
-
- template<typename T>
- constexpr vec3_base(const vec2_base<T> &xy, bT z)
- : x(static_cast<bT>(xy.x)), y(static_cast<bT>(xy.y)), z(z)
- {
- }
-
- template<typename T>
- constexpr vec3_base(bT x, const vec2_base<T> &yz)
- : x(x), y(static_cast<bT>(yz.x)), z(static_cast<bT>(yz.y))
- {
- }
-
- /** Masking. */
-
- explicit operator vec2_base<bT>() const
- {
- return vec2_base<bT>(x, y);
- }
-
- /** C-style pointer dereference. */
-
- operator const bT *() const
- {
- return &x;
- }
-
- operator bT *()
- {
- return &x;
- }
-
- /** Array access. */
-
- const bT &operator[](int64_t index) const
- {
- BLI_assert(index < type_length);
- return (&x)[index];
- }
-
- bT &operator[](int64_t index)
- {
- BLI_assert(index < type_length);
- return (&x)[index];
- }
-
- /** Arithmetic. */
-
- friend vec3_base operator+(const vec3_base &a, const vec3_base &b)
- {
- return {a.x + b.x, a.y + b.y, a.z + b.z};
- }
-
- friend vec3_base operator+(const vec3_base &a, const bT &b)
- {
- return {a.x + b, a.y + b, a.z + b};
- }
-
- friend vec3_base operator+(const bT &a, const vec3_base &b)
- {
- return b + a;
- }
-
- vec3_base &operator+=(const vec3_base &b)
- {
- x += b.x;
- y += b.y;
- z += b.z;
- return *this;
- }
-
- vec3_base &operator+=(const bT &b)
- {
- x += b;
- y += b;
- z += b;
- return *this;
- }
-
- friend vec3_base operator-(const vec3_base &a)
- {
- return {-a.x, -a.y, -a.z};
- }
-
- friend vec3_base operator-(const vec3_base &a, const vec3_base &b)
- {
- return {a.x - b.x, a.y - b.y, a.z - b.z};
- }
-
- friend vec3_base operator-(const vec3_base &a, const bT &b)
- {
- return {a.x - b, a.y - b, a.z - b};
- }
-
- friend vec3_base operator-(const bT &a, const vec3_base &b)
- {
- return {a - b.x, a - b.y, a - b.z};
- }
-
- vec3_base &operator-=(const vec3_base &b)
- {
- x -= b.x;
- y -= b.y;
- z -= b.z;
- return *this;
- }
-
- vec3_base &operator-=(const bT &b)
- {
- x -= b;
- y -= b;
- z -= b;
- return *this;
- }
-
- friend vec3_base operator*(const vec3_base &a, const vec3_base &b)
- {
- return {a.x * b.x, a.y * b.y, a.z * b.z};
- }
-
- friend vec3_base operator*(const vec3_base &a, bT b)
- {
- return {a.x * b, a.y * b, a.z * b};
- }
-
- friend vec3_base operator*(bT a, const vec3_base &b)
- {
- return b * a;
- }
-
- vec3_base &operator*=(bT b)
- {
- x *= b;
- y *= b;
- z *= b;
- return *this;
- }
-
- vec3_base &operator*=(const vec3_base &b)
- {
- x *= b.x;
- y *= b.y;
- z *= b.z;
- return *this;
- }
-
- friend vec3_base operator/(const vec3_base &a, const vec3_base &b)
- {
- BLI_assert(b.x != bT(0) && b.y != bT(0) && b.z != bT(0));
- return {a.x / b.x, a.y / b.y, a.z / b.z};
- }
-
- friend vec3_base operator/(const vec3_base &a, bT b)
- {
- BLI_assert(b != bT(0));
- return {a.x / b, a.y / b, a.z / b};
- }
-
- friend vec3_base operator/(bT a, const vec3_base &b)
- {
- BLI_assert(b.x != bT(0) && b.y != bT(0) && b.z != bT(0));
- return {a / b.x, a / b.y, a / b.z};
- }
-
- vec3_base &operator/=(bT b)
- {
- BLI_assert(b != bT(0));
- x /= b;
- y /= b;
- z /= b;
- return *this;
- }
-
- vec3_base &operator/=(const vec3_base &b)
- {
- BLI_assert(b.x != bT(0) && b.y != bT(0) && b.z != bT(0));
- x /= b.x;
- y /= b.y;
- z /= b.z;
- return *this;
- }
-
- /** Binary operator. */
-
- INTEGRAL_OP friend vec3_base operator&(const vec3_base &a, const vec3_base &b)
- {
- return {a.x & b.x, a.y & b.y, a.z & b.z};
- }
-
- INTEGRAL_OP friend vec3_base operator&(const vec3_base &a, bT b)
- {
- return {a.x & b, a.y & b, a.z & b};
- }
-
- INTEGRAL_OP friend vec3_base operator&(bT a, const vec3_base &b)
- {
- return b & a;
- }
-
- INTEGRAL_OP vec3_base &operator&=(bT b)
- {
- x &= b;
- y &= b;
- z &= b;
- return *this;
- }
-
- INTEGRAL_OP vec3_base &operator&=(const vec3_base &b)
- {
- x &= b.x;
- y &= b.y;
- z &= b.z;
- return *this;
- }
-
- INTEGRAL_OP friend vec3_base operator|(const vec3_base &a, const vec3_base &b)
- {
- return {a.x | b.x, a.y | b.y, a.z | b.z};
- }
-
- INTEGRAL_OP friend vec3_base operator|(const vec3_base &a, bT b)
- {
- return {a.x | b, a.y | b, a.z | b};
- }
-
- INTEGRAL_OP friend vec3_base operator|(bT a, const vec3_base &b)
- {
- return b | a;
- }
-
- INTEGRAL_OP vec3_base &operator|=(bT b)
- {
- x |= b;
- y |= b;
- z |= b;
- return *this;
- }
-
- INTEGRAL_OP vec3_base &operator|=(const vec3_base &b)
- {
- x |= b.x;
- y |= b.y;
- z |= b.z;
- return *this;
- }
-
- INTEGRAL_OP friend vec3_base operator^(const vec3_base &a, const vec3_base &b)
- {
- return {a.x ^ b.x, a.y ^ b.y, a.z ^ b.z};
- }
-
- INTEGRAL_OP friend vec3_base operator^(const vec3_base &a, bT b)
- {
- return {a.x ^ b, a.y ^ b, a.z ^ b};
- }
-
- INTEGRAL_OP friend vec3_base operator^(bT a, const vec3_base &b)
- {
- return b ^ a;
- }
-
- INTEGRAL_OP vec3_base &operator^=(bT b)
- {
- x ^= b;
- y ^= b;
- z ^= b;
- return *this;
- }
-
- INTEGRAL_OP vec3_base &operator^=(const vec3_base &b)
- {
- x ^= b.x;
- y ^= b.y;
- z ^= b.z;
- return *this;
- }
-
- INTEGRAL_OP friend vec3_base operator~(const vec3_base &a)
- {
- return {~a.x, ~a.y, ~a.z};
- }
-
- /** Modulo operator. */
-
- INTEGRAL_OP friend vec3_base operator%(const vec3_base &a, const vec3_base &b)
- {
- return {a.x % b.x, a.y % b.y, a.z % b.z};
- }
-
- INTEGRAL_OP friend vec3_base operator%(const vec3_base &a, bT b)
- {
- return {a.x % b, a.y % b, a.z % b};
- }
-
- INTEGRAL_OP friend vec3_base operator%(bT a, const vec3_base &b)
- {
- return {a % b.x, a % b.y, a % b.z};
- }
-
- /** Compare. */
-
- friend bool operator==(const vec3_base &a, const vec3_base &b)
- {
- return a.x == b.x && a.y == b.y && a.z == b.z;
- }
-
- friend bool operator!=(const vec3_base &a, const vec3_base &b)
- {
- return !(a == b);
- }
-
- bool is_zero() const
- {
- return x == 0 && y == 0 && z == 0;
- }
-
- uint64_t hash() const
- {
- return math::vector_hash(*this);
- }
-
- /** Print. */
-
- friend std::ostream &operator<<(std::ostream &stream, const vec3_base &v)
- {
- stream << "(" << v.x << ", " << v.y << ", " << v.z << ")";
- return stream;
- }
-};
-
-template<typename bT> struct vec4_base {
-
- static constexpr int type_length = 4;
-
- typedef bT base_type;
- typedef vec4_base<as_uint_type<bT>> uint_type;
-
- bT x, y, z, w;
-
- vec4_base() = default;
-
- explicit vec4_base(uint value) : x(value), y(value), z(value), w(value)
- {
- }
-
- explicit vec4_base(int value) : x(value), y(value), z(value), w(value)
- {
- }
-
- explicit vec4_base(float value) : x(value), y(value), z(value), w(value)
- {
- }
-
- explicit vec4_base(double value) : x(value), y(value), z(value), w(value)
- {
- }
-
- vec4_base(bT x, bT y, bT z, bT w) : x(x), y(y), z(z), w(w)
- {
- }
-
- /** Conversion from pointers (from C-style vectors). */
-
- vec4_base(const bT *ptr) : x(ptr[0]), y(ptr[1]), z(ptr[2]), w(ptr[3])
- {
- }
-
- vec4_base(const bT (*ptr)[4]) : vec4_base(static_cast<const bT *>(ptr[0]))
- {
- }
-
- /** Conversion from other vec4 types. */
-
- template<typename T>
- explicit vec4_base(const vec4_base<T> &vec)
- : x(static_cast<bT>(vec.x)),
- y(static_cast<bT>(vec.y)),
- z(static_cast<bT>(vec.z)),
- w(static_cast<bT>(vec.w))
- {
- }
-
- /** Mixed scalar-vector constructors. */
-
- template<typename T>
- vec4_base(vec3_base<T> xyz, bT w)
- : x(static_cast<bT>(xyz.x)),
- y(static_cast<bT>(xyz.y)),
- z(static_cast<bT>(xyz.z)),
- w(static_cast<bT>(w))
- {
- }
-
- template<typename T>
- vec4_base(bT x, vec3_base<T> yzw)
- : x(static_cast<bT>(x)),
- y(static_cast<bT>(yzw.x)),
- z(static_cast<bT>(yzw.y)),
- w(static_cast<bT>(yzw.z))
- {
- }
-
- template<typename T>
- vec4_base(vec2_base<T> xy, vec2_base<T> zw)
- : x(static_cast<bT>(xy.x)),
- y(static_cast<bT>(xy.y)),
- z(static_cast<bT>(zw.x)),
- w(static_cast<bT>(zw.y))
- {
- }
-
- template<typename T>
- vec4_base(vec2_base<T> xy, bT z, bT w)
- : x(static_cast<bT>(xy.x)),
- y(static_cast<bT>(xy.y)),
- z(static_cast<bT>(z)),
- w(static_cast<bT>(w))
- {
- }
-
- template<typename T>
- vec4_base(bT x, vec2_base<T> yz, bT w)
- : x(static_cast<bT>(x)),
- y(static_cast<bT>(yz.x)),
- z(static_cast<bT>(yz.y)),
- w(static_cast<bT>(w))
- {
- }
-
- template<typename T>
- vec4_base(bT x, bT y, vec2_base<T> zw)
- : x(static_cast<bT>(x)),
- y(static_cast<bT>(y)),
- z(static_cast<bT>(zw.x)),
- w(static_cast<bT>(zw.y))
- {
- }
-
- /** Masking. */
-
- explicit operator vec2_base<bT>() const
- {
- return vec2_base<bT>(x, y);
- }
-
- explicit operator vec3_base<bT>() const
- {
- return vec3_base<bT>(x, y, z);
- }
-
- /** C-style pointer dereference. */
-
- operator const bT *() const
- {
- return &x;
- }
-
- operator bT *()
- {
- return &x;
- }
-
- /** Array access. */
-
- const bT &operator[](int64_t index) const
- {
- BLI_assert(index < type_length);
- return (&x)[index];
- }
-
- bT &operator[](int64_t index)
- {
- BLI_assert(index < type_length);
- return (&x)[index];
- }
-
- /** Arithmetic. */
-
- friend vec4_base operator+(const vec4_base &a, const vec4_base &b)
- {
- return {a.x + b.x, a.y + b.y, a.z + b.z, a.w + b.w};
- }
-
- friend vec4_base operator+(const vec4_base &a, const bT &b)
- {
- return {a.x + b, a.y + b, a.z + b, a.w + b};
- }
-
- friend vec4_base operator+(const bT &a, const vec4_base &b)
- {
- return b + a;
- }
-
- vec4_base &operator+=(const vec4_base &b)
- {
- x += b.x;
- y += b.y;
- z += b.z;
- w += b.w;
- return *this;
- }
-
- vec4_base &operator+=(const bT &b)
- {
- x += b;
- y += b;
- z += b;
- w += b;
- return *this;
- }
-
- friend vec4_base operator-(const vec4_base &a)
- {
- return {-a.x, -a.y, -a.z, -a.w};
- }
-
- friend vec4_base operator-(const vec4_base &a, const vec4_base &b)
- {
- return {a.x - b.x, a.y - b.y, a.z - b.z, a.w - b.w};
- }
-
- friend vec4_base operator-(const vec4_base &a, const bT &b)
- {
- return {a.x - b, a.y - b, a.z - b, a.w - b};
- }
-
- friend vec4_base operator-(const bT &a, const vec4_base &b)
- {
- return {a - b.x, a - b.y, a - b.z, a - b.w};
- }
-
- vec4_base &operator-=(const vec4_base &b)
- {
- x -= b.x;
- y -= b.y;
- z -= b.z;
- w -= b.w;
- return *this;
- }
-
- vec4_base &operator-=(const bT &b)
- {
- x -= b;
- y -= b;
- z -= b;
- w -= b;
- return *this;
- }
-
- friend vec4_base operator*(const vec4_base &a, const vec4_base &b)
- {
- return {a.x * b.x, a.y * b.y, a.z * b.z, a.w * b.w};
- }
-
- friend vec4_base operator*(const vec4_base &a, bT b)
- {
- return {a.x * b, a.y * b, a.z * b, a.w * b};
- }
-
- friend vec4_base operator*(bT a, const vec4_base &b)
- {
- return b * a;
- }
-
- vec4_base &operator*=(bT b)
- {
- x *= b;
- y *= b;
- z *= b;
- w *= b;
- return *this;
- }
-
- vec4_base &operator*=(const vec4_base &b)
- {
- x *= b.x;
- y *= b.y;
- z *= b.z;
- w *= b.w;
- return *this;
- }
-
- friend vec4_base operator/(const vec4_base &a, const vec4_base &b)
- {
- BLI_assert(b.x != 0.0f && b.y != 0.0f && b.z != 0.0f && b.w != 0.0f);
- return {a.x / b.x, a.y / b.y, a.z / b.z, a.w / b.w};
- }
-
- friend vec4_base operator/(const vec4_base &a, bT b)
- {
- BLI_assert(b != 0.0f);
- return {a.x / b, a.y / b, a.z / b, a.w / b};
- }
-
- friend vec4_base operator/(bT a, const vec4_base &b)
- {
- BLI_assert(b.x != 0.0f && b.y != 0.0f && b.z != 0.0f && b.w != 0.0f);
- return {a / b.x, a / b.y, a / b.z, a / b.w};
- }
-
- vec4_base &operator/=(bT b)
- {
- BLI_assert(b != 0.0f);
- x /= b;
- y /= b;
- z /= b;
- w /= b;
- return *this;
- }
-
- vec4_base &operator/=(const vec4_base &b)
- {
- BLI_assert(b.x != 0.0f && b.y != 0.0f && b.z != 0.0f && b.w != 0.0f);
- x /= b.x;
- y /= b.y;
- z /= b.z;
- w /= b.w;
- return *this;
- }
-
- /** Binary operator. */
-
- INTEGRAL_OP friend vec4_base operator&(const vec4_base &a, const vec4_base &b)
- {
- return {a.x & b.x, a.y & b.y, a.z & b.z, a.w & b.w};
- }
-
- INTEGRAL_OP friend vec4_base operator&(const vec4_base &a, bT b)
- {
- return {a.x & b, a.y & b, a.z & b, a.w & b};
- }
-
- INTEGRAL_OP friend vec4_base operator&(bT a, const vec4_base &b)
- {
- return b & a;
- }
-
- INTEGRAL_OP vec4_base &operator&=(bT b)
- {
- x &= b;
- y &= b;
- z &= b;
- w &= b;
- return *this;
- }
-
- INTEGRAL_OP vec4_base &operator&=(const vec4_base &b)
- {
- x &= b.x;
- y &= b.y;
- z &= b.z;
- w &= b.w;
- return *this;
- }
-
- INTEGRAL_OP friend vec4_base operator|(const vec4_base &a, const vec4_base &b)
- {
- return {a.x | b.x, a.y | b.y, a.z | b.z, a.w | b.w};
- }
-
- INTEGRAL_OP friend vec4_base operator|(const vec4_base &a, bT b)
- {
- return {a.x | b, a.y | b, a.z | b, a.w | b};
- }
-
- INTEGRAL_OP friend vec4_base operator|(bT a, const vec4_base &b)
- {
- return b | a;
- }
-
- INTEGRAL_OP vec4_base &operator|=(bT b)
- {
- x |= b;
- y |= b;
- z |= b;
- w |= b;
- return *this;
- }
-
- INTEGRAL_OP vec4_base &operator|=(const vec4_base &b)
- {
- x |= b.x;
- y |= b.y;
- z |= b.z;
- w |= b.w;
- return *this;
- }
-
- INTEGRAL_OP friend vec4_base operator^(const vec4_base &a, const vec4_base &b)
- {
- return {a.x ^ b.x, a.y ^ b.y, a.z ^ b.z, a.w ^ b.w};
- }
-
- INTEGRAL_OP friend vec4_base operator^(const vec4_base &a, bT b)
- {
- return {a.x ^ b, a.y ^ b, a.z ^ b, a.w ^ b};
- }
-
- INTEGRAL_OP friend vec4_base operator^(bT a, const vec4_base &b)
- {
- return b ^ a;
- }
-
- INTEGRAL_OP vec4_base &operator^=(bT b)
- {
- x ^= b;
- y ^= b;
- z ^= b;
- w ^= b;
- return *this;
- }
-
- INTEGRAL_OP vec4_base &operator^=(const vec4_base &b)
- {
- x ^= b.x;
- y ^= b.y;
- z ^= b.z;
- w ^= b.w;
- return *this;
- }
-
- INTEGRAL_OP friend vec4_base operator~(const vec4_base &a)
- {
- return {~a.x, ~a.y, ~a.z, ~a.w};
- }
-
- /** Modulo operator. */
-
- INTEGRAL_OP friend vec4_base operator%(const vec4_base &a, const vec4_base &b)
- {
- return {a.x % b.x, a.y % b.y, a.z % b.z, a.w % b.w};
- }
-
- INTEGRAL_OP friend vec4_base operator%(const vec4_base &a, bT b)
- {
- return {a.x % b, a.y % b, a.z % b, a.w % b};
- }
-
- INTEGRAL_OP friend vec4_base operator%(bT a, const vec4_base &b)
- {
- return {a % b.x, a % b.y, a % b.z, a % b.w};
- }
-
- /** Compare. */
-
- friend bool operator==(const vec4_base &a, const vec4_base &b)
- {
- return a.x == b.x && a.y == b.y && a.z == b.z && a.w == b.w;
- }
-
- friend bool operator!=(const vec4_base &a, const vec4_base &b)
- {
- return !(a == b);
- }
-
- bool is_zero() const
- {
- return x == 0 && y == 0 && z == 0 && w == 0;
- }
-
- uint64_t hash() const
- {
- return math::vector_hash(*this);
- }
-
- /** Print. */
-
- friend std::ostream &operator<<(std::ostream &stream, const vec4_base &v)
- {
- stream << "(" << v.x << ", " << v.y << ", " << v.z << ", " << v.w << ")";
- return stream;
- }
-};
-
#undef INTEGRAL_OP
} // namespace blender