Make mat4x4 binary operators for scalars consistent with other types

This commit is contained in:
Roger Leigh 2022-09-19 21:05:26 +01:00
parent 32c2bb8296
commit 7da7f7c887
2 changed files with 50 additions and 50 deletions

View File

@ -36,7 +36,7 @@ namespace glm
template<qualifier P>
GLM_FUNC_DECL GLM_CONSTEXPR mat(mat<4, 4, T, P> const& m);
GLM_FUNC_DECL explicit GLM_CONSTEXPR mat(T const& x);
GLM_FUNC_DECL explicit GLM_CONSTEXPR mat(T s);
GLM_FUNC_DECL GLM_CONSTEXPR mat(
T const& x0, T const& y0, T const& z0, T const& w0,
T const& x1, T const& y1, T const& z1, T const& w1,
@ -122,28 +122,28 @@ namespace glm
// -- Binary operators --
template<typename T, qualifier Q>
GLM_FUNC_DECL mat<4, 4, T, Q> operator+(mat<4, 4, T, Q> const& m, T const& s);
GLM_FUNC_DECL mat<4, 4, T, Q> operator+(mat<4, 4, T, Q> const& m, T scalar);
template<typename T, qualifier Q>
GLM_FUNC_DECL mat<4, 4, T, Q> operator+(T const& s, mat<4, 4, T, Q> const& m);
GLM_FUNC_DECL mat<4, 4, T, Q> operator+(T scalar, mat<4, 4, T, Q> const& m);
template<typename T, qualifier Q>
GLM_FUNC_DECL mat<4, 4, T, Q> operator+(mat<4, 4, T, Q> const& m1, mat<4, 4, T, Q> const& m2);
template<typename T, qualifier Q>
GLM_FUNC_DECL mat<4, 4, T, Q> operator-(mat<4, 4, T, Q> const& m, T const& s);
GLM_FUNC_DECL mat<4, 4, T, Q> operator-(mat<4, 4, T, Q> const& m, T scalar);
template<typename T, qualifier Q>
GLM_FUNC_DECL mat<4, 4, T, Q> operator-(T const& s, mat<4, 4, T, Q> const& m);
GLM_FUNC_DECL mat<4, 4, T, Q> operator-(T scalar, mat<4, 4, T, Q> const& m);
template<typename T, qualifier Q>
GLM_FUNC_DECL mat<4, 4, T, Q> operator-(mat<4, 4, T, Q> const& m1, mat<4, 4, T, Q> const& m2);
template<typename T, qualifier Q>
GLM_FUNC_DECL mat<4, 4, T, Q> operator*(mat<4, 4, T, Q> const& m, T const& s);
GLM_FUNC_DECL mat<4, 4, T, Q> operator*(mat<4, 4, T, Q> const& m, T scalar);
template<typename T, qualifier Q>
GLM_FUNC_DECL mat<4, 4, T, Q> operator*(T const& s, mat<4, 4, T, Q> const& m);
GLM_FUNC_DECL mat<4, 4, T, Q> operator*(T scalar, mat<4, 4, T, Q> const& m);
template<typename T, qualifier Q>
GLM_FUNC_DECL 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);
@ -161,10 +161,10 @@ namespace glm
GLM_FUNC_DECL mat<4, 4, T, Q> operator*(mat<4, 4, T, Q> const& m1, mat<4, 4, T, Q> const& m2);
template<typename T, qualifier Q>
GLM_FUNC_DECL mat<4, 4, T, Q> operator/(mat<4, 4, T, Q> const& m, T const& s);
GLM_FUNC_DECL mat<4, 4, T, Q> operator/(mat<4, 4, T, Q> const& m, T scalar);
template<typename T, qualifier Q>
GLM_FUNC_DECL mat<4, 4, T, Q> operator/(T const& s, mat<4, 4, T, Q> const& m);
GLM_FUNC_DECL mat<4, 4, T, Q> operator/(T scalar, mat<4, 4, T, Q> const& m);
template<typename T, qualifier Q>
GLM_FUNC_DECL 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);

View File

@ -36,7 +36,7 @@ namespace glm
}
template<typename T, qualifier Q>
GLM_FUNC_QUALIFIER GLM_CONSTEXPR mat<4, 4, T, Q>::mat(T const& s)
GLM_FUNC_QUALIFIER GLM_CONSTEXPR mat<4, 4, T, Q>::mat(T s)
# if GLM_HAS_INITIALIZER_LISTS
: value{col_type(s, 0, 0, 0), col_type(0, s, 0, 0), col_type(0, 0, s, 0), col_type(0, 0, 0, s)}
# endif
@ -453,23 +453,23 @@ namespace glm
// -- Binary arithmetic operators --
template<typename T, qualifier Q>
GLM_FUNC_QUALIFIER mat<4, 4, T, Q> operator+(mat<4, 4, T, Q> const& m, T const& s)
GLM_FUNC_QUALIFIER mat<4, 4, T, Q> operator+(mat<4, 4, T, Q> const& m, T scalar)
{
return mat<4, 4, T, Q>(
m[0] + s,
m[1] + s,
m[2] + s,
m[3] + s);
m[0] + scalar,
m[1] + scalar,
m[2] + scalar,
m[3] + scalar);
}
template<typename T, qualifier Q>
GLM_FUNC_QUALIFIER mat<4, 4, T, Q> operator+(T const& s, mat<4, 4, T, Q> const& m)
GLM_FUNC_QUALIFIER mat<4, 4, T, Q> operator+(T scalar, mat<4, 4, T, Q> const& m)
{
return mat<4, 4, T, Q>(
m[0] + s,
m[1] + s,
m[2] + s,
m[3] + s);
m[0] + scalar,
m[1] + scalar,
m[2] + scalar,
m[3] + scalar);
}
template<typename T, qualifier Q>
@ -483,23 +483,23 @@ namespace glm
}
template<typename T, qualifier Q>
GLM_FUNC_QUALIFIER mat<4, 4, T, Q> operator-(mat<4, 4, T, Q> const& m, T const& s)
GLM_FUNC_QUALIFIER mat<4, 4, T, Q> operator-(mat<4, 4, T, Q> const& m, T scalar)
{
return mat<4, 4, T, Q>(
m[0] - s,
m[1] - s,
m[2] - s,
m[3] - s);
m[0] - scalar,
m[1] - scalar,
m[2] - scalar,
m[3] - scalar);
}
template<typename T, qualifier Q>
GLM_FUNC_QUALIFIER mat<4, 4, T, Q> operator-(T const& s, mat<4, 4, T, Q> const& m)
GLM_FUNC_QUALIFIER mat<4, 4, T, Q> operator-(T scalar, mat<4, 4, T, Q> const& m)
{
return mat<4, 4, T, Q>(
s - m[0],
s - m[1],
s - m[2],
s - m[3]);
scalar - m[0],
scalar - m[1],
scalar - m[2],
scalar - m[3]);
}
template<typename T, qualifier Q>
@ -513,23 +513,23 @@ namespace glm
}
template<typename T, qualifier Q>
GLM_FUNC_QUALIFIER mat<4, 4, T, Q> operator*(mat<4, 4, T, Q> const& m, T const & s)
GLM_FUNC_QUALIFIER mat<4, 4, T, Q> operator*(mat<4, 4, T, Q> const& m, T scalar)
{
return mat<4, 4, T, Q>(
m[0] * s,
m[1] * s,
m[2] * s,
m[3] * s);
m[0] * scalar,
m[1] * scalar,
m[2] * scalar,
m[3] * scalar);
}
template<typename T, qualifier Q>
GLM_FUNC_QUALIFIER mat<4, 4, T, Q> operator*(T const& s, mat<4, 4, T, Q> const& m)
GLM_FUNC_QUALIFIER mat<4, 4, T, Q> operator*(T scalar, mat<4, 4, T, Q> const& m)
{
return mat<4, 4, T, Q>(
m[0] * s,
m[1] * s,
m[2] * s,
m[3] * s);
m[0] * scalar,
m[1] * scalar,
m[2] * scalar,
m[3] * scalar);
}
template<typename T, qualifier Q>
@ -648,23 +648,23 @@ namespace glm
}
template<typename T, qualifier Q>
GLM_FUNC_QUALIFIER mat<4, 4, T, Q> operator/(mat<4, 4, T, Q> const& m, T const& s)
GLM_FUNC_QUALIFIER mat<4, 4, T, Q> operator/(mat<4, 4, T, Q> const& m, T scalar)
{
return mat<4, 4, T, Q>(
m[0] / s,
m[1] / s,
m[2] / s,
m[3] / s);
m[0] / scalar,
m[1] / scalar,
m[2] / scalar,
m[3] / scalar);
}
template<typename T, qualifier Q>
GLM_FUNC_QUALIFIER mat<4, 4, T, Q> operator/(T const& s, mat<4, 4, T, Q> const& m)
GLM_FUNC_QUALIFIER mat<4, 4, T, Q> operator/(T scalar, mat<4, 4, T, Q> const& m)
{
return mat<4, 4, T, Q>(
s / m[0],
s / m[1],
s / m[2],
s / m[3]);
scalar / m[0],
scalar / m[1],
scalar / m[2],
scalar / m[3]);
}
template<typename T, qualifier Q>