From bb563dc6b0a51325553a0f4630aa5a56427a2dfc Mon Sep 17 00:00:00 2001 From: ZXShady <153229951+ZXShady@users.noreply.github.com> Date: Sat, 5 Oct 2024 15:34:38 +0100 Subject: [PATCH] remove_unneccessary_overloads Removed many overloads by using templates and delegating to already existing operators --- glm/detail/_noise.hpp | 48 +-- glm/detail/mat2xn_common_ops.hpp | 53 +++ glm/detail/mat2xn_common_ops.inl | 106 ++++++ glm/detail/mat3xn_common_ops.hpp | 54 +++ glm/detail/mat3xn_common_ops.inl | 117 ++++++ glm/detail/mat4xn_common_ops.hpp | 52 +++ glm/detail/mat4xn_common_ops.inl | 131 +++++++ glm/detail/mat_common_ops.hpp | 37 ++ glm/detail/mat_common_ops.inl | 67 ++++ glm/detail/qualifier.hpp | 31 +- glm/detail/type_float.hpp | 3 +- glm/detail/type_mat2x2.hpp | 72 +--- glm/detail/type_mat2x2.inl | 207 +---------- glm/detail/type_mat2x3.hpp | 59 +-- glm/detail/type_mat2x3.inl | 208 +---------- glm/detail/type_mat2x4.hpp | 60 +-- glm/detail/type_mat2x4.inl | 225 +----------- glm/detail/type_mat3x2.hpp | 63 +--- glm/detail/type_mat3x2.inl | 221 +---------- glm/detail/type_mat3x3.hpp | 72 +--- glm/detail/type_mat3x3.inl | 225 +----------- glm/detail/type_mat3x4.hpp | 58 +-- glm/detail/type_mat3x4.inl | 413 ++++++--------------- glm/detail/type_mat4x2.hpp | 55 +-- glm/detail/type_mat4x2.inl | 215 ----------- glm/detail/type_mat4x3.hpp | 60 +-- glm/detail/type_mat4x3.inl | 213 ----------- glm/detail/type_mat4x4.hpp | 72 +--- glm/detail/type_mat4x4.inl | 253 +------------ glm/detail/type_vec1.hpp | 143 ++------ glm/detail/type_vec1.inl | 370 +++---------------- glm/detail/type_vec2.hpp | 209 +---------- glm/detail/type_vec2.inl | 609 ------------------------------- glm/detail/type_vec3.hpp | 180 +-------- glm/detail/type_vec3.inl | 449 +---------------------- glm/detail/type_vec4.hpp | 197 +--------- glm/detail/type_vec4.inl | 477 +----------------------- glm/detail/vec_common_ops.hpp | 175 +++++++++ glm/detail/vec_common_ops.inl | 329 +++++++++++++++++ glm/gtc/type_ptr.inl | 148 +------- test/CMakeLists.txt | 3 + test/core/core_type_aligned.cpp | 2 + 42 files changed, 1422 insertions(+), 5319 deletions(-) create mode 100644 glm/detail/mat2xn_common_ops.hpp create mode 100644 glm/detail/mat2xn_common_ops.inl create mode 100644 glm/detail/mat3xn_common_ops.hpp create mode 100644 glm/detail/mat3xn_common_ops.inl create mode 100644 glm/detail/mat4xn_common_ops.hpp create mode 100644 glm/detail/mat4xn_common_ops.inl create mode 100644 glm/detail/mat_common_ops.hpp create mode 100644 glm/detail/mat_common_ops.inl create mode 100644 glm/detail/vec_common_ops.hpp create mode 100644 glm/detail/vec_common_ops.inl diff --git a/glm/detail/_noise.hpp b/glm/detail/_noise.hpp index 5a874a02..bb439225 100644 --- a/glm/detail/_noise.hpp +++ b/glm/detail/_noise.hpp @@ -17,20 +17,8 @@ namespace detail return mod289(((x * static_cast(34)) + static_cast(1)) * x); } - template - GLM_FUNC_QUALIFIER vec<2, T, Q> permute(vec<2, T, Q> const& x) - { - return mod289(((x * static_cast(34)) + static_cast(1)) * x); - } - - template - GLM_FUNC_QUALIFIER vec<3, T, Q> permute(vec<3, T, Q> const& x) - { - return mod289(((x * static_cast(34)) + static_cast(1)) * x); - } - - template - GLM_FUNC_QUALIFIER vec<4, T, Q> permute(vec<4, T, Q> const& x) + template + GLM_FUNC_QUALIFIER vec permute(vec const& x) { return mod289(((x * static_cast(34)) + static_cast(1)) * x); } @@ -41,38 +29,14 @@ namespace detail return static_cast(1.79284291400159) - static_cast(0.85373472095314) * r; } - template - GLM_FUNC_QUALIFIER vec<2, T, Q> taylorInvSqrt(vec<2, T, Q> const& r) + template + GLM_FUNC_QUALIFIER vec taylorInvSqrt(vec const& r) { return static_cast(1.79284291400159) - static_cast(0.85373472095314) * r; } - template - GLM_FUNC_QUALIFIER vec<3, T, Q> taylorInvSqrt(vec<3, T, Q> const& r) - { - return static_cast(1.79284291400159) - static_cast(0.85373472095314) * r; - } - - template - GLM_FUNC_QUALIFIER vec<4, T, Q> taylorInvSqrt(vec<4, T, Q> const& r) - { - return static_cast(1.79284291400159) - static_cast(0.85373472095314) * r; - } - - template - GLM_FUNC_QUALIFIER vec<2, T, Q> fade(vec<2, T, Q> const& t) - { - return (t * t * t) * (t * (t * static_cast(6) - static_cast(15)) + static_cast(10)); - } - - template - GLM_FUNC_QUALIFIER vec<3, T, Q> fade(vec<3, T, Q> const& t) - { - return (t * t * t) * (t * (t * static_cast(6) - static_cast(15)) + static_cast(10)); - } - - template - GLM_FUNC_QUALIFIER vec<4, T, Q> fade(vec<4, T, Q> const& t) + template + GLM_FUNC_QUALIFIER vec fade(vec const& t) { return (t * t * t) * (t * (t * static_cast(6) - static_cast(15)) + static_cast(10)); } diff --git a/glm/detail/mat2xn_common_ops.hpp b/glm/detail/mat2xn_common_ops.hpp new file mode 100644 index 00000000..b52c8178 --- /dev/null +++ b/glm/detail/mat2xn_common_ops.hpp @@ -0,0 +1,53 @@ +#pragma once + +#include "qualifier.hpp" +#include "mat_common_ops.hpp" + +namespace glm { + template + GLM_FUNC_DECL GLM_CONSTEXPR mat<2, R, T, Q> operator-(mat<2, R, T, Q> const& m1); + + template + GLM_FUNC_DISCARD_DECL GLM_CONSTEXPR mat<2, R, T, Q>& operator++(mat<2, R, T, Q>& m); + template + GLM_FUNC_DISCARD_DECL GLM_CONSTEXPR mat<2, R, T, Q>& operator--(mat<2, R, T, Q>& m); + + + template + GLM_FUNC_DISCARD_DECL GLM_CONSTEXPR mat<2, R, T, Q>& operator+=(mat<2, R, T, Q>& m, U scalar); + template + GLM_FUNC_DISCARD_DECL GLM_CONSTEXPR mat<2, R, T, Q>& operator-=(mat<2, R, T, Q>& m, U scalar); + template + GLM_FUNC_DISCARD_DECL GLM_CONSTEXPR mat<2, R, T, Q>& operator*=(mat<2, R, T, Q>& m, U scalar); + template + GLM_FUNC_DISCARD_DECL GLM_CONSTEXPR mat<2, R, T, Q>& operator/=(mat<2, R, T, Q>& m, U scalar); + + // Matrices + template + GLM_FUNC_DISCARD_DECL GLM_CONSTEXPR mat<2, R, T, Q>& operator+=(mat<2, R, T, Q>& m1, mat<2,R,U,Q> const& m2); + template + GLM_FUNC_DISCARD_DECL GLM_CONSTEXPR mat<2, R, T, Q>& operator-=(mat<2, R, T, Q>& m1, mat<2,R,U,Q> const& m2); + + + // Matrices + template + GLM_FUNC_DECL GLM_CONSTEXPR mat<2, R, T, Q> operator+(mat<2, R, T, Q> const& m1, mat<2, R, T, Q> const& m2); + template + GLM_FUNC_DECL GLM_CONSTEXPR mat<2, R, T, Q> operator-(mat<2, R, T, Q> const& m1, mat<2, R, T, Q> const& m2); + + template + GLM_FUNC_DECL GLM_CONSTEXPR mat<2, R, T, Q> operator-(T scalar, mat<2, R, T, Q> const& m); + template + GLM_FUNC_DECL GLM_CONSTEXPR mat<2, R, T, Q> operator/(T scalar, mat<2, R, T, Q>const& m); + + // -- Boolean operators -- + template + GLM_FUNC_DECL GLM_CONSTEXPR bool operator==(mat<2, R, T, Q> const& m1, mat<2, R, T, Q> const& m2); + + +} + + +#ifndef GLM_EXTERNAL_TEMPLATE +#include "mat2xn_common_ops.inl" +#endif//!GLM_EXTERNAL_TEMPLATE diff --git a/glm/detail/mat2xn_common_ops.inl b/glm/detail/mat2xn_common_ops.inl new file mode 100644 index 00000000..f01c2cd5 --- /dev/null +++ b/glm/detail/mat2xn_common_ops.inl @@ -0,0 +1,106 @@ +#include "qualifier.hpp" + +namespace glm { + + template + GLM_FUNC_QUALIFIER GLM_CONSTEXPR mat<2, R, T, Q>& operator++(mat<2, R, T, Q>& m) { + ++m[0]; + ++m[1]; + return m; + } + + template + GLM_FUNC_QUALIFIER GLM_CONSTEXPR mat<2, R, T, Q>& operator--(mat<2, R, T, Q>& m) { + --m[0]; + --m[1]; + return m; + } + + template + GLM_FUNC_QUALIFIER GLM_CONSTEXPR mat<2, R, T, Q>& operator+=(mat<2, R, T, Q>& m, U scalar) { + m[0] += scalar; + m[1] += scalar; + return m; + } + template + GLM_FUNC_QUALIFIER GLM_CONSTEXPR mat<2, R, T, Q>& operator-=(mat<2, R, T, Q>& m, U scalar) { + m[0] -= scalar; + m[1] -= scalar; + return m; + } + template + GLM_FUNC_QUALIFIER GLM_CONSTEXPR mat<2, R, T, Q>& operator*=(mat<2, R, T, Q>& m, U scalar) { + m[0] *= scalar; + m[1] *= scalar; + return m; + } + template + GLM_FUNC_QUALIFIER GLM_CONSTEXPR mat<2, R, T, Q>& operator/=(mat<2, R, T, Q>& m, U scalar) { + m[0] /= scalar; + m[1] /= scalar; + return m; + } + + // Matrices + template + GLM_FUNC_QUALIFIER GLM_CONSTEXPR mat<2, R, T, Q>& operator+=(mat<2, R, T, Q>& m1, mat<2, R, U, Q> const& m2) { + m1[0] += m2[0]; + m1[1] += m2[1]; + return m1; + } + + template + GLM_FUNC_QUALIFIER GLM_CONSTEXPR mat<2, R, T, Q>& operator-=(mat<2, R, T, Q>& m1, mat<2, R, U, Q> const& m2) { + m1[0] -= m2[0]; + m1[1] -= m2[1]; + return m1; + } + + + // Matrices + + template + GLM_FUNC_QUALIFIER GLM_CONSTEXPR mat<2, R, T, Q> operator+(mat<2, R, T, Q> const& m1, mat<2, R, T, Q> const& m2) { + return mat<2, R, T, Q>( + m1[0] + m2[0], + m1[1] + m2[1]); + } + template + GLM_FUNC_QUALIFIER GLM_CONSTEXPR mat<2, R, T, Q> operator-(mat<2, R, T, Q> const& m1, mat<2, R, T, Q> const& m2) { + return mat<2, R, T, Q>( + m1[0] - m2[0], + m1[1] - m2[1]); + } + + // Scalars + + template + GLM_FUNC_QUALIFIER GLM_CONSTEXPR mat<2, R, T, Q> operator-(T scalar, mat<2, R, T, Q> const& m) { + return mat<2, R, T, Q>( + scalar - m[0], + scalar - m[1]); + } + template + GLM_FUNC_QUALIFIER GLM_CONSTEXPR mat<2, R, T, Q> operator/(T scalar, mat<2, R, T, Q> const& m) { + return mat<2, R, T, Q>( + scalar / m[0], + scalar / m[1]); + } + + + + template + GLM_FUNC_QUALIFIER GLM_CONSTEXPR mat<2, R, T, Q> operator-(mat<2, R, T, Q> const& m) + { + return mat<2, R, T, Q>( + -m[0], + -m[1]); + } + + // -- Boolean operators -- + template + GLM_FUNC_QUALIFIER GLM_CONSTEXPR bool operator==(mat<2, R, T, Q> const& m1, mat<2, R, T, Q> const& m2) { + return m1[0] == m2[0] + && m1[1] == m2[1]; + } +} diff --git a/glm/detail/mat3xn_common_ops.hpp b/glm/detail/mat3xn_common_ops.hpp new file mode 100644 index 00000000..60b03983 --- /dev/null +++ b/glm/detail/mat3xn_common_ops.hpp @@ -0,0 +1,54 @@ +#pragma once + +#include "qualifier.hpp" +#include "mat_common_ops.hpp" + +namespace glm { + template + GLM_FUNC_DECL GLM_CONSTEXPR mat<3, R, T, Q> operator-(mat<3, R, T, Q> const& m1); + + template + GLM_FUNC_DISCARD_DECL GLM_CONSTEXPR mat<3, R, T, Q>& operator++(mat<3, R, T, Q>& m); + template + GLM_FUNC_DISCARD_DECL GLM_CONSTEXPR mat<3, R, T, Q>& operator--(mat<3, R, T, Q>& m); + + + template + GLM_FUNC_DISCARD_DECL GLM_CONSTEXPR mat<3, R, T, Q>& operator+=(mat<3, R, T, Q>& m, U scalar); + template + GLM_FUNC_DISCARD_DECL GLM_CONSTEXPR mat<3, R, T, Q>& operator-=(mat<3, R, T, Q>& m, U scalar); + template + GLM_FUNC_DISCARD_DECL GLM_CONSTEXPR mat<3, R, T, Q>& operator*=(mat<3, R, T, Q>& m, U scalar); + template + GLM_FUNC_DISCARD_DECL GLM_CONSTEXPR mat<3, R, T, Q>& operator/=(mat<3, R, T, Q>& m, U scalar); + + // Matrices + template + GLM_FUNC_DISCARD_DECL GLM_CONSTEXPR mat<3, R, T, Q>& operator+=(mat<3, R, T, Q>& m1, mat<3, R, U, Q> const& m2); + + template + GLM_FUNC_DISCARD_DECL GLM_CONSTEXPR mat<3, R, T, Q>& operator-=(mat<3, R, T, Q>& m1, mat<3, R, U, Q> const& m2); + + // Matrices + template + GLM_FUNC_DECL GLM_CONSTEXPR mat<3, R, T, Q> operator+(mat<3, R, T, Q> const& m1, mat<3, R, T, Q> const& m2); + template + GLM_FUNC_DECL GLM_CONSTEXPR mat<3, R, T, Q> operator-(mat<3, R, T, Q> const& m1, mat<3, R, T, Q> const& m2); + + // Scalars + template + GLM_FUNC_DECL GLM_CONSTEXPR mat<3, R, T, Q> operator-(T scalar, mat<3, R, T, Q> const& m); + template + GLM_FUNC_DECL GLM_CONSTEXPR mat<3, R, T, Q> operator/(T scalar, mat<3, R, T, Q>const& m); + + // -- Boolean operators -- + template + GLM_FUNC_DECL GLM_CONSTEXPR bool operator==(mat<3, R, T, Q> const& m1, mat<3, R, T, Q> const& m3); + + +} + + +#ifndef GLM_EXTERNAL_TEMPLATE +#include "mat3xn_common_ops.inl" +#endif//!GLM_EXTERNAL_TEMPLATE diff --git a/glm/detail/mat3xn_common_ops.inl b/glm/detail/mat3xn_common_ops.inl new file mode 100644 index 00000000..245474bd --- /dev/null +++ b/glm/detail/mat3xn_common_ops.inl @@ -0,0 +1,117 @@ +#include "qualifier.hpp" + +namespace glm { + + template + GLM_FUNC_QUALIFIER GLM_CONSTEXPR mat<3, R, T, Q>& operator++(mat<3, R, T, Q>& m) { + ++m[0]; + ++m[1]; + ++m[2]; + return m; + } + + template + GLM_FUNC_QUALIFIER GLM_CONSTEXPR mat<3, R, T, Q>& operator--(mat<3, R, T, Q>& m) { + --m[0]; + --m[1]; + --m[2]; + return m; + } + + template + GLM_FUNC_QUALIFIER GLM_CONSTEXPR mat<3, R, T, Q>& operator+=(mat<3, R, T, Q>& m, U scalar) { + m[0] += scalar; + m[1] += scalar; + m[2] += scalar; + return m; + } + template + GLM_FUNC_QUALIFIER GLM_CONSTEXPR mat<3, R, T, Q>& operator-=(mat<3, R, T, Q>& m, U scalar) { + m[0] -= scalar; + m[1] -= scalar; + m[2] -= scalar; + return m; + } + template + GLM_FUNC_QUALIFIER GLM_CONSTEXPR mat<3, R, T, Q>& operator*=(mat<3, R, T, Q>& m, U scalar) { + m[0] *= scalar; + m[1] *= scalar; + m[2] *= scalar; + return m; + } + template + GLM_FUNC_QUALIFIER GLM_CONSTEXPR mat<3, R, T, Q>& operator/=(mat<3, R, T, Q>& m, U scalar) { + m[0] /= scalar; + m[1] /= scalar; + m[2] /= scalar; + return m; + } + + + // Matrices + template + GLM_FUNC_QUALIFIER GLM_CONSTEXPR mat<3, R, T, Q>& operator+=(mat<3, R, T, Q>& m1, mat<3, R, U, Q> const& m2) { + m1[0] += m2[0]; + m1[1] += m2[1]; + m1[2] += m2[2]; + return m1; + } + + template + GLM_FUNC_QUALIFIER GLM_CONSTEXPR mat<3, R, T, Q>& operator-=(mat<3, R, T, Q>& m1, mat<3, R, U, Q> const& m2) { + m1[0] -= m2[0]; + m1[1] -= m2[1]; + m1[2] -= m2[2]; + return m1; + } + + + // Matrices + template + GLM_FUNC_QUALIFIER GLM_CONSTEXPR mat<3, R, T, Q> operator+(mat<3, R, T, Q> const& m1, mat<3, R, T, Q> const& m2) { + return mat<3, R, T, Q>( + m1[0] + m2[0], + m1[1] + m2[1], + m1[2] + m2[2]); + } + template + GLM_FUNC_QUALIFIER GLM_CONSTEXPR mat<3, R, T, Q> operator-(mat<3, R, T, Q> const& m1, mat<3, R, T, Q> const& m2) { + return mat<3, R, T, Q>( + m1[0] - m2[0], + m1[1] - m2[1], + m1[2] - m2[2]); + } + + // Scalars + template + GLM_FUNC_QUALIFIER GLM_CONSTEXPR mat<3, R, T, Q> operator-(T scalar, mat<3, R, T, Q> const& m) { + return mat<3, R, T, Q>( + scalar - m[0], + scalar - m[1], + scalar - m[2]); + } + template + GLM_FUNC_QUALIFIER GLM_CONSTEXPR mat<3, R, T, Q> operator/(T scalar, mat<3, R, T, Q> const& m) { + return mat<3, R, T, Q>( + scalar / m[0], + scalar / m[1], + scalar / m[2]); + } + + template + GLM_FUNC_QUALIFIER GLM_CONSTEXPR mat<3, R, T, Q> operator-(mat<3, R, T, Q> const& m) + { + return mat<3, R, T, Q>( + -m[0], + -m[1], + -m[2]); + } + + // -- Boolean operators -- + template + GLM_FUNC_QUALIFIER GLM_CONSTEXPR bool operator==(mat<3, R, T, Q> const& m1, mat<3, R, T, Q> const& m2) { + return m1[0] == m2[0] + && m1[1] == m2[1] + && m1[2] == m2[2]; + } +} diff --git a/glm/detail/mat4xn_common_ops.hpp b/glm/detail/mat4xn_common_ops.hpp new file mode 100644 index 00000000..d7e0647d --- /dev/null +++ b/glm/detail/mat4xn_common_ops.hpp @@ -0,0 +1,52 @@ +#pragma once + +#include "qualifier.hpp" +#include "mat_common_ops.hpp" + +namespace glm { + template + GLM_FUNC_DECL GLM_CONSTEXPR mat<4, R, T, Q> operator-(mat<4, R, T, Q> const& m1); + + template + GLM_FUNC_DISCARD_DECL GLM_CONSTEXPR mat<4, R, T, Q>& operator++(mat<4, R, T, Q>& m); + template + GLM_FUNC_DISCARD_DECL GLM_CONSTEXPR mat<4, R, T, Q>& operator--(mat<4, R, T, Q>& m); + + + template + GLM_FUNC_DISCARD_DECL GLM_CONSTEXPR mat<4, R, T, Q>& operator+=(mat<4, R, T, Q>& m, U scalar); + template + GLM_FUNC_DISCARD_DECL GLM_CONSTEXPR mat<4, R, T, Q>& operator-=(mat<4, R, T, Q>& m, U scalar); + template + GLM_FUNC_DISCARD_DECL GLM_CONSTEXPR mat<4, R, T, Q>& operator*=(mat<4, R, T, Q>& m, U scalar); + template + GLM_FUNC_DISCARD_DECL GLM_CONSTEXPR mat<4, R, T, Q>& operator/=(mat<4, R, T, Q>& m, U scalar); + + // Matrices + template + GLM_FUNC_DISCARD_DECL GLM_CONSTEXPR mat<4, R, T, Q>& operator+=(mat<4, R, T, Q>& m1, mat<4, R, U, Q> const& m2); + + template + GLM_FUNC_DISCARD_DECL GLM_CONSTEXPR mat<4, R, T, Q>& operator-=(mat<4, R, T, Q>& m1, mat<4, R, U, Q> const& m2); + + // Matrices + template + GLM_FUNC_DECL GLM_CONSTEXPR mat<4, R, T, Q> operator+(mat<4, R, T, Q> const& m1, mat<4, R, T, Q> const& m2); + template + GLM_FUNC_DECL GLM_CONSTEXPR mat<4, R, T, Q> operator-(mat<4, R, T, Q> const& m1, mat<4, R, T, Q> const& m2); + + // Scalars + template + GLM_FUNC_DECL GLM_CONSTEXPR mat<4, R, T, Q> operator-(T scalar, mat<4, R, T, Q> const& m); + template + GLM_FUNC_DECL GLM_CONSTEXPR mat<4, R, T, Q> operator/(T scalar, mat<4, R, T, Q> const& m); + + // -- Boolean operators -- + template + GLM_FUNC_DECL GLM_CONSTEXPR bool operator==(mat<4, R, T, Q> const& m1, mat<4, R, T, Q> const& m4); +} + + +#ifndef GLM_EXTERNAL_TEMPLATE +#include "mat4xn_common_ops.inl" +#endif//!GLM_EXTERNAL_TEMPLATE diff --git a/glm/detail/mat4xn_common_ops.inl b/glm/detail/mat4xn_common_ops.inl new file mode 100644 index 00000000..7c8f43a2 --- /dev/null +++ b/glm/detail/mat4xn_common_ops.inl @@ -0,0 +1,131 @@ +#include "qualifier.hpp" + +namespace glm { + + template + GLM_FUNC_QUALIFIER GLM_CONSTEXPR mat<4, R, T, Q>& operator++(mat<4, R, T, Q>& m) { + ++m[0]; + ++m[1]; + ++m[2]; + ++m[3]; + return m; + } + + template + GLM_FUNC_QUALIFIER GLM_CONSTEXPR mat<4, R, T, Q>& operator--(mat<4, R, T, Q>& m) { + --m[0]; + --m[1]; + --m[2]; + --m[3]; + return m; + } + + template + GLM_FUNC_QUALIFIER GLM_CONSTEXPR mat<4, R, T, Q>& operator+=(mat<4, R, T, Q>& m, U scalar) { + m[0] += scalar; + m[1] += scalar; + m[2] += scalar; + m[3] += scalar; + return m; + } + template + GLM_FUNC_QUALIFIER GLM_CONSTEXPR mat<4, R, T, Q>& operator-=(mat<4, R, T, Q>& m, U scalar) { + m[0] -= scalar; + m[1] -= scalar; + m[2] -= scalar; + m[3] -= scalar; + return m; + } + template + GLM_FUNC_QUALIFIER GLM_CONSTEXPR mat<4, R, T, Q>& operator*=(mat<4, R, T, Q>& m, U scalar) { + m[0] *= scalar; + m[1] *= scalar; + m[2] *= scalar; + m[3] *= scalar; + return m; + } + template + GLM_FUNC_QUALIFIER GLM_CONSTEXPR mat<4, R, T, Q>& operator/=(mat<4, R, T, Q>& m, U scalar) { + m[0] /= scalar; + m[1] /= scalar; + m[2] /= scalar; + m[3] /= scalar; + return m; + } + + // Matrices + template + GLM_FUNC_QUALIFIER GLM_CONSTEXPR mat<4, R, T, Q>& operator+=(mat<4, R, T, Q>& m1, mat<4, R, U, Q> const& m2) { + m1[0] += m2[0]; + m1[1] += m2[1]; + m1[2] += m2[2]; + m1[3] += m2[3]; + return m1; + } + + template + GLM_FUNC_QUALIFIER GLM_CONSTEXPR mat<4, R, T, Q>& operator-=(mat<4, R, T, Q>& m1, mat<4, R, U, Q> const& m2) { + m1[0] -= m2[0]; + m1[1] -= m2[1]; + m1[2] -= m2[2]; + m1[3] -= m2[3]; + return m1; + } + // Matrices + template + GLM_FUNC_QUALIFIER GLM_CONSTEXPR mat<4, R, T, Q> operator+(mat<4, R, T, Q> const& m1, mat<4, R, T, Q> const& m2) { + return mat<4, R, T, Q>( + m1[0] + m2[0], + m1[1] + m2[1], + m1[2] + m2[2], + m1[3] + m2[3]); + } + template + GLM_FUNC_QUALIFIER GLM_CONSTEXPR mat<4, R, T, Q> operator-(mat<4, R, T, Q> const& m1, mat<4, R, T, Q> const& m2) { + return mat<4, R, T, Q>( + m1[0] - m2[0], + m1[1] - m2[1], + m1[2] - m2[2], + m1[3] - m2[3]); + } + + // Scalars + + + + template + GLM_FUNC_QUALIFIER GLM_CONSTEXPR mat<4, R, T, Q> operator-(T scalar, mat<4, R, T, Q> const& m) { + return mat<4, R, T, Q>( + scalar - m[0], + scalar - m[1], + scalar - m[2], + scalar - m[3]); + } + template + GLM_FUNC_QUALIFIER GLM_CONSTEXPR mat<4, R, T, Q> operator/(T scalar, mat<4, R, T, Q>const& m) { + return mat<4, R, T, Q>( + scalar / m[0], + scalar / m[1], + scalar / m[2], + scalar / m[3]); + } + + template + GLM_FUNC_QUALIFIER GLM_CONSTEXPR mat<4, R, T, Q> operator-(mat<4, R, T, Q> const& m) + { + return mat<4, R, T, Q>( + -m[0], + -m[1], + -m[2], + -m[3]); + } + + // -- Boolean operators -- + template + GLM_FUNC_QUALIFIER GLM_CONSTEXPR bool operator==(mat<4, R, T, Q> const& m1, mat<4, R, T, Q> const& m2) { + return m1[0] == m2[0] + && m1[1] == m2[1] + && m1[2] == m2[2] + && m1[3] == m2[3]; + } +} diff --git a/glm/detail/mat_common_ops.hpp b/glm/detail/mat_common_ops.hpp new file mode 100644 index 00000000..7d6e01b5 --- /dev/null +++ b/glm/detail/mat_common_ops.hpp @@ -0,0 +1,37 @@ +#pragma once + +#include "qualifier.hpp" + +namespace glm { + + template + GLM_FUNC_DECL GLM_CONSTEXPR mat operator+(mat const& m); + + template + GLM_FUNC_DECL GLM_CONSTEXPR mat operator++(mat& m, int); + + template + GLM_FUNC_DECL GLM_CONSTEXPR mat operator--(mat& m, int); + + template + GLM_FUNC_DECL GLM_CONSTEXPR mat operator+(mat const& m, T scalar); + template + GLM_FUNC_DECL GLM_CONSTEXPR mat operator-(mat const& m, T scalar); + template + GLM_FUNC_DECL GLM_CONSTEXPR mat operator*(mat const& m, T scalar); + template + GLM_FUNC_DECL GLM_CONSTEXPR mat operator/(mat const& m, T scalar); + + template + GLM_FUNC_DECL GLM_CONSTEXPR mat operator+(T scalar, mat const& m); + template + GLM_FUNC_DECL GLM_CONSTEXPR mat operator*(T scalar, mat const& m); + + template + GLM_FUNC_DECL GLM_CONSTEXPR bool operator!=(mat const& m1, mat const& m2); +} + + +#ifndef GLM_EXTERNAL_TEMPLATE +#include "mat_common_ops.inl" +#endif//!GLM_EXTERNAL_TEMPLATE diff --git a/glm/detail/mat_common_ops.inl b/glm/detail/mat_common_ops.inl new file mode 100644 index 00000000..ca981c99 --- /dev/null +++ b/glm/detail/mat_common_ops.inl @@ -0,0 +1,67 @@ +#include "qualifier.hpp" + +namespace glm { + template + GLM_FUNC_QUALIFIER GLM_CONSTEXPR mat operator+(mat const& m) { + return m; + } + template + GLM_FUNC_QUALIFIER GLM_CONSTEXPR mat operator++(mat& m,int) + { + mat Result(m); + ++m; + return Result; + } + + template + GLM_FUNC_QUALIFIER GLM_CONSTEXPR mat operator--(mat& m, int) + { + mat Result(m); + --m; + return Result; + } + + + template + GLM_FUNC_QUALIFIER GLM_CONSTEXPR bool operator!=(mat const& m1, mat const& m2) { + return !(m1 == m2); + } + + + template + GLM_FUNC_QUALIFIER GLM_CONSTEXPR mat operator+(mat const& m, T scalar) { + mat Result(m); + Result += scalar; + return Result; + } + + template + GLM_FUNC_QUALIFIER GLM_CONSTEXPR mat operator-(mat const& m, T scalar) { + mat Result(m); + Result -= scalar; + return Result; + } + + template + GLM_FUNC_QUALIFIER GLM_CONSTEXPR mat operator*(mat const& m, T scalar) { + mat Result(m); + Result *= scalar; + return Result; + } + + template + GLM_FUNC_QUALIFIER GLM_CONSTEXPR mat operator/(mat const& m, T scalar) { + mat Result(m); + Result /= scalar; + return Result; + } + + template + GLM_FUNC_QUALIFIER GLM_CONSTEXPR mat operator+(T scalar, mat const& m) { + return m + scalar; + } + template + GLM_FUNC_QUALIFIER GLM_CONSTEXPR mat operator*(T scalar, mat const& m) { + return m * scalar; + } +} diff --git a/glm/detail/qualifier.hpp b/glm/detail/qualifier.hpp index cb4e108a..f2f1d284 100644 --- a/glm/detail/qualifier.hpp +++ b/glm/detail/qualifier.hpp @@ -58,28 +58,12 @@ namespace detail template struct is_aligned { - static const bool value = false; - }; - # if GLM_CONFIG_ALIGNED_GENTYPES == GLM_ENABLE - template<> - struct is_aligned - { - static const bool value = true; - }; - - template<> - struct is_aligned - { - static const bool value = true; - }; - - template<> - struct is_aligned - { - static const bool value = true; - }; + static const bool value = (P == glm::aligned_lowp || P == glm::aligned_mediump || P == glm::aligned_highp); +# else + static const bool value = false; # endif + }; template struct storage @@ -258,8 +242,7 @@ namespace detail }; template - struct genTypeTrait - {}; + struct genTypeTrait; template struct genTypeTrait > @@ -268,9 +251,7 @@ namespace detail }; template - struct init_gentype - { - }; + struct init_gentype; template struct init_gentype diff --git a/glm/detail/type_float.hpp b/glm/detail/type_float.hpp index c8037ebd..9b7a39de 100644 --- a/glm/detail/type_float.hpp +++ b/glm/detail/type_float.hpp @@ -11,8 +11,7 @@ namespace glm{ namespace detail { template - union float_t - {}; + union float_t; // undefined // https://randomascii.wordpress.com/2012/02/25/comparing-floating-point-numbers-2012-edition/ template <> diff --git a/glm/detail/type_mat2x2.hpp b/glm/detail/type_mat2x2.hpp index 82e9f66c..750a953b 100644 --- a/glm/detail/type_mat2x2.hpp +++ b/glm/detail/type_mat2x2.hpp @@ -6,7 +6,7 @@ #include "type_vec2.hpp" #include #include - +#include "mat2xn_common_ops.hpp" namespace glm { template @@ -73,66 +73,17 @@ namespace glm // -- Unary arithmetic operators -- template - GLM_FUNC_DISCARD_DECL GLM_CONSTEXPR mat<2, 2, T, Q> & operator=(mat<2, 2, U, Q> const& m); + GLM_FUNC_DISCARD_DECL GLM_CONSTEXPR mat<2, 2, T, Q>& operator=(mat<2, 2, U, Q> const& m); + template - GLM_FUNC_DISCARD_DECL GLM_CONSTEXPR mat<2, 2, T, Q> & operator+=(U s); + GLM_FUNC_DISCARD_DECL GLM_CONSTEXPR mat<2, 2, T, Q>& operator*=(mat<2, 2, U, Q> const& m); template - GLM_FUNC_DISCARD_DECL GLM_CONSTEXPR mat<2, 2, T, Q> & operator+=(mat<2, 2, U, Q> const& m); - template - GLM_FUNC_DISCARD_DECL GLM_CONSTEXPR mat<2, 2, T, Q> & operator-=(U s); - template - GLM_FUNC_DISCARD_DECL GLM_CONSTEXPR mat<2, 2, T, Q> & operator-=(mat<2, 2, U, Q> const& m); - template - GLM_FUNC_DISCARD_DECL GLM_CONSTEXPR mat<2, 2, T, Q> & operator*=(U s); - template - GLM_FUNC_DISCARD_DECL GLM_CONSTEXPR mat<2, 2, T, Q> & operator*=(mat<2, 2, U, Q> const& m); - template - GLM_FUNC_DISCARD_DECL GLM_CONSTEXPR mat<2, 2, T, Q> & operator/=(U s); - template - GLM_FUNC_DISCARD_DECL GLM_CONSTEXPR mat<2, 2, T, Q> & operator/=(mat<2, 2, U, Q> const& m); + GLM_FUNC_DISCARD_DECL GLM_CONSTEXPR mat<2, 2, T, Q>& operator/=(mat<2, 2, U, Q> const& m); - // -- Increment and decrement operators -- - - GLM_FUNC_DISCARD_DECL GLM_CONSTEXPR mat<2, 2, T, Q> & operator++ (); - GLM_FUNC_DISCARD_DECL GLM_CONSTEXPR mat<2, 2, T, Q> & operator-- (); - GLM_FUNC_DECL GLM_CONSTEXPR mat<2, 2, T, Q> operator++(int); - GLM_FUNC_DECL GLM_CONSTEXPR mat<2, 2, T, Q> operator--(int); }; - // -- Unary operators -- - - template - GLM_FUNC_DECL GLM_CONSTEXPR mat<2, 2, T, Q> operator+(mat<2, 2, T, Q> const& m); - - template - GLM_FUNC_DECL GLM_CONSTEXPR mat<2, 2, T, Q> operator-(mat<2, 2, T, Q> const& m); - // -- Binary operators -- - template - GLM_FUNC_DECL GLM_CONSTEXPR mat<2, 2, T, Q> operator+(mat<2, 2, T, Q> const& m, T scalar); - - template - GLM_FUNC_DECL GLM_CONSTEXPR mat<2, 2, T, Q> operator+(T scalar, mat<2, 2, T, Q> const& m); - - template - GLM_FUNC_DECL GLM_CONSTEXPR mat<2, 2, T, Q> operator+(mat<2, 2, T, Q> const& m1, mat<2, 2, T, Q> const& m2); - - template - GLM_FUNC_DECL GLM_CONSTEXPR mat<2, 2, T, Q> operator-(mat<2, 2, T, Q> const& m, T scalar); - - template - GLM_FUNC_DECL GLM_CONSTEXPR mat<2, 2, T, Q> operator-(T scalar, mat<2, 2, T, Q> const& m); - - template - GLM_FUNC_DECL GLM_CONSTEXPR mat<2, 2, T, Q> operator-(mat<2, 2, T, Q> const& m1, mat<2, 2, T, Q> const& m2); - - template - GLM_FUNC_DECL GLM_CONSTEXPR mat<2, 2, T, Q> operator*(mat<2, 2, T, Q> const& m, T scalar); - - template - GLM_FUNC_DECL GLM_CONSTEXPR mat<2, 2, T, Q> operator*(T scalar, mat<2, 2, T, Q> const& m); - template GLM_FUNC_DECL GLM_CONSTEXPR typename mat<2, 2, T, Q>::col_type operator*(mat<2, 2, T, Q> const& m, typename mat<2, 2, T, Q>::row_type const& v); @@ -148,12 +99,6 @@ namespace glm template GLM_FUNC_DECL GLM_CONSTEXPR mat<4, 2, T, Q> operator*(mat<2, 2, T, Q> const& m1, mat<4, 2, T, Q> const& m2); - template - GLM_FUNC_DECL GLM_CONSTEXPR mat<2, 2, T, Q> operator/(mat<2, 2, T, Q> const& m, T scalar); - - template - GLM_FUNC_DECL GLM_CONSTEXPR mat<2, 2, T, Q> operator/(T scalar, mat<2, 2, T, Q> const& m); - template GLM_FUNC_DECL GLM_CONSTEXPR typename mat<2, 2, T, Q>::col_type operator/(mat<2, 2, T, Q> const& m, typename mat<2, 2, T, Q>::row_type const& v); @@ -163,13 +108,6 @@ namespace glm template GLM_FUNC_DECL GLM_CONSTEXPR mat<2, 2, T, Q> operator/(mat<2, 2, T, Q> const& m1, mat<2, 2, T, Q> const& m2); - // -- Boolean operators -- - - template - GLM_FUNC_DECL GLM_CONSTEXPR bool operator==(mat<2, 2, T, Q> const& m1, mat<2, 2, T, Q> const& m2); - - template - GLM_FUNC_DECL GLM_CONSTEXPR bool operator!=(mat<2, 2, T, Q> const& m1, mat<2, 2, T, Q> const& m2); } //namespace glm #ifndef GLM_EXTERNAL_TEMPLATE diff --git a/glm/detail/type_mat2x2.inl b/glm/detail/type_mat2x2.inl index afb2b31e..ff7801c7 100644 --- a/glm/detail/type_mat2x2.inl +++ b/glm/detail/type_mat2x2.inl @@ -243,187 +243,16 @@ namespace glm template template - GLM_FUNC_QUALIFIER GLM_CONSTEXPR mat<2, 2, T, Q>& mat<2, 2, T, Q>::operator+=(U scalar) - { - this->value[0] += scalar; - this->value[1] += scalar; - return *this; + GLM_FUNC_QUALIFIER GLM_CONSTEXPR mat<2, 2, T, Q>& mat<2, 2, T, Q>::operator*=(mat<2, 2, U, Q> const& m) { + return *this = *this * m; } template template - GLM_FUNC_QUALIFIER GLM_CONSTEXPR mat<2, 2, T, Q>& mat<2, 2, T, Q>::operator+=(mat<2, 2, U, Q> const& m) - { - this->value[0] += m[0]; - this->value[1] += m[1]; - return *this; - } - - template - template - GLM_FUNC_QUALIFIER GLM_CONSTEXPR mat<2, 2, T, Q>& mat<2, 2, T, Q>::operator-=(U scalar) - { - this->value[0] -= scalar; - this->value[1] -= scalar; - return *this; - } - - template - template - GLM_FUNC_QUALIFIER GLM_CONSTEXPR mat<2, 2, T, Q>& mat<2, 2, T, Q>::operator-=(mat<2, 2, U, Q> const& m) - { - this->value[0] -= m[0]; - this->value[1] -= m[1]; - return *this; - } - - template - template - GLM_FUNC_QUALIFIER GLM_CONSTEXPR mat<2, 2, T, Q>& mat<2, 2, T, Q>::operator*=(U scalar) - { - this->value[0] *= scalar; - this->value[1] *= scalar; - return *this; - } - - template - template - GLM_FUNC_QUALIFIER GLM_CONSTEXPR mat<2, 2, T, Q>& mat<2, 2, T, Q>::operator*=(mat<2, 2, U, Q> const& m) - { - return (*this = *this * m); - } - - template - template - GLM_FUNC_QUALIFIER GLM_CONSTEXPR mat<2, 2, T, Q>& mat<2, 2, T, Q>::operator/=(U scalar) - { - this->value[0] /= scalar; - this->value[1] /= scalar; - return *this; - } - - template - template - GLM_FUNC_QUALIFIER GLM_CONSTEXPR mat<2, 2, T, Q>& mat<2, 2, T, Q>::operator/=(mat<2, 2, U, Q> const& m) - { + GLM_FUNC_QUALIFIER GLM_CONSTEXPR mat<2, 2, T, Q>& mat<2, 2, T, Q>::operator/=(mat<2, 2, U, Q> const& m) { return *this *= inverse(m); } - // -- Increment and decrement operators -- - - template - GLM_FUNC_QUALIFIER GLM_CONSTEXPR mat<2, 2, T, Q>& mat<2, 2, T, Q>::operator++() - { - ++this->value[0]; - ++this->value[1]; - return *this; - } - - template - GLM_FUNC_QUALIFIER GLM_CONSTEXPR mat<2, 2, T, Q>& mat<2, 2, T, Q>::operator--() - { - --this->value[0]; - --this->value[1]; - return *this; - } - - template - GLM_FUNC_QUALIFIER GLM_CONSTEXPR mat<2, 2, T, Q> mat<2, 2, T, Q>::operator++(int) - { - mat<2, 2, T, Q> Result(*this); - ++*this; - return Result; - } - - template - GLM_FUNC_QUALIFIER GLM_CONSTEXPR mat<2, 2, T, Q> mat<2, 2, T, Q>::operator--(int) - { - mat<2, 2, T, Q> Result(*this); - --*this; - return Result; - } - - // -- Unary arithmetic operators -- - - template - GLM_FUNC_QUALIFIER GLM_CONSTEXPR mat<2, 2, T, Q> operator+(mat<2, 2, T, Q> const& m) - { - return m; - } - - template - GLM_FUNC_QUALIFIER GLM_CONSTEXPR mat<2, 2, T, Q> operator-(mat<2, 2, T, Q> const& m) - { - return mat<2, 2, T, Q>( - -m[0], - -m[1]); - } - - // -- Binary arithmetic operators -- - - template - GLM_FUNC_QUALIFIER GLM_CONSTEXPR mat<2, 2, T, Q> operator+(mat<2, 2, T, Q> const& m, T scalar) - { - return mat<2, 2, T, Q>( - m[0] + scalar, - m[1] + scalar); - } - - template - GLM_FUNC_QUALIFIER GLM_CONSTEXPR mat<2, 2, T, Q> operator+(T scalar, mat<2, 2, T, Q> const& m) - { - return mat<2, 2, T, Q>( - m[0] + scalar, - m[1] + scalar); - } - - template - GLM_FUNC_QUALIFIER GLM_CONSTEXPR mat<2, 2, T, Q> operator+(mat<2, 2, T, Q> const& m1, mat<2, 2, T, Q> const& m2) - { - return mat<2, 2, T, Q>( - m1[0] + m2[0], - m1[1] + m2[1]); - } - - template - GLM_FUNC_QUALIFIER GLM_CONSTEXPR mat<2, 2, T, Q> operator-(mat<2, 2, T, Q> const& m, T scalar) - { - return mat<2, 2, T, Q>( - m[0] - scalar, - m[1] - scalar); - } - - template - GLM_FUNC_QUALIFIER GLM_CONSTEXPR mat<2, 2, T, Q> operator-(T scalar, mat<2, 2, T, Q> const& m) - { - return mat<2, 2, T, Q>( - scalar - m[0], - scalar - m[1]); - } - - template - GLM_FUNC_QUALIFIER GLM_CONSTEXPR mat<2, 2, T, Q> operator-(mat<2, 2, T, Q> const& m1, mat<2, 2, T, Q> const& m2) - { - return mat<2, 2, T, Q>( - m1[0] - m2[0], - m1[1] - m2[1]); - } - - template - GLM_FUNC_QUALIFIER GLM_CONSTEXPR mat<2, 2, T, Q> operator*(mat<2, 2, T, Q> const& m, T scalar) - { - return mat<2, 2, T, Q>( - m[0] * scalar, - m[1] * scalar); - } - - template - GLM_FUNC_QUALIFIER GLM_CONSTEXPR mat<2, 2, T, Q> operator*(T scalar, mat<2, 2, T, Q> const& m) - { - return mat<2, 2, T, Q>( - m[0] * scalar, - m[1] * scalar); - } template GLM_FUNC_QUALIFIER GLM_CONSTEXPR typename mat<2, 2, T, Q>::col_type operator* @@ -485,22 +314,6 @@ namespace glm m1[0][1] * m2[3][0] + m1[1][1] * m2[3][1]); } - template - GLM_FUNC_QUALIFIER GLM_CONSTEXPR mat<2, 2, T, Q> operator/(mat<2, 2, T, Q> const& m, T scalar) - { - return mat<2, 2, T, Q>( - m[0] / scalar, - m[1] / scalar); - } - - template - GLM_FUNC_QUALIFIER GLM_CONSTEXPR mat<2, 2, T, Q> operator/(T scalar, mat<2, 2, T, Q> const& m) - { - return mat<2, 2, T, Q>( - scalar / m[0], - scalar / m[1]); - } - template GLM_FUNC_QUALIFIER GLM_CONSTEXPR typename mat<2, 2, T, Q>::col_type operator/(mat<2, 2, T, Q> const& m, typename mat<2, 2, T, Q>::row_type const& v) { @@ -519,18 +332,4 @@ namespace glm mat<2, 2, T, Q> m1_copy(m1); return m1_copy /= m2; } - - // -- Boolean operators -- - - template - GLM_FUNC_QUALIFIER GLM_CONSTEXPR bool operator==(mat<2, 2, T, Q> const& m1, mat<2, 2, T, Q> const& m2) - { - return (m1[0] == m2[0]) && (m1[1] == m2[1]); - } - - template - GLM_FUNC_QUALIFIER GLM_CONSTEXPR bool operator!=(mat<2, 2, T, Q> const& m1, mat<2, 2, T, Q> const& m2) - { - return (m1[0] != m2[0]) || (m1[1] != m2[1]); - } } //namespace glm diff --git a/glm/detail/type_mat2x3.hpp b/glm/detail/type_mat2x3.hpp index b65d1c5c..bd6dd865 100644 --- a/glm/detail/type_mat2x3.hpp +++ b/glm/detail/type_mat2x3.hpp @@ -5,6 +5,7 @@ #include "type_vec2.hpp" #include "type_vec3.hpp" +#include "mat2xn_common_ops.hpp" #include #include @@ -75,55 +76,10 @@ namespace glm template GLM_FUNC_DISCARD_DECL GLM_CONSTEXPR mat<2, 3, T, Q> & operator=(mat<2, 3, U, Q> const& m); - template - GLM_FUNC_DISCARD_DECL GLM_CONSTEXPR mat<2, 3, T, Q> & operator+=(U s); - template - GLM_FUNC_DISCARD_DECL GLM_CONSTEXPR mat<2, 3, T, Q> & operator+=(mat<2, 3, U, Q> const& m); - template - GLM_FUNC_DISCARD_DECL GLM_CONSTEXPR mat<2, 3, T, Q> & operator-=(U s); - template - GLM_FUNC_DISCARD_DECL GLM_CONSTEXPR mat<2, 3, T, Q> & operator-=(mat<2, 3, U, Q> const& m); - template - GLM_FUNC_DISCARD_DECL GLM_CONSTEXPR mat<2, 3, T, Q> & operator*=(U s); - template - GLM_FUNC_DISCARD_DECL GLM_CONSTEXPR mat<2, 3, T, Q> & operator/=(U s); - - // -- Increment and decrement operators -- - - GLM_FUNC_DISCARD_DECL GLM_CONSTEXPR mat<2, 3, T, Q> & operator++ (); - GLM_FUNC_DISCARD_DECL GLM_CONSTEXPR mat<2, 3, T, Q> & operator-- (); - GLM_FUNC_DECL GLM_CONSTEXPR mat<2, 3, T, Q> operator++(int); - GLM_FUNC_DECL GLM_CONSTEXPR mat<2, 3, T, Q> operator--(int); }; - // -- Unary operators -- - - template - GLM_FUNC_DECL GLM_CONSTEXPR mat<2, 3, T, Q> operator+(mat<2, 3, T, Q> const& m); - - template - GLM_FUNC_DECL GLM_CONSTEXPR mat<2, 3, T, Q> operator-(mat<2, 3, T, Q> const& m); - // -- Binary operators -- - template - GLM_FUNC_DECL GLM_CONSTEXPR mat<2, 3, T, Q> operator+(mat<2, 3, T, Q> const& m, T scalar); - - template - GLM_FUNC_DECL GLM_CONSTEXPR mat<2, 3, T, Q> operator+(mat<2, 3, T, Q> const& m1, mat<2, 3, T, Q> const& m2); - - template - GLM_FUNC_DECL GLM_CONSTEXPR mat<2, 3, T, Q> operator-(mat<2, 3, T, Q> const& m, T scalar); - - template - GLM_FUNC_DECL GLM_CONSTEXPR mat<2, 3, T, Q> operator-(mat<2, 3, T, Q> const& m1, mat<2, 3, T, Q> const& m2); - - template - GLM_FUNC_DECL GLM_CONSTEXPR mat<2, 3, T, Q> operator*(mat<2, 3, T, Q> const& m, T scalar); - - template - GLM_FUNC_DECL GLM_CONSTEXPR mat<2, 3, T, Q> operator*(T scalar, mat<2, 3, T, Q> const& m); - template GLM_FUNC_DECL GLM_CONSTEXPR typename mat<2, 3, T, Q>::col_type operator*(mat<2, 3, T, Q> const& m, typename mat<2, 3, T, Q>::row_type const& v); @@ -139,19 +95,6 @@ namespace glm template GLM_FUNC_DECL GLM_CONSTEXPR mat<4, 3, T, Q> operator*(mat<2, 3, T, Q> const& m1, mat<4, 2, T, Q> const& m2); - template - GLM_FUNC_DECL GLM_CONSTEXPR mat<2, 3, T, Q> operator/(mat<2, 3, T, Q> const& m, T scalar); - - template - GLM_FUNC_DECL GLM_CONSTEXPR mat<2, 3, T, Q> operator/(T scalar, mat<2, 3, T, Q> const& m); - - // -- Boolean operators -- - - template - GLM_FUNC_DECL GLM_CONSTEXPR bool operator==(mat<2, 3, T, Q> const& m1, mat<2, 3, T, Q> const& m2); - - template - GLM_FUNC_DECL GLM_CONSTEXPR bool operator!=(mat<2, 3, T, Q> const& m1, mat<2, 3, T, Q> const& m2); }//namespace glm #ifndef GLM_EXTERNAL_TEMPLATE diff --git a/glm/detail/type_mat2x3.inl b/glm/detail/type_mat2x3.inl index 345ac8ac..93df3fdf 100644 --- a/glm/detail/type_mat2x3.inl +++ b/glm/detail/type_mat2x3.inl @@ -241,160 +241,7 @@ namespace glm return *this; } - template - template - GLM_FUNC_QUALIFIER GLM_CONSTEXPR mat<2, 3, T, Q> & mat<2, 3, T, Q>::operator+=(U s) - { - this->value[0] += s; - this->value[1] += s; - return *this; - } - - template - template - GLM_FUNC_QUALIFIER GLM_CONSTEXPR mat<2, 3, T, Q>& mat<2, 3, T, Q>::operator+=(mat<2, 3, U, Q> const& m) - { - this->value[0] += m[0]; - this->value[1] += m[1]; - return *this; - } - - template - template - GLM_FUNC_QUALIFIER GLM_CONSTEXPR mat<2, 3, T, Q>& mat<2, 3, T, Q>::operator-=(U s) - { - this->value[0] -= s; - this->value[1] -= s; - return *this; - } - - template - template - GLM_FUNC_QUALIFIER GLM_CONSTEXPR mat<2, 3, T, Q>& mat<2, 3, T, Q>::operator-=(mat<2, 3, U, Q> const& m) - { - this->value[0] -= m[0]; - this->value[1] -= m[1]; - return *this; - } - - template - template - GLM_FUNC_QUALIFIER GLM_CONSTEXPR mat<2, 3, T, Q>& mat<2, 3, T, Q>::operator*=(U s) - { - this->value[0] *= s; - this->value[1] *= s; - return *this; - } - - template - template - GLM_FUNC_QUALIFIER GLM_CONSTEXPR mat<2, 3, T, Q> & mat<2, 3, T, Q>::operator/=(U s) - { - this->value[0] /= s; - this->value[1] /= s; - return *this; - } - - // -- Increment and decrement operators -- - - template - GLM_FUNC_QUALIFIER GLM_CONSTEXPR mat<2, 3, T, Q> & mat<2, 3, T, Q>::operator++() - { - ++this->value[0]; - ++this->value[1]; - return *this; - } - - template - GLM_FUNC_QUALIFIER GLM_CONSTEXPR mat<2, 3, T, Q> & mat<2, 3, T, Q>::operator--() - { - --this->value[0]; - --this->value[1]; - return *this; - } - - template - GLM_FUNC_QUALIFIER GLM_CONSTEXPR mat<2, 3, T, Q> mat<2, 3, T, Q>::operator++(int) - { - mat<2, 3, T, Q> Result(*this); - ++*this; - return Result; - } - - template - GLM_FUNC_QUALIFIER GLM_CONSTEXPR mat<2, 3, T, Q> mat<2, 3, T, Q>::operator--(int) - { - mat<2, 3, T, Q> Result(*this); - --*this; - return Result; - } - - // -- Unary arithmetic operators -- - - template - GLM_FUNC_QUALIFIER GLM_CONSTEXPR mat<2, 3, T, Q> operator+(mat<2, 3, T, Q> const& m) - { - return m; - } - - template - GLM_FUNC_QUALIFIER GLM_CONSTEXPR mat<2, 3, T, Q> operator-(mat<2, 3, T, Q> const& m) - { - return mat<2, 3, T, Q>( - -m[0], - -m[1]); - } - - // -- Binary arithmetic operators -- - - template - GLM_FUNC_QUALIFIER GLM_CONSTEXPR mat<2, 3, T, Q> operator+(mat<2, 3, T, Q> const& m, T scalar) - { - return mat<2, 3, T, Q>( - m[0] + scalar, - m[1] + scalar); - } - - template - GLM_FUNC_QUALIFIER GLM_CONSTEXPR mat<2, 3, T, Q> operator+(mat<2, 3, T, Q> const& m1, mat<2, 3, T, Q> const& m2) - { - return mat<2, 3, T, Q>( - m1[0] + m2[0], - m1[1] + m2[1]); - } - - template - GLM_FUNC_QUALIFIER GLM_CONSTEXPR mat<2, 3, T, Q> operator-(mat<2, 3, T, Q> const& m, T scalar) - { - return mat<2, 3, T, Q>( - m[0] - scalar, - m[1] - scalar); - } - - template - GLM_FUNC_QUALIFIER GLM_CONSTEXPR mat<2, 3, T, Q> operator-(mat<2, 3, T, Q> const& m1, mat<2, 3, T, Q> const& m2) - { - return mat<2, 3, T, Q>( - m1[0] - m2[0], - m1[1] - m2[1]); - } - - template - GLM_FUNC_QUALIFIER GLM_CONSTEXPR mat<2, 3, T, Q> operator*(mat<2, 3, T, Q> const& m, T scalar) - { - return mat<2, 3, T, Q>( - m[0] * scalar, - m[1] * scalar); - } - - template - GLM_FUNC_QUALIFIER GLM_CONSTEXPR mat<2, 3, T, Q> operator*(T scalar, mat<2, 3, T, Q> const& m) - { - return mat<2, 3, T, Q>( - m[0] * scalar, - m[1] * scalar); - } - + // -- Binary operators -- template GLM_FUNC_QUALIFIER GLM_CONSTEXPR typename mat<2, 3, T, Q>::col_type operator* ( @@ -433,19 +280,19 @@ namespace glm template GLM_FUNC_QUALIFIER GLM_CONSTEXPR mat<3, 3, T, Q> operator*(mat<2, 3, T, Q> const& m1, mat<3, 2, T, Q> const& m2) { - T SrcA00 = m1[0][0]; - T SrcA01 = m1[0][1]; - T SrcA02 = m1[0][2]; - T SrcA10 = m1[1][0]; - T SrcA11 = m1[1][1]; - T SrcA12 = m1[1][2]; + T const SrcA00 = m1[0][0]; + T const SrcA01 = m1[0][1]; + T const SrcA02 = m1[0][2]; + T const SrcA10 = m1[1][0]; + T const SrcA11 = m1[1][1]; + T const SrcA12 = m1[1][2]; - T SrcB00 = m2[0][0]; - T SrcB01 = m2[0][1]; - T SrcB10 = m2[1][0]; - T SrcB11 = m2[1][1]; - T SrcB20 = m2[2][0]; - T SrcB21 = m2[2][1]; + T const SrcB00 = m2[0][0]; + T const SrcB01 = m2[0][1]; + T const SrcB10 = m2[1][0]; + T const SrcB11 = m2[1][1]; + T const SrcB20 = m2[2][0]; + T const SrcB21 = m2[2][1]; mat<3, 3, T, Q> Result; Result[0][0] = SrcA00 * SrcB00 + SrcA10 * SrcB01; @@ -478,33 +325,4 @@ namespace glm m1[0][2] * m2[3][0] + m1[1][2] * m2[3][1]); } - template - GLM_FUNC_QUALIFIER GLM_CONSTEXPR mat<2, 3, T, Q> operator/(mat<2, 3, T, Q> const& m, T scalar) - { - return mat<2, 3, T, Q>( - m[0] / scalar, - m[1] / scalar); - } - - template - GLM_FUNC_QUALIFIER GLM_CONSTEXPR mat<2, 3, T, Q> operator/(T scalar, mat<2, 3, T, Q> const& m) - { - return mat<2, 3, T, Q>( - scalar / m[0], - scalar / m[1]); - } - - // -- Boolean operators -- - - template - GLM_FUNC_QUALIFIER GLM_CONSTEXPR bool operator==(mat<2, 3, T, Q> const& m1, mat<2, 3, T, Q> const& m2) - { - return (m1[0] == m2[0]) && (m1[1] == m2[1]); - } - - template - GLM_FUNC_QUALIFIER GLM_CONSTEXPR bool operator!=(mat<2, 3, T, Q> const& m1, mat<2, 3, T, Q> const& m2) - { - return (m1[0] != m2[0]) || (m1[1] != m2[1]); - } } //namespace glm diff --git a/glm/detail/type_mat2x4.hpp b/glm/detail/type_mat2x4.hpp index 7ca43e59..9c343c02 100644 --- a/glm/detail/type_mat2x4.hpp +++ b/glm/detail/type_mat2x4.hpp @@ -5,6 +5,7 @@ #include "type_vec2.hpp" #include "type_vec4.hpp" +#include "mat2xn_common_ops.hpp" #include #include @@ -77,55 +78,9 @@ namespace glm template GLM_FUNC_DISCARD_DECL GLM_CONSTEXPR mat<2, 4, T, Q> & operator=(mat<2, 4, U, Q> const& m); - template - GLM_FUNC_DISCARD_DECL GLM_CONSTEXPR mat<2, 4, T, Q> & operator+=(U s); - template - GLM_FUNC_DISCARD_DECL GLM_CONSTEXPR mat<2, 4, T, Q> & operator+=(mat<2, 4, U, Q> const& m); - template - GLM_FUNC_DISCARD_DECL GLM_CONSTEXPR mat<2, 4, T, Q> & operator-=(U s); - template - GLM_FUNC_DISCARD_DECL GLM_CONSTEXPR mat<2, 4, T, Q> & operator-=(mat<2, 4, U, Q> const& m); - template - GLM_FUNC_DISCARD_DECL GLM_CONSTEXPR mat<2, 4, T, Q> & operator*=(U s); - template - GLM_FUNC_DISCARD_DECL GLM_CONSTEXPR mat<2, 4, T, Q> & operator/=(U s); - - // -- Increment and decrement operators -- - - GLM_FUNC_DISCARD_DECL GLM_CONSTEXPR mat<2, 4, T, Q> & operator++ (); - GLM_FUNC_DISCARD_DECL GLM_CONSTEXPR mat<2, 4, T, Q> & operator-- (); - GLM_FUNC_DECL GLM_CONSTEXPR mat<2, 4, T, Q> operator++(int); - GLM_FUNC_DECL GLM_CONSTEXPR mat<2, 4, T, Q> operator--(int); }; - // -- Unary operators -- - - template - GLM_FUNC_DECL GLM_CONSTEXPR mat<2, 4, T, Q> operator+(mat<2, 4, T, Q> const& m); - - template - GLM_FUNC_DECL GLM_CONSTEXPR mat<2, 4, T, Q> operator-(mat<2, 4, T, Q> const& m); - // -- Binary operators -- - - template - GLM_FUNC_DECL GLM_CONSTEXPR mat<2, 4, T, Q> operator+(mat<2, 4, T, Q> const& m, T scalar); - - template - GLM_FUNC_DECL GLM_CONSTEXPR mat<2, 4, T, Q> operator+(mat<2, 4, T, Q> const& m1, mat<2, 4, T, Q> const& m2); - - template - GLM_FUNC_DECL GLM_CONSTEXPR mat<2, 4, T, Q> operator-(mat<2, 4, T, Q> const& m, T scalar); - - template - GLM_FUNC_DECL GLM_CONSTEXPR mat<2, 4, T, Q> operator-(mat<2, 4, T, Q> const& m1, mat<2, 4, T, Q> const& m2); - - template - GLM_FUNC_DECL GLM_CONSTEXPR mat<2, 4, T, Q> operator*(mat<2, 4, T, Q> const& m, T scalar); - - template - GLM_FUNC_DECL GLM_CONSTEXPR mat<2, 4, T, Q> operator*(T scalar, mat<2, 4, T, Q> const& m); - template GLM_FUNC_DECL GLM_CONSTEXPR typename mat<2, 4, T, Q>::col_type operator*(mat<2, 4, T, Q> const& m, typename mat<2, 4, T, Q>::row_type const& v); @@ -141,19 +96,6 @@ namespace glm template GLM_FUNC_DECL GLM_CONSTEXPR mat<3, 4, T, Q> operator*(mat<2, 4, T, Q> const& m1, mat<3, 2, T, Q> const& m2); - template - GLM_FUNC_DECL GLM_CONSTEXPR mat<2, 4, T, Q> operator/(mat<2, 4, T, Q> const& m, T scalar); - - template - GLM_FUNC_DECL GLM_CONSTEXPR mat<2, 4, T, Q> operator/(T scalar, mat<2, 4, T, Q> const& m); - - // -- Boolean operators -- - - template - GLM_FUNC_DECL GLM_CONSTEXPR bool operator==(mat<2, 4, T, Q> const& m1, mat<2, 4, T, Q> const& m2); - - template - GLM_FUNC_DECL GLM_CONSTEXPR bool operator!=(mat<2, 4, T, Q> const& m1, mat<2, 4, T, Q> const& m2); }//namespace glm #ifndef GLM_EXTERNAL_TEMPLATE diff --git a/glm/detail/type_mat2x4.inl b/glm/detail/type_mat2x4.inl index 1c182c9d..50045f3d 100644 --- a/glm/detail/type_mat2x4.inl +++ b/glm/detail/type_mat2x4.inl @@ -232,171 +232,7 @@ namespace glm return this->value[i]; } - // -- Unary updatable operators -- - - template - template - GLM_FUNC_QUALIFIER GLM_CONSTEXPR mat<2, 4, T, Q>& mat<2, 4, T, Q>::operator=(mat<2, 4, U, Q> const& m) - { - this->value[0] = m[0]; - this->value[1] = m[1]; - return *this; - } - - template - template - GLM_FUNC_QUALIFIER GLM_CONSTEXPR mat<2, 4, T, Q>& mat<2, 4, T, Q>::operator+=(U s) - { - this->value[0] += s; - this->value[1] += s; - return *this; - } - - template - template - GLM_FUNC_QUALIFIER GLM_CONSTEXPR mat<2, 4, T, Q>& mat<2, 4, T, Q>::operator+=(mat<2, 4, U, Q> const& m) - { - this->value[0] += m[0]; - this->value[1] += m[1]; - return *this; - } - - template - template - GLM_FUNC_QUALIFIER GLM_CONSTEXPR mat<2, 4, T, Q>& mat<2, 4, T, Q>::operator-=(U s) - { - this->value[0] -= s; - this->value[1] -= s; - return *this; - } - - template - template - GLM_FUNC_QUALIFIER GLM_CONSTEXPR mat<2, 4, T, Q>& mat<2, 4, T, Q>::operator-=(mat<2, 4, U, Q> const& m) - { - this->value[0] -= m[0]; - this->value[1] -= m[1]; - return *this; - } - - template - template - GLM_FUNC_QUALIFIER GLM_CONSTEXPR mat<2, 4, T, Q>& mat<2, 4, T, Q>::operator*=(U s) - { - this->value[0] *= s; - this->value[1] *= s; - return *this; - } - - template - template - GLM_FUNC_QUALIFIER GLM_CONSTEXPR mat<2, 4, T, Q> & mat<2, 4, T, Q>::operator/=(U s) - { - this->value[0] /= s; - this->value[1] /= s; - return *this; - } - - // -- Increment and decrement operators -- - - template - GLM_FUNC_QUALIFIER GLM_CONSTEXPR mat<2, 4, T, Q>& mat<2, 4, T, Q>::operator++() - { - ++this->value[0]; - ++this->value[1]; - return *this; - } - - template - GLM_FUNC_QUALIFIER GLM_CONSTEXPR mat<2, 4, T, Q>& mat<2, 4, T, Q>::operator--() - { - --this->value[0]; - --this->value[1]; - return *this; - } - - template - GLM_FUNC_QUALIFIER GLM_CONSTEXPR mat<2, 4, T, Q> mat<2, 4, T, Q>::operator++(int) - { - mat<2, 4, T, Q> Result(*this); - ++*this; - return Result; - } - - template - GLM_FUNC_QUALIFIER GLM_CONSTEXPR mat<2, 4, T, Q> mat<2, 4, T, Q>::operator--(int) - { - mat<2, 4, T, Q> Result(*this); - --*this; - return Result; - } - - // -- Unary arithmetic operators -- - - template - GLM_FUNC_QUALIFIER GLM_CONSTEXPR mat<2, 4, T, Q> operator+(mat<2, 4, T, Q> const& m) - { - return m; - } - - template - GLM_FUNC_QUALIFIER GLM_CONSTEXPR mat<2, 4, T, Q> operator-(mat<2, 4, T, Q> const& m) - { - return mat<2, 4, T, Q>( - -m[0], - -m[1]); - } - // -- Binary arithmetic operators -- - - template - GLM_FUNC_QUALIFIER GLM_CONSTEXPR mat<2, 4, T, Q> operator+(mat<2, 4, T, Q> const& m, T scalar) - { - return mat<2, 4, T, Q>( - m[0] + scalar, - m[1] + scalar); - } - - template - GLM_FUNC_QUALIFIER GLM_CONSTEXPR mat<2, 4, T, Q> operator+(mat<2, 4, T, Q> const& m1, mat<2, 4, T, Q> const& m2) - { - return mat<2, 4, T, Q>( - m1[0] + m2[0], - m1[1] + m2[1]); - } - - template - GLM_FUNC_QUALIFIER GLM_CONSTEXPR mat<2, 4, T, Q> operator-(mat<2, 4, T, Q> const& m, T scalar) - { - return mat<2, 4, T, Q>( - m[0] - scalar, - m[1] - scalar); - } - - template - GLM_FUNC_QUALIFIER GLM_CONSTEXPR mat<2, 4, T, Q> operator-(mat<2, 4, T, Q> const& m1, mat<2, 4, T, Q> const& m2) - { - return mat<2, 4, T, Q>( - m1[0] - m2[0], - m1[1] - m2[1]); - } - - template - GLM_FUNC_QUALIFIER GLM_CONSTEXPR mat<2, 4, T, Q> operator*(mat<2, 4, T, Q> const& m, T scalar) - { - return mat<2, 4, T, Q>( - m[0] * scalar, - m[1] * scalar); - } - - template - GLM_FUNC_QUALIFIER GLM_CONSTEXPR mat<2, 4, T, Q> operator*(T scalar, mat<2, 4, T, Q> const& m) - { - return mat<2, 4, T, Q>( - m[0] * scalar, - m[1] * scalar); - } - template GLM_FUNC_QUALIFIER GLM_CONSTEXPR typename mat<2, 4, T, Q>::col_type operator*(mat<2, 4, T, Q> const& m, typename mat<2, 4, T, Q>::row_type const& v) { @@ -418,23 +254,23 @@ namespace glm template GLM_FUNC_QUALIFIER GLM_CONSTEXPR mat<4, 4, T, Q> operator*(mat<2, 4, T, Q> const& m1, mat<4, 2, T, Q> const& m2) { - T SrcA00 = m1[0][0]; - T SrcA01 = m1[0][1]; - T SrcA02 = m1[0][2]; - T SrcA03 = m1[0][3]; - T SrcA10 = m1[1][0]; - T SrcA11 = m1[1][1]; - T SrcA12 = m1[1][2]; - T SrcA13 = m1[1][3]; + T const SrcA00 = m1[0][0]; + T const SrcA01 = m1[0][1]; + T const SrcA02 = m1[0][2]; + T const SrcA03 = m1[0][3]; + T const SrcA10 = m1[1][0]; + T const SrcA11 = m1[1][1]; + T const SrcA12 = m1[1][2]; + T const SrcA13 = m1[1][3]; - T SrcB00 = m2[0][0]; - T SrcB01 = m2[0][1]; - T SrcB10 = m2[1][0]; - T SrcB11 = m2[1][1]; - T SrcB20 = m2[2][0]; - T SrcB21 = m2[2][1]; - T SrcB30 = m2[3][0]; - T SrcB31 = m2[3][1]; + T const SrcB00 = m2[0][0]; + T const SrcB01 = m2[0][1]; + T const SrcB10 = m2[1][0]; + T const SrcB11 = m2[1][1]; + T const SrcB20 = m2[2][0]; + T const SrcB21 = m2[2][1]; + T const SrcB30 = m2[3][0]; + T const SrcB31 = m2[3][1]; mat<4, 4, T, Q> Result; Result[0][0] = SrcA00 * SrcB00 + SrcA10 * SrcB01; @@ -488,33 +324,4 @@ namespace glm m1[0][3] * m2[2][0] + m1[1][3] * m2[2][1]); } - template - GLM_FUNC_QUALIFIER GLM_CONSTEXPR mat<2, 4, T, Q> operator/(mat<2, 4, T, Q> const& m, T scalar) - { - return mat<2, 4, T, Q>( - m[0] / scalar, - m[1] / scalar); - } - - template - GLM_FUNC_QUALIFIER GLM_CONSTEXPR mat<2, 4, T, Q> operator/(T scalar, mat<2, 4, T, Q> const& m) - { - return mat<2, 4, T, Q>( - scalar / m[0], - scalar / m[1]); - } - - // -- Boolean operators -- - - template - GLM_FUNC_QUALIFIER GLM_CONSTEXPR bool operator==(mat<2, 4, T, Q> const& m1, mat<2, 4, T, Q> const& m2) - { - return (m1[0] == m2[0]) && (m1[1] == m2[1]); - } - - template - GLM_FUNC_QUALIFIER GLM_CONSTEXPR bool operator!=(mat<2, 4, T, Q> const& m1, mat<2, 4, T, Q> const& m2) - { - return (m1[0] != m2[0]) || (m1[1] != m2[1]); - } } //namespace glm diff --git a/glm/detail/type_mat3x2.hpp b/glm/detail/type_mat3x2.hpp index 0249befd..e3480f27 100644 --- a/glm/detail/type_mat3x2.hpp +++ b/glm/detail/type_mat3x2.hpp @@ -5,6 +5,7 @@ #include "type_vec2.hpp" #include "type_vec3.hpp" +#include "mat3xn_common_ops.hpp" #include #include @@ -78,59 +79,13 @@ namespace glm GLM_CTOR_DECL GLM_EXPLICIT mat(mat<4, 2, T, Q> const& x); GLM_CTOR_DECL GLM_EXPLICIT mat(mat<4, 3, T, Q> const& x); - // -- Unary arithmetic operators -- - + // Assignment Operator template GLM_FUNC_DISCARD_DECL GLM_CONSTEXPR mat<3, 2, T, Q> & operator=(mat<3, 2, U, Q> const& m); - template - GLM_FUNC_DISCARD_DECL GLM_CONSTEXPR mat<3, 2, T, Q> & operator+=(U s); - template - GLM_FUNC_DISCARD_DECL GLM_CONSTEXPR mat<3, 2, T, Q> & operator+=(mat<3, 2, U, Q> const& m); - template - GLM_FUNC_DISCARD_DECL GLM_CONSTEXPR mat<3, 2, T, Q> & operator-=(U s); - template - GLM_FUNC_DISCARD_DECL GLM_CONSTEXPR mat<3, 2, T, Q> & operator-=(mat<3, 2, U, Q> const& m); - template - GLM_FUNC_DISCARD_DECL GLM_CONSTEXPR mat<3, 2, T, Q> & operator*=(U s); - template - GLM_FUNC_DISCARD_DECL GLM_CONSTEXPR mat<3, 2, T, Q> & operator/=(U s); - - // -- Increment and decrement operators -- - - GLM_FUNC_DISCARD_DECL GLM_CONSTEXPR mat<3, 2, T, Q> & operator++ (); - GLM_FUNC_DISCARD_DECL GLM_CONSTEXPR mat<3, 2, T, Q> & operator-- (); - GLM_FUNC_DECL GLM_CONSTEXPR mat<3, 2, T, Q> operator++(int); - GLM_FUNC_DECL GLM_CONSTEXPR mat<3, 2, T, Q> operator--(int); }; - // -- Unary operators -- - - template - GLM_FUNC_DECL GLM_CONSTEXPR mat<3, 2, T, Q> operator+(mat<3, 2, T, Q> const& m); - - template - GLM_FUNC_DECL GLM_CONSTEXPR mat<3, 2, T, Q> operator-(mat<3, 2, T, Q> const& m); - // -- Binary operators -- - template - GLM_FUNC_DECL GLM_CONSTEXPR mat<3, 2, T, Q> operator+(mat<3, 2, T, Q> const& m, T scalar); - - template - GLM_FUNC_DECL GLM_CONSTEXPR mat<3, 2, T, Q> operator+(mat<3, 2, T, Q> const& m1, mat<3, 2, T, Q> const& m2); - - template - GLM_FUNC_DECL GLM_CONSTEXPR mat<3, 2, T, Q> operator-(mat<3, 2, T, Q> const& m, T scalar); - - template - GLM_FUNC_DECL GLM_CONSTEXPR mat<3, 2, T, Q> operator-(mat<3, 2, T, Q> const& m1, mat<3, 2, T, Q> const& m2); - - template - GLM_FUNC_DECL GLM_CONSTEXPR mat<3, 2, T, Q> operator*(mat<3, 2, T, Q> const& m, T scalar); - - template - GLM_FUNC_DECL GLM_CONSTEXPR mat<3, 2, T, Q> operator*(T scalar, mat<3, 2, T, Q> const& m); - template GLM_FUNC_DECL GLM_CONSTEXPR typename mat<3, 2, T, Q>::col_type operator*(mat<3, 2, T, Q> const& m, typename mat<3, 2, T, Q>::row_type const& v); @@ -146,20 +101,6 @@ namespace glm template GLM_FUNC_DECL GLM_CONSTEXPR mat<4, 2, T, Q> operator*(mat<3, 2, T, Q> const& m1, mat<4, 3, T, Q> const& m2); - template - GLM_FUNC_DECL GLM_CONSTEXPR mat<3, 2, T, Q> operator/(mat<3, 2, T, Q> const& m, T scalar); - - template - GLM_FUNC_DECL GLM_CONSTEXPR mat<3, 2, T, Q> operator/(T scalar, mat<3, 2, T, Q> const& m); - - // -- Boolean operators -- - - template - GLM_FUNC_DECL GLM_CONSTEXPR bool operator==(mat<3, 2, T, Q> const& m1, mat<3, 2, T, Q> const& m2); - - template - GLM_FUNC_DECL GLM_CONSTEXPR bool operator!=(mat<3, 2, T, Q> const& m1, mat<3, 2, T, Q> const& m2); - }//namespace glm #ifndef GLM_EXTERNAL_TEMPLATE diff --git a/glm/detail/type_mat3x2.inl b/glm/detail/type_mat3x2.inl index cd9f46cc..5d7da7bf 100644 --- a/glm/detail/type_mat3x2.inl +++ b/glm/detail/type_mat3x2.inl @@ -261,175 +261,8 @@ namespace glm return *this; } - template - template - GLM_FUNC_QUALIFIER GLM_CONSTEXPR mat<3, 2, T, Q>& mat<3, 2, T, Q>::operator+=(U s) - { - this->value[0] += s; - this->value[1] += s; - this->value[2] += s; - return *this; - } - - template - template - GLM_FUNC_QUALIFIER GLM_CONSTEXPR mat<3, 2, T, Q>& mat<3, 2, T, Q>::operator+=(mat<3, 2, U, Q> const& m) - { - this->value[0] += m[0]; - this->value[1] += m[1]; - this->value[2] += m[2]; - return *this; - } - - template - template - GLM_FUNC_QUALIFIER GLM_CONSTEXPR mat<3, 2, T, Q>& mat<3, 2, T, Q>::operator-=(U s) - { - this->value[0] -= s; - this->value[1] -= s; - this->value[2] -= s; - return *this; - } - - template - template - GLM_FUNC_QUALIFIER GLM_CONSTEXPR mat<3, 2, T, Q>& mat<3, 2, T, Q>::operator-=(mat<3, 2, U, Q> const& m) - { - this->value[0] -= m[0]; - this->value[1] -= m[1]; - this->value[2] -= m[2]; - return *this; - } - - template - template - GLM_FUNC_QUALIFIER GLM_CONSTEXPR mat<3, 2, T, Q>& mat<3, 2, T, Q>::operator*=(U s) - { - this->value[0] *= s; - this->value[1] *= s; - this->value[2] *= s; - return *this; - } - - template - template - GLM_FUNC_QUALIFIER GLM_CONSTEXPR mat<3, 2, T, Q> & mat<3, 2, T, Q>::operator/=(U s) - { - this->value[0] /= s; - this->value[1] /= s; - this->value[2] /= s; - return *this; - } - - // -- Increment and decrement operators -- - - template - GLM_FUNC_QUALIFIER GLM_CONSTEXPR mat<3, 2, T, Q>& mat<3, 2, T, Q>::operator++() - { - ++this->value[0]; - ++this->value[1]; - ++this->value[2]; - return *this; - } - - template - GLM_FUNC_QUALIFIER GLM_CONSTEXPR mat<3, 2, T, Q>& mat<3, 2, T, Q>::operator--() - { - --this->value[0]; - --this->value[1]; - --this->value[2]; - return *this; - } - - template - GLM_FUNC_QUALIFIER GLM_CONSTEXPR mat<3, 2, T, Q> mat<3, 2, T, Q>::operator++(int) - { - mat<3, 2, T, Q> Result(*this); - ++*this; - return Result; - } - - template - GLM_FUNC_QUALIFIER GLM_CONSTEXPR mat<3, 2, T, Q> mat<3, 2, T, Q>::operator--(int) - { - mat<3, 2, T, Q> Result(*this); - --*this; - return Result; - } - - // -- Unary arithmetic operators -- - - template - GLM_FUNC_QUALIFIER GLM_CONSTEXPR mat<3, 2, T, Q> operator+(mat<3, 2, T, Q> const& m) - { - return m; - } - - template - GLM_FUNC_QUALIFIER GLM_CONSTEXPR mat<3, 2, T, Q> operator-(mat<3, 2, T, Q> const& m) - { - return mat<3, 2, T, Q>( - -m[0], - -m[1], - -m[2]); - } - // -- Binary arithmetic operators -- - template - GLM_FUNC_QUALIFIER GLM_CONSTEXPR mat<3, 2, T, Q> operator+(mat<3, 2, T, Q> const& m, T scalar) - { - return mat<3, 2, T, Q>( - m[0] + scalar, - m[1] + scalar, - m[2] + scalar); - } - - template - GLM_FUNC_QUALIFIER GLM_CONSTEXPR mat<3, 2, T, Q> operator+(mat<3, 2, T, Q> const& m1, mat<3, 2, T, Q> const& m2) - { - return mat<3, 2, T, Q>( - m1[0] + m2[0], - m1[1] + m2[1], - m1[2] + m2[2]); - } - - template - GLM_FUNC_QUALIFIER GLM_CONSTEXPR mat<3, 2, T, Q> operator-(mat<3, 2, T, Q> const& m, T scalar) - { - return mat<3, 2, T, Q>( - m[0] - scalar, - m[1] - scalar, - m[2] - scalar); - } - - template - GLM_FUNC_QUALIFIER GLM_CONSTEXPR mat<3, 2, T, Q> operator-(mat<3, 2, T, Q> const& m1, mat<3, 2, T, Q> const& m2) - { - return mat<3, 2, T, Q>( - m1[0] - m2[0], - m1[1] - m2[1], - m1[2] - m2[2]); - } - - template - GLM_FUNC_QUALIFIER GLM_CONSTEXPR mat<3, 2, T, Q> operator*(mat<3, 2, T, Q> const& m, T scalar) - { - return mat<3, 2, T, Q>( - m[0] * scalar, - m[1] * scalar, - m[2] * scalar); - } - - template - GLM_FUNC_QUALIFIER GLM_CONSTEXPR mat<3, 2, T, Q> operator*(T scalar, mat<3, 2, T, Q> const& m) - { - return mat<3, 2, T, Q>( - m[0] * scalar, - m[1] * scalar, - m[2] * scalar); - } - template GLM_FUNC_QUALIFIER GLM_CONSTEXPR typename mat<3, 2, T, Q>::col_type operator*(mat<3, 2, T, Q> const& m, typename mat<3, 2, T, Q>::row_type const& v) { @@ -450,19 +283,19 @@ namespace glm template GLM_FUNC_QUALIFIER GLM_CONSTEXPR mat<2, 2, T, Q> operator*(mat<3, 2, T, Q> const& m1, mat<2, 3, T, Q> const& m2) { - const T SrcA00 = m1[0][0]; - const T SrcA01 = m1[0][1]; - const T SrcA10 = m1[1][0]; - const T SrcA11 = m1[1][1]; - const T SrcA20 = m1[2][0]; - const T SrcA21 = m1[2][1]; + T const SrcA00 = m1[0][0]; + T const SrcA01 = m1[0][1]; + T const SrcA10 = m1[1][0]; + T const SrcA11 = m1[1][1]; + T const SrcA20 = m1[2][0]; + T const SrcA21 = m1[2][1]; - const T SrcB00 = m2[0][0]; - const T SrcB01 = m2[0][1]; - const T SrcB02 = m2[0][2]; - const T SrcB10 = m2[1][0]; - const T SrcB11 = m2[1][1]; - const T SrcB12 = m2[1][2]; + T const SrcB00 = m2[0][0]; + T const SrcB01 = m2[0][1]; + T const SrcB02 = m2[0][2]; + T const SrcB10 = m2[1][0]; + T const SrcB11 = m2[1][1]; + T const SrcB12 = m2[1][2]; mat<2, 2, T, Q> Result; Result[0][0] = SrcA00 * SrcB00 + SrcA10 * SrcB01 + SrcA20 * SrcB02; @@ -498,35 +331,5 @@ namespace glm m1[0][1] * m2[3][0] + m1[1][1] * m2[3][1] + m1[2][1] * m2[3][2]); } - template - GLM_FUNC_QUALIFIER GLM_CONSTEXPR mat<3, 2, T, Q> operator/(mat<3, 2, T, Q> const& m, T scalar) - { - return mat<3, 2, T, Q>( - m[0] / scalar, - m[1] / scalar, - m[2] / scalar); - } - template - GLM_FUNC_QUALIFIER GLM_CONSTEXPR mat<3, 2, T, Q> operator/(T scalar, mat<3, 2, T, Q> const& m) - { - return mat<3, 2, T, Q>( - scalar / m[0], - scalar / m[1], - scalar / m[2]); - } - - // -- Boolean operators -- - - template - GLM_FUNC_QUALIFIER GLM_CONSTEXPR bool operator==(mat<3, 2, T, Q> const& m1, mat<3, 2, T, Q> const& m2) - { - return (m1[0] == m2[0]) && (m1[1] == m2[1]) && (m1[2] == m2[2]); - } - - template - GLM_FUNC_QUALIFIER GLM_CONSTEXPR bool operator!=(mat<3, 2, T, Q> const& m1, mat<3, 2, T, Q> const& m2) - { - return (m1[0] != m2[0]) || (m1[1] != m2[1]) || (m1[2] != m2[2]); - } } //namespace glm diff --git a/glm/detail/type_mat3x3.hpp b/glm/detail/type_mat3x3.hpp index e4cbbdce..01ab73a2 100644 --- a/glm/detail/type_mat3x3.hpp +++ b/glm/detail/type_mat3x3.hpp @@ -6,6 +6,7 @@ #include "type_vec3.hpp" #include #include +#include "mat3xn_common_ops.hpp" namespace glm { @@ -81,65 +82,15 @@ namespace glm template GLM_FUNC_DISCARD_DECL GLM_CONSTEXPR mat<3, 3, T, Q> & operator=(mat<3, 3, U, Q> const& m); - template - GLM_FUNC_DISCARD_DECL GLM_CONSTEXPR mat<3, 3, T, Q> & operator+=(U s); - template - GLM_FUNC_DISCARD_DECL GLM_CONSTEXPR mat<3, 3, T, Q> & operator+=(mat<3, 3, U, Q> const& m); - template - GLM_FUNC_DISCARD_DECL GLM_CONSTEXPR mat<3, 3, T, Q> & operator-=(U s); - template - GLM_FUNC_DISCARD_DECL GLM_CONSTEXPR mat<3, 3, T, Q> & operator-=(mat<3, 3, U, Q> const& m); - template - GLM_FUNC_DISCARD_DECL GLM_CONSTEXPR mat<3, 3, T, Q> & operator*=(U s); - template - GLM_FUNC_DISCARD_DECL GLM_CONSTEXPR mat<3, 3, T, Q> & operator*=(mat<3, 3, U, Q> const& m); - template - GLM_FUNC_DISCARD_DECL GLM_CONSTEXPR mat<3, 3, T, Q> & operator/=(U s); - template - GLM_FUNC_DISCARD_DECL GLM_CONSTEXPR mat<3, 3, T, Q> & operator/=(mat<3, 3, U, Q> const& m); - // -- Increment and decrement operators -- - - GLM_FUNC_DISCARD_DECL GLM_CONSTEXPR mat<3, 3, T, Q> & operator++(); - GLM_FUNC_DISCARD_DECL GLM_CONSTEXPR mat<3, 3, T, Q> & operator--(); - GLM_FUNC_DECL GLM_CONSTEXPR mat<3, 3, T, Q> operator++(int); - GLM_FUNC_DECL GLM_CONSTEXPR mat<3, 3, T, Q> operator--(int); + template + GLM_FUNC_DISCARD_DECL GLM_CONSTEXPR mat<3, 3, T, Q>& operator*=(mat<3,3 , U, Q> const& m); + template + GLM_FUNC_DISCARD_DECL GLM_CONSTEXPR mat<3, 3, T, Q>& operator/=(mat<3, 3, U, Q> const& m); }; - // -- Unary operators -- - - template - GLM_FUNC_DECL GLM_CONSTEXPR mat<3, 3, T, Q> operator+(mat<3, 3, T, Q> const& m); - - template - GLM_FUNC_DECL GLM_CONSTEXPR mat<3, 3, T, Q> operator-(mat<3, 3, T, Q> const& m); - // -- Binary operators -- - template - GLM_FUNC_DECL GLM_CONSTEXPR mat<3, 3, T, Q> operator+(mat<3, 3, T, Q> const& m, T scalar); - - template - GLM_FUNC_DECL GLM_CONSTEXPR mat<3, 3, T, Q> operator+(T scalar, mat<3, 3, T, Q> const& m); - - template - GLM_FUNC_DECL GLM_CONSTEXPR mat<3, 3, T, Q> operator+(mat<3, 3, T, Q> const& m1, mat<3, 3, T, Q> const& m2); - - template - GLM_FUNC_DECL GLM_CONSTEXPR mat<3, 3, T, Q> operator-(mat<3, 3, T, Q> const& m, T scalar); - - template - GLM_FUNC_DECL GLM_CONSTEXPR mat<3, 3, T, Q> operator-(T scalar, mat<3, 3, T, Q> const& m); - - template - GLM_FUNC_DECL GLM_CONSTEXPR mat<3, 3, T, Q> operator-(mat<3, 3, T, Q> const& m1, mat<3, 3, T, Q> const& m2); - - template - GLM_FUNC_DECL GLM_CONSTEXPR mat<3, 3, T, Q> operator*(mat<3, 3, T, Q> const& m, T scalar); - - template - GLM_FUNC_DECL GLM_CONSTEXPR mat<3, 3, T, Q> operator*(T scalar, mat<3, 3, T, Q> const& m); - template GLM_FUNC_DECL GLM_CONSTEXPR typename mat<3, 3, T, Q>::col_type operator*(mat<3, 3, T, Q> const& m, typename mat<3, 3, T, Q>::row_type const& v); @@ -155,12 +106,6 @@ namespace glm template GLM_FUNC_DECL GLM_CONSTEXPR mat<4, 3, T, Q> operator*(mat<3, 3, T, Q> const& m1, mat<4, 3, T, Q> const& m2); - template - GLM_FUNC_DECL GLM_CONSTEXPR mat<3, 3, T, Q> operator/(mat<3, 3, T, Q> const& m, T scalar); - - template - GLM_FUNC_DECL GLM_CONSTEXPR mat<3, 3, T, Q> operator/(T scalar, mat<3, 3, T, Q> const& m); - template GLM_FUNC_DECL GLM_CONSTEXPR typename mat<3, 3, T, Q>::col_type operator/(mat<3, 3, T, Q> const& m, typename mat<3, 3, T, Q>::row_type const& v); @@ -170,13 +115,6 @@ namespace glm template GLM_FUNC_DECL GLM_CONSTEXPR mat<3, 3, T, Q> operator/(mat<3, 3, T, Q> const& m1, mat<3, 3, T, Q> const& m2); - // -- Boolean operators -- - - template - GLM_FUNC_DECL GLM_CONSTEXPR bool operator==(mat<3, 3, T, Q> const& m1, mat<3, 3, T, Q> const& m2); - - template - GLM_FUNC_DECL GLM_CONSTEXPR bool operator!=(mat<3, 3, T, Q> const& m1, mat<3, 3, T, Q> const& m2); }//namespace glm #ifndef GLM_EXTERNAL_TEMPLATE diff --git a/glm/detail/type_mat3x3.inl b/glm/detail/type_mat3x3.inl index 5ccfb229..aecd9c27 100644 --- a/glm/detail/type_mat3x3.inl +++ b/glm/detail/type_mat3x3.inl @@ -266,206 +266,18 @@ namespace glm template template - GLM_FUNC_QUALIFIER GLM_CONSTEXPR mat<3, 3, T, Q> & mat<3, 3, T, Q>::operator+=(U s) - { - this->value[0] += s; - this->value[1] += s; - this->value[2] += s; - return *this; + GLM_FUNC_QUALIFIER GLM_CONSTEXPR mat<3, 3, T, Q>& mat<3, 3, T, Q>::operator*=(mat<3, 3, U, Q> const& m) { + return *this = *this * m; } template template - GLM_FUNC_QUALIFIER GLM_CONSTEXPR mat<3, 3, T, Q> & mat<3, 3, T, Q>::operator+=(mat<3, 3, U, Q> const& m) - { - this->value[0] += m[0]; - this->value[1] += m[1]; - this->value[2] += m[2]; - return *this; - } - - template - template - GLM_FUNC_QUALIFIER GLM_CONSTEXPR mat<3, 3, T, Q> & mat<3, 3, T, Q>::operator-=(U s) - { - this->value[0] -= s; - this->value[1] -= s; - this->value[2] -= s; - return *this; - } - - template - template - GLM_FUNC_QUALIFIER GLM_CONSTEXPR mat<3, 3, T, Q> & mat<3, 3, T, Q>::operator-=(mat<3, 3, U, Q> const& m) - { - this->value[0] -= m[0]; - this->value[1] -= m[1]; - this->value[2] -= m[2]; - return *this; - } - - template - template - GLM_FUNC_QUALIFIER GLM_CONSTEXPR mat<3, 3, T, Q> & mat<3, 3, T, Q>::operator*=(U s) - { - col_type sv(s); - this->value[0] *= sv; - this->value[1] *= sv; - this->value[2] *= sv; - return *this; - } - - template - template - GLM_FUNC_QUALIFIER GLM_CONSTEXPR mat<3, 3, T, Q> & mat<3, 3, T, Q>::operator*=(mat<3, 3, U, Q> const& m) - { - return (*this = *this * m); - } - - template - template - GLM_FUNC_QUALIFIER GLM_CONSTEXPR mat<3, 3, T, Q> & mat<3, 3, T, Q>::operator/=(U s) - { - this->value[0] /= s; - this->value[1] /= s; - this->value[2] /= s; - return *this; - } - - template - template - GLM_FUNC_QUALIFIER GLM_CONSTEXPR mat<3, 3, T, Q> & mat<3, 3, T, Q>::operator/=(mat<3, 3, U, Q> const& m) - { + GLM_FUNC_QUALIFIER GLM_CONSTEXPR mat<3, 3, T, Q>& mat<3, 3, T, Q>::operator/=(mat<3, 3, U, Q> const& m) { return *this *= inverse(m); } - // -- Increment and decrement operators -- - - template - GLM_FUNC_QUALIFIER GLM_CONSTEXPR mat<3, 3, T, Q> & mat<3, 3, T, Q>::operator++() - { - ++this->value[0]; - ++this->value[1]; - ++this->value[2]; - return *this; - } - - template - GLM_FUNC_QUALIFIER GLM_CONSTEXPR mat<3, 3, T, Q> & mat<3, 3, T, Q>::operator--() - { - --this->value[0]; - --this->value[1]; - --this->value[2]; - return *this; - } - - template - GLM_FUNC_QUALIFIER GLM_CONSTEXPR mat<3, 3, T, Q> mat<3, 3, T, Q>::operator++(int) - { - mat<3, 3, T, Q> Result(*this); - ++*this; - return Result; - } - - template - GLM_FUNC_QUALIFIER GLM_CONSTEXPR mat<3, 3, T, Q> mat<3, 3, T, Q>::operator--(int) - { - mat<3, 3, T, Q> Result(*this); - --*this; - return Result; - } - - // -- Unary arithmetic operators -- - - template - GLM_FUNC_QUALIFIER GLM_CONSTEXPR mat<3, 3, T, Q> operator+(mat<3, 3, T, Q> const& m) - { - return m; - } - - template - GLM_FUNC_QUALIFIER GLM_CONSTEXPR mat<3, 3, T, Q> operator-(mat<3, 3, T, Q> const& m) - { - return mat<3, 3, T, Q>( - -m[0], - -m[1], - -m[2]); - } // -- Binary arithmetic operators -- - - template - GLM_FUNC_QUALIFIER GLM_CONSTEXPR mat<3, 3, T, Q> operator+(mat<3, 3, T, Q> const& m, T scalar) - { - return mat<3, 3, T, Q>( - m[0] + scalar, - m[1] + scalar, - m[2] + scalar); - } - - template - GLM_FUNC_QUALIFIER GLM_CONSTEXPR mat<3, 3, T, Q> operator+(T scalar, mat<3, 3, T, Q> const& m) - { - return mat<3, 3, T, Q>( - m[0] + scalar, - m[1] + scalar, - m[2] + scalar); - } - - template - GLM_FUNC_QUALIFIER GLM_CONSTEXPR mat<3, 3, T, Q> operator+(mat<3, 3, T, Q> const& m1, mat<3, 3, T, Q> const& m2) - { - return mat<3, 3, T, Q>( - m1[0] + m2[0], - m1[1] + m2[1], - m1[2] + m2[2]); - } - - template - GLM_FUNC_QUALIFIER GLM_CONSTEXPR mat<3, 3, T, Q> operator-(mat<3, 3, T, Q> const& m, T scalar) - { - return mat<3, 3, T, Q>( - m[0] - scalar, - m[1] - scalar, - m[2] - scalar); - } - - template - GLM_FUNC_QUALIFIER GLM_CONSTEXPR mat<3, 3, T, Q> operator-(T scalar, mat<3, 3, T, Q> const& m) - { - return mat<3, 3, T, Q>( - scalar - m[0], - scalar - m[1], - scalar - m[2]); - } - - template - GLM_FUNC_QUALIFIER GLM_CONSTEXPR mat<3, 3, T, Q> operator-(mat<3, 3, T, Q> const& m1, mat<3, 3, T, Q> const& m2) - { - return mat<3, 3, T, Q>( - m1[0] - m2[0], - m1[1] - m2[1], - m1[2] - m2[2]); - } - - template - GLM_FUNC_QUALIFIER GLM_CONSTEXPR mat<3, 3, T, Q> operator*(mat<3, 3, T, Q> const& m, T scalar) - { - return mat<3, 3, T, Q>( - m[0] * scalar, - m[1] * scalar, - m[2] * scalar); - } - - template - GLM_FUNC_QUALIFIER GLM_CONSTEXPR mat<3, 3, T, Q> operator*(T scalar, mat<3, 3, T, Q> const& m) - { - return mat<3, 3, T, Q>( - m[0] * scalar, - m[1] * scalar, - m[2] * scalar); - } - template GLM_FUNC_QUALIFIER GLM_CONSTEXPR typename mat<3, 3, T, Q>::col_type operator*(mat<3, 3, T, Q> const& m, typename mat<3, 3, T, Q>::row_type const& v) { @@ -582,24 +394,6 @@ namespace glm m1[0][2] * m2[3][0] + m1[1][2] * m2[3][1] + m1[2][2] * m2[3][2]); } - template - GLM_FUNC_QUALIFIER GLM_CONSTEXPR mat<3, 3, T, Q> operator/(mat<3, 3, T, Q> const& m, T scalar) - { - return mat<3, 3, T, Q>( - m[0] / scalar, - m[1] / scalar, - m[2] / scalar); - } - - template - GLM_FUNC_QUALIFIER GLM_CONSTEXPR mat<3, 3, T, Q> operator/(T scalar, mat<3, 3, T, Q> const& m) - { - return mat<3, 3, T, Q>( - scalar / m[0], - scalar / m[1], - scalar / m[2]); - } - template GLM_FUNC_QUALIFIER GLM_CONSTEXPR typename mat<3, 3, T, Q>::col_type operator/(mat<3, 3, T, Q> const& m, typename mat<3, 3, T, Q>::row_type const& v) { @@ -619,17 +413,4 @@ namespace glm return m1_copy /= m2; } - // -- Boolean operators -- - - template - GLM_FUNC_QUALIFIER GLM_CONSTEXPR bool operator==(mat<3, 3, T, Q> const& m1, mat<3, 3, T, Q> const& m2) - { - return (m1[0] == m2[0]) && (m1[1] == m2[1]) && (m1[2] == m2[2]); - } - - template - GLM_FUNC_QUALIFIER GLM_CONSTEXPR bool operator!=(mat<3, 3, T, Q> const& m1, mat<3, 3, T, Q> const& m2) - { - return (m1[0] != m2[0]) || (m1[1] != m2[1]) || (m1[2] != m2[2]); - } } //namespace glm diff --git a/glm/detail/type_mat3x4.hpp b/glm/detail/type_mat3x4.hpp index f9913d27..3b0d3e56 100644 --- a/glm/detail/type_mat3x4.hpp +++ b/glm/detail/type_mat3x4.hpp @@ -7,6 +7,7 @@ #include "type_vec4.hpp" #include #include +#include "mat3xn_common_ops.hpp" namespace glm { @@ -82,55 +83,11 @@ namespace glm template GLM_FUNC_DISCARD_DECL GLM_CONSTEXPR mat<3, 4, T, Q> & operator=(mat<3, 4, U, Q> const& m); - template - GLM_FUNC_DISCARD_DECL GLM_CONSTEXPR mat<3, 4, T, Q> & operator+=(U s); - template - GLM_FUNC_DISCARD_DECL GLM_CONSTEXPR mat<3, 4, T, Q> & operator+=(mat<3, 4, U, Q> const& m); - template - GLM_FUNC_DISCARD_DECL GLM_CONSTEXPR mat<3, 4, T, Q> & operator-=(U s); - template - GLM_FUNC_DISCARD_DECL GLM_CONSTEXPR mat<3, 4, T, Q> & operator-=(mat<3, 4, U, Q> const& m); - template - GLM_FUNC_DISCARD_DECL GLM_CONSTEXPR mat<3, 4, T, Q> & operator*=(U s); - template - GLM_FUNC_DISCARD_DECL GLM_CONSTEXPR mat<3, 4, T, Q> & operator/=(U s); - // -- Increment and decrement operators -- - - GLM_FUNC_DISCARD_DECL GLM_CONSTEXPR mat<3, 4, T, Q> & operator++(); - GLM_FUNC_DISCARD_DECL GLM_CONSTEXPR mat<3, 4, T, Q> & operator--(); - GLM_FUNC_DECL GLM_CONSTEXPR mat<3, 4, T, Q> operator++(int); - GLM_FUNC_DECL GLM_CONSTEXPR mat<3, 4, T, Q> operator--(int); }; - // -- Unary operators -- - - template - GLM_FUNC_DECL GLM_CONSTEXPR mat<3, 4, T, Q> operator+(mat<3, 4, T, Q> const& m); - - template - GLM_FUNC_DECL GLM_CONSTEXPR mat<3, 4, T, Q> operator-(mat<3, 4, T, Q> const& m); - // -- Binary operators -- - template - GLM_FUNC_DECL GLM_CONSTEXPR mat<3, 4, T, Q> operator+(mat<3, 4, T, Q> const& m, T scalar); - - template - GLM_FUNC_DECL GLM_CONSTEXPR mat<3, 4, T, Q> operator+(mat<3, 4, T, Q> const& m1, mat<3, 4, T, Q> const& m2); - - template - GLM_FUNC_DECL GLM_CONSTEXPR mat<3, 4, T, Q> operator-(mat<3, 4, T, Q> const& m, T scalar); - - template - GLM_FUNC_DECL GLM_CONSTEXPR mat<3, 4, T, Q> operator-(mat<3, 4, T, Q> const& m1, mat<3, 4, T, Q> const& m2); - - template - GLM_FUNC_DECL GLM_CONSTEXPR mat<3, 4, T, Q> operator*(mat<3, 4, T, Q> const& m, T scalar); - - template - GLM_FUNC_DECL GLM_CONSTEXPR mat<3, 4, T, Q> operator*(T scalar, mat<3, 4, T, Q> const& m); - template GLM_FUNC_DECL GLM_CONSTEXPR typename mat<3, 4, T, Q>::col_type operator*(mat<3, 4, T, Q> const& m, typename mat<3, 4, T, Q>::row_type const& v); @@ -146,19 +103,6 @@ namespace glm template GLM_FUNC_DECL GLM_CONSTEXPR mat<3, 4, T, Q> operator*(mat<3, 4, T, Q> const& m1, mat<3, 3, T, Q> const& m2); - template - GLM_FUNC_DECL GLM_CONSTEXPR mat<3, 4, T, Q> operator/(mat<3, 4, T, Q> const& m, T scalar); - - template - GLM_FUNC_DECL GLM_CONSTEXPR mat<3, 4, T, Q> operator/(T scalar, mat<3, 4, T, Q> const& m); - - // -- Boolean operators -- - - template - GLM_FUNC_DECL GLM_CONSTEXPR bool operator==(mat<3, 4, T, Q> const& m1, mat<3, 4, T, Q> const& m2); - - template - GLM_FUNC_DECL GLM_CONSTEXPR bool operator!=(mat<3, 4, T, Q> const& m1, mat<3, 4, T, Q> const& m2); }//namespace glm #ifndef GLM_EXTERNAL_TEMPLATE diff --git a/glm/detail/type_mat3x4.inl b/glm/detail/type_mat3x4.inl index 209e9d90..288543cf 100644 --- a/glm/detail/type_mat3x4.inl +++ b/glm/detail/type_mat3x4.inl @@ -3,44 +3,44 @@ namespace glm // -- Constructors -- # if GLM_CONFIG_DEFAULTED_DEFAULT_CTOR == GLM_DISABLE - template - GLM_DEFAULTED_DEFAULT_CTOR_QUALIFIER GLM_CONSTEXPR mat<3, 4, T, Q>::mat() + template + GLM_DEFAULTED_DEFAULT_CTOR_QUALIFIER GLM_CONSTEXPR mat<3, 4, T, Q>::mat() # if GLM_CONFIG_CTOR_INIT == GLM_CTOR_INITIALIZER_LIST - : value{col_type(1, 0, 0, 0), col_type(0, 1, 0, 0), col_type(0, 0, 1, 0)} + : value{ col_type(1, 0, 0, 0), col_type(0, 1, 0, 0), col_type(0, 0, 1, 0) } # endif - { + { # if GLM_CONFIG_CTOR_INIT == GLM_CTOR_INITIALISATION - this->value[0] = col_type(1, 0, 0, 0); - this->value[1] = col_type(0, 1, 0, 0); - this->value[2] = col_type(0, 0, 1, 0); + this->value[0] = col_type(1, 0, 0, 0); + this->value[1] = col_type(0, 1, 0, 0); + this->value[2] = col_type(0, 0, 1, 0); # endif - } + } # endif template template GLM_FUNC_QUALIFIER GLM_CONSTEXPR mat<3, 4, T, Q>::mat(mat<3, 4, T, P> const& m) # if GLM_HAS_INITIALIZER_LISTS - : value{col_type(m[0]), col_type(m[1]), col_type(m[2])} + : value{ col_type(m[0]), col_type(m[1]), col_type(m[2]) } # endif { # if !GLM_HAS_INITIALIZER_LISTS - this->value[0] = m[0]; - this->value[1] = m[1]; - this->value[2] = m[2]; + this->value[0] = m[0]; + this->value[1] = m[1]; + this->value[2] = m[2]; # endif } template GLM_FUNC_QUALIFIER GLM_CONSTEXPR mat<3, 4, T, Q>::mat(T s) # if GLM_HAS_INITIALIZER_LISTS - : value{col_type(s, 0, 0, 0), col_type(0, s, 0, 0), col_type(0, 0, s, 0)} + : value{ col_type(s, 0, 0, 0), col_type(0, s, 0, 0), col_type(0, 0, s, 0) } # endif { # if !GLM_HAS_INITIALIZER_LISTS - this->value[0] = col_type(s, 0, 0, 0); - this->value[1] = col_type(0, s, 0, 0); - this->value[2] = col_type(0, 0, s, 0); + this->value[0] = col_type(s, 0, 0, 0); + this->value[1] = col_type(0, s, 0, 0); + this->value[2] = col_type(0, 0, s, 0); # endif } @@ -52,29 +52,29 @@ namespace glm T x2, T y2, T z2, T w2 ) # if GLM_HAS_INITIALIZER_LISTS - : value{ - col_type(x0, y0, z0, w0), - col_type(x1, y1, z1, w1), - col_type(x2, y2, z2, w2)} + : value{ + col_type(x0, y0, z0, w0), + col_type(x1, y1, z1, w1), + col_type(x2, y2, z2, w2) } # endif { # if !GLM_HAS_INITIALIZER_LISTS - this->value[0] = col_type(x0, y0, z0, w0); - this->value[1] = col_type(x1, y1, z1, w1); - this->value[2] = col_type(x2, y2, z2, w2); + this->value[0] = col_type(x0, y0, z0, w0); + this->value[1] = col_type(x1, y1, z1, w1); + this->value[2] = col_type(x2, y2, z2, w2); # endif } template GLM_FUNC_QUALIFIER GLM_CONSTEXPR mat<3, 4, T, Q>::mat(col_type const& v0, col_type const& v1, col_type const& v2) # if GLM_HAS_INITIALIZER_LISTS - : value{col_type(v0), col_type(v1), col_type(v2)} + : value{ col_type(v0), col_type(v1), col_type(v2) } # endif { # if !GLM_HAS_INITIALIZER_LISTS - this->value[0] = v0; - this->value[1] = v1; - this->value[2] = v2; + this->value[0] = v0; + this->value[1] = v1; + this->value[2] = v2; # endif } @@ -92,16 +92,16 @@ namespace glm X2 x2, Y2 y2, Z2 z2, W2 w2 ) # if GLM_HAS_INITIALIZER_LISTS - : value{ - col_type(x0, y0, z0, w0), - col_type(x1, y1, z1, w1), - col_type(x2, y2, z2, w2)} + : value{ + col_type(x0, y0, z0, w0), + col_type(x1, y1, z1, w1), + col_type(x2, y2, z2, w2) } # endif { # if !GLM_HAS_INITIALIZER_LISTS - this->value[0] = col_type(x0, y0, z0, w0); - this->value[1] = col_type(x1, y1, z1, w1); - this->value[2] = col_type(x2, y2, z2, w2); + this->value[0] = col_type(x0, y0, z0, w0); + this->value[1] = col_type(x1, y1, z1, w1); + this->value[2] = col_type(x2, y2, z2, w2); # endif } @@ -109,13 +109,13 @@ namespace glm template GLM_FUNC_QUALIFIER GLM_CONSTEXPR mat<3, 4, T, Q>::mat(vec<4, V1, Q> const& v0, vec<4, V2, Q> const& v1, vec<4, V3, Q> const& v2) # if GLM_HAS_INITIALIZER_LISTS - : value{col_type(v0), col_type(v1), col_type(v2)} + : value{ col_type(v0), col_type(v1), col_type(v2) } # endif { # if !GLM_HAS_INITIALIZER_LISTS - this->value[0] = col_type(v0); - this->value[1] = col_type(v1); - this->value[2] = col_type(v2); + this->value[0] = col_type(v0); + this->value[1] = col_type(v1); + this->value[2] = col_type(v2); # endif } @@ -125,124 +125,124 @@ namespace glm template GLM_FUNC_QUALIFIER GLM_CONSTEXPR mat<3, 4, T, Q>::mat(mat<3, 4, U, P> const& m) # if GLM_HAS_INITIALIZER_LISTS - : value{col_type(m[0]), col_type(m[1]), col_type(m[2])} + : value{ col_type(m[0]), col_type(m[1]), col_type(m[2]) } # endif { # if !GLM_HAS_INITIALIZER_LISTS - this->value[0] = col_type(m[0]); - this->value[1] = col_type(m[1]); - this->value[2] = col_type(m[2]); + this->value[0] = col_type(m[0]); + this->value[1] = col_type(m[1]); + this->value[2] = col_type(m[2]); # endif } template GLM_FUNC_QUALIFIER GLM_CONSTEXPR mat<3, 4, T, Q>::mat(mat<2, 2, T, Q> const& m) # if GLM_HAS_INITIALIZER_LISTS - : value{col_type(m[0], 0, 0), col_type(m[1], 0, 0), col_type(0, 0, 1, 0)} + : value{ col_type(m[0], 0, 0), col_type(m[1], 0, 0), col_type(0, 0, 1, 0) } # endif { # if !GLM_HAS_INITIALIZER_LISTS - this->value[0] = col_type(m[0], 0, 0); - this->value[1] = col_type(m[1], 0, 0); - this->value[2] = col_type(0, 0, 1, 0); + this->value[0] = col_type(m[0], 0, 0); + this->value[1] = col_type(m[1], 0, 0); + this->value[2] = col_type(0, 0, 1, 0); # endif } template GLM_FUNC_QUALIFIER GLM_CONSTEXPR mat<3, 4, T, Q>::mat(mat<3, 3, T, Q> const& m) # if GLM_HAS_INITIALIZER_LISTS - : value{col_type(m[0], 0), col_type(m[1], 0), col_type(m[2], 0)} + : value{ col_type(m[0], 0), col_type(m[1], 0), col_type(m[2], 0) } # endif { # if !GLM_HAS_INITIALIZER_LISTS - this->value[0] = col_type(m[0], 0); - this->value[1] = col_type(m[1], 0); - this->value[2] = col_type(m[2], 0); + this->value[0] = col_type(m[0], 0); + this->value[1] = col_type(m[1], 0); + this->value[2] = col_type(m[2], 0); # endif } template GLM_FUNC_QUALIFIER GLM_CONSTEXPR mat<3, 4, T, Q>::mat(mat<4, 4, T, Q> const& m) # if GLM_HAS_INITIALIZER_LISTS - : value{col_type(m[0]), col_type(m[1]), col_type(m[2])} + : value{ col_type(m[0]), col_type(m[1]), col_type(m[2]) } # endif { # if !GLM_HAS_INITIALIZER_LISTS - this->value[0] = col_type(m[0]); - this->value[1] = col_type(m[1]); - this->value[2] = col_type(m[2]); + this->value[0] = col_type(m[0]); + this->value[1] = col_type(m[1]); + this->value[2] = col_type(m[2]); # endif } template GLM_FUNC_QUALIFIER GLM_CONSTEXPR mat<3, 4, T, Q>::mat(mat<2, 3, T, Q> const& m) # if GLM_HAS_INITIALIZER_LISTS - : value{col_type(m[0], 0), col_type(m[1], 0), col_type(0, 0, 1, 0)} + : value{ col_type(m[0], 0), col_type(m[1], 0), col_type(0, 0, 1, 0) } # endif { # if !GLM_HAS_INITIALIZER_LISTS - this->value[0] = col_type(m[0], 0); - this->value[1] = col_type(m[1], 0); - this->value[2] = col_type(0, 0, 1, 0); + this->value[0] = col_type(m[0], 0); + this->value[1] = col_type(m[1], 0); + this->value[2] = col_type(0, 0, 1, 0); # endif } template GLM_FUNC_QUALIFIER GLM_CONSTEXPR mat<3, 4, T, Q>::mat(mat<3, 2, T, Q> const& m) # if GLM_HAS_INITIALIZER_LISTS - : value{col_type(m[0], 0, 0), col_type(m[1], 0, 0), col_type(m[2], 1, 0)} + : value{ col_type(m[0], 0, 0), col_type(m[1], 0, 0), col_type(m[2], 1, 0) } # endif { # if !GLM_HAS_INITIALIZER_LISTS - this->value[0] = col_type(m[0], 0, 0); - this->value[1] = col_type(m[1], 0, 0); - this->value[2] = col_type(m[2], 1, 0); + this->value[0] = col_type(m[0], 0, 0); + this->value[1] = col_type(m[1], 0, 0); + this->value[2] = col_type(m[2], 1, 0); # endif } template GLM_FUNC_QUALIFIER GLM_CONSTEXPR mat<3, 4, T, Q>::mat(mat<2, 4, T, Q> const& m) # if GLM_HAS_INITIALIZER_LISTS - : value{col_type(m[0]), col_type(m[1]), col_type(0, 0, 1, 0)} + : value{ col_type(m[0]), col_type(m[1]), col_type(0, 0, 1, 0) } # endif { # if !GLM_HAS_INITIALIZER_LISTS - this->value[0] = col_type(m[0]); - this->value[1] = col_type(m[1]); - this->value[2] = col_type(0, 0, 1, 0); + this->value[0] = col_type(m[0]); + this->value[1] = col_type(m[1]); + this->value[2] = col_type(0, 0, 1, 0); # endif } template GLM_FUNC_QUALIFIER GLM_CONSTEXPR mat<3, 4, T, Q>::mat(mat<4, 2, T, Q> const& m) # if GLM_HAS_INITIALIZER_LISTS - : value{col_type(m[0], 0, 0), col_type(m[1], 0, 0), col_type(m[2], 1, 0)} + : value{ col_type(m[0], 0, 0), col_type(m[1], 0, 0), col_type(m[2], 1, 0) } # endif { # if !GLM_HAS_INITIALIZER_LISTS - this->value[0] = col_type(m[0], 0, 0); - this->value[1] = col_type(m[1], 0, 0); - this->value[2] = col_type(m[2], 1, 0); + this->value[0] = col_type(m[0], 0, 0); + this->value[1] = col_type(m[1], 0, 0); + this->value[2] = col_type(m[2], 1, 0); # endif } template GLM_FUNC_QUALIFIER GLM_CONSTEXPR mat<3, 4, T, Q>::mat(mat<4, 3, T, Q> const& m) # if GLM_HAS_INITIALIZER_LISTS - : value{col_type(m[0], 0), col_type(m[1], 0), col_type(m[2], 0)} + : value{ col_type(m[0], 0), col_type(m[1], 0), col_type(m[2], 0) } # endif { # if !GLM_HAS_INITIALIZER_LISTS - this->value[0] = col_type(m[0], 0); - this->value[1] = col_type(m[1], 0); - this->value[2] = col_type(m[2], 0); + this->value[0] = col_type(m[0], 0); + this->value[1] = col_type(m[1], 0); + this->value[2] = col_type(m[2], 0); # endif } // -- Accesses -- template - GLM_FUNC_QUALIFIER GLM_CONSTEXPR typename mat<3, 4, T, Q>::col_type & mat<3, 4, T, Q>::operator[](typename mat<3, 4, T, Q>::length_type i) GLM_NOEXCEPT + GLM_FUNC_QUALIFIER GLM_CONSTEXPR typename mat<3, 4, T, Q>::col_type& mat<3, 4, T, Q>::operator[](typename mat<3, 4, T, Q>::length_type i) GLM_NOEXCEPT { GLM_ASSERT_LENGTH(i, this->length()); return this->value[i]; @@ -267,181 +267,14 @@ namespace glm return *this; } - template - template - GLM_FUNC_QUALIFIER GLM_CONSTEXPR mat<3, 4, T, Q>& mat<3, 4, T, Q>::operator+=(U s) - { - this->value[0] += s; - this->value[1] += s; - this->value[2] += s; - return *this; - } - - template - template - GLM_FUNC_QUALIFIER GLM_CONSTEXPR mat<3, 4, T, Q>& mat<3, 4, T, Q>::operator+=(mat<3, 4, U, Q> const& m) - { - this->value[0] += m[0]; - this->value[1] += m[1]; - this->value[2] += m[2]; - return *this; - } - - template - template - GLM_FUNC_QUALIFIER GLM_CONSTEXPR mat<3, 4, T, Q>& mat<3, 4, T, Q>::operator-=(U s) - { - this->value[0] -= s; - this->value[1] -= s; - this->value[2] -= s; - return *this; - } - - template - template - GLM_FUNC_QUALIFIER GLM_CONSTEXPR mat<3, 4, T, Q>& mat<3, 4, T, Q>::operator-=(mat<3, 4, U, Q> const& m) - { - this->value[0] -= m[0]; - this->value[1] -= m[1]; - this->value[2] -= m[2]; - return *this; - } - - template - template - GLM_FUNC_QUALIFIER GLM_CONSTEXPR mat<3, 4, T, Q>& mat<3, 4, T, Q>::operator*=(U s) - { - this->value[0] *= s; - this->value[1] *= s; - this->value[2] *= s; - return *this; - } - - template - template - GLM_FUNC_QUALIFIER GLM_CONSTEXPR mat<3, 4, T, Q> & mat<3, 4, T, Q>::operator/=(U s) - { - this->value[0] /= s; - this->value[1] /= s; - this->value[2] /= s; - return *this; - } - - // -- Increment and decrement operators -- - - template - GLM_FUNC_QUALIFIER GLM_CONSTEXPR mat<3, 4, T, Q>& mat<3, 4, T, Q>::operator++() - { - ++this->value[0]; - ++this->value[1]; - ++this->value[2]; - return *this; - } - - template - GLM_FUNC_QUALIFIER GLM_CONSTEXPR mat<3, 4, T, Q>& mat<3, 4, T, Q>::operator--() - { - --this->value[0]; - --this->value[1]; - --this->value[2]; - return *this; - } - - template - GLM_FUNC_QUALIFIER GLM_CONSTEXPR mat<3, 4, T, Q> mat<3, 4, T, Q>::operator++(int) - { - mat<3, 4, T, Q> Result(*this); - ++*this; - return Result; - } - - template - GLM_FUNC_QUALIFIER GLM_CONSTEXPR mat<3, 4, T, Q> mat<3, 4, T, Q>::operator--(int) - { - mat<3, 4, T, Q> Result(*this); - --*this; - return Result; - } - - // -- Unary arithmetic operators -- - - template - GLM_FUNC_QUALIFIER GLM_CONSTEXPR mat<3, 4, T, Q> operator+(mat<3, 4, T, Q> const& m) - { - return m; - } - - template - GLM_FUNC_QUALIFIER GLM_CONSTEXPR mat<3, 4, T, Q> operator-(mat<3, 4, T, Q> const& m) - { - return mat<3, 4, T, Q>( - -m[0], - -m[1], - -m[2]); - } - // -- Binary arithmetic operators -- - template - GLM_FUNC_QUALIFIER GLM_CONSTEXPR mat<3, 4, T, Q> operator+(mat<3, 4, T, Q> const& m, T scalar) - { - return mat<3, 4, T, Q>( - m[0] + scalar, - m[1] + scalar, - m[2] + scalar); - } - - template - GLM_FUNC_QUALIFIER GLM_CONSTEXPR mat<3, 4, T, Q> operator+(mat<3, 4, T, Q> const& m1, mat<3, 4, T, Q> const& m2) - { - return mat<3, 4, T, Q>( - m1[0] + m2[0], - m1[1] + m2[1], - m1[2] + m2[2]); - } - - template - GLM_FUNC_QUALIFIER GLM_CONSTEXPR mat<3, 4, T, Q> operator-(mat<3, 4, T, Q> const& m, T scalar) - { - return mat<3, 4, T, Q>( - m[0] - scalar, - m[1] - scalar, - m[2] - scalar); - } - - template - GLM_FUNC_QUALIFIER GLM_CONSTEXPR mat<3, 4, T, Q> operator-(mat<3, 4, T, Q> const& m1, mat<3, 4, T, Q> const& m2) - { - return mat<3, 4, T, Q>( - m1[0] - m2[0], - m1[1] - m2[1], - m1[2] - m2[2]); - } - - template - GLM_FUNC_QUALIFIER GLM_CONSTEXPR mat<3, 4, T, Q> operator*(mat<3, 4, T, Q> const& m, T scalar) - { - return mat<3, 4, T, Q>( - m[0] * scalar, - m[1] * scalar, - m[2] * scalar); - } - - template - GLM_FUNC_QUALIFIER GLM_CONSTEXPR mat<3, 4, T, Q> operator*(T scalar, mat<3, 4, T, Q> const& m) - { - return mat<3, 4, T, Q>( - m[0] * scalar, - m[1] * scalar, - m[2] * scalar); - } - template GLM_FUNC_QUALIFIER GLM_CONSTEXPR typename mat<3, 4, T, Q>::col_type operator* - ( - mat<3, 4, T, Q> const& m, - typename mat<3, 4, T, Q>::row_type const& v - ) + ( + mat<3, 4, T, Q> const& m, + typename mat<3, 4, T, Q>::row_type const& v + ) { return typename mat<3, 4, T, Q>::col_type( m[0][0] * v.x + m[1][0] * v.y + m[2][0] * v.z, @@ -452,10 +285,10 @@ namespace glm template GLM_FUNC_QUALIFIER GLM_CONSTEXPR typename mat<3, 4, T, Q>::row_type operator* - ( - typename mat<3, 4, T, Q>::col_type const& v, - mat<3, 4, T, Q> const& m - ) + ( + typename mat<3, 4, T, Q>::col_type const& v, + mat<3, 4, T, Q> const& m + ) { return typename mat<3, 4, T, Q>::row_type( v.x * m[0][0] + v.y * m[0][1] + v.z * m[0][2] + v.w * m[0][3], @@ -466,31 +299,31 @@ namespace glm template GLM_FUNC_QUALIFIER GLM_CONSTEXPR mat<4, 4, T, Q> operator*(mat<3, 4, T, Q> const& m1, mat<4, 3, T, Q> const& m2) { - const T SrcA00 = m1[0][0]; - const T SrcA01 = m1[0][1]; - const T SrcA02 = m1[0][2]; - const T SrcA03 = m1[0][3]; - const T SrcA10 = m1[1][0]; - const T SrcA11 = m1[1][1]; - const T SrcA12 = m1[1][2]; - const T SrcA13 = m1[1][3]; - const T SrcA20 = m1[2][0]; - const T SrcA21 = m1[2][1]; - const T SrcA22 = m1[2][2]; - const T SrcA23 = m1[2][3]; + T const SrcA00 = m1[0][0]; + T const SrcA01 = m1[0][1]; + T const SrcA02 = m1[0][2]; + T const SrcA03 = m1[0][3]; + T const SrcA10 = m1[1][0]; + T const SrcA11 = m1[1][1]; + T const SrcA12 = m1[1][2]; + T const SrcA13 = m1[1][3]; + T const SrcA20 = m1[2][0]; + T const SrcA21 = m1[2][1]; + T const SrcA22 = m1[2][2]; + T const SrcA23 = m1[2][3]; - const T SrcB00 = m2[0][0]; - const T SrcB01 = m2[0][1]; - const T SrcB02 = m2[0][2]; - const T SrcB10 = m2[1][0]; - const T SrcB11 = m2[1][1]; - const T SrcB12 = m2[1][2]; - const T SrcB20 = m2[2][0]; - const T SrcB21 = m2[2][1]; - const T SrcB22 = m2[2][2]; - const T SrcB30 = m2[3][0]; - const T SrcB31 = m2[3][1]; - const T SrcB32 = m2[3][2]; + T const SrcB00 = m2[0][0]; + T const SrcB01 = m2[0][1]; + T const SrcB02 = m2[0][2]; + T const SrcB10 = m2[1][0]; + T const SrcB11 = m2[1][1]; + T const SrcB12 = m2[1][2]; + T const SrcB20 = m2[2][0]; + T const SrcB21 = m2[2][1]; + T const SrcB22 = m2[2][2]; + T const SrcB30 = m2[3][0]; + T const SrcB31 = m2[3][1]; + T const SrcB32 = m2[3][2]; mat<4, 4, T, Q> Result; Result[0][0] = SrcA00 * SrcB00 + SrcA10 * SrcB01 + SrcA20 * SrcB02; @@ -543,36 +376,4 @@ namespace glm m1[0][2] * m2[2][0] + m1[1][2] * m2[2][1] + m1[2][2] * m2[2][2], m1[0][3] * m2[2][0] + m1[1][3] * m2[2][1] + m1[2][3] * m2[2][2]); } - - template - GLM_FUNC_QUALIFIER GLM_CONSTEXPR mat<3, 4, T, Q> operator/(mat<3, 4, T, Q> const& m, T scalar) - { - return mat<3, 4, T, Q>( - m[0] / scalar, - m[1] / scalar, - m[2] / scalar); - } - - template - GLM_FUNC_QUALIFIER GLM_CONSTEXPR mat<3, 4, T, Q> operator/(T scalar, mat<3, 4, T, Q> const& m) - { - return mat<3, 4, T, Q>( - scalar / m[0], - scalar / m[1], - scalar / m[2]); - } - - // -- Boolean operators -- - - template - GLM_FUNC_QUALIFIER GLM_CONSTEXPR bool operator==(mat<3, 4, T, Q> const& m1, mat<3, 4, T, Q> const& m2) - { - return (m1[0] == m2[0]) && (m1[1] == m2[1]) && (m1[2] == m2[2]); - } - - template - GLM_FUNC_QUALIFIER GLM_CONSTEXPR bool operator!=(mat<3, 4, T, Q> const& m1, mat<3, 4, T, Q> const& m2) - { - return (m1[0] != m2[0]) || (m1[1] != m2[1]) || (m1[2] != m2[2]); - } } //namespace glm diff --git a/glm/detail/type_mat4x2.hpp b/glm/detail/type_mat4x2.hpp index 7057d4ce..67ab5462 100644 --- a/glm/detail/type_mat4x2.hpp +++ b/glm/detail/type_mat4x2.hpp @@ -5,6 +5,7 @@ #include "type_vec2.hpp" #include "type_vec4.hpp" +#include "mat4xn_common_ops.hpp" #include #include @@ -87,55 +88,14 @@ namespace glm template GLM_FUNC_DISCARD_DECL GLM_CONSTEXPR mat<4, 2, T, Q> & operator=(mat<4, 2, U, Q> const& m); - template - GLM_FUNC_DISCARD_DECL GLM_CONSTEXPR mat<4, 2, T, Q> & operator+=(U s); - template - GLM_FUNC_DISCARD_DECL GLM_CONSTEXPR mat<4, 2, T, Q> & operator+=(mat<4, 2, U, Q> const& m); - template - GLM_FUNC_DISCARD_DECL GLM_CONSTEXPR mat<4, 2, T, Q> & operator-=(U s); - template - GLM_FUNC_DISCARD_DECL GLM_CONSTEXPR mat<4, 2, T, Q> & operator-=(mat<4, 2, U, Q> const& m); - template - GLM_FUNC_DISCARD_DECL GLM_CONSTEXPR mat<4, 2, T, Q> & operator*=(U s); - template - GLM_FUNC_DISCARD_DECL GLM_CONSTEXPR mat<4, 2, T, Q> & operator/=(U s); - - // -- Increment and decrement operators -- - - GLM_FUNC_DISCARD_DECL GLM_CONSTEXPR mat<4, 2, T, Q> & operator++ (); - GLM_FUNC_DISCARD_DECL GLM_CONSTEXPR mat<4, 2, T, Q> & operator-- (); - GLM_FUNC_DECL GLM_CONSTEXPR mat<4, 2, T, Q> operator++(int); - GLM_FUNC_DECL GLM_CONSTEXPR mat<4, 2, T, Q> operator--(int); }; - // -- Unary operators -- - - template - GLM_FUNC_DECL GLM_CONSTEXPR mat<4, 2, T, Q> operator+(mat<4, 2, T, Q> const& m); - - template - GLM_FUNC_DECL GLM_CONSTEXPR mat<4, 2, T, Q> operator-(mat<4, 2, T, Q> const& m); - - // -- Binary operators -- - - template - GLM_FUNC_DECL GLM_CONSTEXPR mat<4, 2, T, Q> operator+(mat<4, 2, T, Q> const& m, T scalar); - - template - GLM_FUNC_DECL GLM_CONSTEXPR mat<4, 2, T, Q> operator+(mat<4, 2, T, Q> const& m1, mat<4, 2, T, Q> const& m2); - template GLM_FUNC_DECL GLM_CONSTEXPR mat<4, 2, T, Q> operator-(mat<4, 2, T, Q> const& m, T scalar); template GLM_FUNC_DECL GLM_CONSTEXPR mat<4, 2, T, Q> operator-(mat<4, 2, T, Q> const& m1, mat<4, 2, T, Q> const& m2); - template - GLM_FUNC_DECL GLM_CONSTEXPR mat<4, 2, T, Q> operator*(mat<4, 2, T, Q> const& m, T scalar); - - template - GLM_FUNC_DECL GLM_CONSTEXPR mat<4, 2, T, Q> operator*(T scalar, mat<4, 2, T, Q> const& m); - template GLM_FUNC_DECL GLM_CONSTEXPR typename mat<4, 2, T, Q>::col_type operator*(mat<4, 2, T, Q> const& m, typename mat<4, 2, T, Q>::row_type const& v); @@ -151,19 +111,6 @@ namespace glm template GLM_FUNC_DECL GLM_CONSTEXPR mat<4, 2, T, Q> operator*(mat<4, 2, T, Q> const& m1, mat<4, 4, T, Q> const& m2); - template - GLM_FUNC_DECL GLM_CONSTEXPR mat<4, 2, T, Q> operator/(mat<4, 2, T, Q> const& m, T scalar); - - template - GLM_FUNC_DECL GLM_CONSTEXPR mat<4, 2, T, Q> operator/(T scalar, mat<4, 2, T, Q> const& m); - - // -- Boolean operators -- - - template - GLM_FUNC_DECL GLM_CONSTEXPR bool operator==(mat<4, 2, T, Q> const& m1, mat<4, 2, T, Q> const& m2); - - template - GLM_FUNC_DECL GLM_CONSTEXPR bool operator!=(mat<4, 2, T, Q> const& m1, mat<4, 2, T, Q> const& m2); }//namespace glm #ifndef GLM_EXTERNAL_TEMPLATE diff --git a/glm/detail/type_mat4x2.inl b/glm/detail/type_mat4x2.inl index 2b9b617a..ea96db81 100644 --- a/glm/detail/type_mat4x2.inl +++ b/glm/detail/type_mat4x2.inl @@ -281,190 +281,8 @@ namespace glm return *this; } - template - template - GLM_FUNC_QUALIFIER GLM_CONSTEXPR mat<4, 2, T, Q> & mat<4, 2, T, Q>::operator+=(U s) - { - this->value[0] += s; - this->value[1] += s; - this->value[2] += s; - this->value[3] += s; - return *this; - } - - template - template - GLM_FUNC_QUALIFIER GLM_CONSTEXPR mat<4, 2, T, Q> & mat<4, 2, T, Q>::operator+=(mat<4, 2, U, Q> const& m) - { - this->value[0] += m[0]; - this->value[1] += m[1]; - this->value[2] += m[2]; - this->value[3] += m[3]; - return *this; - } - - template - template - GLM_FUNC_QUALIFIER GLM_CONSTEXPR mat<4, 2, T, Q> & mat<4, 2, T, Q>::operator-=(U s) - { - this->value[0] -= s; - this->value[1] -= s; - this->value[2] -= s; - this->value[3] -= s; - return *this; - } - - template - template - GLM_FUNC_QUALIFIER GLM_CONSTEXPR mat<4, 2, T, Q> & mat<4, 2, T, Q>::operator-=(mat<4, 2, U, Q> const& m) - { - this->value[0] -= m[0]; - this->value[1] -= m[1]; - this->value[2] -= m[2]; - this->value[3] -= m[3]; - return *this; - } - - template - template - GLM_FUNC_QUALIFIER GLM_CONSTEXPR mat<4, 2, T, Q> & mat<4, 2, T, Q>::operator*=(U s) - { - this->value[0] *= s; - this->value[1] *= s; - this->value[2] *= s; - this->value[3] *= s; - return *this; - } - - template - template - GLM_FUNC_QUALIFIER GLM_CONSTEXPR mat<4, 2, T, Q> & mat<4, 2, T, Q>::operator/=(U s) - { - this->value[0] /= s; - this->value[1] /= s; - this->value[2] /= s; - this->value[3] /= s; - return *this; - } - - // -- Increment and decrement operators -- - - template - GLM_FUNC_QUALIFIER GLM_CONSTEXPR mat<4, 2, T, Q> & mat<4, 2, T, Q>::operator++() - { - ++this->value[0]; - ++this->value[1]; - ++this->value[2]; - ++this->value[3]; - return *this; - } - - template - GLM_FUNC_QUALIFIER GLM_CONSTEXPR mat<4, 2, T, Q> & mat<4, 2, T, Q>::operator--() - { - --this->value[0]; - --this->value[1]; - --this->value[2]; - --this->value[3]; - return *this; - } - - template - GLM_FUNC_QUALIFIER GLM_CONSTEXPR mat<4, 2, T, Q> mat<4, 2, T, Q>::operator++(int) - { - mat<4, 2, T, Q> Result(*this); - ++*this; - return Result; - } - - template - GLM_FUNC_QUALIFIER GLM_CONSTEXPR mat<4, 2, T, Q> mat<4, 2, T, Q>::operator--(int) - { - mat<4, 2, T, Q> Result(*this); - --*this; - return Result; - } - - // -- Unary arithmetic operators -- - - template - GLM_FUNC_QUALIFIER GLM_CONSTEXPR mat<4, 2, T, Q> operator+(mat<4, 2, T, Q> const& m) - { - return m; - } - - template - GLM_FUNC_QUALIFIER GLM_CONSTEXPR mat<4, 2, T, Q> operator-(mat<4, 2, T, Q> const& m) - { - return mat<4, 2, T, Q>( - -m[0], - -m[1], - -m[2], - -m[3]); - } - // -- Binary arithmetic operators -- - template - GLM_FUNC_QUALIFIER GLM_CONSTEXPR mat<4, 2, T, Q> operator+(mat<4, 2, T, Q> const& m, T scalar) - { - return mat<4, 2, T, Q>( - m[0] + scalar, - m[1] + scalar, - m[2] + scalar, - m[3] + scalar); - } - - template - GLM_FUNC_QUALIFIER GLM_CONSTEXPR mat<4, 2, T, Q> operator+(mat<4, 2, T, Q> const& m1, mat<4, 2, T, Q> const& m2) - { - return mat<4, 2, T, Q>( - m1[0] + m2[0], - m1[1] + m2[1], - m1[2] + m2[2], - m1[3] + m2[3]); - } - - template - GLM_FUNC_QUALIFIER GLM_CONSTEXPR mat<4, 2, T, Q> operator-(mat<4, 2, T, Q> const& m, T scalar) - { - return mat<4, 2, T, Q>( - m[0] - scalar, - m[1] - scalar, - m[2] - scalar, - m[3] - scalar); - } - - template - GLM_FUNC_QUALIFIER GLM_CONSTEXPR mat<4, 2, T, Q> operator-(mat<4, 2, T, Q> const& m1, mat<4, 2, T, Q> const& m2) - { - return mat<4, 2, T, Q>( - m1[0] - m2[0], - m1[1] - m2[1], - m1[2] - m2[2], - m1[3] - m2[3]); - } - - template - GLM_FUNC_QUALIFIER GLM_CONSTEXPR mat<4, 2, T, Q> operator*(mat<4, 2, T, Q> const& m, T scalar) - { - return mat<4, 2, T, Q>( - m[0] * scalar, - m[1] * scalar, - m[2] * scalar, - m[3] * scalar); - } - - template - GLM_FUNC_QUALIFIER GLM_CONSTEXPR mat<4, 2, T, Q> operator*(T scalar, mat<4, 2, T, Q> const& m) - { - return mat<4, 2, T, Q>( - m[0] * scalar, - m[1] * scalar, - m[2] * scalar, - m[3] * scalar); - } - template GLM_FUNC_QUALIFIER GLM_CONSTEXPR typename mat<4, 2, T, Q>::col_type operator*(mat<4, 2, T, Q> const& m, typename mat<4, 2, T, Q>::row_type const& v) { @@ -538,37 +356,4 @@ namespace glm m1[0][1] * m2[3][0] + m1[1][1] * m2[3][1] + m1[2][1] * m2[3][2] + m1[3][1] * m2[3][3]); } - template - GLM_FUNC_QUALIFIER GLM_CONSTEXPR mat<4, 2, T, Q> operator/(mat<4, 2, T, Q> const& m, T scalar) - { - return mat<4, 2, T, Q>( - m[0] / scalar, - m[1] / scalar, - m[2] / scalar, - m[3] / scalar); - } - - template - GLM_FUNC_QUALIFIER GLM_CONSTEXPR mat<4, 2, T, Q> operator/(T scalar, mat<4, 2, T, Q> const& m) - { - return mat<4, 2, T, Q>( - scalar / m[0], - scalar / m[1], - scalar / m[2], - scalar / m[3]); - } - - // -- Boolean operators -- - - template - GLM_FUNC_QUALIFIER GLM_CONSTEXPR bool operator==(mat<4, 2, T, Q> const& m1, mat<4, 2, T, Q> const& m2) - { - return (m1[0] == m2[0]) && (m1[1] == m2[1]) && (m1[2] == m2[2]) && (m1[3] == m2[3]); - } - - template - GLM_FUNC_QUALIFIER GLM_CONSTEXPR bool operator!=(mat<4, 2, T, Q> const& m1, mat<4, 2, T, Q> const& m2) - { - return (m1[0] != m2[0]) || (m1[1] != m2[1]) || (m1[2] != m2[2]) || (m1[3] != m2[3]); - } } //namespace glm diff --git a/glm/detail/type_mat4x3.hpp b/glm/detail/type_mat4x3.hpp index 52a38d87..fd10afa8 100644 --- a/glm/detail/type_mat4x3.hpp +++ b/glm/detail/type_mat4x3.hpp @@ -5,6 +5,8 @@ #include "type_vec3.hpp" #include "type_vec4.hpp" +#include "mat4xn_common_ops.hpp" + #include #include @@ -87,55 +89,10 @@ namespace glm template GLM_FUNC_DISCARD_DECL GLM_CONSTEXPR mat<4, 3, T, Q> & operator=(mat<4, 3, U, Q> const& m); - template - GLM_FUNC_DISCARD_DECL GLM_CONSTEXPR mat<4, 3, T, Q> & operator+=(U s); - template - GLM_FUNC_DISCARD_DECL GLM_CONSTEXPR mat<4, 3, T, Q> & operator+=(mat<4, 3, U, Q> const& m); - template - GLM_FUNC_DISCARD_DECL GLM_CONSTEXPR mat<4, 3, T, Q> & operator-=(U s); - template - GLM_FUNC_DISCARD_DECL GLM_CONSTEXPR mat<4, 3, T, Q> & operator-=(mat<4, 3, U, Q> const& m); - template - GLM_FUNC_DISCARD_DECL GLM_CONSTEXPR mat<4, 3, T, Q> & operator*=(U s); - template - GLM_FUNC_DISCARD_DECL GLM_CONSTEXPR mat<4, 3, T, Q> & operator/=(U s); - // -- Increment and decrement operators -- - - GLM_FUNC_DISCARD_DECL GLM_CONSTEXPR mat<4, 3, T, Q>& operator++(); - GLM_FUNC_DISCARD_DECL GLM_CONSTEXPR mat<4, 3, T, Q>& operator--(); - GLM_FUNC_DECL GLM_CONSTEXPR mat<4, 3, T, Q> operator++(int); - GLM_FUNC_DECL GLM_CONSTEXPR mat<4, 3, T, Q> operator--(int); }; - // -- Unary operators -- - - template - GLM_FUNC_DECL GLM_CONSTEXPR mat<4, 3, T, Q> operator+(mat<4, 3, T, Q> const& m); - - template - GLM_FUNC_DECL GLM_CONSTEXPR mat<4, 3, T, Q> operator-(mat<4, 3, T, Q> const& m); - // -- Binary operators -- - - template - GLM_FUNC_DECL GLM_CONSTEXPR mat<4, 3, T, Q> operator+(mat<4, 3, T, Q> const& m, T scalar); - - template - GLM_FUNC_DECL GLM_CONSTEXPR mat<4, 3, T, Q> operator+(mat<4, 3, T, Q> const& m1, mat<4, 3, T, Q> const& m2); - - template - GLM_FUNC_DECL GLM_CONSTEXPR mat<4, 3, T, Q> operator-(mat<4, 3, T, Q> const& m, T scalar); - - template - GLM_FUNC_DECL GLM_CONSTEXPR mat<4, 3, T, Q> operator-(mat<4, 3, T, Q> const& m1, mat<4, 3, T, Q> const& m2); - - template - GLM_FUNC_DECL GLM_CONSTEXPR mat<4, 3, T, Q> operator*(mat<4, 3, T, Q> const& m, T scalar); - - template - GLM_FUNC_DECL GLM_CONSTEXPR mat<4, 3, T, Q> operator*(T scalar, mat<4, 3, T, Q> const& m); - template GLM_FUNC_DECL GLM_CONSTEXPR typename mat<4, 3, T, Q>::col_type operator*(mat<4, 3, T, Q> const& m, typename mat<4, 3, T, Q>::row_type const& v); @@ -151,19 +108,6 @@ namespace glm template GLM_FUNC_DECL GLM_CONSTEXPR mat<4, 3, T, Q> operator*(mat<4, 3, T, Q> const& m1, mat<4, 4, T, Q> const& m2); - template - GLM_FUNC_DECL GLM_CONSTEXPR mat<4, 3, T, Q> operator/(mat<4, 3, T, Q> const& m, T scalar); - - template - GLM_FUNC_DECL GLM_CONSTEXPR mat<4, 3, T, Q> operator/(T scalar, mat<4, 3, T, Q> const& m); - - // -- Boolean operators -- - - template - GLM_FUNC_DECL GLM_CONSTEXPR bool operator==(mat<4, 3, T, Q> const& m1, mat<4, 3, T, Q> const& m2); - - template - GLM_FUNC_DECL GLM_CONSTEXPR bool operator!=(mat<4, 3, T, Q> const& m1, mat<4, 3, T, Q> const& m2); }//namespace glm #ifndef GLM_EXTERNAL_TEMPLATE diff --git a/glm/detail/type_mat4x3.inl b/glm/detail/type_mat4x3.inl index 8430bc07..4333cf39 100644 --- a/glm/detail/type_mat4x3.inl +++ b/glm/detail/type_mat4x3.inl @@ -281,189 +281,8 @@ namespace glm return *this; } - template - template - GLM_FUNC_QUALIFIER GLM_CONSTEXPR mat<4, 3, T, Q> & mat<4, 3, T, Q>::operator+=(U s) - { - this->value[0] += s; - this->value[1] += s; - this->value[2] += s; - this->value[3] += s; - return *this; - } - - template - template - GLM_FUNC_QUALIFIER GLM_CONSTEXPR mat<4, 3, T, Q> & mat<4, 3, T, Q>::operator+=(mat<4, 3, U, Q> const& m) - { - this->value[0] += m[0]; - this->value[1] += m[1]; - this->value[2] += m[2]; - this->value[3] += m[3]; - return *this; - } - - template - template - GLM_FUNC_QUALIFIER GLM_CONSTEXPR mat<4, 3, T, Q> & mat<4, 3, T, Q>::operator-=(U s) - { - this->value[0] -= s; - this->value[1] -= s; - this->value[2] -= s; - this->value[3] -= s; - return *this; - } - - template - template - GLM_FUNC_QUALIFIER GLM_CONSTEXPR mat<4, 3, T, Q> & mat<4, 3, T, Q>::operator-=(mat<4, 3, U, Q> const& m) - { - this->value[0] -= m[0]; - this->value[1] -= m[1]; - this->value[2] -= m[2]; - this->value[3] -= m[3]; - return *this; - } - - template - template - GLM_FUNC_QUALIFIER GLM_CONSTEXPR mat<4, 3, T, Q> & mat<4, 3, T, Q>::operator*=(U s) - { - this->value[0] *= s; - this->value[1] *= s; - this->value[2] *= s; - this->value[3] *= s; - return *this; - } - - template - template - GLM_FUNC_QUALIFIER GLM_CONSTEXPR mat<4, 3, T, Q> & mat<4, 3, T, Q>::operator/=(U s) - { - this->value[0] /= s; - this->value[1] /= s; - this->value[2] /= s; - this->value[3] /= s; - return *this; - } - - // -- Increment and decrement operators -- - - template - GLM_FUNC_QUALIFIER GLM_CONSTEXPR mat<4, 3, T, Q> & mat<4, 3, T, Q>::operator++() - { - ++this->value[0]; - ++this->value[1]; - ++this->value[2]; - ++this->value[3]; - return *this; - } - - template - GLM_FUNC_QUALIFIER GLM_CONSTEXPR mat<4, 3, T, Q> & mat<4, 3, T, Q>::operator--() - { - --this->value[0]; - --this->value[1]; - --this->value[2]; - --this->value[3]; - return *this; - } - - template - GLM_FUNC_QUALIFIER GLM_CONSTEXPR mat<4, 3, T, Q> mat<4, 3, T, Q>::operator++(int) - { - mat<4, 3, T, Q> Result(*this); - ++*this; - return Result; - } - - template - GLM_FUNC_QUALIFIER GLM_CONSTEXPR mat<4, 3, T, Q> mat<4, 3, T, Q>::operator--(int) - { - mat<4, 3, T, Q> Result(*this); - --*this; - return Result; - } - - // -- Unary arithmetic operators -- - - template - GLM_FUNC_QUALIFIER GLM_CONSTEXPR mat<4, 3, T, Q> operator+(mat<4, 3, T, Q> const& m) - { - return m; - } - - template - GLM_FUNC_QUALIFIER GLM_CONSTEXPR mat<4, 3, T, Q> operator-(mat<4, 3, T, Q> const& m) - { - return mat<4, 3, T, Q>( - -m[0], - -m[1], - -m[2], - -m[3]); - } - // -- Binary arithmetic operators -- - template - GLM_FUNC_QUALIFIER GLM_CONSTEXPR mat<4, 3, T, Q> operator+(mat<4, 3, T, Q> const& m, T scalar) - { - return mat<4, 3, T, Q>( - m[0] + scalar, - m[1] + scalar, - m[2] + scalar, - m[3] + scalar); - } - - template - GLM_FUNC_QUALIFIER GLM_CONSTEXPR mat<4, 3, T, Q> operator+(mat<4, 3, T, Q> const& m1, mat<4, 3, T, Q> const& m2) - { - return mat<4, 3, T, Q>( - m1[0] + m2[0], - m1[1] + m2[1], - m1[2] + m2[2], - m1[3] + m2[3]); - } - - template - GLM_FUNC_QUALIFIER GLM_CONSTEXPR mat<4, 3, T, Q> operator-(mat<4, 3, T, Q> const& m, T scalar) - { - return mat<4, 3, T, Q>( - m[0] - scalar, - m[1] - scalar, - m[2] - scalar, - m[3] - scalar); - } - - template - GLM_FUNC_QUALIFIER GLM_CONSTEXPR mat<4, 3, T, Q> operator-(mat<4, 3, T, Q> const& m1, mat<4, 3, T, Q> const& m2) - { - return mat<4, 3, T, Q>( - m1[0] - m2[0], - m1[1] - m2[1], - m1[2] - m2[2], - m1[3] - m2[3]); - } - - template - GLM_FUNC_QUALIFIER GLM_CONSTEXPR mat<4, 3, T, Q> operator*(mat<4, 3, T, Q> const& m, T scalar) - { - return mat<4, 3, T, Q>( - m[0] * scalar, - m[1] * scalar, - m[2] * scalar, - m[3] * scalar); - } - - template - GLM_FUNC_QUALIFIER GLM_CONSTEXPR mat<4, 3, T, Q> operator*(T scalar, mat<4, 3, T, Q> const& m) - { - return mat<4, 3, T, Q>( - m[0] * scalar, - m[1] * scalar, - m[2] * scalar, - m[3] * scalar); - } template GLM_FUNC_QUALIFIER GLM_CONSTEXPR typename mat<4, 3, T, Q>::col_type operator* @@ -562,37 +381,5 @@ namespace glm m1[0][2] * m2[3][0] + m1[1][2] * m2[3][1] + m1[2][2] * m2[3][2] + m1[3][2] * m2[3][3]); } - template - GLM_FUNC_QUALIFIER GLM_CONSTEXPR mat<4, 3, T, Q> operator/(mat<4, 3, T, Q> const& m, T scalar) - { - return mat<4, 3, T, Q>( - m[0] / scalar, - m[1] / scalar, - m[2] / scalar, - m[3] / scalar); - } - template - GLM_FUNC_QUALIFIER GLM_CONSTEXPR mat<4, 3, T, Q> operator/(T scalar, mat<4, 3, T, Q> const& m) - { - return mat<4, 3, T, Q>( - scalar / m[0], - scalar / m[1], - scalar / m[2], - scalar / m[3]); - } - - // -- Boolean operators -- - - template - GLM_FUNC_QUALIFIER GLM_CONSTEXPR bool operator==(mat<4, 3, T, Q> const& m1, mat<4, 3, T, Q> const& m2) - { - return (m1[0] == m2[0]) && (m1[1] == m2[1]) && (m1[2] == m2[2]) && (m1[3] == m2[3]); - } - - template - GLM_FUNC_QUALIFIER GLM_CONSTEXPR bool operator!=(mat<4, 3, T, Q> const& m1, mat<4, 3, T, Q> const& m2) - { - return (m1[0] != m2[0]) || (m1[1] != m2[1]) || (m1[2] != m2[2]) || (m1[3] != m2[3]); - } } //namespace glm diff --git a/glm/detail/type_mat4x4.hpp b/glm/detail/type_mat4x4.hpp index ad7597b8..705b52be 100644 --- a/glm/detail/type_mat4x4.hpp +++ b/glm/detail/type_mat4x4.hpp @@ -4,6 +4,8 @@ #pragma once #include "type_vec4.hpp" +#include "mat4xn_common_ops.hpp" + #include #include @@ -86,65 +88,16 @@ namespace glm template GLM_FUNC_DISCARD_DECL GLM_CONSTEXPR mat<4, 4, T, Q> & operator=(mat<4, 4, U, Q> const& m); - template - GLM_FUNC_DISCARD_DECL GLM_CONSTEXPR mat<4, 4, T, Q> & operator+=(U s); - template - GLM_FUNC_DISCARD_DECL GLM_CONSTEXPR mat<4, 4, T, Q> & operator+=(mat<4, 4, U, Q> const& m); - template - GLM_FUNC_DISCARD_DECL GLM_CONSTEXPR mat<4, 4, T, Q> & operator-=(U s); - template - GLM_FUNC_DISCARD_DECL GLM_CONSTEXPR mat<4, 4, T, Q> & operator-=(mat<4, 4, U, Q> const& m); - template - GLM_FUNC_DISCARD_DECL GLM_CONSTEXPR mat<4, 4, T, Q> & operator*=(U s); - template - GLM_FUNC_DISCARD_DECL GLM_CONSTEXPR mat<4, 4, T, Q> & operator*=(mat<4, 4, U, Q> const& m); - template - GLM_FUNC_DISCARD_DECL GLM_CONSTEXPR mat<4, 4, T, Q> & operator/=(U s); - template - GLM_FUNC_DISCARD_DECL GLM_CONSTEXPR mat<4, 4, T, Q> & operator/=(mat<4, 4, U, Q> const& m); - // -- Increment and decrement operators -- + template + GLM_FUNC_DISCARD_DECL GLM_CONSTEXPR mat<4, 4, T, Q>& operator*=(mat<4, 4, U, Q> const& m); + template + GLM_FUNC_DISCARD_DECL GLM_CONSTEXPR mat<4, 4, T, Q>& operator/=(mat<4, 4, U, Q> const& m); - GLM_FUNC_DISCARD_DECL GLM_CONSTEXPR mat<4, 4, T, Q> & operator++(); - GLM_FUNC_DISCARD_DECL GLM_CONSTEXPR mat<4, 4, T, Q> & operator--(); - GLM_FUNC_DECL GLM_CONSTEXPR mat<4, 4, T, Q> operator++(int); - GLM_FUNC_DECL GLM_CONSTEXPR mat<4, 4, T, Q> operator--(int); }; - // -- Unary operators -- - - template - GLM_FUNC_DECL GLM_CONSTEXPR mat<4, 4, T, Q> operator+(mat<4, 4, T, Q> const& m); - - template - GLM_FUNC_DECL GLM_CONSTEXPR mat<4, 4, T, Q> operator-(mat<4, 4, T, Q> const& m); - // -- Binary operators -- - template - GLM_FUNC_DECL GLM_CONSTEXPR mat<4, 4, T, Q> operator+(mat<4, 4, T, Q> const& m, T scalar); - - template - GLM_FUNC_DECL GLM_CONSTEXPR mat<4, 4, T, Q> operator+(T scalar, mat<4, 4, T, Q> const& m); - - template - GLM_FUNC_DECL GLM_CONSTEXPR mat<4, 4, T, Q> operator+(mat<4, 4, T, Q> const& m1, mat<4, 4, T, Q> const& m2); - - template - GLM_FUNC_DECL GLM_CONSTEXPR mat<4, 4, T, Q> operator-(mat<4, 4, T, Q> const& m, T scalar); - - template - GLM_FUNC_DECL GLM_CONSTEXPR mat<4, 4, T, Q> operator-(T scalar, mat<4, 4, T, Q> const& m); - - template - GLM_FUNC_DECL GLM_CONSTEXPR mat<4, 4, T, Q> operator-(mat<4, 4, T, Q> const& m1, mat<4, 4, T, Q> const& m2); - - template - GLM_FUNC_DECL GLM_CONSTEXPR mat<4, 4, T, Q> operator*(mat<4, 4, T, Q> const& m, T scalar); - - template - GLM_FUNC_DECL GLM_CONSTEXPR mat<4, 4, T, Q> operator*(T scalar, mat<4, 4, T, Q> const& m); - template GLM_FUNC_DECL GLM_CONSTEXPR typename mat<4, 4, T, Q>::col_type operator*(mat<4, 4, T, Q> const& m, typename mat<4, 4, T, Q>::row_type const& v); @@ -160,12 +113,6 @@ namespace glm template GLM_FUNC_DECL GLM_CONSTEXPR mat<4, 4, T, Q> operator*(mat<4, 4, T, Q> const& m1, mat<4, 4, T, Q> const& m2); - template - GLM_FUNC_DECL GLM_CONSTEXPR mat<4, 4, T, Q> operator/(mat<4, 4, T, Q> const& m, T scalar); - - template - GLM_FUNC_DECL GLM_CONSTEXPR mat<4, 4, T, Q> operator/(T scalar, mat<4, 4, T, Q> const& m); - template GLM_FUNC_DECL GLM_CONSTEXPR typename mat<4, 4, T, Q>::col_type operator/(mat<4, 4, T, Q> const& m, typename mat<4, 4, T, Q>::row_type const& v); @@ -175,13 +122,6 @@ namespace glm template GLM_FUNC_DECL GLM_CONSTEXPR mat<4, 4, T, Q> operator/(mat<4, 4, T, Q> const& m1, mat<4, 4, T, Q> const& m2); - // -- Boolean operators -- - - template - GLM_FUNC_DECL GLM_CONSTEXPR bool operator==(mat<4, 4, T, Q> const& m1, mat<4, 4, T, Q> const& m2); - - template - GLM_FUNC_DECL GLM_CONSTEXPR bool operator!=(mat<4, 4, T, Q> const& m1, mat<4, 4, T, Q> const& m2); }//namespace glm #ifndef GLM_EXTERNAL_TEMPLATE diff --git a/glm/detail/type_mat4x4.inl b/glm/detail/type_mat4x4.inl index 6e328a9e..d971cfee 100644 --- a/glm/detail/type_mat4x4.inl +++ b/glm/detail/type_mat4x4.inl @@ -308,6 +308,7 @@ namespace glm { //memcpy could be faster //memcpy(&this->value, &m.value, 16 * sizeof(valType)); + //but memcpy is not constexpr this->value[0] = m[0]; this->value[1] = m[1]; this->value[2] = m[2]; @@ -315,224 +316,20 @@ namespace glm return *this; } - template + template template - GLM_FUNC_QUALIFIER GLM_CONSTEXPR mat<4, 4, T, Q>& mat<4, 4, T, Q>::operator+=(U s) - { - this->value[0] += s; - this->value[1] += s; - this->value[2] += s; - this->value[3] += s; - return *this; + GLM_FUNC_QUALIFIER GLM_CONSTEXPR mat<4, 4, T, Q>& mat<4, 4, T, Q>::operator*=(mat<4, 4, U, Q> const& m) { + return *this = *this * m; } - + template template - GLM_FUNC_QUALIFIER GLM_CONSTEXPR mat<4, 4, T, Q>& mat<4, 4, T, Q>::operator+=(mat<4, 4, U, Q> const& m) - { - this->value[0] += m[0]; - this->value[1] += m[1]; - this->value[2] += m[2]; - this->value[3] += m[3]; - return *this; - } - - template - template - GLM_FUNC_QUALIFIER GLM_CONSTEXPR mat<4, 4, T, Q> & mat<4, 4, T, Q>::operator-=(U s) - { - this->value[0] -= s; - this->value[1] -= s; - this->value[2] -= s; - this->value[3] -= s; - return *this; - } - - template - template - GLM_FUNC_QUALIFIER GLM_CONSTEXPR mat<4, 4, T, Q> & mat<4, 4, T, Q>::operator-=(mat<4, 4, U, Q> const& m) - { - this->value[0] -= m[0]; - this->value[1] -= m[1]; - this->value[2] -= m[2]; - this->value[3] -= m[3]; - return *this; - } - - template - template - GLM_FUNC_QUALIFIER GLM_CONSTEXPR mat<4, 4, T, Q> & mat<4, 4, T, Q>::operator*=(U s) - { - this->value[0] *= s; - this->value[1] *= s; - this->value[2] *= s; - this->value[3] *= s; - return *this; - } - - template - template - GLM_FUNC_QUALIFIER GLM_CONSTEXPR mat<4, 4, T, Q> & mat<4, 4, T, Q>::operator*=(mat<4, 4, U, Q> const& m) - { - return (*this = *this * m); - } - - template - template - GLM_FUNC_QUALIFIER GLM_CONSTEXPR mat<4, 4, T, Q> & mat<4, 4, T, Q>::operator/=(U s) - { - this->value[0] /= s; - this->value[1] /= s; - this->value[2] /= s; - this->value[3] /= s; - return *this; - } - - template - template - GLM_FUNC_QUALIFIER GLM_CONSTEXPR mat<4, 4, T, Q> & mat<4, 4, T, Q>::operator/=(mat<4, 4, U, Q> const& m) - { + GLM_FUNC_QUALIFIER GLM_CONSTEXPR mat<4, 4, T, Q>& mat<4, 4, T, Q>::operator/=(mat<4, 4, U, Q> const& m) { return *this *= inverse(m); } - // -- Increment and decrement operators -- - - template - GLM_FUNC_QUALIFIER GLM_CONSTEXPR mat<4, 4, T, Q> & mat<4, 4, T, Q>::operator++() - { - ++this->value[0]; - ++this->value[1]; - ++this->value[2]; - ++this->value[3]; - return *this; - } - - template - GLM_FUNC_QUALIFIER GLM_CONSTEXPR mat<4, 4, T, Q> & mat<4, 4, T, Q>::operator--() - { - --this->value[0]; - --this->value[1]; - --this->value[2]; - --this->value[3]; - return *this; - } - - template - GLM_FUNC_QUALIFIER GLM_CONSTEXPR mat<4, 4, T, Q> mat<4, 4, T, Q>::operator++(int) - { - mat<4, 4, T, Q> Result(*this); - ++*this; - return Result; - } - - template - GLM_FUNC_QUALIFIER GLM_CONSTEXPR mat<4, 4, T, Q> mat<4, 4, T, Q>::operator--(int) - { - mat<4, 4, T, Q> Result(*this); - --*this; - return Result; - } - - // -- Unary constant operators -- - - template - GLM_FUNC_QUALIFIER GLM_CONSTEXPR mat<4, 4, T, Q> operator+(mat<4, 4, T, Q> const& m) - { - return m; - } - - template - GLM_FUNC_QUALIFIER GLM_CONSTEXPR mat<4, 4, T, Q> operator-(mat<4, 4, T, Q> const& m) - { - return mat<4, 4, T, Q>( - -m[0], - -m[1], - -m[2], - -m[3]); - } - // -- Binary arithmetic operators -- - template - GLM_FUNC_QUALIFIER GLM_CONSTEXPR mat<4, 4, T, Q> operator+(mat<4, 4, T, Q> const& m, T scalar) - { - return mat<4, 4, T, Q>( - m[0] + scalar, - m[1] + scalar, - m[2] + scalar, - m[3] + scalar); - } - - template - GLM_FUNC_QUALIFIER GLM_CONSTEXPR mat<4, 4, T, Q> operator+(T scalar, mat<4, 4, T, Q> const& m) - { - return mat<4, 4, T, Q>( - m[0] + scalar, - m[1] + scalar, - m[2] + scalar, - m[3] + scalar); - } - - template - GLM_FUNC_QUALIFIER GLM_CONSTEXPR mat<4, 4, T, Q> operator+(mat<4, 4, T, Q> const& m1, mat<4, 4, T, Q> const& m2) - { - return mat<4, 4, T, Q>( - m1[0] + m2[0], - m1[1] + m2[1], - m1[2] + m2[2], - m1[3] + m2[3]); - } - - template - GLM_FUNC_QUALIFIER GLM_CONSTEXPR mat<4, 4, T, Q> operator-(mat<4, 4, T, Q> const& m, T scalar) - { - return mat<4, 4, T, Q>( - m[0] - scalar, - m[1] - scalar, - m[2] - scalar, - m[3] - scalar); - } - - template - GLM_FUNC_QUALIFIER GLM_CONSTEXPR mat<4, 4, T, Q> operator-(T scalar, mat<4, 4, T, Q> const& m) - { - return mat<4, 4, T, Q>( - scalar - m[0], - scalar - m[1], - scalar - m[2], - scalar - m[3]); - } - - template - GLM_FUNC_QUALIFIER GLM_CONSTEXPR mat<4, 4, T, Q> operator-(mat<4, 4, T, Q> const& m1, mat<4, 4, T, Q> const& m2) - { - return mat<4, 4, T, Q>( - m1[0] - m2[0], - m1[1] - m2[1], - m1[2] - m2[2], - m1[3] - m2[3]); - } - - template - GLM_FUNC_QUALIFIER GLM_CONSTEXPR mat<4, 4, T, Q> operator*(mat<4, 4, T, Q> const& m, T scalar) - { - return mat<4, 4, T, Q>( - m[0] * scalar, - m[1] * scalar, - m[2] * scalar, - m[3] * scalar); - } - - template - GLM_FUNC_QUALIFIER GLM_CONSTEXPR mat<4, 4, T, Q> operator*(T scalar, mat<4, 4, T, Q> const& m) - { - return mat<4, 4, T, Q>( - m[0] * scalar, - m[1] * scalar, - m[2] * scalar, - m[3] * scalar); - } - template GLM_FUNC_QUALIFIER GLM_CONSTEXPR typename mat<4, 4, T, Q>::col_type operator* ( @@ -630,7 +427,7 @@ namespace glm namespace detail { template - struct mul4x4 {}; + struct mul4x4; template struct mul4x4 @@ -712,26 +509,6 @@ namespace glm return detail::mul4x4::value>::call(m1, m2); } - template - GLM_FUNC_QUALIFIER GLM_CONSTEXPR mat<4, 4, T, Q> operator/(mat<4, 4, T, Q> const& m, T scalar) - { - return mat<4, 4, T, Q>( - m[0] / scalar, - m[1] / scalar, - m[2] / scalar, - m[3] / scalar); - } - - template - GLM_FUNC_QUALIFIER GLM_CONSTEXPR mat<4, 4, T, Q> operator/(T scalar, mat<4, 4, T, Q> const& m) - { - return mat<4, 4, T, Q>( - scalar / m[0], - scalar / m[1], - scalar / m[2], - scalar / m[3]); - } - template GLM_FUNC_QUALIFIER GLM_CONSTEXPR typename mat<4, 4, T, Q>::col_type operator/(mat<4, 4, T, Q> const& m, typename mat<4, 4, T, Q>::row_type const& v) { @@ -748,22 +525,10 @@ namespace glm GLM_FUNC_QUALIFIER GLM_CONSTEXPR mat<4, 4, T, Q> operator/(mat<4, 4, T, Q> const& m1, mat<4, 4, T, Q> const& m2) { mat<4, 4, T, Q> m1_copy(m1); - return m1_copy /= m2; + m1_copy /= m2; + return m1_copy; } - // -- Boolean operators -- - - template - GLM_FUNC_QUALIFIER GLM_CONSTEXPR bool operator==(mat<4, 4, T, Q> const& m1, mat<4, 4, T, Q> const& m2) - { - return (m1[0] == m2[0]) && (m1[1] == m2[1]) && (m1[2] == m2[2]) && (m1[3] == m2[3]); - } - - template - GLM_FUNC_QUALIFIER GLM_CONSTEXPR bool operator!=(mat<4, 4, T, Q> const& m1, mat<4, 4, T, Q> const& m2) - { - return (m1[0] != m2[0]) || (m1[1] != m2[1]) || (m1[2] != m2[2]) || (m1[3] != m2[3]); - } }//namespace glm #if GLM_CONFIG_SIMD == GLM_ENABLE diff --git a/glm/detail/type_vec1.hpp b/glm/detail/type_vec1.hpp index 0cc7b5d4..5ecf24c4 100644 --- a/glm/detail/type_vec1.hpp +++ b/glm/detail/type_vec1.hpp @@ -4,6 +4,7 @@ #pragma once #include "qualifier.hpp" +#include "vec_common_ops.hpp" #if GLM_CONFIG_SWIZZLE == GLM_SWIZZLE_OPERATOR # include "_swizzle.hpp" #elif GLM_CONFIG_SWIZZLE == GLM_SWIZZLE_FUNCTION @@ -130,171 +131,77 @@ namespace glm // -- Unary arithmetic operators -- GLM_DEFAULTED_FUNC_DECL GLM_CONSTEXPR vec<1, T, Q> & operator=(vec const& v) GLM_DEFAULT; - template GLM_FUNC_DISCARD_DECL GLM_CONSTEXPR vec<1, T, Q> & operator=(vec<1, U, Q> const& v); template - GLM_FUNC_DISCARD_DECL GLM_CONSTEXPR vec<1, T, Q> & operator+=(U scalar); - template - GLM_FUNC_DISCARD_DECL GLM_CONSTEXPR vec<1, T, Q> & operator+=(vec<1, U, Q> const& v); - template - GLM_FUNC_DISCARD_DECL GLM_CONSTEXPR vec<1, T, Q> & operator-=(U scalar); + GLM_FUNC_DISCARD_DECL GLM_CONSTEXPR vec<1, T, Q> & operator+=(vec<1,U,Q> const& v); template GLM_FUNC_DISCARD_DECL GLM_CONSTEXPR vec<1, T, Q> & operator-=(vec<1, U, Q> const& v); template - GLM_FUNC_DISCARD_DECL GLM_CONSTEXPR vec<1, T, Q> & operator*=(U scalar); - template GLM_FUNC_DISCARD_DECL GLM_CONSTEXPR vec<1, T, Q> & operator*=(vec<1, U, Q> const& v); template - GLM_FUNC_DISCARD_DECL GLM_CONSTEXPR vec<1, T, Q> & operator/=(U scalar); - template GLM_FUNC_DISCARD_DECL GLM_CONSTEXPR vec<1, T, Q> & operator/=(vec<1, U, Q> const& v); // -- Increment and decrement operators -- GLM_FUNC_DISCARD_DECL GLM_CONSTEXPR vec<1, T, Q> & operator++(); GLM_FUNC_DISCARD_DECL GLM_CONSTEXPR vec<1, T, Q> & operator--(); - GLM_FUNC_DECL GLM_CONSTEXPR vec<1, T, Q> operator++(int); - GLM_FUNC_DECL GLM_CONSTEXPR vec<1, T, Q> operator--(int); // -- Unary bit operators -- - template - GLM_FUNC_DISCARD_DECL GLM_CONSTEXPR vec<1, T, Q> & operator%=(U scalar); template GLM_FUNC_DISCARD_DECL GLM_CONSTEXPR vec<1, T, Q> & operator%=(vec<1, U, Q> const& v); template - GLM_FUNC_DISCARD_DECL GLM_CONSTEXPR vec<1, T, Q> & operator&=(U scalar); - template GLM_FUNC_DISCARD_DECL GLM_CONSTEXPR vec<1, T, Q> & operator&=(vec<1, U, Q> const& v); template - GLM_FUNC_DISCARD_DECL GLM_CONSTEXPR vec<1, T, Q> & operator|=(U scalar); - template GLM_FUNC_DISCARD_DECL GLM_CONSTEXPR vec<1, T, Q> & operator|=(vec<1, U, Q> const& v); template - GLM_FUNC_DISCARD_DECL GLM_CONSTEXPR vec<1, T, Q> & operator^=(U scalar); - template GLM_FUNC_DISCARD_DECL GLM_CONSTEXPR vec<1, T, Q> & operator^=(vec<1, U, Q> const& v); template - GLM_FUNC_DISCARD_DECL GLM_CONSTEXPR vec<1, T, Q> & operator<<=(U scalar); - template GLM_FUNC_DISCARD_DECL GLM_CONSTEXPR vec<1, T, Q> & operator<<=(vec<1, U, Q> const& v); template - GLM_FUNC_DISCARD_DECL GLM_CONSTEXPR vec<1, T, Q> & operator>>=(U scalar); - template GLM_FUNC_DISCARD_DECL GLM_CONSTEXPR vec<1, T, Q> & operator>>=(vec<1, U, Q> const& v); }; // -- Unary operators -- - template - GLM_FUNC_DECL GLM_CONSTEXPR vec<1, T, Q> operator+(vec<1, T, Q> const& v); - template GLM_FUNC_DECL GLM_CONSTEXPR vec<1, T, Q> operator-(vec<1, T, Q> const& v); // -- Binary operators -- - template - GLM_FUNC_DECL GLM_CONSTEXPR vec<1, T, Q> operator+(vec<1, T, Q> const& v, T scalar); - - template - GLM_FUNC_DECL GLM_CONSTEXPR vec<1, T, Q> operator+(T scalar, vec<1, T, Q> const& v); - - template - GLM_FUNC_DECL GLM_CONSTEXPR vec<1, T, Q> operator+(vec<1, T, Q> const& v1, vec<1, T, Q> const& v2); - - template - GLM_FUNC_DECL GLM_CONSTEXPR vec<1, T, Q> operator-(vec<1, T, Q> const& v, T scalar); - - template - GLM_FUNC_DECL GLM_CONSTEXPR vec<1, T, Q> operator-(T scalar, vec<1, T, Q> const& v); - - template - GLM_FUNC_DECL GLM_CONSTEXPR vec<1, T, Q> operator-(vec<1, T, Q> const& v1, vec<1, T, Q> const& v2); - - template - GLM_FUNC_DECL GLM_CONSTEXPR vec<1, T, Q> operator*(vec<1, T, Q> const& v, T scalar); - - template - GLM_FUNC_DECL GLM_CONSTEXPR vec<1, T, Q> operator*(T scalar, vec<1, T, Q> const& v); - - template - GLM_FUNC_DECL GLM_CONSTEXPR vec<1, T, Q> operator*(vec<1, T, Q> const& v1, vec<1, T, Q> const& v2); - - template - GLM_FUNC_DECL GLM_CONSTEXPR vec<1, T, Q> operator/(vec<1, T, Q> const& v, T scalar); - - template - GLM_FUNC_DECL GLM_CONSTEXPR vec<1, T, Q> operator/(T scalar, vec<1, T, Q> const& v); - - template - GLM_FUNC_DECL GLM_CONSTEXPR vec<1, T, Q> operator/(vec<1, T, Q> const& v1, vec<1, T, Q> const& v2); - - template - GLM_FUNC_DECL GLM_CONSTEXPR vec<1, T, Q> operator%(vec<1, T, Q> const& v, T scalar); - - template - GLM_FUNC_DECL GLM_CONSTEXPR vec<1, T, Q> operator%(T scalar, vec<1, T, Q> const& v); - - template - GLM_FUNC_DECL GLM_CONSTEXPR vec<1, T, Q> operator%(vec<1, T, Q> const& v1, vec<1, T, Q> const& v2); - - template - GLM_FUNC_DECL GLM_CONSTEXPR vec<1, T, Q> operator&(vec<1, T, Q> const& v, T scalar); - - template - GLM_FUNC_DECL GLM_CONSTEXPR vec<1, T, Q> operator&(T scalar, vec<1, T, Q> const& v); - - template - GLM_FUNC_DECL GLM_CONSTEXPR vec<1, T, Q> operator&(vec<1, T, Q> const& v1, vec<1, T, Q> const& v2); - - template - GLM_FUNC_DECL GLM_CONSTEXPR vec<1, T, Q> operator|(vec<1, T, Q> const& v, T scalar); - - template - GLM_FUNC_DECL GLM_CONSTEXPR vec<1, T, Q> operator|(T scalar, vec<1, T, Q> const& v); - - template - GLM_FUNC_DECL GLM_CONSTEXPR vec<1, T, Q> operator|(vec<1, T, Q> const& v1, vec<1, T, Q> const& v2); - - template - GLM_FUNC_DECL GLM_CONSTEXPR vec<1, T, Q> operator^(vec<1, T, Q> const& v, T scalar); - - template - GLM_FUNC_DECL GLM_CONSTEXPR vec<1, T, Q> operator^(T scalar, vec<1, T, Q> const& v); - - template - GLM_FUNC_DECL GLM_CONSTEXPR vec<1, T, Q> operator^(vec<1, T, Q> const& v1, vec<1, T, Q> const& v2); - - template - GLM_FUNC_DECL GLM_CONSTEXPR vec<1, T, Q> operator<<(vec<1, T, Q> const& v, T scalar); - - template - GLM_FUNC_DECL GLM_CONSTEXPR vec<1, T, Q> operator<<(T scalar, vec<1, T, Q> const& v); - - template - GLM_FUNC_DECL GLM_CONSTEXPR vec<1, T, Q> operator<<(vec<1, T, Q> const& v1, vec<1, T, Q> const& v2); - - template - GLM_FUNC_DECL GLM_CONSTEXPR vec<1, T, Q> operator>>(vec<1, T, Q> const& v, T scalar); - - template - GLM_FUNC_DECL GLM_CONSTEXPR vec<1, T, Q> operator>>(T scalar, vec<1, T, Q> const& v); - - template - GLM_FUNC_DECL GLM_CONSTEXPR vec<1, T, Q> operator>>(vec<1, T, Q> const& v1, vec<1, T, Q> const& v2); template GLM_FUNC_DECL GLM_CONSTEXPR vec<1, T, Q> operator~(vec<1, T, Q> const& v); + // These are to avoid ambigiuities + template + GLM_FUNC_DECL GLM_CONSTEXPR vec<1, T, Q> operator+(vec<1, T, Q> const& v1, vec<1, T, Q> const& v2); + template + GLM_FUNC_DECL GLM_CONSTEXPR vec<1, T, Q> operator-(vec<1, T, Q> const& v1, vec<1, T, Q> const& v2); + template + GLM_FUNC_DECL GLM_CONSTEXPR vec<1, T, Q> operator*(vec<1, T, Q> const& v1, vec<1, T, Q> const& v2); + template + GLM_FUNC_DECL GLM_CONSTEXPR vec<1, T, Q> operator/(vec<1, T, Q> const& v1, vec<1, T, Q> const& v2); + template + GLM_FUNC_DECL GLM_CONSTEXPR vec<1, T, Q> operator%(vec<1, T, Q> const& v1, vec<1, T, Q> const& v2); + template + GLM_FUNC_DECL GLM_CONSTEXPR vec<1, T, Q> operator&(vec<1, T, Q> const& v1, vec<1, T, Q> const& v2); + template + GLM_FUNC_DECL GLM_CONSTEXPR vec<1, T, Q> operator|(vec<1, T, Q> const& v1, vec<1, T, Q> const& v2); + template + GLM_FUNC_DECL GLM_CONSTEXPR vec<1, T, Q> operator^(vec<1, T, Q> const& v1, vec<1, T, Q> const& v2); + template + GLM_FUNC_DECL GLM_CONSTEXPR vec<1, T, Q> operator<<(vec<1, T, Q> const& v1, vec<1, T, Q> const& v2); + template + GLM_FUNC_DECL GLM_CONSTEXPR vec<1, T, Q> operator>>(vec<1, T, Q> const& v1, vec<1, T, Q> const& v2); + + // -- Boolean operators -- template GLM_FUNC_DECL GLM_CONSTEXPR bool operator==(vec<1, T, Q> const& v1, vec<1, T, Q> const& v2); - template - GLM_FUNC_DECL GLM_CONSTEXPR bool operator!=(vec<1, T, Q> const& v1, vec<1, T, Q> const& v2); template GLM_FUNC_DECL GLM_CONSTEXPR vec<1, bool, Q> operator&&(vec<1, bool, Q> const& v1, vec<1, bool, Q> const& v2); diff --git a/glm/detail/type_vec1.inl b/glm/detail/type_vec1.inl index 18411e7f..64769f21 100644 --- a/glm/detail/type_vec1.inl +++ b/glm/detail/type_vec1.inl @@ -94,14 +94,6 @@ namespace glm return *this; } - template - template - GLM_FUNC_QUALIFIER GLM_CONSTEXPR vec<1, T, Q> & vec<1, T, Q>::operator+=(U scalar) - { - this->x += static_cast(scalar); - return *this; - } - template template GLM_FUNC_QUALIFIER GLM_CONSTEXPR vec<1, T, Q> & vec<1, T, Q>::operator+=(vec<1, U, Q> const& v) @@ -110,14 +102,6 @@ namespace glm return *this; } - template - template - GLM_FUNC_QUALIFIER GLM_CONSTEXPR vec<1, T, Q> & vec<1, T, Q>::operator-=(U scalar) - { - this->x -= static_cast(scalar); - return *this; - } - template template GLM_FUNC_QUALIFIER GLM_CONSTEXPR vec<1, T, Q> & vec<1, T, Q>::operator-=(vec<1, U, Q> const& v) @@ -126,14 +110,6 @@ namespace glm return *this; } - template - template - GLM_FUNC_QUALIFIER GLM_CONSTEXPR vec<1, T, Q> & vec<1, T, Q>::operator*=(U scalar) - { - this->x *= static_cast(scalar); - return *this; - } - template template GLM_FUNC_QUALIFIER GLM_CONSTEXPR vec<1, T, Q> & vec<1, T, Q>::operator*=(vec<1, U, Q> const& v) @@ -142,14 +118,6 @@ namespace glm return *this; } - template - template - GLM_FUNC_QUALIFIER GLM_CONSTEXPR vec<1, T, Q> & vec<1, T, Q>::operator/=(U scalar) - { - this->x /= static_cast(scalar); - return *this; - } - template template GLM_FUNC_QUALIFIER GLM_CONSTEXPR vec<1, T, Q> & vec<1, T, Q>::operator/=(vec<1, U, Q> const& v) @@ -174,48 +142,15 @@ namespace glm return *this; } - template - GLM_FUNC_QUALIFIER GLM_CONSTEXPR vec<1, T, Q> vec<1, T, Q>::operator++(int) - { - vec<1, T, Q> Result(*this); - ++*this; - return Result; - } - - template - GLM_FUNC_QUALIFIER GLM_CONSTEXPR vec<1, T, Q> vec<1, T, Q>::operator--(int) - { - vec<1, T, Q> Result(*this); - --*this; - return Result; - } - // -- Unary bit operators -- template template - GLM_FUNC_QUALIFIER GLM_CONSTEXPR vec<1, T, Q> & vec<1, T, Q>::operator%=(U scalar) - { - this->x %= static_cast(scalar); - return *this; - } - - template - template - GLM_FUNC_QUALIFIER GLM_CONSTEXPR vec<1, T, Q> & vec<1, T, Q>::operator%=(vec<1, U, Q> const& v) + GLM_FUNC_QUALIFIER GLM_CONSTEXPR vec<1, T, Q> & vec<1, T, Q>::operator%=(vec<1,U,Q> const& v) { this->x %= static_cast(v.x); return *this; } - - template - template - GLM_FUNC_QUALIFIER GLM_CONSTEXPR vec<1, T, Q> & vec<1, T, Q>::operator&=(U scalar) - { - this->x &= static_cast(scalar); - return *this; - } - template template GLM_FUNC_QUALIFIER GLM_CONSTEXPR vec<1, T, Q> & vec<1, T, Q>::operator&=(vec<1, U, Q> const& v) @@ -224,14 +159,6 @@ namespace glm return *this; } - template - template - GLM_FUNC_QUALIFIER GLM_CONSTEXPR vec<1, T, Q> & vec<1, T, Q>::operator|=(U scalar) - { - this->x |= static_cast(scalar); - return *this; - } - template template GLM_FUNC_QUALIFIER GLM_CONSTEXPR vec<1, T, Q> & vec<1, T, Q>::operator|=(vec<1, U, Q> const& v) @@ -240,14 +167,6 @@ namespace glm return *this; } - template - template - GLM_FUNC_QUALIFIER GLM_CONSTEXPR vec<1, T, Q> & vec<1, T, Q>::operator^=(U scalar) - { - this->x ^= static_cast(scalar); - return *this; - } - template template GLM_FUNC_QUALIFIER GLM_CONSTEXPR vec<1, T, Q> & vec<1, T, Q>::operator^=(vec<1, U, Q> const& v) @@ -256,14 +175,6 @@ namespace glm return *this; } - template - template - GLM_FUNC_QUALIFIER GLM_CONSTEXPR vec<1, T, Q> & vec<1, T, Q>::operator<<=(U scalar) - { - this->x <<= static_cast(scalar); - return *this; - } - template template GLM_FUNC_QUALIFIER GLM_CONSTEXPR vec<1, T, Q> & vec<1, T, Q>::operator<<=(vec<1, U, Q> const& v) @@ -272,14 +183,6 @@ namespace glm return *this; } - template - template - GLM_FUNC_QUALIFIER GLM_CONSTEXPR vec<1, T, Q> & vec<1, T, Q>::operator>>=(U scalar) - { - this->x >>= static_cast(scalar); - return *this; - } - template template GLM_FUNC_QUALIFIER GLM_CONSTEXPR vec<1, T, Q> & vec<1, T, Q>::operator>>=(vec<1, U, Q> const& v) @@ -289,13 +192,6 @@ namespace glm } // -- Unary constant operators -- - - template - GLM_FUNC_QUALIFIER GLM_CONSTEXPR vec<1, T, Q> operator+(vec<1, T, Q> const& v) - { - return v; - } - template GLM_FUNC_QUALIFIER GLM_CONSTEXPR vec<1, T, Q> operator-(vec<1, T, Q> const& v) { @@ -304,220 +200,6 @@ namespace glm } // -- Binary arithmetic operators -- - - template - GLM_FUNC_QUALIFIER GLM_CONSTEXPR vec<1, T, Q> operator+(vec<1, T, Q> const& v, T scalar) - { - return vec<1, T, Q>( - v.x + scalar); - } - - template - GLM_FUNC_QUALIFIER GLM_CONSTEXPR vec<1, T, Q> operator+(T scalar, vec<1, T, Q> const& v) - { - return vec<1, T, Q>( - scalar + v.x); - } - - template - GLM_FUNC_QUALIFIER GLM_CONSTEXPR vec<1, T, Q> operator+(vec<1, T, Q> const& v1, vec<1, T, Q> const& v2) - { - return vec<1, T, Q>( - v1.x + v2.x); - } - - //operator- - template - GLM_FUNC_QUALIFIER GLM_CONSTEXPR vec<1, T, Q> operator-(vec<1, T, Q> const& v, T scalar) - { - return vec<1, T, Q>( - v.x - scalar); - } - - template - GLM_FUNC_QUALIFIER GLM_CONSTEXPR vec<1, T, Q> operator-(T scalar, vec<1, T, Q> const& v) - { - return vec<1, T, Q>( - scalar - v.x); - } - - template - GLM_FUNC_QUALIFIER GLM_CONSTEXPR vec<1, T, Q> operator-(vec<1, T, Q> const& v1, vec<1, T, Q> const& v2) - { - return vec<1, T, Q>( - v1.x - v2.x); - } - - template - GLM_FUNC_QUALIFIER GLM_CONSTEXPR vec<1, T, Q> operator*(vec<1, T, Q> const& v, T scalar) - { - return vec<1, T, Q>( - v.x * scalar); - } - - template - GLM_FUNC_QUALIFIER GLM_CONSTEXPR vec<1, T, Q> operator*(T scalar, vec<1, T, Q> const& v) - { - return vec<1, T, Q>( - scalar * v.x); - } - - template - GLM_FUNC_QUALIFIER GLM_CONSTEXPR vec<1, T, Q> operator*(vec<1, T, Q> const& v1, vec<1, T, Q> const& v2) - { - return vec<1, T, Q>( - v1.x * v2.x); - } - - template - GLM_FUNC_QUALIFIER GLM_CONSTEXPR vec<1, T, Q> operator/(vec<1, T, Q> const& v, T scalar) - { - return vec<1, T, Q>( - v.x / scalar); - } - - template - GLM_FUNC_QUALIFIER GLM_CONSTEXPR vec<1, T, Q> operator/(T scalar, vec<1, T, Q> const& v) - { - return vec<1, T, Q>( - scalar / v.x); - } - - template - GLM_FUNC_QUALIFIER GLM_CONSTEXPR vec<1, T, Q> operator/(vec<1, T, Q> const& v1, vec<1, T, Q> const& v2) - { - return vec<1, T, Q>( - v1.x / v2.x); - } - - // -- Binary bit operators -- - - template - GLM_FUNC_QUALIFIER GLM_CONSTEXPR vec<1, T, Q> operator%(vec<1, T, Q> const& v, T scalar) - { - return vec<1, T, Q>( - v.x % scalar); - } - - template - GLM_FUNC_QUALIFIER GLM_CONSTEXPR vec<1, T, Q> operator%(T scalar, vec<1, T, Q> const& v) - { - return vec<1, T, Q>( - scalar % v.x); - } - - template - GLM_FUNC_QUALIFIER GLM_CONSTEXPR vec<1, T, Q> operator%(vec<1, T, Q> const& v1, vec<1, T, Q> const& v2) - { - return vec<1, T, Q>( - v1.x % v2.x); - } - - template - GLM_FUNC_QUALIFIER GLM_CONSTEXPR vec<1, T, Q> operator&(vec<1, T, Q> const& v, T scalar) - { - return vec<1, T, Q>( - v.x & scalar); - } - - template - GLM_FUNC_QUALIFIER GLM_CONSTEXPR vec<1, T, Q> operator&(T scalar, vec<1, T, Q> const& v) - { - return vec<1, T, Q>( - scalar & v.x); - } - - template - GLM_FUNC_QUALIFIER GLM_CONSTEXPR vec<1, T, Q> operator&(vec<1, T, Q> const& v1, vec<1, T, Q> const& v2) - { - return vec<1, T, Q>( - v1.x & v2.x); - } - - template - GLM_FUNC_QUALIFIER GLM_CONSTEXPR vec<1, T, Q> operator|(vec<1, T, Q> const& v, T scalar) - { - return vec<1, T, Q>( - v.x | scalar); - } - - template - GLM_FUNC_QUALIFIER GLM_CONSTEXPR vec<1, T, Q> operator|(T scalar, vec<1, T, Q> const& v) - { - return vec<1, T, Q>( - scalar | v.x); - } - - template - GLM_FUNC_QUALIFIER GLM_CONSTEXPR vec<1, T, Q> operator|(vec<1, T, Q> const& v1, vec<1, T, Q> const& v2) - { - return vec<1, T, Q>( - v1.x | v2.x); - } - - template - GLM_FUNC_QUALIFIER GLM_CONSTEXPR vec<1, T, Q> operator^(vec<1, T, Q> const& v, T scalar) - { - return vec<1, T, Q>( - v.x ^ scalar); - } - - template - GLM_FUNC_QUALIFIER GLM_CONSTEXPR vec<1, T, Q> operator^(T scalar, vec<1, T, Q> const& v) - { - return vec<1, T, Q>( - scalar ^ v.x); - } - - template - GLM_FUNC_QUALIFIER GLM_CONSTEXPR vec<1, T, Q> operator^(vec<1, T, Q> const& v1, vec<1, T, Q> const& v2) - { - return vec<1, T, Q>( - v1.x ^ v2.x); - } - - template - GLM_FUNC_QUALIFIER GLM_CONSTEXPR vec<1, T, Q> operator<<(vec<1, T, Q> const& v, T scalar) - { - return vec<1, T, Q>( - static_cast(v.x << scalar)); - } - - template - GLM_FUNC_QUALIFIER GLM_CONSTEXPR vec<1, T, Q> operator<<(T scalar, vec<1, T, Q> const& v) - { - return vec<1, T, Q>( - static_cast(scalar << v.x)); - } - - template - GLM_FUNC_QUALIFIER GLM_CONSTEXPR vec<1, T, Q> operator<<(vec<1, T, Q> const& v1, vec<1, T, Q> const& v2) - { - return vec<1, T, Q>( - static_cast(v1.x << v2.x)); - } - - template - GLM_FUNC_QUALIFIER GLM_CONSTEXPR vec<1, T, Q> operator>>(vec<1, T, Q> const& v, T scalar) - { - return vec<1, T, Q>( - static_cast(v.x >> scalar)); - } - - template - GLM_FUNC_QUALIFIER GLM_CONSTEXPR vec<1, T, Q> operator>>(T scalar, vec<1, T, Q> const& v) - { - return vec<1, T, Q>( - static_cast(scalar >> v.x)); - } - - template - GLM_FUNC_QUALIFIER GLM_CONSTEXPR vec<1, T, Q> operator>>(vec<1, T, Q> const& v1, vec<1, T, Q> const& v2) - { - return vec<1, T, Q>( - static_cast(v1.x >> v2.x)); - } - template GLM_FUNC_QUALIFIER GLM_CONSTEXPR vec<1, T, Q> operator~(vec<1, T, Q> const& v) { @@ -525,6 +207,50 @@ namespace glm ~v.x); } + + // These are to avoid ambigiuities + template + GLM_FUNC_QUALIFIER GLM_CONSTEXPR vec<1, T, Q> operator+(vec<1, T, Q> const& v1, vec<1, T, Q> const& v2) { + return vec<1, T, Q>(v1.x + v2.x); + } + template + GLM_FUNC_QUALIFIER GLM_CONSTEXPR vec<1, T, Q> operator-(vec<1, T, Q> const& v1, vec<1, T, Q> const& v2) { + return vec<1, T, Q>(v1.x - v2.x); + } + template + GLM_FUNC_QUALIFIER GLM_CONSTEXPR vec<1, T, Q> operator*(vec<1, T, Q> const& v1, vec<1, T, Q> const& v2) { + return vec<1, T, Q>(v1.x * v2.x); + } + template + GLM_FUNC_QUALIFIER GLM_CONSTEXPR vec<1, T, Q> operator/(vec<1, T, Q> const& v1, vec<1, T, Q> const& v2) { + return vec<1, T, Q>(v1.x / v2.x); + } + template + GLM_FUNC_QUALIFIER GLM_CONSTEXPR vec<1, T, Q> operator%(vec<1, T, Q> const& v1, vec<1, T, Q> const& v2) { + return vec<1, T, Q>(v1.x % v2.x); + } + template + GLM_FUNC_QUALIFIER GLM_CONSTEXPR vec<1, T, Q> operator&(vec<1, T, Q> const& v1, vec<1, T, Q> const& v2) { + return vec<1, T, Q>(v1.x & v2.x); + } + template + GLM_FUNC_QUALIFIER GLM_CONSTEXPR vec<1, T, Q> operator|(vec<1, T, Q> const& v1, vec<1, T, Q> const& v2) { + return vec<1, T, Q>(v1.x | v2.x); + } + template + GLM_FUNC_QUALIFIER GLM_CONSTEXPR vec<1, T, Q> operator^(vec<1, T, Q> const& v1, vec<1, T, Q> const& v2) { + return vec<1, T, Q>(v1.x ^ v2.x); + } + template + GLM_FUNC_QUALIFIER GLM_CONSTEXPR vec<1, T, Q> operator<<(vec<1, T, Q> const& v1, vec<1, T, Q> const& v2) { + return vec<1, T, Q>(v1.x << v2.x); + } + template + GLM_FUNC_QUALIFIER GLM_CONSTEXPR vec<1, T, Q> operator>>(vec<1, T, Q> const& v1, vec<1, T, Q> const& v2) { + return vec<1, T, Q>(v1.x >> v2.x); + } + + // -- Boolean operators -- template @@ -533,12 +259,6 @@ namespace glm return detail::compute_equal::is_iec559>::call(v1.x, v2.x); } - template - GLM_FUNC_QUALIFIER GLM_CONSTEXPR bool operator!=(vec<1, T, Q> const& v1, vec<1, T, Q> const& v2) - { - return !(v1 == v2); - } - template GLM_FUNC_QUALIFIER GLM_CONSTEXPR vec<1, bool, Q> operator&&(vec<1, bool, Q> const& v1, vec<1, bool, Q> const& v2) { diff --git a/glm/detail/type_vec2.hpp b/glm/detail/type_vec2.hpp index 66c6137c..c785ff51 100644 --- a/glm/detail/type_vec2.hpp +++ b/glm/detail/type_vec2.hpp @@ -4,6 +4,8 @@ #pragma once #include "qualifier.hpp" +#include "vec_common_ops.hpp" + #if GLM_CONFIG_SWIZZLE == GLM_SWIZZLE_OPERATOR # include "_swizzle.hpp" #elif GLM_CONFIG_SWIZZLE == GLM_SWIZZLE_FUNCTION @@ -152,237 +154,41 @@ namespace glm template GLM_FUNC_DISCARD_DECL GLM_CONSTEXPR vec<2, T, Q> & operator=(vec<2, U, Q> const& v); template - GLM_FUNC_DISCARD_DECL GLM_CONSTEXPR vec<2, T, Q> & operator+=(U scalar); - template - GLM_FUNC_DISCARD_DECL GLM_CONSTEXPR vec<2, T, Q> & operator+=(vec<1, U, Q> const& v); - template GLM_FUNC_DISCARD_DECL GLM_CONSTEXPR vec<2, T, Q> & operator+=(vec<2, U, Q> const& v); template - GLM_FUNC_DISCARD_DECL GLM_CONSTEXPR vec<2, T, Q> & operator-=(U scalar); - template - GLM_FUNC_DISCARD_DECL GLM_CONSTEXPR vec<2, T, Q> & operator-=(vec<1, U, Q> const& v); - template GLM_FUNC_DISCARD_DECL GLM_CONSTEXPR vec<2, T, Q> & operator-=(vec<2, U, Q> const& v); template - GLM_FUNC_DISCARD_DECL GLM_CONSTEXPR vec<2, T, Q> & operator*=(U scalar); - template - GLM_FUNC_DISCARD_DECL GLM_CONSTEXPR vec<2, T, Q> & operator*=(vec<1, U, Q> const& v); - template GLM_FUNC_DISCARD_DECL GLM_CONSTEXPR vec<2, T, Q> & operator*=(vec<2, U, Q> const& v); template - GLM_FUNC_DISCARD_DECL GLM_CONSTEXPR vec<2, T, Q> & operator/=(U scalar); - template - GLM_FUNC_DISCARD_DECL GLM_CONSTEXPR vec<2, T, Q> & operator/=(vec<1, U, Q> const& v); - template GLM_FUNC_DISCARD_DECL GLM_CONSTEXPR vec<2, T, Q> & operator/=(vec<2, U, Q> const& v); + template + GLM_FUNC_DISCARD_DECL GLM_CONSTEXPR vec<2, T, Q> & operator%=(vec<2, U, Q> const& v); + // -- Increment and decrement operators -- GLM_FUNC_DISCARD_DECL GLM_CONSTEXPR vec<2, T, Q> & operator++(); GLM_FUNC_DISCARD_DECL GLM_CONSTEXPR vec<2, T, Q> & operator--(); - GLM_FUNC_DECL GLM_CONSTEXPR vec<2, T, Q> operator++(int); - GLM_FUNC_DECL GLM_CONSTEXPR vec<2, T, Q> operator--(int); // -- Unary bit operators -- - template - GLM_FUNC_DISCARD_DECL GLM_CONSTEXPR vec<2, T, Q> & operator%=(U scalar); - template - GLM_FUNC_DISCARD_DECL GLM_CONSTEXPR vec<2, T, Q> & operator%=(vec<1, U, Q> const& v); - template - GLM_FUNC_DISCARD_DECL GLM_CONSTEXPR vec<2, T, Q> & operator%=(vec<2, U, Q> const& v); - template - GLM_FUNC_DISCARD_DECL GLM_CONSTEXPR vec<2, T, Q> & operator&=(U scalar); - template - GLM_FUNC_DISCARD_DECL GLM_CONSTEXPR vec<2, T, Q> & operator&=(vec<1, U, Q> const& v); - template - GLM_FUNC_DISCARD_DECL GLM_CONSTEXPR vec<2, T, Q> & operator&=(vec<2, U, Q> const& v); - template - GLM_FUNC_DISCARD_DECL GLM_CONSTEXPR vec<2, T, Q> & operator|=(U scalar); - template - GLM_FUNC_DISCARD_DECL GLM_CONSTEXPR vec<2, T, Q> & operator|=(vec<1, U, Q> const& v); + GLM_FUNC_DISCARD_DECL GLM_CONSTEXPR vec<2, T, Q>& operator&=(vec<2, U, Q> const& v); template GLM_FUNC_DISCARD_DECL GLM_CONSTEXPR vec<2, T, Q> & operator|=(vec<2, U, Q> const& v); template - GLM_FUNC_DISCARD_DECL GLM_CONSTEXPR vec<2, T, Q> & operator^=(U scalar); - template - GLM_FUNC_DISCARD_DECL GLM_CONSTEXPR vec<2, T, Q> & operator^=(vec<1, U, Q> const& v); - template GLM_FUNC_DISCARD_DECL GLM_CONSTEXPR vec<2, T, Q> & operator^=(vec<2, U, Q> const& v); template - GLM_FUNC_DISCARD_DECL GLM_CONSTEXPR vec<2, T, Q> & operator<<=(U scalar); - template - GLM_FUNC_DISCARD_DECL GLM_CONSTEXPR vec<2, T, Q> & operator<<=(vec<1, U, Q> const& v); - template GLM_FUNC_DISCARD_DECL GLM_CONSTEXPR vec<2, T, Q> & operator<<=(vec<2, U, Q> const& v); template - GLM_FUNC_DISCARD_DECL GLM_CONSTEXPR vec<2, T, Q> & operator>>=(U scalar); - template - GLM_FUNC_DISCARD_DECL GLM_CONSTEXPR vec<2, T, Q> & operator>>=(vec<1, U, Q> const& v); - template GLM_FUNC_DISCARD_DECL GLM_CONSTEXPR vec<2, T, Q> & operator>>=(vec<2, U, Q> const& v); }; // -- Unary operators -- - - template - GLM_FUNC_DECL GLM_CONSTEXPR vec<2, T, Q> operator+(vec<2, T, Q> const& v); - template GLM_FUNC_DECL GLM_CONSTEXPR vec<2, T, Q> operator-(vec<2, T, Q> const& v); // -- Binary operators -- - template - GLM_FUNC_DECL GLM_CONSTEXPR vec<2, T, Q> operator+(vec<2, T, Q> const& v, T scalar); - - template - GLM_FUNC_DECL GLM_CONSTEXPR vec<2, T, Q> operator+(vec<2, T, Q> const& v1, vec<1, T, Q> const& v2); - - template - GLM_FUNC_DECL GLM_CONSTEXPR vec<2, T, Q> operator+(T scalar, vec<2, T, Q> const& v); - - template - GLM_FUNC_DECL GLM_CONSTEXPR vec<2, T, Q> operator+(vec<1, T, Q> const& v1, vec<2, T, Q> const& v2); - - template - GLM_FUNC_DECL GLM_CONSTEXPR vec<2, T, Q> operator+(vec<2, T, Q> const& v1, vec<2, T, Q> const& v2); - - template - GLM_FUNC_DECL GLM_CONSTEXPR vec<2, T, Q> operator-(vec<2, T, Q> const& v, T scalar); - - template - GLM_FUNC_DECL GLM_CONSTEXPR vec<2, T, Q> operator-(vec<2, T, Q> const& v1, vec<1, T, Q> const& v2); - - template - GLM_FUNC_DECL GLM_CONSTEXPR vec<2, T, Q> operator-(T scalar, vec<2, T, Q> const& v); - - template - GLM_FUNC_DECL GLM_CONSTEXPR vec<2, T, Q> operator-(vec<1, T, Q> const& v1, vec<2, T, Q> const& v2); - - template - GLM_FUNC_DECL GLM_CONSTEXPR vec<2, T, Q> operator-(vec<2, T, Q> const& v1, vec<2, T, Q> const& v2); - - template - GLM_FUNC_DECL GLM_CONSTEXPR vec<2, T, Q> operator*(vec<2, T, Q> const& v, T scalar); - - template - GLM_FUNC_DECL GLM_CONSTEXPR vec<2, T, Q> operator*(vec<2, T, Q> const& v1, vec<1, T, Q> const& v2); - - template - GLM_FUNC_DECL GLM_CONSTEXPR vec<2, T, Q> operator*(T scalar, vec<2, T, Q> const& v); - - template - GLM_FUNC_DECL GLM_CONSTEXPR vec<2, T, Q> operator*(vec<1, T, Q> const& v1, vec<2, T, Q> const& v2); - - template - GLM_FUNC_DECL GLM_CONSTEXPR vec<2, T, Q> operator*(vec<2, T, Q> const& v1, vec<2, T, Q> const& v2); - - template - GLM_FUNC_DECL GLM_CONSTEXPR vec<2, T, Q> operator/(vec<2, T, Q> const& v, T scalar); - - template - GLM_FUNC_DECL GLM_CONSTEXPR vec<2, T, Q> operator/(vec<2, T, Q> const& v1, vec<1, T, Q> const& v2); - - template - GLM_FUNC_DECL GLM_CONSTEXPR vec<2, T, Q> operator/(T scalar, vec<2, T, Q> const& v); - - template - GLM_FUNC_DECL GLM_CONSTEXPR vec<2, T, Q> operator/(vec<1, T, Q> const& v1, vec<2, T, Q> const& v2); - - template - GLM_FUNC_DECL GLM_CONSTEXPR vec<2, T, Q> operator/(vec<2, T, Q> const& v1, vec<2, T, Q> const& v2); - - template - GLM_FUNC_DECL GLM_CONSTEXPR vec<2, T, Q> operator%(vec<2, T, Q> const& v, T scalar); - - template - GLM_FUNC_DECL GLM_CONSTEXPR vec<2, T, Q> operator%(vec<2, T, Q> const& v1, vec<1, T, Q> const& v2); - - template - GLM_FUNC_DECL GLM_CONSTEXPR vec<2, T, Q> operator%(T scalar, vec<2, T, Q> const& v); - - template - GLM_FUNC_DECL GLM_CONSTEXPR vec<2, T, Q> operator%(vec<1, T, Q> const& v1, vec<2, T, Q> const& v2); - - template - GLM_FUNC_DECL GLM_CONSTEXPR vec<2, T, Q> operator%(vec<2, T, Q> const& v1, vec<2, T, Q> const& v2); - - template - GLM_FUNC_DECL GLM_CONSTEXPR vec<2, T, Q> operator&(vec<2, T, Q> const& v, T scalar); - - template - GLM_FUNC_DECL GLM_CONSTEXPR vec<2, T, Q> operator&(vec<2, T, Q> const& v1, vec<1, T, Q> const& v2); - - template - GLM_FUNC_DECL GLM_CONSTEXPR vec<2, T, Q> operator&(T scalar, vec<2, T, Q> const& v); - - template - GLM_FUNC_DECL GLM_CONSTEXPR vec<2, T, Q> operator&(vec<1, T, Q> const& v1, vec<2, T, Q> const& v2); - - template - GLM_FUNC_DECL GLM_CONSTEXPR vec<2, T, Q> operator&(vec<2, T, Q> const& v1, vec<2, T, Q> const& v2); - - template - GLM_FUNC_DECL GLM_CONSTEXPR vec<2, T, Q> operator|(vec<2, T, Q> const& v, T scalar); - - template - GLM_FUNC_DECL GLM_CONSTEXPR vec<2, T, Q> operator|(vec<2, T, Q> const& v1, vec<1, T, Q> const& v2); - - template - GLM_FUNC_DECL GLM_CONSTEXPR vec<2, T, Q> operator|(T scalar, vec<2, T, Q> const& v); - - template - GLM_FUNC_DECL GLM_CONSTEXPR vec<2, T, Q> operator|(vec<1, T, Q> const& v1, vec<2, T, Q> const& v2); - - template - GLM_FUNC_DECL GLM_CONSTEXPR vec<2, T, Q> operator|(vec<2, T, Q> const& v1, vec<2, T, Q> const& v2); - - template - GLM_FUNC_DECL GLM_CONSTEXPR vec<2, T, Q> operator^(vec<2, T, Q> const& v, T scalar); - - template - GLM_FUNC_DECL GLM_CONSTEXPR vec<2, T, Q> operator^(vec<2, T, Q> const& v1, vec<1, T, Q> const& v2); - - template - GLM_FUNC_DECL GLM_CONSTEXPR vec<2, T, Q> operator^(T scalar, vec<2, T, Q> const& v); - - template - GLM_FUNC_DECL GLM_CONSTEXPR vec<2, T, Q> operator^(vec<1, T, Q> const& v1, vec<2, T, Q> const& v2); - - template - GLM_FUNC_DECL GLM_CONSTEXPR vec<2, T, Q> operator^(vec<2, T, Q> const& v1, vec<2, T, Q> const& v2); - - template - GLM_FUNC_DECL GLM_CONSTEXPR vec<2, T, Q> operator<<(vec<2, T, Q> const& v, T scalar); - - template - GLM_FUNC_DECL GLM_CONSTEXPR vec<2, T, Q> operator<<(vec<2, T, Q> const& v1, vec<1, T, Q> const& v2); - - template - GLM_FUNC_DECL GLM_CONSTEXPR vec<2, T, Q> operator<<(T scalar, vec<2, T, Q> const& v); - - template - GLM_FUNC_DECL GLM_CONSTEXPR vec<2, T, Q> operator<<(vec<1, T, Q> const& v1, vec<2, T, Q> const& v2); - - template - GLM_FUNC_DECL GLM_CONSTEXPR vec<2, T, Q> operator<<(vec<2, T, Q> const& v1, vec<2, T, Q> const& v2); - - template - GLM_FUNC_DECL GLM_CONSTEXPR vec<2, T, Q> operator>>(vec<2, T, Q> const& v, T scalar); - - template - GLM_FUNC_DECL GLM_CONSTEXPR vec<2, T, Q> operator>>(vec<2, T, Q> const& v1, vec<1, T, Q> const& v2); - - template - GLM_FUNC_DECL GLM_CONSTEXPR vec<2, T, Q> operator>>(T scalar, vec<2, T, Q> const& v); - - template - GLM_FUNC_DECL GLM_CONSTEXPR vec<2, T, Q> operator>>(vec<1, T, Q> const& v1, vec<2, T, Q> const& v2); - - template - GLM_FUNC_DECL GLM_CONSTEXPR vec<2, T, Q> operator>>(vec<2, T, Q> const& v1, vec<2, T, Q> const& v2); - template GLM_FUNC_DECL GLM_CONSTEXPR vec<2, T, Q> operator~(vec<2, T, Q> const& v); @@ -391,9 +197,6 @@ namespace glm template GLM_FUNC_DECL GLM_CONSTEXPR bool operator==(vec<2, T, Q> const& v1, vec<2, T, Q> const& v2); - template - GLM_FUNC_DECL GLM_CONSTEXPR bool operator!=(vec<2, T, Q> const& v1, vec<2, T, Q> const& v2); - template GLM_FUNC_DECL GLM_CONSTEXPR vec<2, bool, Q> operator&&(vec<2, bool, Q> const& v1, vec<2, bool, Q> const& v2); diff --git a/glm/detail/type_vec2.inl b/glm/detail/type_vec2.inl index e8408997..d4f65fb0 100644 --- a/glm/detail/type_vec2.inl +++ b/glm/detail/type_vec2.inl @@ -151,24 +151,6 @@ namespace glm return *this; } - template - template - GLM_FUNC_QUALIFIER GLM_CONSTEXPR vec<2, T, Q> & vec<2, T, Q>::operator+=(U scalar) - { - this->x += static_cast(scalar); - this->y += static_cast(scalar); - return *this; - } - - template - template - GLM_FUNC_QUALIFIER GLM_CONSTEXPR vec<2, T, Q> & vec<2, T, Q>::operator+=(vec<1, U, Q> const& v) - { - this->x += static_cast(v.x); - this->y += static_cast(v.x); - return *this; - } - template template GLM_FUNC_QUALIFIER GLM_CONSTEXPR vec<2, T, Q> & vec<2, T, Q>::operator+=(vec<2, U, Q> const& v) @@ -178,24 +160,6 @@ namespace glm return *this; } - template - template - GLM_FUNC_QUALIFIER GLM_CONSTEXPR vec<2, T, Q> & vec<2, T, Q>::operator-=(U scalar) - { - this->x -= static_cast(scalar); - this->y -= static_cast(scalar); - return *this; - } - - template - template - GLM_FUNC_QUALIFIER GLM_CONSTEXPR vec<2, T, Q> & vec<2, T, Q>::operator-=(vec<1, U, Q> const& v) - { - this->x -= static_cast(v.x); - this->y -= static_cast(v.x); - return *this; - } - template template GLM_FUNC_QUALIFIER GLM_CONSTEXPR vec<2, T, Q> & vec<2, T, Q>::operator-=(vec<2, U, Q> const& v) @@ -205,24 +169,6 @@ namespace glm return *this; } - template - template - GLM_FUNC_QUALIFIER GLM_CONSTEXPR vec<2, T, Q> & vec<2, T, Q>::operator*=(U scalar) - { - this->x *= static_cast(scalar); - this->y *= static_cast(scalar); - return *this; - } - - template - template - GLM_FUNC_QUALIFIER GLM_CONSTEXPR vec<2, T, Q> & vec<2, T, Q>::operator*=(vec<1, U, Q> const& v) - { - this->x *= static_cast(v.x); - this->y *= static_cast(v.x); - return *this; - } - template template GLM_FUNC_QUALIFIER GLM_CONSTEXPR vec<2, T, Q> & vec<2, T, Q>::operator*=(vec<2, U, Q> const& v) @@ -232,24 +178,6 @@ namespace glm return *this; } - template - template - GLM_FUNC_QUALIFIER GLM_CONSTEXPR vec<2, T, Q> & vec<2, T, Q>::operator/=(U scalar) - { - this->x /= static_cast(scalar); - this->y /= static_cast(scalar); - return *this; - } - - template - template - GLM_FUNC_QUALIFIER GLM_CONSTEXPR vec<2, T, Q> & vec<2, T, Q>::operator/=(vec<1, U, Q> const& v) - { - this->x /= static_cast(v.x); - this->y /= static_cast(v.x); - return *this; - } - template template GLM_FUNC_QUALIFIER GLM_CONSTEXPR vec<2, T, Q> & vec<2, T, Q>::operator/=(vec<2, U, Q> const& v) @@ -277,42 +205,8 @@ namespace glm return *this; } - template - GLM_FUNC_QUALIFIER GLM_CONSTEXPR vec<2, T, Q> vec<2, T, Q>::operator++(int) - { - vec<2, T, Q> Result(*this); - ++*this; - return Result; - } - - template - GLM_FUNC_QUALIFIER GLM_CONSTEXPR vec<2, T, Q> vec<2, T, Q>::operator--(int) - { - vec<2, T, Q> Result(*this); - --*this; - return Result; - } - // -- Unary bit operators -- - template - template - GLM_FUNC_QUALIFIER GLM_CONSTEXPR vec<2, T, Q> & vec<2, T, Q>::operator%=(U scalar) - { - this->x %= static_cast(scalar); - this->y %= static_cast(scalar); - return *this; - } - - template - template - GLM_FUNC_QUALIFIER GLM_CONSTEXPR vec<2, T, Q> & vec<2, T, Q>::operator%=(vec<1, U, Q> const& v) - { - this->x %= static_cast(v.x); - this->y %= static_cast(v.x); - return *this; - } - template template GLM_FUNC_QUALIFIER GLM_CONSTEXPR vec<2, T, Q> & vec<2, T, Q>::operator%=(vec<2, U, Q> const& v) @@ -322,24 +216,6 @@ namespace glm return *this; } - template - template - GLM_FUNC_QUALIFIER GLM_CONSTEXPR vec<2, T, Q> & vec<2, T, Q>::operator&=(U scalar) - { - this->x &= static_cast(scalar); - this->y &= static_cast(scalar); - return *this; - } - - template - template - GLM_FUNC_QUALIFIER GLM_CONSTEXPR vec<2, T, Q> & vec<2, T, Q>::operator&=(vec<1, U, Q> const& v) - { - this->x &= static_cast(v.x); - this->y &= static_cast(v.x); - return *this; - } - template template GLM_FUNC_QUALIFIER GLM_CONSTEXPR vec<2, T, Q> & vec<2, T, Q>::operator&=(vec<2, U, Q> const& v) @@ -349,24 +225,6 @@ namespace glm return *this; } - template - template - GLM_FUNC_QUALIFIER GLM_CONSTEXPR vec<2, T, Q> & vec<2, T, Q>::operator|=(U scalar) - { - this->x |= static_cast(scalar); - this->y |= static_cast(scalar); - return *this; - } - - template - template - GLM_FUNC_QUALIFIER GLM_CONSTEXPR vec<2, T, Q> & vec<2, T, Q>::operator|=(vec<1, U, Q> const& v) - { - this->x |= static_cast(v.x); - this->y |= static_cast(v.x); - return *this; - } - template template GLM_FUNC_QUALIFIER GLM_CONSTEXPR vec<2, T, Q> & vec<2, T, Q>::operator|=(vec<2, U, Q> const& v) @@ -376,24 +234,6 @@ namespace glm return *this; } - template - template - GLM_FUNC_QUALIFIER GLM_CONSTEXPR vec<2, T, Q> & vec<2, T, Q>::operator^=(U scalar) - { - this->x ^= static_cast(scalar); - this->y ^= static_cast(scalar); - return *this; - } - - template - template - GLM_FUNC_QUALIFIER GLM_CONSTEXPR vec<2, T, Q> & vec<2, T, Q>::operator^=(vec<1, U, Q> const& v) - { - this->x ^= static_cast(v.x); - this->y ^= static_cast(v.x); - return *this; - } - template template GLM_FUNC_QUALIFIER GLM_CONSTEXPR vec<2, T, Q> & vec<2, T, Q>::operator^=(vec<2, U, Q> const& v) @@ -403,24 +243,6 @@ namespace glm return *this; } - template - template - GLM_FUNC_QUALIFIER GLM_CONSTEXPR vec<2, T, Q> & vec<2, T, Q>::operator<<=(U scalar) - { - this->x <<= static_cast(scalar); - this->y <<= static_cast(scalar); - return *this; - } - - template - template - GLM_FUNC_QUALIFIER GLM_CONSTEXPR vec<2, T, Q> & vec<2, T, Q>::operator<<=(vec<1, U, Q> const& v) - { - this->x <<= static_cast(v.x); - this->y <<= static_cast(v.x); - return *this; - } - template template GLM_FUNC_QUALIFIER GLM_CONSTEXPR vec<2, T, Q> & vec<2, T, Q>::operator<<=(vec<2, U, Q> const& v) @@ -430,24 +252,6 @@ namespace glm return *this; } - template - template - GLM_FUNC_QUALIFIER GLM_CONSTEXPR vec<2, T, Q> & vec<2, T, Q>::operator>>=(U scalar) - { - this->x >>= static_cast(scalar); - this->y >>= static_cast(scalar); - return *this; - } - - template - template - GLM_FUNC_QUALIFIER GLM_CONSTEXPR vec<2, T, Q> & vec<2, T, Q>::operator>>=(vec<1, U, Q> const& v) - { - this->x >>= static_cast(v.x); - this->y >>= static_cast(v.x); - return *this; - } - template template GLM_FUNC_QUALIFIER GLM_CONSTEXPR vec<2, T, Q> & vec<2, T, Q>::operator>>=(vec<2, U, Q> const& v) @@ -459,12 +263,6 @@ namespace glm // -- Unary arithmetic operators -- - template - GLM_FUNC_QUALIFIER GLM_CONSTEXPR vec<2, T, Q> operator+(vec<2, T, Q> const& v) - { - return v; - } - template GLM_FUNC_QUALIFIER GLM_CONSTEXPR vec<2, T, Q> operator-(vec<2, T, Q> const& v) { @@ -475,407 +273,6 @@ namespace glm // -- Binary arithmetic operators -- - template - GLM_FUNC_QUALIFIER GLM_CONSTEXPR vec<2, T, Q> operator+(vec<2, T, Q> const& v, T scalar) - { - return vec<2, T, Q>( - v.x + scalar, - v.y + scalar); - } - - template - GLM_FUNC_QUALIFIER GLM_CONSTEXPR vec<2, T, Q> operator+(vec<2, T, Q> const& v1, vec<1, T, Q> const& v2) - { - return vec<2, T, Q>( - v1.x + v2.x, - v1.y + v2.x); - } - - template - GLM_FUNC_QUALIFIER GLM_CONSTEXPR vec<2, T, Q> operator+(T scalar, vec<2, T, Q> const& v) - { - return vec<2, T, Q>( - scalar + v.x, - scalar + v.y); - } - - template - GLM_FUNC_QUALIFIER GLM_CONSTEXPR vec<2, T, Q> operator+(vec<1, T, Q> const& v1, vec<2, T, Q> const& v2) - { - return vec<2, T, Q>( - v1.x + v2.x, - v1.x + v2.y); - } - - template - GLM_FUNC_QUALIFIER GLM_CONSTEXPR vec<2, T, Q> operator+(vec<2, T, Q> const& v1, vec<2, T, Q> const& v2) - { - return vec<2, T, Q>( - v1.x + v2.x, - v1.y + v2.y); - } - - template - GLM_FUNC_QUALIFIER GLM_CONSTEXPR vec<2, T, Q> operator-(vec<2, T, Q> const& v, T scalar) - { - return vec<2, T, Q>( - v.x - scalar, - v.y - scalar); - } - - template - GLM_FUNC_QUALIFIER GLM_CONSTEXPR vec<2, T, Q> operator-(vec<2, T, Q> const& v1, vec<1, T, Q> const& v2) - { - return vec<2, T, Q>( - v1.x - v2.x, - v1.y - v2.x); - } - - template - GLM_FUNC_QUALIFIER GLM_CONSTEXPR vec<2, T, Q> operator-(T scalar, vec<2, T, Q> const& v) - { - return vec<2, T, Q>( - scalar - v.x, - scalar - v.y); - } - - template - GLM_FUNC_QUALIFIER GLM_CONSTEXPR vec<2, T, Q> operator-(vec<1, T, Q> const& v1, vec<2, T, Q> const& v2) - { - return vec<2, T, Q>( - v1.x - v2.x, - v1.x - v2.y); - } - - template - GLM_FUNC_QUALIFIER GLM_CONSTEXPR vec<2, T, Q> operator-(vec<2, T, Q> const& v1, vec<2, T, Q> const& v2) - { - return vec<2, T, Q>( - v1.x - v2.x, - v1.y - v2.y); - } - - template - GLM_FUNC_QUALIFIER GLM_CONSTEXPR vec<2, T, Q> operator*(vec<2, T, Q> const& v, T scalar) - { - return vec<2, T, Q>( - v.x * scalar, - v.y * scalar); - } - - template - GLM_FUNC_QUALIFIER GLM_CONSTEXPR vec<2, T, Q> operator*(vec<2, T, Q> const& v1, vec<1, T, Q> const& v2) - { - return vec<2, T, Q>( - v1.x * v2.x, - v1.y * v2.x); - } - - template - GLM_FUNC_QUALIFIER GLM_CONSTEXPR vec<2, T, Q> operator*(T scalar, vec<2, T, Q> const& v) - { - return vec<2, T, Q>( - scalar * v.x, - scalar * v.y); - } - - template - GLM_FUNC_QUALIFIER GLM_CONSTEXPR vec<2, T, Q> operator*(vec<1, T, Q> const& v1, vec<2, T, Q> const& v2) - { - return vec<2, T, Q>( - v1.x * v2.x, - v1.x * v2.y); - } - - template - GLM_FUNC_QUALIFIER GLM_CONSTEXPR vec<2, T, Q> operator*(vec<2, T, Q> const& v1, vec<2, T, Q> const& v2) - { - return vec<2, T, Q>( - v1.x * v2.x, - v1.y * v2.y); - } - - template - GLM_FUNC_QUALIFIER GLM_CONSTEXPR vec<2, T, Q> operator/(vec<2, T, Q> const& v, T scalar) - { - return vec<2, T, Q>( - v.x / scalar, - v.y / scalar); - } - - template - GLM_FUNC_QUALIFIER GLM_CONSTEXPR vec<2, T, Q> operator/(vec<2, T, Q> const& v1, vec<1, T, Q> const& v2) - { - return vec<2, T, Q>( - v1.x / v2.x, - v1.y / v2.x); - } - - template - GLM_FUNC_QUALIFIER GLM_CONSTEXPR vec<2, T, Q> operator/(T scalar, vec<2, T, Q> const& v) - { - return vec<2, T, Q>( - scalar / v.x, - scalar / v.y); - } - - template - GLM_FUNC_QUALIFIER GLM_CONSTEXPR vec<2, T, Q> operator/(vec<1, T, Q> const& v1, vec<2, T, Q> const& v2) - { - return vec<2, T, Q>( - v1.x / v2.x, - v1.x / v2.y); - } - - template - GLM_FUNC_QUALIFIER GLM_CONSTEXPR vec<2, T, Q> operator/(vec<2, T, Q> const& v1, vec<2, T, Q> const& v2) - { - return vec<2, T, Q>( - v1.x / v2.x, - v1.y / v2.y); - } - - // -- Binary bit operators -- - - template - GLM_FUNC_QUALIFIER GLM_CONSTEXPR vec<2, T, Q> operator%(vec<2, T, Q> const& v, T scalar) - { - return vec<2, T, Q>( - v.x % scalar, - v.y % scalar); - } - - template - GLM_FUNC_QUALIFIER GLM_CONSTEXPR vec<2, T, Q> operator%(vec<2, T, Q> const& v1, vec<1, T, Q> const& v2) - { - return vec<2, T, Q>( - v1.x % v2.x, - v1.y % v2.x); - } - - template - GLM_FUNC_QUALIFIER GLM_CONSTEXPR vec<2, T, Q> operator%(T scalar, vec<2, T, Q> const& v) - { - return vec<2, T, Q>( - scalar % v.x, - scalar % v.y); - } - - template - GLM_FUNC_QUALIFIER GLM_CONSTEXPR vec<2, T, Q> operator%(vec<1, T, Q> const& v1, vec<2, T, Q> const& v2) - { - return vec<2, T, Q>( - v1.x % v2.x, - v1.x % v2.y); - } - - template - GLM_FUNC_QUALIFIER GLM_CONSTEXPR vec<2, T, Q> operator%(vec<2, T, Q> const& v1, vec<2, T, Q> const& v2) - { - return vec<2, T, Q>( - v1.x % v2.x, - v1.y % v2.y); - } - - template - GLM_FUNC_QUALIFIER GLM_CONSTEXPR vec<2, T, Q> operator&(vec<2, T, Q> const& v, T scalar) - { - return vec<2, T, Q>( - v.x & scalar, - v.y & scalar); - } - - template - GLM_FUNC_QUALIFIER GLM_CONSTEXPR vec<2, T, Q> operator&(vec<2, T, Q> const& v1, vec<1, T, Q> const& v2) - { - return vec<2, T, Q>( - v1.x & v2.x, - v1.y & v2.x); - } - - template - GLM_FUNC_QUALIFIER GLM_CONSTEXPR vec<2, T, Q> operator&(T scalar, vec<2, T, Q> const& v) - { - return vec<2, T, Q>( - scalar & v.x, - scalar & v.y); - } - - template - GLM_FUNC_QUALIFIER GLM_CONSTEXPR vec<2, T, Q> operator&(vec<1, T, Q> const& v1, vec<2, T, Q> const& v2) - { - return vec<2, T, Q>( - v1.x & v2.x, - v1.x & v2.y); - } - - template - GLM_FUNC_QUALIFIER GLM_CONSTEXPR vec<2, T, Q> operator&(vec<2, T, Q> const& v1, vec<2, T, Q> const& v2) - { - return vec<2, T, Q>( - v1.x & v2.x, - v1.y & v2.y); - } - - template - GLM_FUNC_QUALIFIER GLM_CONSTEXPR vec<2, T, Q> operator|(vec<2, T, Q> const& v, T scalar) - { - return vec<2, T, Q>( - v.x | scalar, - v.y | scalar); - } - - template - GLM_FUNC_QUALIFIER GLM_CONSTEXPR vec<2, T, Q> operator|(vec<2, T, Q> const& v1, vec<1, T, Q> const& v2) - { - return vec<2, T, Q>( - v1.x | v2.x, - v1.y | v2.x); - } - - template - GLM_FUNC_QUALIFIER GLM_CONSTEXPR vec<2, T, Q> operator|(T scalar, vec<2, T, Q> const& v) - { - return vec<2, T, Q>( - scalar | v.x, - scalar | v.y); - } - - template - GLM_FUNC_QUALIFIER GLM_CONSTEXPR vec<2, T, Q> operator|(vec<1, T, Q> const& v1, vec<2, T, Q> const& v2) - { - return vec<2, T, Q>( - v1.x | v2.x, - v1.x | v2.y); - } - - template - GLM_FUNC_QUALIFIER GLM_CONSTEXPR vec<2, T, Q> operator|(vec<2, T, Q> const& v1, vec<2, T, Q> const& v2) - { - return vec<2, T, Q>( - v1.x | v2.x, - v1.y | v2.y); - } - - template - GLM_FUNC_QUALIFIER GLM_CONSTEXPR vec<2, T, Q> operator^(vec<2, T, Q> const& v, T scalar) - { - return vec<2, T, Q>( - v.x ^ scalar, - v.y ^ scalar); - } - - template - GLM_FUNC_QUALIFIER GLM_CONSTEXPR vec<2, T, Q> operator^(vec<2, T, Q> const& v1, vec<1, T, Q> const& v2) - { - return vec<2, T, Q>( - v1.x ^ v2.x, - v1.y ^ v2.x); - } - - template - GLM_FUNC_QUALIFIER GLM_CONSTEXPR vec<2, T, Q> operator^(T scalar, vec<2, T, Q> const& v) - { - return vec<2, T, Q>( - scalar ^ v.x, - scalar ^ v.y); - } - - template - GLM_FUNC_QUALIFIER GLM_CONSTEXPR vec<2, T, Q> operator^(vec<1, T, Q> const& v1, vec<2, T, Q> const& v2) - { - return vec<2, T, Q>( - v1.x ^ v2.x, - v1.x ^ v2.y); - } - - template - GLM_FUNC_QUALIFIER GLM_CONSTEXPR vec<2, T, Q> operator^(vec<2, T, Q> const& v1, vec<2, T, Q> const& v2) - { - return vec<2, T, Q>( - v1.x ^ v2.x, - v1.y ^ v2.y); - } - - template - GLM_FUNC_QUALIFIER GLM_CONSTEXPR vec<2, T, Q> operator<<(vec<2, T, Q> const& v, T scalar) - { - return vec<2, T, Q>( - v.x << scalar, - v.y << scalar); - } - - template - GLM_FUNC_QUALIFIER GLM_CONSTEXPR vec<2, T, Q> operator<<(vec<2, T, Q> const& v1, vec<1, T, Q> const& v2) - { - return vec<2, T, Q>( - v1.x << v2.x, - v1.y << v2.x); - } - - template - GLM_FUNC_QUALIFIER GLM_CONSTEXPR vec<2, T, Q> operator<<(T scalar, vec<2, T, Q> const& v) - { - return vec<2, T, Q>( - scalar << v.x, - scalar << v.y); - } - - template - GLM_FUNC_QUALIFIER GLM_CONSTEXPR vec<2, T, Q> operator<<(vec<1, T, Q> const& v1, vec<2, T, Q> const& v2) - { - return vec<2, T, Q>( - v1.x << v2.x, - v1.x << v2.y); - } - - template - GLM_FUNC_QUALIFIER GLM_CONSTEXPR vec<2, T, Q> operator<<(vec<2, T, Q> const& v1, vec<2, T, Q> const& v2) - { - return vec<2, T, Q>( - v1.x << v2.x, - v1.y << v2.y); - } - - template - GLM_FUNC_QUALIFIER GLM_CONSTEXPR vec<2, T, Q> operator>>(vec<2, T, Q> const& v, T scalar) - { - return vec<2, T, Q>( - v.x >> scalar, - v.y >> scalar); - } - - template - GLM_FUNC_QUALIFIER GLM_CONSTEXPR vec<2, T, Q> operator>>(vec<2, T, Q> const& v1, vec<1, T, Q> const& v2) - { - return vec<2, T, Q>( - v1.x >> v2.x, - v1.y >> v2.x); - } - - template - GLM_FUNC_QUALIFIER GLM_CONSTEXPR vec<2, T, Q> operator>>(T scalar, vec<2, T, Q> const& v) - { - return vec<2, T, Q>( - scalar >> v.x, - scalar >> v.y); - } - - template - GLM_FUNC_QUALIFIER GLM_CONSTEXPR vec<2, T, Q> operator>>(vec<1, T, Q> const& v1, vec<2, T, Q> const& v2) - { - return vec<2, T, Q>( - v1.x >> v2.x, - v1.x >> v2.y); - } - - template - GLM_FUNC_QUALIFIER GLM_CONSTEXPR vec<2, T, Q> operator>>(vec<2, T, Q> const& v1, vec<2, T, Q> const& v2) - { - return vec<2, T, Q>( - v1.x >> v2.x, - v1.y >> v2.y); - } template GLM_FUNC_QUALIFIER GLM_CONSTEXPR vec<2, T, Q> operator~(vec<2, T, Q> const& v) @@ -895,12 +292,6 @@ namespace glm detail::compute_equal::is_iec559>::call(v1.y, v2.y); } - template - GLM_FUNC_QUALIFIER GLM_CONSTEXPR bool operator!=(vec<2, T, Q> const& v1, vec<2, T, Q> const& v2) - { - return !(v1 == v2); - } - template GLM_FUNC_QUALIFIER GLM_CONSTEXPR vec<2, bool, Q> operator&&(vec<2, bool, Q> const& v1, vec<2, bool, Q> const& v2) { diff --git a/glm/detail/type_vec3.hpp b/glm/detail/type_vec3.hpp index 90de2f8a..72e3226d 100644 --- a/glm/detail/type_vec3.hpp +++ b/glm/detail/type_vec3.hpp @@ -4,6 +4,7 @@ #pragma once #include "qualifier.hpp" +#include "vec_common_ops.hpp" #if GLM_CONFIG_SWIZZLE == GLM_SWIZZLE_OPERATOR # include "_swizzle.hpp" #elif GLM_CONFIG_SWIZZLE == GLM_SWIZZLE_FUNCTION @@ -189,72 +190,49 @@ namespace glm template GLM_FUNC_DISCARD_DECL GLM_CONSTEXPR vec<3, T, Q> & operator+=(U scalar); template - GLM_FUNC_DISCARD_DECL GLM_CONSTEXPR vec<3, T, Q> & operator+=(vec<1, U, Q> const& v); - template GLM_FUNC_DISCARD_DECL GLM_CONSTEXPR vec<3, T, Q> & operator+=(vec<3, U, Q> const& v); template GLM_FUNC_DISCARD_DECL GLM_CONSTEXPR vec<3, T, Q> & operator-=(U scalar); template - GLM_FUNC_DISCARD_DECL GLM_CONSTEXPR vec<3, T, Q> & operator-=(vec<1, U, Q> const& v); - template GLM_FUNC_DISCARD_DECL GLM_CONSTEXPR vec<3, T, Q> & operator-=(vec<3, U, Q> const& v); template GLM_FUNC_DISCARD_DECL GLM_CONSTEXPR vec<3, T, Q> & operator*=(U scalar); template - GLM_FUNC_DISCARD_DECL GLM_CONSTEXPR vec<3, T, Q> & operator*=(vec<1, U, Q> const& v); - template GLM_FUNC_DISCARD_DECL GLM_CONSTEXPR vec<3, T, Q> & operator*=(vec<3, U, Q> const& v); template GLM_FUNC_DISCARD_DECL GLM_CONSTEXPR vec<3, T, Q> & operator/=(U scalar); template - GLM_FUNC_DISCARD_DECL GLM_CONSTEXPR vec<3, T, Q> & operator/=(vec<1, U, Q> const& v); - template GLM_FUNC_DISCARD_DECL GLM_CONSTEXPR vec<3, T, Q> & operator/=(vec<3, U, Q> const& v); // -- Increment and decrement operators -- GLM_FUNC_DISCARD_DECL GLM_CONSTEXPR vec<3, T, Q> & operator++(); GLM_FUNC_DISCARD_DECL GLM_CONSTEXPR vec<3, T, Q> & operator--(); - GLM_FUNC_DECL GLM_CONSTEXPR vec<3, T, Q> operator++(int); - GLM_FUNC_DECL GLM_CONSTEXPR vec<3, T, Q> operator--(int); - // -- Unary bit operators -- template GLM_FUNC_DISCARD_DECL GLM_CONSTEXPR vec<3, T, Q> & operator%=(U scalar); template - GLM_FUNC_DISCARD_DECL GLM_CONSTEXPR vec<3, T, Q> & operator%=(vec<1, U, Q> const& v); - template GLM_FUNC_DISCARD_DECL GLM_CONSTEXPR vec<3, T, Q> & operator%=(vec<3, U, Q> const& v); template GLM_FUNC_DISCARD_DECL GLM_CONSTEXPR vec<3, T, Q> & operator&=(U scalar); template - GLM_FUNC_DISCARD_DECL GLM_CONSTEXPR vec<3, T, Q> & operator&=(vec<1, U, Q> const& v); - template GLM_FUNC_DISCARD_DECL GLM_CONSTEXPR vec<3, T, Q> & operator&=(vec<3, U, Q> const& v); template GLM_FUNC_DISCARD_DECL GLM_CONSTEXPR vec<3, T, Q> & operator|=(U scalar); template - GLM_FUNC_DISCARD_DECL GLM_CONSTEXPR vec<3, T, Q> & operator|=(vec<1, U, Q> const& v); - template GLM_FUNC_DISCARD_DECL GLM_CONSTEXPR vec<3, T, Q> & operator|=(vec<3, U, Q> const& v); template GLM_FUNC_DISCARD_DECL GLM_CONSTEXPR vec<3, T, Q> & operator^=(U scalar); template - GLM_FUNC_DISCARD_DECL GLM_CONSTEXPR vec<3, T, Q> & operator^=(vec<1, U, Q> const& v); - template GLM_FUNC_DISCARD_DECL GLM_CONSTEXPR vec<3, T, Q> & operator^=(vec<3, U, Q> const& v); template GLM_FUNC_DISCARD_DECL GLM_CONSTEXPR vec<3, T, Q> & operator<<=(U scalar); template - GLM_FUNC_DISCARD_DECL GLM_CONSTEXPR vec<3, T, Q> & operator<<=(vec<1, U, Q> const& v); - template GLM_FUNC_DISCARD_DECL GLM_CONSTEXPR vec<3, T, Q> & operator<<=(vec<3, U, Q> const& v); template GLM_FUNC_DISCARD_DECL GLM_CONSTEXPR vec<3, T, Q> & operator>>=(U scalar); template - GLM_FUNC_DISCARD_DECL GLM_CONSTEXPR vec<3, T, Q> & operator>>=(vec<1, U, Q> const& v); - template GLM_FUNC_DISCARD_DECL GLM_CONSTEXPR vec<3, T, Q> & operator>>=(vec<3, U, Q> const& v); }; @@ -262,164 +240,11 @@ namespace glm // -- Unary operators -- - template - GLM_FUNC_DECL GLM_CONSTEXPR vec<3, T, Q> operator+(vec<3, T, Q> const& v); - template GLM_FUNC_DECL GLM_CONSTEXPR vec<3, T, Q> operator-(vec<3, T, Q> const& v); // -- Binary operators -- - template - GLM_FUNC_DECL GLM_CONSTEXPR vec<3, T, Q> operator+(vec<3, T, Q> const& v, T scalar); - - template - GLM_FUNC_DECL GLM_CONSTEXPR vec<3, T, Q> operator+(vec<3, T, Q> const& v, vec<1, T, Q> const& scalar); - - template - GLM_FUNC_DECL GLM_CONSTEXPR vec<3, T, Q> operator+(T scalar, vec<3, T, Q> const& v); - - template - GLM_FUNC_DECL GLM_CONSTEXPR vec<3, T, Q> operator+(vec<1, T, Q> const& v1, vec<3, T, Q> const& v2); - - template - GLM_FUNC_DECL GLM_CONSTEXPR vec<3, T, Q> operator+(vec<3, T, Q> const& v1, vec<3, T, Q> const& v2); - - template - GLM_FUNC_DECL GLM_CONSTEXPR vec<3, T, Q> operator-(vec<3, T, Q> const& v, T scalar); - - template - GLM_FUNC_DECL GLM_CONSTEXPR vec<3, T, Q> operator-(vec<3, T, Q> const& v1, vec<1, T, Q> const& v2); - - template - GLM_FUNC_DECL GLM_CONSTEXPR vec<3, T, Q> operator-(T scalar, vec<3, T, Q> const& v); - - template - GLM_FUNC_DECL GLM_CONSTEXPR vec<3, T, Q> operator-(vec<1, T, Q> const& v1, vec<3, T, Q> const& v2); - - template - GLM_FUNC_DECL GLM_CONSTEXPR vec<3, T, Q> operator-(vec<3, T, Q> const& v1, vec<3, T, Q> const& v2); - - template - GLM_FUNC_DECL GLM_CONSTEXPR vec<3, T, Q> operator*(vec<3, T, Q> const& v, T scalar); - - template - GLM_FUNC_DECL GLM_CONSTEXPR vec<3, T, Q> operator*(vec<3, T, Q> const& v1, vec<1, T, Q> const& v2); - - template - GLM_FUNC_DECL GLM_CONSTEXPR vec<3, T, Q> operator*(T scalar, vec<3, T, Q> const& v); - - template - GLM_FUNC_DECL GLM_CONSTEXPR vec<3, T, Q> operator*(vec<1, T, Q> const& v1, vec<3, T, Q> const& v2); - - template - GLM_FUNC_DECL GLM_CONSTEXPR vec<3, T, Q> operator*(vec<3, T, Q> const& v1, vec<3, T, Q> const& v2); - - template - GLM_FUNC_DECL GLM_CONSTEXPR vec<3, T, Q> operator/(vec<3, T, Q> const& v, T scalar); - - template - GLM_FUNC_DECL GLM_CONSTEXPR vec<3, T, Q> operator/(vec<3, T, Q> const& v1, vec<1, T, Q> const& v2); - - template - GLM_FUNC_DECL GLM_CONSTEXPR vec<3, T, Q> operator/(T scalar, vec<3, T, Q> const& v); - - template - GLM_FUNC_DECL GLM_CONSTEXPR vec<3, T, Q> operator/(vec<1, T, Q> const& v1, vec<3, T, Q> const& v2); - - template - GLM_FUNC_DECL GLM_CONSTEXPR vec<3, T, Q> operator/(vec<3, T, Q> const& v1, vec<3, T, Q> const& v2); - - template - GLM_FUNC_DECL GLM_CONSTEXPR vec<3, T, Q> operator%(vec<3, T, Q> const& v, T scalar); - - template - GLM_FUNC_DECL GLM_CONSTEXPR vec<3, T, Q> operator%(vec<3, T, Q> const& v1, vec<1, T, Q> const& v2); - - template - GLM_FUNC_DECL GLM_CONSTEXPR vec<3, T, Q> operator%(T scalar, vec<3, T, Q> const& v); - - template - GLM_FUNC_DECL GLM_CONSTEXPR vec<3, T, Q> operator%(vec<1, T, Q> const& v1, vec<3, T, Q> const& v2); - - template - GLM_FUNC_DECL GLM_CONSTEXPR vec<3, T, Q> operator%(vec<3, T, Q> const& v1, vec<3, T, Q> const& v2); - - template - GLM_FUNC_DECL GLM_CONSTEXPR vec<3, T, Q> operator&(vec<3, T, Q> const& v1, T scalar); - - template - GLM_FUNC_DECL GLM_CONSTEXPR vec<3, T, Q> operator&(vec<3, T, Q> const& v1, vec<1, T, Q> const& v2); - - template - GLM_FUNC_DECL GLM_CONSTEXPR vec<3, T, Q> operator&(T scalar, vec<3, T, Q> const& v); - - template - GLM_FUNC_DECL GLM_CONSTEXPR vec<3, T, Q> operator&(vec<1, T, Q> const& v1, vec<3, T, Q> const& v2); - - template - GLM_FUNC_DECL GLM_CONSTEXPR vec<3, T, Q> operator&(vec<3, T, Q> const& v1, vec<3, T, Q> const& v2); - - template - GLM_FUNC_DECL GLM_CONSTEXPR vec<3, T, Q> operator|(vec<3, T, Q> const& v, T scalar); - - template - GLM_FUNC_DECL GLM_CONSTEXPR vec<3, T, Q> operator|(vec<3, T, Q> const& v1, vec<1, T, Q> const& v2); - - template - GLM_FUNC_DECL GLM_CONSTEXPR vec<3, T, Q> operator|(T scalar, vec<3, T, Q> const& v); - - template - GLM_FUNC_DECL GLM_CONSTEXPR vec<3, T, Q> operator|(vec<1, T, Q> const& v1, vec<3, T, Q> const& v2); - - template - GLM_FUNC_DECL GLM_CONSTEXPR vec<3, T, Q> operator|(vec<3, T, Q> const& v1, vec<3, T, Q> const& v2); - - template - GLM_FUNC_DECL GLM_CONSTEXPR vec<3, T, Q> operator^(vec<3, T, Q> const& v, T scalar); - - template - GLM_FUNC_DECL GLM_CONSTEXPR vec<3, T, Q> operator^(vec<3, T, Q> const& v1, vec<1, T, Q> const& v2); - - template - GLM_FUNC_DECL GLM_CONSTEXPR vec<3, T, Q> operator^(T scalar, vec<3, T, Q> const& v); - - template - GLM_FUNC_DECL GLM_CONSTEXPR vec<3, T, Q> operator^(vec<1, T, Q> const& v1, vec<3, T, Q> const& v2); - - template - GLM_FUNC_DECL GLM_CONSTEXPR vec<3, T, Q> operator^(vec<3, T, Q> const& v1, vec<3, T, Q> const& v2); - - template - GLM_FUNC_DECL GLM_CONSTEXPR vec<3, T, Q> operator<<(vec<3, T, Q> const& v, T scalar); - - template - GLM_FUNC_DECL GLM_CONSTEXPR vec<3, T, Q> operator<<(vec<3, T, Q> const& v1, vec<1, T, Q> const& v2); - - template - GLM_FUNC_DECL GLM_CONSTEXPR vec<3, T, Q> operator<<(T scalar, vec<3, T, Q> const& v); - - template - GLM_FUNC_DECL GLM_CONSTEXPR vec<3, T, Q> operator<<(vec<1, T, Q> const& v1, vec<3, T, Q> const& v2); - - template - GLM_FUNC_DECL GLM_CONSTEXPR vec<3, T, Q> operator<<(vec<3, T, Q> const& v1, vec<3, T, Q> const& v2); - - template - GLM_FUNC_DECL GLM_CONSTEXPR vec<3, T, Q> operator>>(vec<3, T, Q> const& v, T scalar); - - template - GLM_FUNC_DECL GLM_CONSTEXPR vec<3, T, Q> operator>>(vec<3, T, Q> const& v1, vec<1, T, Q> const& v2); - - template - GLM_FUNC_DECL GLM_CONSTEXPR vec<3, T, Q> operator>>(T scalar, vec<3, T, Q> const& v); - - template - GLM_FUNC_DECL GLM_CONSTEXPR vec<3, T, Q> operator>>(vec<1, T, Q> const& v1, vec<3, T, Q> const& v2); - - template - GLM_FUNC_DECL GLM_CONSTEXPR vec<3, T, Q> operator>>(vec<3, T, Q> const& v1, vec<3, T, Q> const& v2); - template GLM_FUNC_DECL GLM_CONSTEXPR vec<3, T, Q> operator~(vec<3, T, Q> const& v); @@ -428,9 +253,6 @@ namespace glm template GLM_FUNC_DECL GLM_CONSTEXPR bool operator==(vec<3, T, Q> const& v1, vec<3, T, Q> const& v2); - template - GLM_FUNC_DECL GLM_CONSTEXPR bool operator!=(vec<3, T, Q> const& v1, vec<3, T, Q> const& v2); - template GLM_FUNC_DECL GLM_CONSTEXPR vec<3, bool, Q> operator&&(vec<3, bool, Q> const& v1, vec<3, bool, Q> const& v2); diff --git a/glm/detail/type_vec3.inl b/glm/detail/type_vec3.inl index fed82bf6..9af49dfd 100644 --- a/glm/detail/type_vec3.inl +++ b/glm/detail/type_vec3.inl @@ -229,13 +229,6 @@ namespace glm return (*this = detail::compute_vec_add<3, T, Q, detail::is_aligned::value>::call(*this, vec<3, T, Q>(scalar))); } - template - template - GLM_FUNC_QUALIFIER GLM_CONSTEXPR vec<3, T, Q> & vec<3, T, Q>::operator+=(vec<1, U, Q> const& v) - { - return (*this = detail::compute_vec_add<3, T, Q, detail::is_aligned::value>::call(*this, vec<1, T, Q>(v.x))); - } - template template GLM_FUNC_QUALIFIER GLM_CONSTEXPR vec<3, T, Q> & vec<3, T, Q>::operator+=(vec<3, U, Q> const& v) @@ -250,13 +243,6 @@ namespace glm return (*this = detail::compute_vec_sub<3, T, Q, detail::is_aligned::value>::call(*this, vec<3, T, Q>(scalar))); } - template - template - GLM_FUNC_QUALIFIER GLM_CONSTEXPR vec<3, T, Q> & vec<3, T, Q>::operator-=(vec<1, U, Q> const& v) - { - return (*this = detail::compute_vec_sub<3, T, Q, detail::is_aligned::value>::call(*this, vec<1, T, Q>(v.x))); - } - template template GLM_FUNC_QUALIFIER GLM_CONSTEXPR vec<3, T, Q> & vec<3, T, Q>::operator-=(vec<3, U, Q> const& v) @@ -271,13 +257,6 @@ namespace glm return (*this = detail::compute_vec_mul<3, T, Q, detail::is_aligned::value>::call(*this, vec<3, T, Q>(static_cast(scalar)))); } - template - template - GLM_FUNC_QUALIFIER GLM_CONSTEXPR vec<3, T, Q> & vec<3, T, Q>::operator*=(vec<1, U, Q> const& v) - { - return (*this = detail::compute_vec_mul<3, T, Q, detail::is_aligned::value>::call(*this, vec<3, T, Q>(v.x))); - } - template template GLM_FUNC_QUALIFIER GLM_CONSTEXPR vec<3, T, Q> & vec<3, T, Q>::operator*=(vec<3, U, Q> const& v) @@ -292,13 +271,6 @@ namespace glm return (*this = detail::compute_vec_div<3, T, Q, detail::is_aligned::value>::call(*this, vec<3, T, Q>(v))); } - template - template - GLM_FUNC_QUALIFIER GLM_CONSTEXPR vec<3, T, Q> & vec<3, T, Q>::operator/=(vec<1, U, Q> const& v) - { - return (*this = detail::compute_vec_div<3, T, Q, detail::is_aligned::value>::call(*this, vec<3, T, Q>(v.x))); - } - template template GLM_FUNC_QUALIFIER GLM_CONSTEXPR vec<3, T, Q> & vec<3, T, Q>::operator/=(vec<3, U, Q> const& v) @@ -326,38 +298,8 @@ namespace glm return *this; } - template - GLM_FUNC_QUALIFIER GLM_CONSTEXPR vec<3, T, Q> vec<3, T, Q>::operator++(int) - { - vec<3, T, Q> Result(*this); - ++*this; - return Result; - } - - template - GLM_FUNC_QUALIFIER GLM_CONSTEXPR vec<3, T, Q> vec<3, T, Q>::operator--(int) - { - vec<3, T, Q> Result(*this); - --*this; - return Result; - } - // -- Unary bit operators -- - template - template - GLM_FUNC_QUALIFIER GLM_CONSTEXPR vec<3, T, Q> & vec<3, T, Q>::operator%=(U scalar) - { - return (*this = detail::compute_vec_mod<3, T, Q, detail::is_aligned::value>::call(*this, vec<3, T, Q>(scalar))); - } - - template - template - GLM_FUNC_QUALIFIER GLM_CONSTEXPR vec<3, T, Q> & vec<3, T, Q>::operator%=(vec<1, U, Q> const& v) - { - return (*this = detail::compute_vec_mod<3, T, Q, detail::is_aligned::value>::call(*this, vec<3, T, Q>(v))); - } - template template GLM_FUNC_QUALIFIER GLM_CONSTEXPR vec<3, T, Q> & vec<3, T, Q>::operator%=(vec<3, U, Q> const& v) @@ -367,37 +309,9 @@ namespace glm template template - GLM_FUNC_QUALIFIER GLM_CONSTEXPR vec<3, T, Q> & vec<3, T, Q>::operator&=(U scalar) + GLM_FUNC_QUALIFIER GLM_CONSTEXPR vec<3, T, Q>& vec<3, T, Q>::operator&=(vec<3, U, Q> const& v) { - return (*this = detail::compute_vec_and<3, T, Q, detail::is_int::value, sizeof(T) * 8, detail::is_aligned::value>::call(*this, vec<3, T, Q>(scalar))); - } - - template - template - GLM_FUNC_QUALIFIER GLM_CONSTEXPR vec<3, T, Q> & vec<3, T, Q>::operator&=(vec<1, U, Q> const& v) - { - return (*this = detail::compute_vec_and<3, T, Q, detail::is_int::value, sizeof(T) * 8, detail::is_aligned::value>::call(*this, vec<3, T, Q>(v))); - } - - template - template - GLM_FUNC_QUALIFIER GLM_CONSTEXPR vec<3, T, Q> & vec<3, T, Q>::operator&=(vec<3, U, Q> const& v) - { - return (*this = detail::compute_vec_and<3, T, Q, detail::is_int::value, sizeof(T) * 8, detail::is_aligned::value>::call(*this, vec<3, T, Q>(v))); - } - - template - template - GLM_FUNC_QUALIFIER GLM_CONSTEXPR vec<3, T, Q> & vec<3, T, Q>::operator|=(U scalar) - { - return (*this = detail::compute_vec_or<3, T, Q, detail::is_int::value, sizeof(T) * 8, detail::is_aligned::value>::call(*this, vec<3, T, Q>(scalar))); - } - - template - template - GLM_FUNC_QUALIFIER GLM_CONSTEXPR vec<3, T, Q> & vec<3, T, Q>::operator|=(vec<1, U, Q> const& v) - { - return (*this = detail::compute_vec_or<3, T, Q, detail::is_int::value, sizeof(T) * 8, detail::is_aligned::value>::call(*this, vec<3, T, Q>(v))); + return (*this = detail::compute_vec_and<3, T, Q, detail::is_int::value, sizeof(T) * 8, detail::is_aligned::value>::call(*this, v)); } template @@ -407,20 +321,6 @@ namespace glm return (*this = detail::compute_vec_or<3, T, Q, detail::is_int::value, sizeof(T) * 8, detail::is_aligned::value>::call(*this, vec<3, T, Q>(v))); } - template - template - GLM_FUNC_QUALIFIER GLM_CONSTEXPR vec<3, T, Q> & vec<3, T, Q>::operator^=(U scalar) - { - return (*this = detail::compute_vec_xor<3, T, Q, detail::is_int::value, sizeof(T) * 8, detail::is_aligned::value>::call(*this, vec<3, T, Q>(scalar))); - } - - template - template - GLM_FUNC_QUALIFIER GLM_CONSTEXPR vec<3, T, Q> & vec<3, T, Q>::operator^=(vec<1, U, Q> const& v) - { - return (*this = detail::compute_vec_xor<3, T, Q, detail::is_int::value, sizeof(T) * 8, detail::is_aligned::value>::call(*this, vec<3, T, Q>(v.x))); - } - template template GLM_FUNC_QUALIFIER GLM_CONSTEXPR vec<3, T, Q> & vec<3, T, Q>::operator^=(vec<3, U, Q> const& v) @@ -428,20 +328,6 @@ namespace glm return (*this = detail::compute_vec_xor<3, T, Q, detail::is_int::value, sizeof(T) * 8, detail::is_aligned::value>::call(*this, vec<3, T, Q>(v))); } - template - template - GLM_FUNC_QUALIFIER GLM_CONSTEXPR vec<3, T, Q> & vec<3, T, Q>::operator<<=(U scalar) - { - return (*this = detail::compute_vec_shift_left<3, T, Q, detail::is_int::value, sizeof(T) * 8, detail::is_aligned::value>::call(*this, vec<3, T, Q>(scalar))); - } - - template - template - GLM_FUNC_QUALIFIER GLM_CONSTEXPR vec<3, T, Q> & vec<3, T, Q>::operator<<=(vec<1, U, Q> const& v) - { - return (*this = detail::compute_vec_shift_left<3, T, Q, detail::is_int::value, sizeof(T) * 8, detail::is_aligned::value>::call(*this, vec<1, T, Q>(v))); - } - template template GLM_FUNC_QUALIFIER GLM_CONSTEXPR vec<3, T, Q> & vec<3, T, Q>::operator<<=(vec<3, U, Q> const& v) @@ -449,20 +335,6 @@ namespace glm return (*this = detail::compute_vec_shift_left<3, T, Q, detail::is_int::value, sizeof(T) * 8, detail::is_aligned::value>::call(*this, vec<3, T, Q>(v))); } - template - template - GLM_FUNC_QUALIFIER GLM_CONSTEXPR vec<3, T, Q> & vec<3, T, Q>::operator>>=(U scalar) - { - return (*this = detail::compute_vec_shift_right<3, T, Q, detail::is_int::value, sizeof(T) * 8, detail::is_aligned::value>::call(*this, vec<3, T, Q>(scalar))); - } - - template - template - GLM_FUNC_QUALIFIER GLM_CONSTEXPR vec<3, T, Q> & vec<3, T, Q>::operator>>=(vec<1, U, Q> const& v) - { - return (*this = detail::compute_vec_shift_right<3, T, Q, detail::is_int::value, sizeof(T) * 8, detail::is_aligned::value>::call(*this, vec<3, T, Q>(v))); - } - template template GLM_FUNC_QUALIFIER GLM_CONSTEXPR vec<3, T, Q> & vec<3, T, Q>::operator>>=(vec<3, U, Q> const& v) @@ -473,12 +345,6 @@ namespace glm // -- Unary arithmetic operators -- - template - GLM_FUNC_QUALIFIER GLM_CONSTEXPR vec<3, T, Q> operator+(vec<3, T, Q> const& v) - { - return v; - } - template GLM_FUNC_QUALIFIER GLM_CONSTEXPR vec<3, T, Q> operator-(vec<3, T, Q> const& v) { @@ -487,309 +353,6 @@ namespace glm // -- Binary arithmetic operators -- - template - GLM_FUNC_QUALIFIER GLM_CONSTEXPR vec<3, T, Q> operator+(vec<3, T, Q> const& v, T scalar) - { - return vec<3, T, Q>(v) += scalar; - } - - template - GLM_FUNC_QUALIFIER GLM_CONSTEXPR vec<3, T, Q> operator+(vec<3, T, Q> const& v1, vec<1, T, Q> const& v2) - { - return vec<3, T, Q>(v1) += v2; - } - - template - GLM_FUNC_QUALIFIER GLM_CONSTEXPR vec<3, T, Q> operator+(T scalar, vec<3, T, Q> const& v) - { - return vec<3, T, Q>(v) += scalar; - } - - template - GLM_FUNC_QUALIFIER GLM_CONSTEXPR vec<3, T, Q> operator+(vec<1, T, Q> const& scalar, vec<3, T, Q> const& v) - { - return vec<3, T, Q>(scalar) += v; - } - - template - GLM_FUNC_QUALIFIER GLM_CONSTEXPR vec<3, T, Q> operator+(vec<3, T, Q> const& v1, vec<3, T, Q> const& v2) - { - return vec<3, T, Q>(v1) += v2; - } - - template - GLM_FUNC_QUALIFIER GLM_CONSTEXPR vec<3, T, Q> operator-(vec<3, T, Q> const& v, T scalar) - { - return vec<3, T, Q>(v) -= scalar; - } - - template - GLM_FUNC_QUALIFIER GLM_CONSTEXPR vec<3, T, Q> operator-(vec<3, T, Q> const& v, vec<1, T, Q> const& scalar) - { - return vec<3, T, Q>(v) -= scalar.x; - } - - template - GLM_FUNC_QUALIFIER GLM_CONSTEXPR vec<3, T, Q> operator-(T scalar, vec<3, T, Q> const& v) - { - return vec<3, T, Q>(scalar) -= v; - } - - template - GLM_FUNC_QUALIFIER GLM_CONSTEXPR vec<3, T, Q> operator-(vec<1, T, Q> const& scalar, vec<3, T, Q> const& v) - { - return vec<3, T, Q>(scalar) -= v; - } - - template - GLM_FUNC_QUALIFIER GLM_CONSTEXPR vec<3, T, Q> operator-(vec<3, T, Q> const& v1, vec<3, T, Q> const& v2) - { - return vec<3, T, Q>(v1) -= v2; - } - - template - GLM_FUNC_QUALIFIER GLM_CONSTEXPR vec<3, T, Q> operator*(vec<3, T, Q> const& v, T scalar) - { - return vec<3, T, Q>(v) *= scalar; - } - - template - GLM_FUNC_QUALIFIER GLM_CONSTEXPR vec<3, T, Q> operator*(vec<3, T, Q> const& v, vec<1, T, Q> const& scalar) - { - return vec<3, T, Q>(v) *= scalar.x; - } - - template - GLM_FUNC_QUALIFIER GLM_CONSTEXPR vec<3, T, Q> operator*(T scalar, vec<3, T, Q> const& v) - { - return vec<3, T, Q>(v) *= scalar; - } - - template - GLM_FUNC_QUALIFIER GLM_CONSTEXPR vec<3, T, Q> operator*(vec<1, T, Q> const& scalar, vec<3, T, Q> const& v) - { - return vec<3, T, Q>(v) *= scalar.x; - } - - template - GLM_FUNC_QUALIFIER GLM_CONSTEXPR vec<3, T, Q> operator*(vec<3, T, Q> const& v1, vec<3, T, Q> const& v2) - { - return vec<3, T, Q>(v1) *= v2; - - } - - template - GLM_FUNC_QUALIFIER GLM_CONSTEXPR vec<3, T, Q> operator/(vec<3, T, Q> const& v, T scalar) - { - return vec<3, T, Q>(v) /= scalar; - } - - template - GLM_FUNC_QUALIFIER GLM_CONSTEXPR vec<3, T, Q> operator/(vec<3, T, Q> const& v, vec<1, T, Q> const& scalar) - { - return vec<3, T, Q>(v) /= scalar.x; - } - - template - GLM_FUNC_QUALIFIER GLM_CONSTEXPR vec<3, T, Q> operator/(T scalar, vec<3, T, Q> const& v) - { - return vec<3, T, Q>(scalar) /= v; - } - - template - GLM_FUNC_QUALIFIER GLM_CONSTEXPR vec<3, T, Q> operator/(vec<1, T, Q> const& scalar, vec<3, T, Q> const& v) - { - return vec<3, T, Q>(scalar) /= v; - } - - template - GLM_FUNC_QUALIFIER GLM_CONSTEXPR vec<3, T, Q> operator/(vec<3, T, Q> const& v1, vec<3, T, Q> const& v2) - { - return vec<3, T, Q>(v1) /= v2; - } - - // -- Binary bit operators -- - - template - GLM_FUNC_QUALIFIER GLM_CONSTEXPR vec<3, T, Q> operator%(vec<3, T, Q> const& v, T scalar) - { - return vec<3, T, Q>(v) %= scalar; - } - - template - GLM_FUNC_QUALIFIER GLM_CONSTEXPR vec<3, T, Q> operator%(vec<3, T, Q> const& v, vec<1, T, Q> const& scalar) - { - return vec<3, T, Q>(v) %= scalar.x; - } - - template - GLM_FUNC_QUALIFIER GLM_CONSTEXPR vec<3, T, Q> operator%(T scalar, vec<3, T, Q> const& v) - { - return vec<3, T, Q>(scalar) %= v; - } - - template - GLM_FUNC_QUALIFIER GLM_CONSTEXPR vec<3, T, Q> operator%(vec<1, T, Q> const& scalar, vec<3, T, Q> const& v) - { - return vec<3, T, Q>(scalar.x) %= v; - } - - template - GLM_FUNC_QUALIFIER GLM_CONSTEXPR vec<3, T, Q> operator%(vec<3, T, Q> const& v1, vec<3, T, Q> const& v2) - { - return vec<3, T, Q>(v1) %= v2; - } - - template - GLM_FUNC_QUALIFIER GLM_CONSTEXPR vec<3, T, Q> operator&(vec<3, T, Q> const& v, T scalar) - { - return vec<3, T, Q>(v) &= scalar; - } - - template - GLM_FUNC_QUALIFIER GLM_CONSTEXPR vec<3, T, Q> operator&(vec<3, T, Q> const& v, vec<1, T, Q> const& scalar) - { - return vec<3, T, Q>(v) &= scalar.x; - } - - template - GLM_FUNC_QUALIFIER GLM_CONSTEXPR vec<3, T, Q> operator&(T scalar, vec<3, T, Q> const& v) - { - return vec<3, T, Q>(scalar) &= v; - } - - template - GLM_FUNC_QUALIFIER GLM_CONSTEXPR vec<3, T, Q> operator&(vec<1, T, Q> const& scalar, vec<3, T, Q> const& v) - { - return vec<3, T, Q>(scalar.x) &= v; - } - - template - GLM_FUNC_QUALIFIER GLM_CONSTEXPR vec<3, T, Q> operator&(vec<3, T, Q> const& v1, vec<3, T, Q> const& v2) - { - return vec<3, T, Q>(v1) &= v2; - } - - template - GLM_FUNC_QUALIFIER GLM_CONSTEXPR vec<3, T, Q> operator|(vec<3, T, Q> const& v, T scalar) - { - return vec<3, T, Q>(v) |= scalar; - } - - template - GLM_FUNC_QUALIFIER GLM_CONSTEXPR vec<3, T, Q> operator|(vec<3, T, Q> const& v, vec<1, T, Q> const& scalar) - { - return vec<3, T, Q>(v) |= scalar.x; - } - - template - GLM_FUNC_QUALIFIER GLM_CONSTEXPR vec<3, T, Q> operator|(T scalar, vec<3, T, Q> const& v) - { - return vec<3, T, Q>(scalar) |= v; - } - - template - GLM_FUNC_QUALIFIER GLM_CONSTEXPR vec<3, T, Q> operator|(vec<1, T, Q> const& scalar, vec<3, T, Q> const& v) - { - return vec<3, T, Q>(scalar.x) |= v; - } - - template - GLM_FUNC_QUALIFIER GLM_CONSTEXPR vec<3, T, Q> operator|(vec<3, T, Q> const& v1, vec<3, T, Q> const& v2) - { - return vec<3, T, Q>(v1) |= v2; - } - - template - GLM_FUNC_QUALIFIER GLM_CONSTEXPR vec<3, T, Q> operator^(vec<3, T, Q> const& v, T scalar) - { - return vec<3, T, Q>(v) ^= scalar; - } - - template - GLM_FUNC_QUALIFIER GLM_CONSTEXPR vec<3, T, Q> operator^(vec<3, T, Q> const& v, vec<1, T, Q> const& scalar) - { - return vec<3, T, Q>(v) ^= scalar.x; - } - - template - GLM_FUNC_QUALIFIER GLM_CONSTEXPR vec<3, T, Q> operator^(T scalar, vec<3, T, Q> const& v) - { - return vec<3, T, Q>(scalar) ^= v; - } - - template - GLM_FUNC_QUALIFIER GLM_CONSTEXPR vec<3, T, Q> operator^(vec<1, T, Q> const& scalar, vec<3, T, Q> const& v) - { - return vec<3, T, Q>(scalar.x) ^= v; - } - - template - GLM_FUNC_QUALIFIER GLM_CONSTEXPR vec<3, T, Q> operator^(vec<3, T, Q> const& v1, vec<3, T, Q> const& v2) - { - return vec<3, T, Q>(v1) ^= v2; - } - - template - GLM_FUNC_QUALIFIER GLM_CONSTEXPR vec<3, T, Q> operator<<(vec<3, T, Q> const& v, T scalar) - { - return vec<3, T, Q>(v) <<= scalar; - } - - template - GLM_FUNC_QUALIFIER GLM_CONSTEXPR vec<3, T, Q> operator<<(vec<3, T, Q> const& v, vec<1, T, Q> const& scalar) - { - return vec<3, T, Q>(v) <<= scalar.x; - } - - template - GLM_FUNC_QUALIFIER GLM_CONSTEXPR vec<3, T, Q> operator<<(T scalar, vec<3, T, Q> const& v) - { - return vec<3, T, Q>(scalar) << v; - } - - template - GLM_FUNC_QUALIFIER GLM_CONSTEXPR vec<3, T, Q> operator<<(vec<1, T, Q> const& scalar, vec<3, T, Q> const& v) - { - return vec<3, T, Q>(scalar.x) << v; - } - - template - GLM_FUNC_QUALIFIER GLM_CONSTEXPR vec<3, T, Q> operator<<(vec<3, T, Q> const& v1, vec<3, T, Q> const& v2) - { - return vec<3, T, Q>(v1) <<= v2; - } - - template - GLM_FUNC_QUALIFIER GLM_CONSTEXPR vec<3, T, Q> operator>>(vec<3, T, Q> const& v, T scalar) - { - return vec<3, T, Q>(v) >>= scalar; - } - - template - GLM_FUNC_QUALIFIER GLM_CONSTEXPR vec<3, T, Q> operator>>(vec<3, T, Q> const& v, vec<1, T, Q> const& scalar) - { - return vec<3, T, Q>(v) >>= scalar.x; - } - - template - GLM_FUNC_QUALIFIER GLM_CONSTEXPR vec<3, T, Q> operator>>(T scalar, vec<3, T, Q> const& v) - { - return vec<3, T, Q>(scalar) >>= v; - } - - template - GLM_FUNC_QUALIFIER GLM_CONSTEXPR vec<3, T, Q> operator>>(vec<1, T, Q> const& scalar, vec<3, T, Q> const& v) - { - return vec<3, T, Q>(scalar.x) >>= v; - } - - template - GLM_FUNC_QUALIFIER GLM_CONSTEXPR vec<3, T, Q> operator>>(vec<3, T, Q> const& v1, vec<3, T, Q> const& v2) - { - return vec<3, T, Q>(v1) >>= v2; - } - template GLM_FUNC_QUALIFIER GLM_CONSTEXPR vec<3, T, Q> operator~(vec<3, T, Q> const& v) { @@ -810,12 +373,6 @@ namespace glm detail::compute_equal::is_iec559>::call(v1.z, v2.z); } - template - GLM_FUNC_QUALIFIER GLM_CONSTEXPR bool operator!=(vec<3, T, Q> const& v1, vec<3, T, Q> const& v2) - { - return !(v1 == v2); - } - template GLM_FUNC_QUALIFIER GLM_CONSTEXPR vec<3, bool, Q> operator&&(vec<3, bool, Q> const& v1, vec<3, bool, Q> const& v2) { @@ -982,4 +539,4 @@ namespace glm { } -#endif +#endif diff --git a/glm/detail/type_vec4.hpp b/glm/detail/type_vec4.hpp index 9ba11229..42072aa5 100644 --- a/glm/detail/type_vec4.hpp +++ b/glm/detail/type_vec4.hpp @@ -4,6 +4,7 @@ #pragma once #include "qualifier.hpp" +#include "vec_common_ops.hpp" #if GLM_CONFIG_SWIZZLE == GLM_SWIZZLE_OPERATOR # include "_swizzle.hpp" #elif GLM_CONFIG_SWIZZLE == GLM_SWIZZLE_FUNCTION @@ -259,238 +260,42 @@ namespace glm template GLM_FUNC_DISCARD_DECL GLM_CONSTEXPR vec<4, T, Q>& operator=(vec<4, U, Q> const& v); template - GLM_FUNC_DISCARD_DECL GLM_CONSTEXPR vec<4, T, Q>& operator+=(U scalar); - template - GLM_FUNC_DISCARD_DECL GLM_CONSTEXPR vec<4, T, Q>& operator+=(vec<1, U, Q> const& v); - template GLM_FUNC_DISCARD_DECL GLM_CONSTEXPR vec<4, T, Q>& operator+=(vec<4, U, Q> const& v); template - GLM_FUNC_DISCARD_DECL GLM_CONSTEXPR vec<4, T, Q>& operator-=(U scalar); - template - GLM_FUNC_DISCARD_DECL GLM_CONSTEXPR vec<4, T, Q>& operator-=(vec<1, U, Q> const& v); - template GLM_FUNC_DISCARD_DECL GLM_CONSTEXPR vec<4, T, Q>& operator-=(vec<4, U, Q> const& v); template - GLM_FUNC_DISCARD_DECL GLM_CONSTEXPR vec<4, T, Q>& operator*=(U scalar); - template - GLM_FUNC_DISCARD_DECL GLM_CONSTEXPR vec<4, T, Q>& operator*=(vec<1, U, Q> const& v); - template GLM_FUNC_DISCARD_DECL GLM_CONSTEXPR vec<4, T, Q>& operator*=(vec<4, U, Q> const& v); template - GLM_FUNC_DISCARD_DECL GLM_CONSTEXPR vec<4, T, Q>& operator/=(U scalar); - template - GLM_FUNC_DISCARD_DECL GLM_CONSTEXPR vec<4, T, Q>& operator/=(vec<1, U, Q> const& v); - template GLM_FUNC_DISCARD_DECL GLM_CONSTEXPR vec<4, T, Q>& operator/=(vec<4, U, Q> const& v); // -- Increment and decrement operators -- GLM_FUNC_DISCARD_DECL GLM_CONSTEXPR vec<4, T, Q> & operator++(); GLM_FUNC_DISCARD_DECL GLM_CONSTEXPR vec<4, T, Q> & operator--(); - GLM_FUNC_DECL GLM_CONSTEXPR vec<4, T, Q> operator++(int); - GLM_FUNC_DECL GLM_CONSTEXPR vec<4, T, Q> operator--(int); - // -- Unary bit operators -- - template - GLM_FUNC_DECL GLM_CONSTEXPR vec<4, T, Q> & operator%=(U scalar); - template - GLM_FUNC_DECL GLM_CONSTEXPR vec<4, T, Q> & operator%=(vec<1, U, Q> const& v); template GLM_FUNC_DECL GLM_CONSTEXPR vec<4, T, Q> & operator%=(vec<4, U, Q> const& v); template - GLM_FUNC_DECL GLM_CONSTEXPR vec<4, T, Q> & operator&=(U scalar); - template - GLM_FUNC_DECL GLM_CONSTEXPR vec<4, T, Q> & operator&=(vec<1, U, Q> const& v); - template GLM_FUNC_DECL GLM_CONSTEXPR vec<4, T, Q> & operator&=(vec<4, U, Q> const& v); template - GLM_FUNC_DECL GLM_CONSTEXPR vec<4, T, Q> & operator|=(U scalar); - template - GLM_FUNC_DECL GLM_CONSTEXPR vec<4, T, Q> & operator|=(vec<1, U, Q> const& v); - template GLM_FUNC_DECL GLM_CONSTEXPR vec<4, T, Q> & operator|=(vec<4, U, Q> const& v); template - GLM_FUNC_DECL GLM_CONSTEXPR vec<4, T, Q> & operator^=(U scalar); - template - GLM_FUNC_DECL GLM_CONSTEXPR vec<4, T, Q> & operator^=(vec<1, U, Q> const& v); - template GLM_FUNC_DECL GLM_CONSTEXPR vec<4, T, Q> & operator^=(vec<4, U, Q> const& v); template - GLM_FUNC_DECL GLM_CONSTEXPR vec<4, T, Q> & operator<<=(U scalar); - template - GLM_FUNC_DECL GLM_CONSTEXPR vec<4, T, Q> & operator<<=(vec<1, U, Q> const& v); - template GLM_FUNC_DECL GLM_CONSTEXPR vec<4, T, Q> & operator<<=(vec<4, U, Q> const& v); template - GLM_FUNC_DECL GLM_CONSTEXPR vec<4, T, Q> & operator>>=(U scalar); - template - GLM_FUNC_DECL GLM_CONSTEXPR vec<4, T, Q> & operator>>=(vec<1, U, Q> const& v); - template GLM_FUNC_DECL GLM_CONSTEXPR vec<4, T, Q> & operator>>=(vec<4, U, Q> const& v); }; // -- Unary operators -- - template - GLM_FUNC_DECL GLM_CONSTEXPR vec<4, T, Q> operator+(vec<4, T, Q> const& v); - template GLM_FUNC_DECL GLM_CONSTEXPR vec<4, T, Q> operator-(vec<4, T, Q> const& v); // -- Binary operators -- - template - GLM_FUNC_DECL GLM_CONSTEXPR vec<4, T, Q> operator+(vec<4, T, Q> const& v, T scalar); - - template - GLM_FUNC_DECL GLM_CONSTEXPR vec<4, T, Q> operator+(vec<4, T, Q> const& v1, vec<1, T, Q> const& v2); - - template - GLM_FUNC_DECL GLM_CONSTEXPR vec<4, T, Q> operator+(T scalar, vec<4, T, Q> const& v); - - template - GLM_FUNC_DECL GLM_CONSTEXPR vec<4, T, Q> operator+(vec<1, T, Q> const& v1, vec<4, T, Q> const& v2); - - template - GLM_FUNC_DECL GLM_CONSTEXPR vec<4, T, Q> operator+(vec<4, T, Q> const& v1, vec<4, T, Q> const& v2); - - template - GLM_FUNC_DECL GLM_CONSTEXPR vec<4, T, Q> operator-(vec<4, T, Q> const& v, T scalar); - - template - GLM_FUNC_DECL GLM_CONSTEXPR vec<4, T, Q> operator-(vec<4, T, Q> const& v1, vec<1, T, Q> const& v2); - - template - GLM_FUNC_DECL GLM_CONSTEXPR vec<4, T, Q> operator-(T scalar, vec<4, T, Q> const& v); - - template - GLM_FUNC_DECL GLM_CONSTEXPR vec<4, T, Q> operator-(vec<1, T, Q> const& v1, vec<4, T, Q> const& v2); - - template - GLM_FUNC_DECL GLM_CONSTEXPR vec<4, T, Q> operator-(vec<4, T, Q> const& v1, vec<4, T, Q> const& v2); - - template - GLM_FUNC_DECL GLM_CONSTEXPR vec<4, T, Q> operator*(vec<4, T, Q> const& v, T scalar); - - template - GLM_FUNC_DECL GLM_CONSTEXPR vec<4, T, Q> operator*(vec<4, T, Q> const& v1, vec<1, T, Q> const& v2); - - template - GLM_FUNC_DECL GLM_CONSTEXPR vec<4, T, Q> operator*(T scalar, vec<4, T, Q> const& v); - - template - GLM_FUNC_DECL GLM_CONSTEXPR vec<4, T, Q> operator*(vec<1, T, Q> const& v1, vec<4, T, Q> const& v2); - - template - GLM_FUNC_DECL GLM_CONSTEXPR vec<4, T, Q> operator*(vec<4, T, Q> const& v1, vec<4, T, Q> const& v2); - - template - GLM_FUNC_DECL GLM_CONSTEXPR vec<4, T, Q> operator/(vec<4, T, Q> const& v, T scalar); - - template - GLM_FUNC_DECL GLM_CONSTEXPR vec<4, T, Q> operator/(vec<4, T, Q> const& v1, vec<1, T, Q> const& v2); - - template - GLM_FUNC_DECL GLM_CONSTEXPR vec<4, T, Q> operator/(T scalar, vec<4, T, Q> const& v); - - template - GLM_FUNC_DECL GLM_CONSTEXPR vec<4, T, Q> operator/(vec<1, T, Q> const& v1, vec<4, T, Q> const& v2); - - template - GLM_FUNC_DECL GLM_CONSTEXPR vec<4, T, Q> operator/(vec<4, T, Q> const& v1, vec<4, T, Q> const& v2); - - template - GLM_FUNC_DECL GLM_CONSTEXPR vec<4, T, Q> operator%(vec<4, T, Q> const& v, T scalar); - - template - GLM_FUNC_DECL GLM_CONSTEXPR vec<4, T, Q> operator%(vec<4, T, Q> const& v, vec<1, T, Q> const& scalar); - - template - GLM_FUNC_DECL GLM_CONSTEXPR vec<4, T, Q> operator%(T scalar, vec<4, T, Q> const& v); - - template - GLM_FUNC_DECL GLM_CONSTEXPR vec<4, T, Q> operator%(vec<1, T, Q> const& scalar, vec<4, T, Q> const& v); - - template - GLM_FUNC_DECL GLM_CONSTEXPR vec<4, T, Q> operator%(vec<4, T, Q> const& v1, vec<4, T, Q> const& v2); - - template - GLM_FUNC_DECL GLM_CONSTEXPR vec<4, T, Q> operator&(vec<4, T, Q> const& v, T scalar); - - template - GLM_FUNC_DECL GLM_CONSTEXPR vec<4, T, Q> operator&(vec<4, T, Q> const& v, vec<1, T, Q> const& scalar); - - template - GLM_FUNC_DECL GLM_CONSTEXPR vec<4, T, Q> operator&(T scalar, vec<4, T, Q> const& v); - - template - GLM_FUNC_DECL GLM_CONSTEXPR vec<4, T, Q> operator&(vec<1, T, Q> const& scalar, vec<4, T, Q> const& v); - - template - GLM_FUNC_DECL GLM_CONSTEXPR vec<4, T, Q> operator&(vec<4, T, Q> const& v1, vec<4, T, Q> const& v2); - - template - GLM_FUNC_DECL GLM_CONSTEXPR vec<4, T, Q> operator|(vec<4, T, Q> const& v, T scalar); - - template - GLM_FUNC_DECL GLM_CONSTEXPR vec<4, T, Q> operator|(vec<4, T, Q> const& v, vec<1, T, Q> const& scalar); - - template - GLM_FUNC_DECL GLM_CONSTEXPR vec<4, T, Q> operator|(T scalar, vec<4, T, Q> const& v); - - template - GLM_FUNC_DECL GLM_CONSTEXPR vec<4, T, Q> operator|(vec<1, T, Q> const& scalar, vec<4, T, Q> const& v); - - template - GLM_FUNC_DECL GLM_CONSTEXPR vec<4, T, Q> operator|(vec<4, T, Q> const& v1, vec<4, T, Q> const& v2); - - template - GLM_FUNC_DECL GLM_CONSTEXPR vec<4, T, Q> operator^(vec<4, T, Q> const& v, T scalar); - - template - GLM_FUNC_DECL GLM_CONSTEXPR vec<4, T, Q> operator^(vec<4, T, Q> const& v, vec<1, T, Q> const& scalar); - - template - GLM_FUNC_DECL GLM_CONSTEXPR vec<4, T, Q> operator^(T scalar, vec<4, T, Q> const& v); - - template - GLM_FUNC_DECL GLM_CONSTEXPR vec<4, T, Q> operator^(vec<1, T, Q> const& scalar, vec<4, T, Q> const& v); - - template - GLM_FUNC_DECL GLM_CONSTEXPR vec<4, T, Q> operator^(vec<4, T, Q> const& v1, vec<4, T, Q> const& v2); - - template - GLM_FUNC_DECL GLM_CONSTEXPR vec<4, T, Q> operator<<(vec<4, T, Q> const& v, T scalar); - - template - GLM_FUNC_DECL GLM_CONSTEXPR vec<4, T, Q> operator<<(vec<4, T, Q> const& v, vec<1, T, Q> const& scalar); - - template - GLM_FUNC_DECL GLM_CONSTEXPR vec<4, T, Q> operator<<(T scalar, vec<4, T, Q> const& v); - - template - GLM_FUNC_DECL GLM_CONSTEXPR vec<4, T, Q> operator<<(vec<1, T, Q> const& scalar, vec<4, T, Q> const& v); - - template - GLM_FUNC_DECL GLM_CONSTEXPR vec<4, T, Q> operator<<(vec<4, T, Q> const& v1, vec<4, T, Q> const& v2); - - template - GLM_FUNC_DECL GLM_CONSTEXPR vec<4, T, Q> operator>>(vec<4, T, Q> const& v, T scalar); - - template - GLM_FUNC_DECL GLM_CONSTEXPR vec<4, T, Q> operator>>(vec<4, T, Q> const& v, vec<1, T, Q> const& scalar); - - template - GLM_FUNC_DECL GLM_CONSTEXPR vec<4, T, Q> operator>>(T scalar, vec<4, T, Q> const& v); - - template - GLM_FUNC_DECL GLM_CONSTEXPR vec<4, T, Q> operator>>(vec<1, T, Q> const& scalar, vec<4, T, Q> const& v); - - template - GLM_FUNC_DECL GLM_CONSTEXPR vec<4, T, Q> operator>>(vec<4, T, Q> const& v1, vec<4, T, Q> const& v2); - template GLM_FUNC_DECL GLM_CONSTEXPR vec<4, T, Q> operator~(vec<4, T, Q> const& v); diff --git a/glm/detail/type_vec4.inl b/glm/detail/type_vec4.inl index 66539e30..2349e26e 100644 --- a/glm/detail/type_vec4.inl +++ b/glm/detail/type_vec4.inl @@ -419,20 +419,6 @@ namespace detail return *this; } - template - template - GLM_FUNC_QUALIFIER GLM_CONSTEXPR vec<4, T, Q> & vec<4, T, Q>::operator+=(U scalar) - { - return (*this = detail::compute_vec_add<4, T, Q, detail::is_aligned::value>::call(*this, vec<4, T, Q>(scalar))); - } - - template - template - GLM_FUNC_QUALIFIER GLM_CONSTEXPR vec<4, T, Q> & vec<4, T, Q>::operator+=(vec<1, U, Q> const& v) - { - return (*this = detail::compute_vec_add<4, T, Q, detail::is_aligned::value>::call(*this, vec<4, T, Q>(v.x))); - } - template template GLM_FUNC_QUALIFIER GLM_CONSTEXPR vec<4, T, Q> & vec<4, T, Q>::operator+=(vec<4, U, Q> const& v) @@ -440,20 +426,6 @@ namespace detail return (*this = detail::compute_vec_add<4, T, Q, detail::is_aligned::value>::call(*this, vec<4, T, Q>(v))); } - template - template - GLM_FUNC_QUALIFIER GLM_CONSTEXPR vec<4, T, Q> & vec<4, T, Q>::operator-=(U scalar) - { - return (*this = detail::compute_vec_sub<4, T, Q, detail::is_aligned::value>::call(*this, vec<4, T, Q>(scalar))); - } - - template - template - GLM_FUNC_QUALIFIER GLM_CONSTEXPR vec<4, T, Q> & vec<4, T, Q>::operator-=(vec<1, U, Q> const& v) - { - return (*this = detail::compute_vec_sub<4, T, Q, detail::is_aligned::value>::call(*this, vec<4, T, Q>(v.x))); - } - template template GLM_FUNC_QUALIFIER GLM_CONSTEXPR vec<4, T, Q> & vec<4, T, Q>::operator-=(vec<4, U, Q> const& v) @@ -461,20 +433,6 @@ namespace detail return (*this = detail::compute_vec_sub<4, T, Q, detail::is_aligned::value>::call(*this, vec<4, T, Q>(v))); } - template - template - GLM_FUNC_QUALIFIER GLM_CONSTEXPR vec<4, T, Q> & vec<4, T, Q>::operator*=(U scalar) - { - return (*this = detail::compute_vec_mul<4,T, Q, detail::is_aligned::value>::call(*this, vec<4, T, Q>(scalar))); - } - - template - template - GLM_FUNC_QUALIFIER GLM_CONSTEXPR vec<4, T, Q> & vec<4, T, Q>::operator*=(vec<1, U, Q> const& v) - { - return (*this = detail::compute_vec_mul<4,T, Q, detail::is_aligned::value>::call(*this, vec<4, T, Q>(v.x))); - } - template template GLM_FUNC_QUALIFIER GLM_CONSTEXPR vec<4, T, Q> & vec<4, T, Q>::operator*=(vec<4, U, Q> const& v) @@ -482,20 +440,6 @@ namespace detail return (*this = detail::compute_vec_mul<4,T, Q, detail::is_aligned::value>::call(*this, vec<4, T, Q>(v))); } - template - template - GLM_FUNC_QUALIFIER GLM_CONSTEXPR vec<4, T, Q> & vec<4, T, Q>::operator/=(U scalar) - { - return (*this = detail::compute_vec_div<4, T, Q, detail::is_aligned::value>::call(*this, vec<4, T, Q>(scalar))); - } - - template - template - GLM_FUNC_QUALIFIER GLM_CONSTEXPR vec<4, T, Q> & vec<4, T, Q>::operator/=(vec<1, U, Q> const& v) - { - return (*this = detail::compute_vec_div<4, T, Q, detail::is_aligned::value>::call(*this, vec<4, T, Q>(v.x))); - } - template template GLM_FUNC_QUALIFIER GLM_CONSTEXPR vec<4, T, Q> & vec<4, T, Q>::operator/=(vec<4, U, Q> const& v) @@ -503,6 +447,13 @@ namespace detail return (*this = detail::compute_vec_div<4, T, Q, detail::is_aligned::value>::call(*this, vec<4, T, Q>(v))); } + template + template + GLM_FUNC_QUALIFIER GLM_CONSTEXPR vec<4, T, Q>& vec<4, T, Q>::operator%=(vec<4, U, Q> const& v) + + { + return (*this = detail::compute_vec_mod<4, T, Q, detail::is_aligned::value>::call(*this, vec<4, T, Q>(v))); + } // -- Increment and decrement operators -- template @@ -525,59 +476,8 @@ namespace detail return *this; } - template - GLM_FUNC_QUALIFIER GLM_CONSTEXPR vec<4, T, Q> vec<4, T, Q>::operator++(int) - { - vec<4, T, Q> Result(*this); - ++*this; - return Result; - } - - template - GLM_FUNC_QUALIFIER GLM_CONSTEXPR vec<4, T, Q> vec<4, T, Q>::operator--(int) - { - vec<4, T, Q> Result(*this); - --*this; - return Result; - } - // -- Unary bit operators -- - template - template - GLM_FUNC_QUALIFIER GLM_CONSTEXPR vec<4, T, Q> & vec<4, T, Q>::operator%=(U scalar) - { - return (*this = detail::compute_vec_mod<4, T, Q, detail::is_aligned::value>::call(*this, vec<4, T, Q>(scalar))); - } - - template - template - GLM_FUNC_QUALIFIER GLM_CONSTEXPR vec<4, T, Q> & vec<4, T, Q>::operator%=(vec<1, U, Q> const& v) - { - return (*this = detail::compute_vec_mod<3, T, Q, detail::is_aligned::value>::call(*this, vec<3, T, Q>(v))); - } - - template - template - GLM_FUNC_QUALIFIER GLM_CONSTEXPR vec<4, T, Q> & vec<4, T, Q>::operator%=(vec<4, U, Q> const& v) - { - return (*this = detail::compute_vec_mod<4, T, Q, detail::is_aligned::value>::call(*this, vec<4, T, Q>(v))); - } - - template - template - GLM_FUNC_QUALIFIER GLM_CONSTEXPR vec<4, T, Q> & vec<4, T, Q>::operator&=(U scalar) - { - return (*this = detail::compute_vec_and<4, T, Q, detail::is_int::value, sizeof(T) * 8, detail::is_aligned::value>::call(*this, vec<4, T, Q>(scalar))); - } - - template - template - GLM_FUNC_QUALIFIER GLM_CONSTEXPR vec<4, T, Q> & vec<4, T, Q>::operator&=(vec<1, U, Q> const& v) - { - return (*this = detail::compute_vec_and<4, T, Q, detail::is_int::value, sizeof(T) * 8, detail::is_aligned::value>::call(*this, vec<4, T, Q>(v))); - } - template template GLM_FUNC_QUALIFIER GLM_CONSTEXPR vec<4, T, Q> & vec<4, T, Q>::operator&=(vec<4, U, Q> const& v) @@ -585,20 +485,6 @@ namespace detail return (*this = detail::compute_vec_and<4, T, Q, detail::is_int::value, sizeof(T) * 8, detail::is_aligned::value>::call(*this, vec<4, T, Q>(v))); } - template - template - GLM_FUNC_QUALIFIER GLM_CONSTEXPR vec<4, T, Q> & vec<4, T, Q>::operator|=(U scalar) - { - return (*this = detail::compute_vec_or<4, T, Q, detail::is_int::value, sizeof(T) * 8, detail::is_aligned::value>::call(*this, vec<4, T, Q>(scalar))); - } - - template - template - GLM_FUNC_QUALIFIER GLM_CONSTEXPR vec<4, T, Q> & vec<4, T, Q>::operator|=(vec<1, U, Q> const& v) - { - return (*this = detail::compute_vec_or<4, T, Q, detail::is_int::value, sizeof(T) * 8, detail::is_aligned::value>::call(*this, vec<4, T, Q>(v))); - } - template template GLM_FUNC_QUALIFIER GLM_CONSTEXPR vec<4, T, Q> & vec<4, T, Q>::operator|=(vec<4, U, Q> const& v) @@ -606,20 +492,6 @@ namespace detail return (*this = detail::compute_vec_or<4, T, Q, detail::is_int::value, sizeof(T) * 8, detail::is_aligned::value>::call(*this, vec<4, T, Q>(v))); } - template - template - GLM_FUNC_QUALIFIER GLM_CONSTEXPR vec<4, T, Q> & vec<4, T, Q>::operator^=(U scalar) - { - return (*this = detail::compute_vec_xor<4, T, Q, detail::is_int::value, sizeof(T) * 8, detail::is_aligned::value>::call(*this, vec<4, T, Q>(scalar))); - } - - template - template - GLM_FUNC_QUALIFIER GLM_CONSTEXPR vec<4, T, Q> & vec<4, T, Q>::operator^=(vec<1, U, Q> const& v) - { - return (*this = detail::compute_vec_xor<4, T, Q, detail::is_int::value, sizeof(T) * 8, detail::is_aligned::value>::call(*this, vec<4, T, Q>(v))); - } - template template GLM_FUNC_QUALIFIER GLM_CONSTEXPR vec<4, T, Q> & vec<4, T, Q>::operator^=(vec<4, U, Q> const& v) @@ -627,19 +499,6 @@ namespace detail return (*this = detail::compute_vec_xor<4, T, Q, detail::is_int::value, sizeof(T) * 8, detail::is_aligned::value>::call(*this, vec<4, T, Q>(v))); } - template - template - GLM_FUNC_QUALIFIER GLM_CONSTEXPR vec<4, T, Q> & vec<4, T, Q>::operator<<=(U scalar) - { - return (*this = detail::compute_vec_shift_left<4, T, Q, detail::is_int::value, sizeof(T) * 8, detail::is_aligned::value>::call(*this, vec<4, T, Q>(scalar))); - } - - template - template - GLM_FUNC_QUALIFIER GLM_CONSTEXPR vec<4, T, Q> & vec<4, T, Q>::operator<<=(vec<1, U, Q> const& v) - { - return (*this = detail::compute_vec_shift_left<4, T, Q, detail::is_int::value, sizeof(T) * 8, detail::is_aligned::value>::call(*this, vec<4, T, Q>(v))); - } template template @@ -648,20 +507,6 @@ namespace detail return (*this = detail::compute_vec_shift_left<4, T, Q, detail::is_int::value, sizeof(T) * 8, detail::is_aligned::value>::call(*this, vec<4, T, Q>(v))); } - template - template - GLM_FUNC_QUALIFIER GLM_CONSTEXPR vec<4, T, Q> & vec<4, T, Q>::operator>>=(U scalar) - { - return (*this = detail::compute_vec_shift_right<4, T, Q, detail::is_int::value, sizeof(T) * 8, detail::is_aligned::value>::call(*this, vec<4, T, Q>(scalar))); - } - - template - template - GLM_FUNC_QUALIFIER GLM_CONSTEXPR vec<4, T, Q> & vec<4, T, Q>::operator>>=(vec<1, U, Q> const& v) - { - return (*this = detail::compute_vec_shift_right<4, T, Q, detail::is_int::value, sizeof(T) * 8, detail::is_aligned::value>::call(*this, vec<4, T, Q>(v))); - } - template template GLM_FUNC_QUALIFIER GLM_CONSTEXPR vec<4, T, Q> & vec<4, T, Q>::operator>>=(vec<4, U, Q> const& v) @@ -671,12 +516,6 @@ namespace detail // -- Unary constant operators -- - template - GLM_FUNC_QUALIFIER GLM_CONSTEXPR vec<4, T, Q> operator+(vec<4, T, Q> const& v) - { - return v; - } - template GLM_FUNC_QUALIFIER GLM_CONSTEXPR vec<4, T, Q> operator-(vec<4, T, Q> const& v) { @@ -685,308 +524,6 @@ namespace detail // -- Binary arithmetic operators -- - template - GLM_FUNC_QUALIFIER GLM_CONSTEXPR vec<4, T, Q> operator+(vec<4, T, Q> const& v, T scalar) - { - return vec<4, T, Q>(v) += scalar; - } - - template - GLM_FUNC_QUALIFIER GLM_CONSTEXPR vec<4, T, Q> operator+(vec<4, T, Q> const& v1, vec<1, T, Q> const& v2) - { - return vec<4, T, Q>(v1) += v2; - } - - template - GLM_FUNC_QUALIFIER GLM_CONSTEXPR vec<4, T, Q> operator+(T scalar, vec<4, T, Q> const& v) - { - return vec<4, T, Q>(v) += scalar; - } - - template - GLM_FUNC_QUALIFIER GLM_CONSTEXPR vec<4, T, Q> operator+(vec<1, T, Q> const& v1, vec<4, T, Q> const& v2) - { - return vec<4, T, Q>(v2) += v1; - } - - template - GLM_FUNC_QUALIFIER GLM_CONSTEXPR vec<4, T, Q> operator+(vec<4, T, Q> const& v1, vec<4, T, Q> const& v2) - { - return vec<4, T, Q>(v1) += v2; - } - - template - GLM_FUNC_QUALIFIER GLM_CONSTEXPR vec<4, T, Q> operator-(vec<4, T, Q> const& v, T scalar) - { - return vec<4, T, Q>(v) -= scalar; - } - - template - GLM_FUNC_QUALIFIER GLM_CONSTEXPR vec<4, T, Q> operator-(vec<4, T, Q> const& v1, vec<1, T, Q> const& v2) - { - return vec<4, T, Q>(v1) -= v2; - } - - template - GLM_FUNC_QUALIFIER GLM_CONSTEXPR vec<4, T, Q> operator-(T scalar, vec<4, T, Q> const& v) - { - return vec<4, T, Q>(scalar) -= v; - } - - template - GLM_FUNC_QUALIFIER GLM_CONSTEXPR vec<4, T, Q> operator-(vec<1, T, Q> const& v1, vec<4, T, Q> const& v2) - { - return vec<4, T, Q>(v1.x) -= v2; - } - - template - GLM_FUNC_QUALIFIER GLM_CONSTEXPR vec<4, T, Q> operator-(vec<4, T, Q> const& v1, vec<4, T, Q> const& v2) - { - return vec<4, T, Q>(v1) -= v2; - } - - template - GLM_FUNC_QUALIFIER GLM_CONSTEXPR vec<4, T, Q> operator*(vec<4, T, Q> const& v, T scalar) - { - return vec<4, T, Q>(v) *= scalar; - } - - template - GLM_FUNC_QUALIFIER GLM_CONSTEXPR vec<4, T, Q> operator*(vec<4, T, Q> const& v1, vec<1, T, Q> const& v2) - { - return vec<4, T, Q>(v1) *= v2; - } - - template - GLM_FUNC_QUALIFIER GLM_CONSTEXPR vec<4, T, Q> operator*(T scalar, vec<4, T, Q> const& v) - { - return vec<4, T, Q>(v) *= scalar; - } - - template - GLM_FUNC_QUALIFIER GLM_CONSTEXPR vec<4, T, Q> operator*(vec<1, T, Q> const& v1, vec<4, T, Q> const& v2) - { - return vec<4, T, Q>(v2) *= v1; - } - - template - GLM_FUNC_QUALIFIER GLM_CONSTEXPR vec<4, T, Q> operator*(vec<4, T, Q> const& v1, vec<4, T, Q> const& v2) - { - return vec<4, T, Q>(v1) *= v2; - } - - template - GLM_FUNC_QUALIFIER GLM_CONSTEXPR vec<4, T, Q> operator/(vec<4, T, Q> const& v, T scalar) - { - return vec<4, T, Q>(v) /= scalar; - } - - template - GLM_FUNC_QUALIFIER GLM_CONSTEXPR vec<4, T, Q> operator/(vec<4, T, Q> const& v1, vec<1, T, Q> const& v2) - { - return vec<4, T, Q>(v1) /= v2; - } - - template - GLM_FUNC_QUALIFIER GLM_CONSTEXPR vec<4, T, Q> operator/(T scalar, vec<4, T, Q> const& v) - { - return vec<4, T, Q>(scalar) /= v; - } - - template - GLM_FUNC_QUALIFIER GLM_CONSTEXPR vec<4, T, Q> operator/(vec<1, T, Q> const& v1, vec<4, T, Q> const& v2) - { - return vec<4, T, Q>(v1.x) /= v2; - } - - template - GLM_FUNC_QUALIFIER GLM_CONSTEXPR vec<4, T, Q> operator/(vec<4, T, Q> const& v1, vec<4, T, Q> const& v2) - { - return vec<4, T, Q>(v1) /= v2; - } - - // -- Binary bit operators -- - - template - GLM_FUNC_QUALIFIER GLM_CONSTEXPR vec<4, T, Q> operator%(vec<4, T, Q> const& v, T scalar) - { - return vec<4, T, Q>(v) %= scalar; - } - - template - GLM_FUNC_QUALIFIER GLM_CONSTEXPR vec<4, T, Q> operator%(vec<4, T, Q> const& v1, vec<1, T, Q> const& v2) - { - return vec<4, T, Q>(v1) %= v2.x; - } - - template - GLM_FUNC_QUALIFIER GLM_CONSTEXPR vec<4, T, Q> operator%(T scalar, vec<4, T, Q> const& v) - { - return vec<4, T, Q>(scalar) %= v; - } - - template - GLM_FUNC_QUALIFIER GLM_CONSTEXPR vec<4, T, Q> operator%(vec<1, T, Q> const& scalar, vec<4, T, Q> const& v) - { - return vec<4, T, Q>(scalar.x) %= v; - } - - template - GLM_FUNC_QUALIFIER GLM_CONSTEXPR vec<4, T, Q> operator%(vec<4, T, Q> const& v1, vec<4, T, Q> const& v2) - { - return vec<4, T, Q>(v1) %= v2; - } - - template - GLM_FUNC_QUALIFIER GLM_CONSTEXPR vec<4, T, Q> operator&(vec<4, T, Q> const& v, T scalar) - { - return vec<4, T, Q>(v) &= scalar; - } - - template - GLM_FUNC_QUALIFIER GLM_CONSTEXPR vec<4, T, Q> operator&(vec<4, T, Q> const& v, vec<1, T, Q> const& scalar) - { - return vec<4, T, Q>(v) &= scalar; - } - - template - GLM_FUNC_QUALIFIER GLM_CONSTEXPR vec<4, T, Q> operator&(T scalar, vec<4, T, Q> const& v) - { - return vec<4, T, Q>(scalar) &= v; - } - - template - GLM_FUNC_QUALIFIER GLM_CONSTEXPR vec<4, T, Q> operator&(vec<1, T, Q> const& v1, vec<4, T, Q> const& v2) - { - return vec<4, T, Q>(v1.x) &= v2; - } - - template - GLM_FUNC_QUALIFIER GLM_CONSTEXPR vec<4, T, Q> operator&(vec<4, T, Q> const& v1, vec<4, T, Q> const& v2) - { - return vec<4, T, Q>(v1) &= v2; - } - - template - GLM_FUNC_QUALIFIER GLM_CONSTEXPR vec<4, T, Q> operator|(vec<4, T, Q> const& v, T scalar) - { - return vec<4, T, Q>(v) |= scalar; - } - - template - GLM_FUNC_QUALIFIER GLM_CONSTEXPR vec<4, T, Q> operator|(vec<4, T, Q> const& v1, vec<1, T, Q> const& v2) - { - return vec<4, T, Q>(v1) |= v2.x; - } - - template - GLM_FUNC_QUALIFIER GLM_CONSTEXPR vec<4, T, Q> operator|(T scalar, vec<4, T, Q> const& v) - { - return vec<4, T, Q>(scalar) |= v; - } - - template - GLM_FUNC_QUALIFIER GLM_CONSTEXPR vec<4, T, Q> operator|(vec<1, T, Q> const& v1, vec<4, T, Q> const& v2) - { - return vec<4, T, Q>(v1.x) |= v2; - } - - template - GLM_FUNC_QUALIFIER GLM_CONSTEXPR vec<4, T, Q> operator|(vec<4, T, Q> const& v1, vec<4, T, Q> const& v2) - { - return vec<4, T, Q>(v1) |= v2; - } - - template - GLM_FUNC_QUALIFIER GLM_CONSTEXPR vec<4, T, Q> operator^(vec<4, T, Q> const& v, T scalar) - { - return vec<4, T, Q>(v) ^= scalar; - } - - template - GLM_FUNC_QUALIFIER GLM_CONSTEXPR vec<4, T, Q> operator^(vec<4, T, Q> const& v1, vec<1, T, Q> const& v2) - { - return vec<4, T, Q>(v1) ^= v2.x; - } - - template - GLM_FUNC_QUALIFIER GLM_CONSTEXPR vec<4, T, Q> operator^(T scalar, vec<4, T, Q> const& v) - { - return vec<4, T, Q>(scalar) ^= v; - } - - template - GLM_FUNC_QUALIFIER GLM_CONSTEXPR vec<4, T, Q> operator^(vec<1, T, Q> const& v1, vec<4, T, Q> const& v2) - { - return vec<4, T, Q>(v1.x) ^= v2; - } - - template - GLM_FUNC_QUALIFIER GLM_CONSTEXPR vec<4, T, Q> operator^(vec<4, T, Q> const& v1, vec<4, T, Q> const& v2) - { - return vec<4, T, Q>(v1) ^= v2; - } - - template - GLM_FUNC_QUALIFIER GLM_CONSTEXPR vec<4, T, Q> operator<<(vec<4, T, Q> const& v, T scalar) - { - return vec<4, T, Q>(v) <<= scalar; - } - - template - GLM_FUNC_QUALIFIER GLM_CONSTEXPR vec<4, T, Q> operator<<(vec<4, T, Q> const& v1, vec<1, T, Q> const& v2) - { - return vec<4, T, Q>(v1) <<= v2.x; - } - - template - GLM_FUNC_QUALIFIER GLM_CONSTEXPR vec<4, T, Q> operator<<(T scalar, vec<4, T, Q> const& v) - { - return vec<4, T, Q>(scalar) <<= v; - } - - template - GLM_FUNC_QUALIFIER GLM_CONSTEXPR vec<4, T, Q> operator<<(vec<1, T, Q> const& v1, vec<4, T, Q> const& v2) - { - return vec<4, T, Q>(v1.x) <<= v2; - } - - template - GLM_FUNC_QUALIFIER GLM_CONSTEXPR vec<4, T, Q> operator<<(vec<4, T, Q> const& v1, vec<4, T, Q> const& v2) - { - return vec<4, T, Q>(v1) <<= v2; - } - - template - GLM_FUNC_QUALIFIER GLM_CONSTEXPR vec<4, T, Q> operator>>(vec<4, T, Q> const& v, T scalar) - { - return vec<4, T, Q>(v) >>= scalar; - } - - template - GLM_FUNC_QUALIFIER GLM_CONSTEXPR vec<4, T, Q> operator>>(vec<4, T, Q> const& v1, vec<1, T, Q> const& v2) - { - return vec<4, T, Q>(v1) >>= v2.x; - } - - template - GLM_FUNC_QUALIFIER GLM_CONSTEXPR vec<4, T, Q> operator>>(T scalar, vec<4, T, Q> const& v) - { - return vec<4, T, Q>(scalar) >>= v; - } - - template - GLM_FUNC_QUALIFIER GLM_CONSTEXPR vec<4, T, Q> operator>>(vec<1, T, Q> const& v1, vec<4, T, Q> const& v2) - { - return vec<4, T, Q>(v1.x) >>= v2; - } - - template - GLM_FUNC_QUALIFIER GLM_CONSTEXPR vec<4, T, Q> operator>>(vec<4, T, Q> const& v1, vec<4, T, Q> const& v2) - { - return vec<4, T, Q>(v1) >>= v2; - } - template GLM_FUNC_QUALIFIER GLM_CONSTEXPR vec<4, T, Q> operator~(vec<4, T, Q> const& v) { diff --git a/glm/detail/vec_common_ops.hpp b/glm/detail/vec_common_ops.hpp new file mode 100644 index 00000000..beff4f0d --- /dev/null +++ b/glm/detail/vec_common_ops.hpp @@ -0,0 +1,175 @@ +#pragma once + +#include "qualifier.hpp" + +namespace glm { + + template + GLM_FUNC_DECL GLM_CONSTEXPR vec operator+(vec const& v); + + template + GLM_FUNC_DECL GLM_CONSTEXPR vec operator++(vec& v, int); + + template + GLM_FUNC_DECL GLM_CONSTEXPR vec operator--(vec& v, int); + + template + GLM_FUNC_DECL GLM_CONSTEXPR vec& operator+=(vec& v1, U scalar); + template + GLM_FUNC_DECL GLM_CONSTEXPR vec& operator-=(vec& v1, U scalar); + template + GLM_FUNC_DECL GLM_CONSTEXPR vec& operator*=(vec& v1, U scalar); + template + GLM_FUNC_DECL GLM_CONSTEXPR vec& operator/=(vec& v1, U scalar); + template + GLM_FUNC_DECL GLM_CONSTEXPR vec& operator%=(vec& v1, U scalar); + template + GLM_FUNC_DECL GLM_CONSTEXPR vec& operator&=(vec& v1, U scalar); + template + GLM_FUNC_DECL GLM_CONSTEXPR vec& operator|=(vec& v1, U scalar); + template + GLM_FUNC_DECL GLM_CONSTEXPR vec& operator^=(vec& v1, U scalar); + template + GLM_FUNC_DECL GLM_CONSTEXPR vec& operator<<=(vec& v1, U scalar); + template + GLM_FUNC_DECL GLM_CONSTEXPR vec& operator>>=(vec& v1, U scalar); + + template + GLM_FUNC_DECL GLM_CONSTEXPR vec& operator+=(vec& v1, vec<1, U, Q> const& v2); + template + GLM_FUNC_DECL GLM_CONSTEXPR vec& operator-=(vec& v1, vec<1, U, Q> const& v2); + template + GLM_FUNC_DECL GLM_CONSTEXPR vec& operator*=(vec& v1, vec<1, U, Q> const& v2); + template + GLM_FUNC_DECL GLM_CONSTEXPR vec& operator/=(vec& v1, vec<1, U, Q> const& v2); + template + GLM_FUNC_DECL GLM_CONSTEXPR vec& operator%=(vec& v1, vec<1, U, Q> const& v2); + template + GLM_FUNC_DECL GLM_CONSTEXPR vec& operator&=(vec& v1, vec<1, U, Q> const& v2); + template + GLM_FUNC_DECL GLM_CONSTEXPR vec& operator|=(vec& v1, vec<1, U, Q> const& v2); + template + GLM_FUNC_DECL GLM_CONSTEXPR vec& operator^=(vec& v1, vec<1, U, Q> const& v2); + template + GLM_FUNC_DECL GLM_CONSTEXPR vec& operator<<=(vec& v1, vec<1, U, Q> const& v2); + template + GLM_FUNC_DECL GLM_CONSTEXPR vec& operator>>=(vec& v1, vec<1, U, Q> const& v2); + + // vectors + + template + GLM_FUNC_DECL GLM_CONSTEXPR vec operator+(vec const& v1, vec const& v2); + template + GLM_FUNC_DECL GLM_CONSTEXPR vec operator-(vec const& v1, vec const& v2); + template + GLM_FUNC_DECL GLM_CONSTEXPR vec operator*(vec const& v1, vec const& v2); + template + GLM_FUNC_DECL GLM_CONSTEXPR vec operator/(vec const& v1, vec const& v2); + template + GLM_FUNC_DECL GLM_CONSTEXPR vec operator%(vec const& v1, vec const& v2); + template + GLM_FUNC_DECL GLM_CONSTEXPR vec operator&(vec const& v1, vec const& v2); + template + GLM_FUNC_DECL GLM_CONSTEXPR vec operator|(vec const& v1, vec const& v2); + template + GLM_FUNC_DECL GLM_CONSTEXPR vec operator^(vec const& v1, vec const& v2); + template + GLM_FUNC_DECL GLM_CONSTEXPR vec operator<<(vec const& v1, vec const& v2); + template + GLM_FUNC_DECL GLM_CONSTEXPR vec operator>>(vec const& v1, vec const& v2); + + + // Scalars + template + GLM_FUNC_DECL GLM_CONSTEXPR vec operator+(vec const& v, T scalar); + template + GLM_FUNC_DECL GLM_CONSTEXPR vec operator-(vec const& v, T scalar); + template + GLM_FUNC_DECL GLM_CONSTEXPR vec operator*(vec const& v, T scalar); + template + GLM_FUNC_DECL GLM_CONSTEXPR vec operator/(vec const& v, T scalar); + template + GLM_FUNC_DECL GLM_CONSTEXPR vec operator%(vec const& v, T scalar); + template + GLM_FUNC_DECL GLM_CONSTEXPR vec operator&(vec const& v, T scalar); + template + GLM_FUNC_DECL GLM_CONSTEXPR vec operator|(vec const& v, T scalar); + template + GLM_FUNC_DECL GLM_CONSTEXPR vec operator^(vec const& v, T scalar); + template + GLM_FUNC_DECL GLM_CONSTEXPR vec operator<<(vec const& v, T scalar); + template + GLM_FUNC_DECL GLM_CONSTEXPR vec operator>>(vec const& v, T scalar); + + template + GLM_FUNC_DECL GLM_CONSTEXPR vec operator+(T scalar, vec const& v); + template + GLM_FUNC_DECL GLM_CONSTEXPR vec operator-(T scalar, vec const& v); + template + GLM_FUNC_DECL GLM_CONSTEXPR vec operator*(T scalar, vec const& v); + template + GLM_FUNC_DECL GLM_CONSTEXPR vec operator/(T scalar, vec const& v); + template + GLM_FUNC_DECL GLM_CONSTEXPR vec operator%(T scalar, vec const& v); + template + GLM_FUNC_DECL GLM_CONSTEXPR vec operator&(T scalar, vec const& v); + template + GLM_FUNC_DECL GLM_CONSTEXPR vec operator|(T scalar, vec const& v); + template + GLM_FUNC_DECL GLM_CONSTEXPR vec operator^(T scalar, vec const& v); + template + GLM_FUNC_DECL GLM_CONSTEXPR vec operator<<(T scalar, vec const& v); + template + GLM_FUNC_DECL GLM_CONSTEXPR vec operator>>(T scalar, vec const& v); + + //////// vec1 + template + GLM_FUNC_DECL GLM_CONSTEXPR vec operator+(vec const& v1, vec<1, T, Q> const& v2); + template + GLM_FUNC_DECL GLM_CONSTEXPR vec operator-(vec const& v1, vec<1, T, Q> const& v2); + template + GLM_FUNC_DECL GLM_CONSTEXPR vec operator*(vec const& v1, vec<1, T, Q> const& v2); + template + GLM_FUNC_DECL GLM_CONSTEXPR vec operator/(vec const& v1, vec<1, T, Q> const& v2); + template + GLM_FUNC_DECL GLM_CONSTEXPR vec operator%(vec const& v1, vec<1, T, Q> const& v2); + template + GLM_FUNC_DECL GLM_CONSTEXPR vec operator&(vec const& v1, vec<1, T, Q> const& v2); + template + GLM_FUNC_DECL GLM_CONSTEXPR vec operator|(vec const& v1, vec<1, T, Q> const& v2); + template + GLM_FUNC_DECL GLM_CONSTEXPR vec operator^(vec const& v1, vec<1, T, Q> const& v2); + template + GLM_FUNC_DECL GLM_CONSTEXPR vec operator<<(vec const& v1, vec<1, T, Q> const& v2); + template + GLM_FUNC_DECL GLM_CONSTEXPR vec operator>>(vec const& v1, vec<1, T, Q> const& v2); + + template + GLM_FUNC_DECL GLM_CONSTEXPR vec operator+(vec<1, T, Q> const& v1, vec const& v2); + template + GLM_FUNC_DECL GLM_CONSTEXPR vec operator-(vec<1, T, Q> const& v1, vec const& v2); + template + GLM_FUNC_DECL GLM_CONSTEXPR vec operator*(vec<1, T, Q> const& v1, vec const& v2); + template + GLM_FUNC_DECL GLM_CONSTEXPR vec operator/(vec<1, T, Q> const& v1, vec const& v2); + template + GLM_FUNC_DECL GLM_CONSTEXPR vec operator%(vec<1, T, Q> const& v1, vec const& v2); + template + GLM_FUNC_DECL GLM_CONSTEXPR vec operator&(vec<1, T, Q> const& v1, vec const& v2); + template + GLM_FUNC_DECL GLM_CONSTEXPR vec operator|(vec<1, T, Q> const& v1, vec const& v2); + template + GLM_FUNC_DECL GLM_CONSTEXPR vec operator^(vec<1, T, Q> const& v1, vec const& v2); + template + GLM_FUNC_DECL GLM_CONSTEXPR vec operator<<(vec<1, T, Q> const& v1, vec const& v2); + template + GLM_FUNC_DECL GLM_CONSTEXPR vec operator>>(vec<1, T, Q> const& v1, vec const& v2); + + template + GLM_FUNC_DECL GLM_CONSTEXPR bool operator!=(vec const& v1, vec const& v2); + +} + +#ifndef GLM_EXTERNAL_TEMPLATE +#include "vec_common_ops.inl" +#endif//GLM_EXTERNAL_TEMPLATE diff --git a/glm/detail/vec_common_ops.inl b/glm/detail/vec_common_ops.inl new file mode 100644 index 00000000..9f8c1e8b --- /dev/null +++ b/glm/detail/vec_common_ops.inl @@ -0,0 +1,329 @@ +#include "qualifier.hpp" + +namespace glm { + + + template + GLM_FUNC_QUALIFIER GLM_CONSTEXPR vec operator+(vec const& v) { + return v; + } + + template + GLM_FUNC_QUALIFIER GLM_CONSTEXPR vec operator++(vec& v, int) { + vec Result(v); + ++v; + return Result; + } + + template + GLM_FUNC_QUALIFIER GLM_CONSTEXPR vec operator--(vec& v, int) { + vec Result(v); + --v; + return Result; + } + + template + GLM_FUNC_QUALIFIER GLM_CONSTEXPR vec& operator+=(vec& v1, U scalar) { + return v1 += vec(static_cast(scalar)); // cast to T to reduce template instatntions + } + template + GLM_FUNC_QUALIFIER GLM_CONSTEXPR vec& operator-=(vec& v1, U scalar) { + return v1 -= vec(static_cast(scalar)); + } + template + GLM_FUNC_QUALIFIER GLM_CONSTEXPR vec& operator*=(vec& v1, U scalar) { + return v1 *= vec(static_cast(scalar)); + } + template + GLM_FUNC_QUALIFIER GLM_CONSTEXPR vec& operator/=(vec& v1, U scalar) { + return v1 /= vec(static_cast(scalar)); + } + template + GLM_FUNC_QUALIFIER GLM_CONSTEXPR vec& operator%=(vec& v1, U scalar) { + return v1 %= vec(static_cast(scalar)); + } + template + GLM_FUNC_QUALIFIER GLM_CONSTEXPR vec& operator&=(vec& v1, U scalar) { + return v1 &= vec(static_cast(scalar)); + } + template + GLM_FUNC_QUALIFIER GLM_CONSTEXPR vec& operator|=(vec& v1, U scalar) { + return v1 &= vec(static_cast(scalar)); + } + template + GLM_FUNC_QUALIFIER GLM_CONSTEXPR vec& operator^=(vec& v1, U scalar) { + return v1 ^= vec(static_cast(scalar)); + } + template + GLM_FUNC_QUALIFIER GLM_CONSTEXPR vec& operator<<=(vec& v1, U scalar) { + return v1 <<= vec(static_cast(scalar)); + } + template + GLM_FUNC_QUALIFIER GLM_CONSTEXPR vec& operator>>=(vec& v1, U scalar) { + return v1 >>= vec(static_cast(scalar)); + } + + // vec2 + + template + GLM_FUNC_QUALIFIER GLM_CONSTEXPR vec& operator+=(vec& v1, vec<1, U, Q> const& v2) { + return v1 += v2.x; + } + template + GLM_FUNC_QUALIFIER GLM_CONSTEXPR vec& operator-=(vec& v1, vec<1, U, Q> const& v2) { + return v1 -= v2.x; + } + template + GLM_FUNC_QUALIFIER GLM_CONSTEXPR vec& operator*=(vec& v1, vec<1, U, Q> const& v2) { + return v1 *= v2.x; + } + template + GLM_FUNC_QUALIFIER GLM_CONSTEXPR vec& operator/=(vec& v1, vec<1, U, Q> const& v2) { + return v1 /= v2.x; + } + template + GLM_FUNC_QUALIFIER GLM_CONSTEXPR vec& operator%=(vec& v1, vec<1, U, Q> const& v2) { + return v1 %= v2.x; + } + template + GLM_FUNC_QUALIFIER GLM_CONSTEXPR vec& operator&=(vec& v1, vec<1, U, Q> const& v2) { + return v1 &= v2.x; + } + template + GLM_FUNC_QUALIFIER GLM_CONSTEXPR vec& operator|=(vec& v1, vec<1, U, Q> const& v2) { + return v1 |= v2.x; + } + template + GLM_FUNC_QUALIFIER GLM_CONSTEXPR vec& operator^=(vec& v1, vec<1, U, Q> const& v2) { + return v1 ^= v2.x; + } + template + GLM_FUNC_QUALIFIER GLM_CONSTEXPR vec& operator<<=(vec& v1, vec<1, U, Q> const& v2) { + return v1 <<= v2.x; + } + template + GLM_FUNC_QUALIFIER GLM_CONSTEXPR vec& operator>>=(vec& v1, vec<1, U, Q> const& v2) { + return v1 >>= v2.x; + } + + + + // Vectors vs Vectors + template + GLM_FUNC_DECL GLM_CONSTEXPR vec operator+(vec const& v1, vec const& v2) { + return vec(v1) += v2; + } + template + GLM_FUNC_DECL GLM_CONSTEXPR vec operator-(vec const& v1, vec const& v2) { + return vec(v1) -= v2; + } + template + GLM_FUNC_DECL GLM_CONSTEXPR vec operator*(vec const& v1, vec const& v2) { + return vec(v1) *= v2; + } + template + GLM_FUNC_DECL GLM_CONSTEXPR vec operator/(vec const& v1, vec const& v2) { + return vec(v1) /= v2; + } + template + GLM_FUNC_DECL GLM_CONSTEXPR vec operator%(vec const& v1, vec const& v2) { + return vec(v1) %= v2; + } + template + GLM_FUNC_DECL GLM_CONSTEXPR vec operator&(vec const& v1, vec const& v2) { + return vec(v1) &= v2; + } + template + GLM_FUNC_DECL GLM_CONSTEXPR vec operator|(vec const& v1, vec const& v2) { + return vec(v1) |= v2; + } + template + GLM_FUNC_DECL GLM_CONSTEXPR vec operator^(vec const& v1, vec const& v2) { + return vec(v1) ^= v2; + } + template + GLM_FUNC_DECL GLM_CONSTEXPR vec operator<<(vec const& v1, vec const& v2) { + return vec(v1) <<= v2; + } + template + GLM_FUNC_DECL GLM_CONSTEXPR vec operator>>(vec const& v1, vec const& v2) { + return vec(v1) >>= v2; + } + + + // Scalars + template + GLM_FUNC_QUALIFIER GLM_CONSTEXPR vec operator+(vec const& v, T scalar) { + return vec(v) += vec(scalar); + } + template + GLM_FUNC_QUALIFIER GLM_CONSTEXPR vec operator-(vec const& v, T scalar) { + return vec(v) -= vec(scalar); + } + template + GLM_FUNC_QUALIFIER GLM_CONSTEXPR vec operator*(vec const& v, T scalar) { + return vec(v) *= vec(scalar); + } + template + GLM_FUNC_QUALIFIER GLM_CONSTEXPR vec operator/(vec const& v, T scalar) { + return vec(v) /= vec(scalar); + } + template + GLM_FUNC_QUALIFIER GLM_CONSTEXPR vec operator%(vec const& v, T scalar) { + return vec(v) %= vec(scalar); + } + template + GLM_FUNC_QUALIFIER GLM_CONSTEXPR vec operator&(vec const& v, T scalar) { + return vec(v) &= vec(scalar); + } + template + GLM_FUNC_QUALIFIER GLM_CONSTEXPR vec operator|(vec const& v, T scalar) { + return vec(v) |= vec(scalar); + } + template + GLM_FUNC_QUALIFIER GLM_CONSTEXPR vec operator^(vec const& v, T scalar) { + return vec(v) ^= vec(scalar); + } + template + GLM_FUNC_QUALIFIER GLM_CONSTEXPR vec operator<<(vec const& v, T scalar) { + return vec(v) <<= vec(scalar); + } + template + GLM_FUNC_QUALIFIER GLM_CONSTEXPR vec operator>>(vec const& v, T scalar) { + return vec(v) >>= vec(scalar); + } + + template + GLM_FUNC_QUALIFIER GLM_CONSTEXPR vec operator+(T scalar, vec const& v) { + return vec(scalar) += v; + } + template + GLM_FUNC_QUALIFIER GLM_CONSTEXPR vec operator-(T scalar, vec const& v) { + return vec(scalar) -= v; + } + template + GLM_FUNC_QUALIFIER GLM_CONSTEXPR vec operator*(T scalar, vec const& v) { + return vec(scalar) *= v; + } + template + GLM_FUNC_QUALIFIER GLM_CONSTEXPR vec operator/(T scalar, vec const& v) { + return vec(scalar) /= v; + } + template + GLM_FUNC_QUALIFIER GLM_CONSTEXPR vec operator%(T scalar, vec const& v) { + return vec(scalar) %= v; + } + template + GLM_FUNC_QUALIFIER GLM_CONSTEXPR vec operator&(T scalar, vec const& v) { + return vec(scalar) &= v; + } + template + GLM_FUNC_QUALIFIER GLM_CONSTEXPR vec operator|(T scalar, vec const& v) { + return vec(scalar) |= v; + } + template + GLM_FUNC_QUALIFIER GLM_CONSTEXPR vec operator^(T scalar, vec const& v) { + return vec(scalar) ^= v; + } + template + GLM_FUNC_QUALIFIER GLM_CONSTEXPR vec operator<<(T scalar, vec const& v) { + return vec(scalar) <<= v; + } + template + GLM_FUNC_QUALIFIER GLM_CONSTEXPR vec operator>>(T scalar, vec const& v) { + return vec(scalar) >>= v; + } + + + + + /// vec1 + + template + GLM_FUNC_QUALIFIER GLM_CONSTEXPR vec operator+(vec<1, T, Q> const& v1, vec const& v2) { + return v1.x + v2; + } + template + GLM_FUNC_QUALIFIER GLM_CONSTEXPR vec operator-(vec<1, T, Q> const& v1, vec const& v2) { + return v1.x - v2; + } + template + GLM_FUNC_QUALIFIER GLM_CONSTEXPR vec operator*(vec<1, T, Q> const& v1, vec const& v2) { + return v1.x * v2; + } + template + GLM_FUNC_QUALIFIER GLM_CONSTEXPR vec operator/(vec<1, T, Q> const& v1, vec const& v2) { + return v1.x / v2; + } + template + GLM_FUNC_QUALIFIER GLM_CONSTEXPR vec operator%(vec<1, T, Q> const& v1, vec const& v2) { + return v1.x % v2; + } + template + GLM_FUNC_QUALIFIER GLM_CONSTEXPR vec operator&(vec<1, T, Q> const& v1, vec const& v2) { + return v1.x & v2; + } + template + GLM_FUNC_QUALIFIER GLM_CONSTEXPR vec operator|(vec<1, T, Q> const& v1, vec const& v2) { + return v1.x | v2; + } + template + GLM_FUNC_QUALIFIER GLM_CONSTEXPR vec operator^(vec<1, T, Q> const& v1, vec const& v2) { + return v1.x ^ v2; + } + template + GLM_FUNC_QUALIFIER GLM_CONSTEXPR vec operator<<(vec<1, T, Q> const& v1, vec const& v2) { + return v1.x << v2; + } + template + GLM_FUNC_QUALIFIER GLM_CONSTEXPR vec operator>>(vec<1, T, Q> const& v1, vec const& v2) { + return v1.x >> v2; + } + + template + GLM_FUNC_QUALIFIER GLM_CONSTEXPR vec operator+(vec const& v1, vec<1, T, Q> const& v2) { + return v1 + v2.x; + } + template + GLM_FUNC_QUALIFIER GLM_CONSTEXPR vec operator-(vec const& v1, vec<1, T, Q> const& v2) { + return v1 - v2.x; + } + template + GLM_FUNC_QUALIFIER GLM_CONSTEXPR vec operator*(vec const& v1, vec<1, T, Q> const& v2) { + return v1 * v2.x; + } + template + GLM_FUNC_QUALIFIER GLM_CONSTEXPR vec operator/(vec const& v1, vec<1, T, Q> const& v2) { + return v1 / v2.x; + } + template + GLM_FUNC_QUALIFIER GLM_CONSTEXPR vec operator%(vec const& v1, vec<1, T, Q> const& v2) { + return v1 / v2.x; + } + template + GLM_FUNC_QUALIFIER GLM_CONSTEXPR vec operator&(vec const& v1, vec<1, T, Q> const& v2) { + return v1 & v2.x; + } + template + GLM_FUNC_QUALIFIER GLM_CONSTEXPR vec operator|(vec const& v1, vec<1, T, Q> const& v2) { + return v1 | v2.x; + } + template + GLM_FUNC_QUALIFIER GLM_CONSTEXPR vec operator^(vec const& v1, vec<1, T, Q> const& v2) { + return v1 ^ v2.x; + } + template + GLM_FUNC_QUALIFIER GLM_CONSTEXPR vec operator<<(vec const& v1, vec<1, T, Q> const& v2) { + return v1 << v2.x; + } + template + GLM_FUNC_QUALIFIER GLM_CONSTEXPR vec operator>>(vec const& v1, vec<1, T, Q> const& v2) { + return v1 >> v2.x; + } + + + template + GLM_FUNC_QUALIFIER GLM_CONSTEXPR bool operator!=(vec const& v1, vec const& v2) { + return !(v1 == v2); + } +} diff --git a/glm/gtc/type_ptr.inl b/glm/gtc/type_ptr.inl index 4e9ed72f..39df6956 100644 --- a/glm/gtc/type_ptr.inl +++ b/glm/gtc/type_ptr.inl @@ -7,158 +7,26 @@ namespace glm /// @addtogroup gtc_type_ptr /// @{ - template - GLM_FUNC_QUALIFIER T const* value_ptr(vec<1, T, Q> const& v) + template + GLM_FUNC_QUALIFIER T const* value_ptr(vec const& v) { return &(v.x); } - template - GLM_FUNC_QUALIFIER T* value_ptr(vec<1, T, Q>& v) + template + GLM_FUNC_QUALIFIER T* value_ptr(vec& v) { return &(v.x); } - template - GLM_FUNC_QUALIFIER T const* value_ptr(vec<2, T, Q> const& v) - { - return &(v.x); - } - - template - GLM_FUNC_QUALIFIER T* value_ptr(vec<2, T, Q>& v) - { - return &(v.x); - } - - template - GLM_FUNC_QUALIFIER T const * value_ptr(vec<3, T, Q> const& v) - { - return &(v.x); - } - - template - GLM_FUNC_QUALIFIER T* value_ptr(vec<3, T, Q>& v) - { - return &(v.x); - } - - template - GLM_FUNC_QUALIFIER T const* value_ptr(vec<4, T, Q> const& v) - { - return &(v.x); - } - - template - GLM_FUNC_QUALIFIER T* value_ptr(vec<4, T, Q>& v) - { - return &(v.x); - } - - template - GLM_FUNC_QUALIFIER T const* value_ptr(mat<2, 2, T, Q> const& m) + template + GLM_FUNC_QUALIFIER T const* value_ptr(mat const& m) { return &(m[0].x); } - template - GLM_FUNC_QUALIFIER T* value_ptr(mat<2, 2, T, Q>& m) - { - return &(m[0].x); - } - - template - GLM_FUNC_QUALIFIER T const* value_ptr(mat<3, 3, T, Q> const& m) - { - return &(m[0].x); - } - - template - GLM_FUNC_QUALIFIER T* value_ptr(mat<3, 3, T, Q>& m) - { - return &(m[0].x); - } - - template - GLM_FUNC_QUALIFIER T const* value_ptr(mat<4, 4, T, Q> const& m) - { - return &(m[0].x); - } - - template - GLM_FUNC_QUALIFIER T* value_ptr(mat<4, 4, T, Q>& m) - { - return &(m[0].x); - } - - template - GLM_FUNC_QUALIFIER T const* value_ptr(mat<2, 3, T, Q> const& m) - { - return &(m[0].x); - } - - template - GLM_FUNC_QUALIFIER T* value_ptr(mat<2, 3, T, Q>& m) - { - return &(m[0].x); - } - - template - GLM_FUNC_QUALIFIER T const* value_ptr(mat<3, 2, T, Q> const& m) - { - return &(m[0].x); - } - - template - GLM_FUNC_QUALIFIER T* value_ptr(mat<3, 2, T, Q>& m) - { - return &(m[0].x); - } - - template - GLM_FUNC_QUALIFIER T const* value_ptr(mat<2, 4, T, Q> const& m) - { - return &(m[0].x); - } - - template - GLM_FUNC_QUALIFIER T* value_ptr(mat<2, 4, T, Q>& m) - { - return &(m[0].x); - } - - template - GLM_FUNC_QUALIFIER T const* value_ptr(mat<4, 2, T, Q> const& m) - { - return &(m[0].x); - } - - template - GLM_FUNC_QUALIFIER T* value_ptr(mat<4, 2, T, Q>& m) - { - return &(m[0].x); - } - - template - GLM_FUNC_QUALIFIER T const* value_ptr(mat<3, 4, T, Q> const& m) - { - return &(m[0].x); - } - - template - GLM_FUNC_QUALIFIER T* value_ptr(mat<3, 4, T, Q>& m) - { - return &(m[0].x); - } - - template - GLM_FUNC_QUALIFIER T const* value_ptr(mat<4, 3, T, Q> const& m) - { - return &(m[0].x); - } - - template - GLM_FUNC_QUALIFIER T * value_ptr(mat<4, 3, T, Q>& m) + template + GLM_FUNC_QUALIFIER T* value_ptr(mat& m) { return &(m[0].x); } diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index c250a780..a9ac269e 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -24,6 +24,9 @@ if(CMAKE_CXX_COMPILER_ID MATCHES "Clang") add_definitions(-D_CRT_SECURE_NO_WARNINGS) if(NOT GLM_DISABLE_AUTO_DETECTION) add_compile_options(-Werror -Weverything) + if(CMAKE_CXX_COMPILER_VERSION VERSION_GREATER 15) + add_compile_options(-Wno-unsafe-buffer-usage) + endif() endif() elseif(CMAKE_CXX_COMPILER_ID MATCHES "GNU") diff --git a/test/core/core_type_aligned.cpp b/test/core/core_type_aligned.cpp index c29593c5..4fb00b52 100644 --- a/test/core/core_type_aligned.cpp +++ b/test/core/core_type_aligned.cpp @@ -38,6 +38,7 @@ static int test_storage_aligned() static int test_storage_unaligned() { + int Error = 0; size_t align1_unaligned = alignof(glm::detail::storage<1, int, false>::type); @@ -111,3 +112,4 @@ int main() return Error; } +