From b845c29ef141a45ae722e6adfe9b7adb0d7f4d28 Mon Sep 17 00:00:00 2001 From: ZXShady <153229951+ZXShady@users.noreply.github.com> Date: Fri, 14 Mar 2025 17:00:59 +0000 Subject: [PATCH] Reuse operators to implement other operators for `glm::mat` --- glm/detail/mat2xR_common_operators.hpp | 54 ++++++ glm/detail/mat2xR_common_operators.inl | 112 +++++++++++ glm/detail/mat3xR_common_operators.hpp | 54 ++++++ glm/detail/mat3xR_common_operators.inl | 120 ++++++++++++ glm/detail/mat4xR_common_operators.hpp | 54 ++++++ glm/detail/mat4xR_common_operators.inl | 128 +++++++++++++ glm/detail/mat_common_operators.hpp | 29 +++ glm/detail/mat_common_operators.inl | 39 ++++ glm/detail/type_mat2x2.hpp | 81 +------- glm/detail/type_mat2x2.inl | 211 --------------------- glm/detail/type_mat2x3.hpp | 61 +----- glm/detail/type_mat2x3.inl | 183 ------------------ glm/detail/type_mat2x4.hpp | 61 +----- glm/detail/type_mat2x4.inl | 183 ------------------ glm/detail/type_mat3x2.hpp | 63 +------ glm/detail/type_mat3x2.inl | 200 -------------------- glm/detail/type_mat3x3.hpp | 73 +------- glm/detail/type_mat3x3.inl | 231 ----------------------- glm/detail/type_mat3x4.hpp | 72 +------ glm/detail/type_mat3x4.inl | 201 -------------------- glm/detail/type_mat4x2.hpp | 63 +------ glm/detail/type_mat4x2.inl | 217 --------------------- glm/detail/type_mat4x3.hpp | 67 +------ glm/detail/type_mat4x3.inl | 217 --------------------- glm/detail/type_mat4x4.hpp | 75 +------- glm/detail/type_mat4x4.inl | 249 ------------------------- util/generate_common_mat_operators.py | 209 +++++++++++++++++++++ 27 files changed, 826 insertions(+), 2481 deletions(-) create mode 100644 glm/detail/mat2xR_common_operators.hpp create mode 100644 glm/detail/mat2xR_common_operators.inl create mode 100644 glm/detail/mat3xR_common_operators.hpp create mode 100644 glm/detail/mat3xR_common_operators.inl create mode 100644 glm/detail/mat4xR_common_operators.hpp create mode 100644 glm/detail/mat4xR_common_operators.inl create mode 100644 glm/detail/mat_common_operators.hpp create mode 100644 glm/detail/mat_common_operators.inl create mode 100644 util/generate_common_mat_operators.py diff --git a/glm/detail/mat2xR_common_operators.hpp b/glm/detail/mat2xR_common_operators.hpp new file mode 100644 index 00000000..1681f38f --- /dev/null +++ b/glm/detail/mat2xR_common_operators.hpp @@ -0,0 +1,54 @@ + +#pragma once +#include "qualifier.hpp" +#include "mat_common_operators.hpp" +namespace glm { + + +template +GLM_FUNC_DECL GLM_CONSTEXPR mat<2,R,T,Q> operator-(mat<2,R,T,Q> const& m); + +template +GLM_FUNC_DECL GLM_CONSTEXPR mat<2,R,T,Q>& operator++(mat<2,R,T,Q>& m); + +template +GLM_FUNC_DECL GLM_CONSTEXPR mat<2,R,T,Q>& operator--(mat<2,R,T,Q>& m); + +template +GLM_FUNC_DECL GLM_CONSTEXPR bool 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+=(mat<2,R,T,Q>& m1, mat<2,R,U,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-=(mat<2,R,T,Q>& m1, mat<2,R,U,Q> const& m2); + +template +GLM_FUNC_DECL GLM_CONSTEXPR mat<2,R, T, Q> operator+(mat<2,R, T, Q> const& m, T scalar); +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-(mat<2,R, T, Q> const& m, T scalar); +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*(mat<2,R, T, Q> const& m, T scalar); +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/(mat<2,R, T, Q> const& m, T scalar); +template +GLM_FUNC_DECL GLM_CONSTEXPR mat<2,R, T, Q> operator/(T scalar,mat<2,R, T, Q> const& m); + +} +#ifndef GLM_EXTERNAL_TEMPLATE +#include "mat2xR_common_operators.inl" +#endif + diff --git a/glm/detail/mat2xR_common_operators.inl b/glm/detail/mat2xR_common_operators.inl new file mode 100644 index 00000000..8eba512d --- /dev/null +++ b/glm/detail/mat2xR_common_operators.inl @@ -0,0 +1,112 @@ + +namespace glm { + + +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]); +} + +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_DECL 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]); +} + +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>& 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> 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>& 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> const& m, T scalar) { + return mat<2,R,T,Q>(m[0] + scalar,m[1] + scalar); +} +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>& 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> const& m, T scalar) { + return mat<2,R,T,Q>(m[0] - scalar,m[1] - scalar); +} +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>& 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> const& m, T scalar) { + return mat<2,R,T,Q>(m[0] * scalar,m[1] * scalar); +} +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>& 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> const& m, T scalar) { + return mat<2,R,T,Q>(m[0] / scalar,m[1] / scalar); +} +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>& m, U scalar) { + m[0] /= scalar; + m[1] /= scalar; + return m; +} + +} + diff --git a/glm/detail/mat3xR_common_operators.hpp b/glm/detail/mat3xR_common_operators.hpp new file mode 100644 index 00000000..6af7e6e9 --- /dev/null +++ b/glm/detail/mat3xR_common_operators.hpp @@ -0,0 +1,54 @@ + +#pragma once +#include "qualifier.hpp" +#include "mat_common_operators.hpp" +namespace glm { + + +template +GLM_FUNC_DECL GLM_CONSTEXPR mat<3,R,T,Q> operator-(mat<3,R,T,Q> const& m); + +template +GLM_FUNC_DECL GLM_CONSTEXPR mat<3,R,T,Q>& operator++(mat<3,R,T,Q>& m); + +template +GLM_FUNC_DECL GLM_CONSTEXPR mat<3,R,T,Q>& operator--(mat<3,R,T,Q>& m); + +template +GLM_FUNC_DECL GLM_CONSTEXPR bool 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); +template +GLM_FUNC_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_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>& m1, mat<3,R,U,Q> const& m2); + +template +GLM_FUNC_DECL GLM_CONSTEXPR mat<3,R, T, Q> operator+(mat<3,R, T, Q> const& m, T scalar); +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-(mat<3,R, T, Q> const& m, T scalar); +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*(mat<3,R, T, Q> const& m, T scalar); +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/(mat<3,R, T, Q> const& m, T scalar); +template +GLM_FUNC_DECL GLM_CONSTEXPR mat<3,R, T, Q> operator/(T scalar,mat<3,R, T, Q> const& m); + +} +#ifndef GLM_EXTERNAL_TEMPLATE +#include "mat3xR_common_operators.inl" +#endif + diff --git a/glm/detail/mat3xR_common_operators.inl b/glm/detail/mat3xR_common_operators.inl new file mode 100644 index 00000000..8ec156ec --- /dev/null +++ b/glm/detail/mat3xR_common_operators.inl @@ -0,0 +1,120 @@ + +namespace glm { + + +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]); +} + +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_DECL 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]); +} + +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>& 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> 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>& 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> const& m, T scalar) { + return mat<3,R,T,Q>(m[0] + scalar,m[1] + scalar,m[2] + scalar); +} +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>& 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> const& m, T scalar) { + return mat<3,R,T,Q>(m[0] - scalar,m[1] - scalar,m[2] - scalar); +} +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>& 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> const& m, T scalar) { + return mat<3,R,T,Q>(m[0] * scalar,m[1] * scalar,m[2] * scalar); +} +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>& 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> const& m, T scalar) { + return mat<3,R,T,Q>(m[0] / scalar,m[1] / scalar,m[2] / scalar); +} +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>& m, U scalar) { + m[0] /= scalar; + m[1] /= scalar; + m[2] /= scalar; + return m; +} + +} + diff --git a/glm/detail/mat4xR_common_operators.hpp b/glm/detail/mat4xR_common_operators.hpp new file mode 100644 index 00000000..2454aa74 --- /dev/null +++ b/glm/detail/mat4xR_common_operators.hpp @@ -0,0 +1,54 @@ + +#pragma once +#include "qualifier.hpp" +#include "mat_common_operators.hpp" +namespace glm { + + +template +GLM_FUNC_DECL GLM_CONSTEXPR mat<4,R,T,Q> operator-(mat<4,R,T,Q> const& m); + +template +GLM_FUNC_DECL GLM_CONSTEXPR mat<4,R,T,Q>& operator++(mat<4,R,T,Q>& m); + +template +GLM_FUNC_DECL GLM_CONSTEXPR mat<4,R,T,Q>& operator--(mat<4,R,T,Q>& m); + +template +GLM_FUNC_DECL GLM_CONSTEXPR bool 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); +template +GLM_FUNC_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_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>& m1, mat<4,R,U,Q> const& m2); + +template +GLM_FUNC_DECL GLM_CONSTEXPR mat<4,R, T, Q> operator+(mat<4,R, T, Q> const& m, T scalar); +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-(mat<4,R, T, Q> const& m, T scalar); +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*(mat<4,R, T, Q> const& m, T scalar); +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/(mat<4,R, T, Q> const& m, T scalar); +template +GLM_FUNC_DECL GLM_CONSTEXPR mat<4,R, T, Q> operator/(T scalar,mat<4,R, T, Q> const& m); + +} +#ifndef GLM_EXTERNAL_TEMPLATE +#include "mat4xR_common_operators.inl" +#endif + diff --git a/glm/detail/mat4xR_common_operators.inl b/glm/detail/mat4xR_common_operators.inl new file mode 100644 index 00000000..732ec789 --- /dev/null +++ b/glm/detail/mat4xR_common_operators.inl @@ -0,0 +1,128 @@ + +namespace glm { + + +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]); +} + +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_DECL 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]); +} + +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>& 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> 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>& 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> const& m, T scalar) { + return mat<4,R,T,Q>(m[0] + scalar,m[1] + scalar,m[2] + scalar,m[3] + scalar); +} +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>& 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> const& m, T scalar) { + return mat<4,R,T,Q>(m[0] - scalar,m[1] - scalar,m[2] - scalar,m[3] - scalar); +} +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>& 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> const& m, T scalar) { + return mat<4,R,T,Q>(m[0] * scalar,m[1] * scalar,m[2] * scalar,m[3] * scalar); +} +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>& 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> const& m, T scalar) { + return mat<4,R,T,Q>(m[0] / scalar,m[1] / scalar,m[2] / scalar,m[3] / scalar); +} +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>& m, U scalar) { + m[0] /= scalar; + m[1] /= scalar; + m[2] /= scalar; + m[3] /= scalar; + return m; +} + +} + diff --git a/glm/detail/mat_common_operators.hpp b/glm/detail/mat_common_operators.hpp new file mode 100644 index 00000000..cfab4b79 --- /dev/null +++ b/glm/detail/mat_common_operators.hpp @@ -0,0 +1,29 @@ +#pragma once + +#include "qualifier.hpp" + +namespace glm { + + 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); + + template + GLM_FUNC_DECL GLM_CONSTEXPR bool operator!=(mat const& m1, mat const& m2); + + template + GLM_FUNC_DECL GLM_CONSTEXPR typename mat::col_type operator/(mat const& m, typename mat::row_type const& v); + + template + GLM_FUNC_DECL GLM_CONSTEXPR typename mat::row_type operator/(typename mat::col_type const& v, mat const& m); + +} + +#ifndef GLM_EXTERNAL_TEMPLATE +#include "mat_common_operators.inl" +#endif diff --git a/glm/detail/mat_common_operators.inl b/glm/detail/mat_common_operators.inl new file mode 100644 index 00000000..63494733 --- /dev/null +++ b/glm/detail/mat_common_operators.inl @@ -0,0 +1,39 @@ +namespace glm { + + 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 mat operator+(mat const& m) { + return m; + } + + template + GLM_FUNC_QUALIFIER GLM_CONSTEXPR bool operator!=(mat const& m1, mat const& m2) { + return !(m1 == m2); + } + + template + GLM_FUNC_QUALIFIER GLM_CONSTEXPR typename mat::col_type operator/(mat const& m, typename mat::row_type const& v) + { + return inverse(m) * v; + } + + template + GLM_FUNC_QUALIFIER GLM_CONSTEXPR typename mat::row_type operator/(typename mat::col_type const& v, mat const& m) + { + return v * inverse(m); + } + +} diff --git a/glm/detail/type_mat2x2.hpp b/glm/detail/type_mat2x2.hpp index 82e9f66c..b2b3f22c 100644 --- a/glm/detail/type_mat2x2.hpp +++ b/glm/detail/type_mat2x2.hpp @@ -3,6 +3,7 @@ #pragma once +#include "mat2xR_common_operators.hpp" #include "type_vec2.hpp" #include #include @@ -27,7 +28,7 @@ namespace glm typedef length_t length_type; GLM_FUNC_DECL static GLM_CONSTEXPR length_type length() { return 2; } - GLM_FUNC_DECL GLM_CONSTEXPR col_type & operator[](length_type i) GLM_NOEXCEPT; + GLM_FUNC_DECL GLM_CONSTEXPR col_type& operator[](length_type i) GLM_NOEXCEPT; GLM_FUNC_DECL GLM_CONSTEXPR col_type const& operator[](length_type i) const GLM_NOEXCEPT; // -- Constructors -- @@ -70,69 +71,16 @@ namespace glm GLM_CTOR_DECL GLM_EXPLICIT mat(mat<3, 4, T, Q> const& x); GLM_CTOR_DECL GLM_EXPLICIT mat(mat<4, 3, T, Q> const& x); - // -- 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_DECL GLM_CONSTEXPR mat& 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_DECL GLM_CONSTEXPR mat& 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); - - // -- 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); + GLM_FUNC_DECL GLM_CONSTEXPR mat& operator/=(mat<2, 2, U, Q> const& m); }; - // -- 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,28 +96,9 @@ 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); - - template - GLM_FUNC_DECL GLM_CONSTEXPR typename mat<2, 2, T, Q>::row_type operator/(typename mat<2, 2, T, Q>::col_type const& v, 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); - // -- 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..5085296c 100644 --- a/glm/detail/type_mat2x2.inl +++ b/glm/detail/type_mat2x2.inl @@ -241,51 +241,6 @@ namespace glm 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) - { - 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) @@ -293,15 +248,6 @@ namespace glm 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) @@ -309,122 +255,6 @@ namespace glm 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,34 +315,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) - { - return inverse(m) * v; - } - - template - GLM_FUNC_QUALIFIER GLM_CONSTEXPR typename mat<2, 2, T, Q>::row_type operator/(typename mat<2, 2, T, Q>::col_type const& v, mat<2, 2, T, Q> const& m) - { - return v * inverse(m); - } - 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) { @@ -520,17 +322,4 @@ namespace glm 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..c9b9402c 100644 --- a/glm/detail/type_mat2x3.hpp +++ b/glm/detail/type_mat2x3.hpp @@ -3,6 +3,7 @@ #pragma once +#include "mat2xR_common_operators.hpp" #include "type_vec2.hpp" #include "type_vec3.hpp" #include @@ -74,56 +75,11 @@ namespace glm // -- Unary arithmetic operators -- 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); + GLM_FUNC_DISCARD_DECL GLM_CONSTEXPR mat& operator=(mat<2, 3, U, Q> const& m); }; - // -- 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 c29666c3..f205f115 100644 --- a/glm/detail/type_mat2x3.inl +++ b/glm/detail/type_mat2x3.inl @@ -241,160 +241,6 @@ 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); - } - template GLM_FUNC_QUALIFIER GLM_CONSTEXPR typename mat<2, 3, T, Q>::col_type operator* ( @@ -463,33 +309,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..99c64846 100644 --- a/glm/detail/type_mat2x4.hpp +++ b/glm/detail/type_mat2x4.hpp @@ -3,6 +3,7 @@ #pragma once +#include "mat2xR_common_operators.hpp" #include "type_vec2.hpp" #include "type_vec4.hpp" #include @@ -76,56 +77,11 @@ namespace glm // -- Unary arithmetic operators -- 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); + GLM_FUNC_DISCARD_DECL GLM_CONSTEXPR mat& operator=(mat<2, 4, U, Q> const& m); }; - // -- 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 +97,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 bde07ced..27a714b0 100644 --- a/glm/detail/type_mat2x4.inl +++ b/glm/detail/type_mat2x4.inl @@ -243,160 +243,6 @@ namespace glm 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) { @@ -469,33 +315,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..58765cc8 100644 --- a/glm/detail/type_mat3x2.hpp +++ b/glm/detail/type_mat3x2.hpp @@ -3,6 +3,7 @@ #pragma once +#include "mat3xR_common_operators.hpp" #include "type_vec2.hpp" #include "type_vec3.hpp" #include @@ -81,56 +82,11 @@ namespace glm // -- Unary arithmetic operators -- 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); + GLM_FUNC_DISCARD_DECL GLM_CONSTEXPR mat& operator=(mat<3, 2, U, Q> const& m); }; // -- 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); @@ -145,21 +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 dc7654d1..5d2c9609 100644 --- a/glm/detail/type_mat3x2.inl +++ b/glm/detail/type_mat3x2.inl @@ -261,175 +261,6 @@ 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) { @@ -483,35 +314,4 @@ 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..4a397cbb 100644 --- a/glm/detail/type_mat3x3.hpp +++ b/glm/detail/type_mat3x3.hpp @@ -3,6 +3,7 @@ #pragma once +#include "mat3xR_common_operators.hpp" #include "type_vec3.hpp" #include #include @@ -80,66 +81,15 @@ namespace glm // -- Unary arithmetic operators -- 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); + GLM_FUNC_DISCARD_DECL GLM_CONSTEXPR mat& 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); 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); }; // -- 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,28 +105,9 @@ 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); - - template - GLM_FUNC_DECL GLM_CONSTEXPR typename mat<3, 3, T, Q>::row_type operator/(typename mat<3, 3, T, Q>::col_type const& v, 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); - // -- 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 d81bdf29..4bf4451d 100644 --- a/glm/detail/type_mat3x3.inl +++ b/glm/detail/type_mat3x3.inl @@ -264,57 +264,6 @@ namespace glm 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) - { - 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) @@ -322,16 +271,6 @@ namespace glm 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) @@ -339,133 +278,6 @@ namespace glm 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) { @@ -578,36 +390,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) - { - return inverse(m) * v; - } - - template - GLM_FUNC_QUALIFIER GLM_CONSTEXPR typename mat<3, 3, T, Q>::row_type operator/(typename mat<3, 3, T, Q>::col_type const& v, mat<3, 3, T, Q> const& m) - { - return v * inverse(m); - } - 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) { @@ -615,17 +397,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..ded2c351 100644 --- a/glm/detail/type_mat3x4.hpp +++ b/glm/detail/type_mat3x4.hpp @@ -3,6 +3,7 @@ #pragma once +#include "mat3xR_common_operators.hpp" #include "type_vec3.hpp" #include "type_vec4.hpp" #include @@ -28,7 +29,7 @@ namespace glm typedef length_t length_type; GLM_FUNC_DECL static GLM_CONSTEXPR length_type length() { return 3; } - GLM_FUNC_DECL GLM_CONSTEXPR col_type & operator[](length_type i) GLM_NOEXCEPT; + GLM_FUNC_DECL GLM_CONSTEXPR col_type& operator[](length_type i) GLM_NOEXCEPT; GLM_FUNC_DECL GLM_CONSTEXPR col_type const& operator[](length_type i) const GLM_NOEXCEPT; // -- Constructors -- @@ -78,59 +79,11 @@ 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 -- + template + GLM_FUNC_DECL GLM_CONSTEXPR mat& operator=(mat<3, 4, U, Q> const& m); - 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); @@ -138,27 +91,14 @@ namespace glm GLM_FUNC_DECL 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); template - GLM_FUNC_DECL GLM_CONSTEXPR mat<4, 4, T, Q> operator*(mat<3, 4, T, Q> const& m1, mat<4, 3, T, Q> const& m2); + GLM_FUNC_DECL GLM_CONSTEXPR mat<4, 4, T, Q> operator*(mat<3, 4, T, Q> const& m1, mat<4, 3, T, Q> const& m2); template GLM_FUNC_DECL GLM_CONSTEXPR mat<2, 4, T, Q> operator*(mat<3, 4, T, Q> const& m1, mat<2, 3, T, Q> const& m2); 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); + 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 a4afac0d..7c1cd6bd 100644 --- a/glm/detail/type_mat3x4.inl +++ b/glm/detail/type_mat3x4.inl @@ -267,175 +267,6 @@ 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* ( @@ -516,36 +347,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..4425ed6c 100644 --- a/glm/detail/type_mat4x2.hpp +++ b/glm/detail/type_mat4x2.hpp @@ -3,6 +3,7 @@ #pragma once +#include "mat4xR_common_operators.hpp" #include "type_vec2.hpp" #include "type_vec4.hpp" #include @@ -83,59 +84,12 @@ namespace glm GLM_CTOR_DECL mat(mat<4, 3, T, Q> const& x); GLM_CTOR_DECL mat(mat<3, 4, T, Q> const& x); - // -- Unary arithmetic operators -- - 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); + GLM_FUNC_DECL GLM_CONSTEXPR mat& operator=(mat<4, 2, U, Q> const& m); }; // -- 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 +105,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 0b7ff048..0ef59a55 100644 --- a/glm/detail/type_mat4x2.inl +++ b/glm/detail/type_mat4x2.inl @@ -281,190 +281,6 @@ 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) { @@ -519,37 +335,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..357cd6bb 100644 --- a/glm/detail/type_mat4x3.hpp +++ b/glm/detail/type_mat4x3.hpp @@ -3,6 +3,7 @@ #pragma once +#include "mat4xR_common_operators.hpp" #include "type_vec3.hpp" #include "type_vec4.hpp" #include @@ -28,7 +29,7 @@ namespace glm typedef length_t length_type; GLM_FUNC_DECL static GLM_CONSTEXPR length_type length() { return 4; } - GLM_FUNC_DECL GLM_CONSTEXPR col_type & operator[](length_type i) GLM_NOEXCEPT; + GLM_FUNC_DECL GLM_CONSTEXPR col_type& operator[](length_type i) GLM_NOEXCEPT; GLM_FUNC_DECL GLM_CONSTEXPR col_type const& operator[](length_type i) const GLM_NOEXCEPT; // -- Constructors -- @@ -83,58 +84,11 @@ namespace glm GLM_CTOR_DECL mat(mat<4, 2, T, Q> const& x); GLM_CTOR_DECL mat(mat<3, 4, T, Q> const& x); - // -- Unary arithmetic operators -- 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); + GLM_FUNC_DECL GLM_CONSTEXPR mat& operator=(mat<4, 3, U, Q> const& m); }; - // -- 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); @@ -146,24 +100,11 @@ namespace glm GLM_FUNC_DECL GLM_CONSTEXPR mat<2, 3, T, Q> operator*(mat<4, 3, T, Q> const& m1, mat<2, 4, T, Q> const& m2); template - GLM_FUNC_DECL GLM_CONSTEXPR mat<3, 3, T, Q> operator*(mat<4, 3, T, Q> const& m1, mat<3, 4, T, Q> const& m2); + GLM_FUNC_DECL GLM_CONSTEXPR mat<3, 3, T, Q> operator*(mat<4, 3, T, Q> const& m1, mat<3, 4, T, Q> const& m2); 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 ab438ffc..9284e82b 100644 --- a/glm/detail/type_mat4x3.inl +++ b/glm/detail/type_mat4x3.inl @@ -281,190 +281,6 @@ 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* ( @@ -535,37 +351,4 @@ 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..51824aed 100644 --- a/glm/detail/type_mat4x4.hpp +++ b/glm/detail/type_mat4x4.hpp @@ -3,6 +3,7 @@ #pragma once +#include "mat4xR_common_operators.hpp" #include "type_vec4.hpp" #include #include @@ -85,66 +86,13 @@ namespace glm // -- Unary arithmetic 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+=(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); + GLM_FUNC_DISCARD_DECL GLM_CONSTEXPR mat& 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); 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 -- - - 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,28 +108,9 @@ 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); - - template - GLM_FUNC_DECL GLM_CONSTEXPR typename mat<4, 4, T, Q>::row_type operator/(typename mat<4, 4, T, Q>::col_type const& v, 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); - // -- 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 9b812034..2d4cf176 100644 --- a/glm/detail/type_mat4x4.inl +++ b/glm/detail/type_mat4x4.inl @@ -315,61 +315,6 @@ namespace glm 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) - { - 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) @@ -377,17 +322,6 @@ namespace glm 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) @@ -395,144 +329,6 @@ namespace glm 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* ( @@ -706,38 +502,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) - { - return inverse(m) * v; - } - - template - GLM_FUNC_QUALIFIER GLM_CONSTEXPR typename mat<4, 4, T, Q>::row_type operator/(typename mat<4, 4, T, Q>::col_type const& v, mat<4, 4, T, Q> const& m) - { - return v * inverse(m); - } - 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) { @@ -745,19 +509,6 @@ namespace glm return m1_copy /= m2; } - // -- 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/util/generate_common_mat_operators.py b/util/generate_common_mat_operators.py new file mode 100644 index 00000000..500c1216 --- /dev/null +++ b/util/generate_common_mat_operators.py @@ -0,0 +1,209 @@ +import itertools +import sys + +def make_unary_minus(column_count,filename): + mat_def = f"mat<{column_count},R,T,Q>" + sys.stdout = open(f"{filename}.hpp", 'a') + print(f""" +template +GLM_FUNC_DECL GLM_CONSTEXPR {mat_def} operator-({mat_def} const& m); +""" ,end="") + sys.stdout.close() + + sys.stdout = open(f"{filename}.inl", 'a') + print(f""" +template +GLM_FUNC_QUALIFIER GLM_CONSTEXPR {mat_def} operator-({mat_def} const& m) {{ + return {mat_def}({",".join([f"-m[{i}]" for i in range(0,column_count)])}); +}} +""" ,end="") + sys.stdout.close() + + + + + + +def make_prefix_incr_decr_funcs(column_count,filename): + op_symbols = ["++","--"] + sys.stdout = open(f"{filename}.hpp", 'a') + mat_def = f"mat<{column_count},R,T,Q>" + for op_symbol in op_symbols: + print(f""" +template +GLM_FUNC_DECL GLM_CONSTEXPR {mat_def}& operator{op_symbol}({mat_def}& m); +""" ,end="") + sys.stdout.close() + + sys.stdout = open(f"{filename}.inl", 'a') + for op_symbol in op_symbols: + print(f""" +template +GLM_FUNC_QUALIFIER GLM_CONSTEXPR {mat_def}& operator{op_symbol}({mat_def}& m) {{ + {" ".join([f"{op_symbol}m[{i}];" + ("\n" if i != column_count-1 else "") for i in range(0,column_count)])} + return m; +}} +""" ,end="") + sys.stdout.close() + + + + +def make_equality_funcs(column_count,filename): + sys.stdout = open(f"{filename}.hpp", 'a') + mat_def = f"mat<{column_count},R,T,Q>" + print(f""" +template +GLM_FUNC_DECL GLM_CONSTEXPR bool operator==({mat_def} const& m1, {mat_def} const& m2); +""" ,end="") + sys.stdout.close() + + sys.stdout = open(f"{filename}.inl", 'a') + print(f""" +template +GLM_FUNC_DECL GLM_CONSTEXPR bool operator==({mat_def} const& m1, {mat_def} const& m2) {{ + return {" && ".join([f"(m1[{i}] == m2[{i}])" for i in range(0,column_count)])}; +}} +""" ,end="") + sys.stdout.close() + +def make_binary_scalar_funcs(op_symbols,column_count,filename): + mat_def = f"mat<{column_count},R,T,Q>" + col_range = range(0,column_count) + template = """ +template +GLM_FUNC_DECL GLM_CONSTEXPR mat<{column_count},R, T, Q> operator{op_symbol}(mat<{column_count},R, T, Q> const& m, T scalar); +template +GLM_FUNC_DECL GLM_CONSTEXPR mat<{column_count},R, T, Q> operator{op_symbol}(T scalar,mat<{column_count},R, T, Q> const& m); +""" + sys.stdout = open(f"{filename}.hpp", 'a') + for op_symbol in op_symbols: + print(template.format( + op_symbol= op_symbol, + column_count= column_count + ),end="") + sys.stdout.close() + + + sys.stdout = open(f"{filename}.inl", 'a') + for op_symbol in op_symbols: + print(f""" +template +GLM_FUNC_QUALIFIER GLM_CONSTEXPR mat<{column_count},R, T, Q> operator{op_symbol}(mat<{column_count},R, T, Q> const& m, T scalar) {{ + return mat<{column_count},R,T,Q>({",".join([f"m[{i}] {op_symbol} scalar" for i in range(0,column_count)])}); +}} +template +GLM_FUNC_QUALIFIER GLM_CONSTEXPR mat<{column_count},R, T, Q> operator{op_symbol}(T scalar,mat<{column_count},R, T, Q> const& m) {{ + return mat<{column_count},R,T,Q>({",".join([f"scalar {op_symbol} m[{i}]" for i in range(0,column_count)])}); +}} +template +GLM_FUNC_QUALIFIER GLM_CONSTEXPR {mat_def}& operator{op_symbol}=({mat_def}& m, U scalar) {{ + {" ".join([f"m[{i}] {op_symbol}= scalar;" + ("\n" if i != col_range.stop-1 else "") for i in col_range])} + return m; +}} +""",end="") + sys.stdout.close() + + +def make_binary_mat_funcs(op_symbols,column_count,filename): + col_range = range(0,column_count) + mat_def = f"mat<{column_count},R,T,Q>" + mat_def_U = f"mat<{column_count},R,U,Q>" + + sys.stdout = open(f"{filename}.hpp", 'a') + for op_symbol in op_symbols: + + print(f""" +template +GLM_FUNC_DECL GLM_CONSTEXPR {mat_def} operator{op_symbol}({mat_def} const& m1, {mat_def} const& m2); +template +GLM_FUNC_DECL GLM_CONSTEXPR {mat_def}& operator{op_symbol}=({mat_def}& m1, {mat_def_U} const& m2); +""",end="") + sys.stdout.close() + + + sys.stdout = open(f"{filename}.inl", 'a') + for op_symbol in op_symbols: + print(f""" +template +GLM_FUNC_QUALIFIER GLM_CONSTEXPR {mat_def} operator{op_symbol}({mat_def} const& m1, {mat_def} const& m2) {{ + return {mat_def}({",".join([f"m1[{i}] {op_symbol} m2[{i}]" for i in col_range])}); +}} +template +GLM_FUNC_QUALIFIER GLM_CONSTEXPR {mat_def}& operator{op_symbol}=({mat_def}& m1, {mat_def_U} const& m2) {{ + {" ".join([f"m1[{i}] {op_symbol}= m2[{i}];" + ("\n" if i != col_range.stop-1 else "") for i in col_range])} + return m1; +}} +""",end="") + sys.stdout.close() + + +def make_scalar_commutative_operators(op_symbols,filename): + template = """ +template +GLM_FUNC_DECL GLM_CONSTEXPR vec operator{op_symbol}(T scalar,vec const& v); +""" + sys.stdout = open(f"{filename}.hpp", 'a') + for op_symbol in op_symbols: + print(template.format( + op_symbol= op_symbol + ),end="") + sys.stdout.close() + + template = """ +template +GLM_FUNC_QUALIFIER GLM_CONSTEXPR vec operator{op_symbol}(T scalar,vec const& v) {{ + return v {op_symbol} scalar; +}} +""" + sys.stdout = open(f"{filename}.inl", 'a') + for op_symbol in op_symbols: + print(template.format( + op_symbol= op_symbol + ),end="") + sys.stdout.close() + + + + +if __name__ == "__main__": + for C in range(2,5): + filename = f"mat{C}xR_common_operators" + sys.stdout = open(f"{filename}.hpp",'w') + print(""" +#pragma once +#include "qualifier.hpp" +#include "mat_common_operators.hpp" +namespace glm { +""") + sys.stdout.close() + + sys.stdout = open(f"{filename}.inl",'w') + print(""" +namespace glm { +""") + sys.stdout.close() + + make_unary_minus(C,filename) + make_prefix_incr_decr_funcs(C,filename) + make_equality_funcs(C,filename) + make_binary_mat_funcs(['+', '-'],C,filename) + make_binary_scalar_funcs(['+', '-', '*','/'],C,filename) + + sys.stdout = open(f"{filename}.hpp",'a') + print(f""" +}} +#ifndef GLM_EXTERNAL_TEMPLATE +#include "{filename}.inl" +#endif +""") + sys.stdout.close() + + + sys.stdout = open(f"{filename}.inl",'a') + print(""" +} +""") + sys.stdout.close() + + #make_scalar_commutative_operators(['+', '*'],"mat") \ No newline at end of file