Browse Source

Non-explicit default constructor for Vector2 and Matrix*.

So you can now write

    mat = {};
    vec = {};

instead of

    mat = Matrix3();
    vec = Vector2();
vectorfields
Vladimír Vondruš 14 years ago
parent
commit
2c52f7b85a
  1. 2
      src/Math/Matrix.h
  2. 2
      src/Math/Matrix3.h
  3. 2
      src/Math/Matrix4.h
  4. 5
      src/Math/Vector2.h

2
src/Math/Matrix.h

@ -62,7 +62,7 @@ template<size_t s, class T> class Matrix: public RectangularMatrix<s, s, T> {
* `Matrix m(Matrix::Identity);`. Optional parameter @p value allows
* you to specify value on diagonal.
*/
inline explicit Matrix(IdentityType = Identity, T value = T(1)) {
inline Matrix(IdentityType = Identity, T value = T(1)) {
for(size_t i = 0; i != size; ++i)
(*this)(i, i) = value;
}

2
src/Math/Matrix3.h

@ -86,7 +86,7 @@ template<class T> class Matrix3: public Matrix<3, T> {
inline constexpr explicit Matrix3(typename Matrix<3, T>::ZeroType): Matrix<3, T>(Matrix<3, T>::Zero) {}
/** @copydoc Matrix::Matrix(IdentityType, T) */
inline constexpr explicit Matrix3(typename Matrix<3, T>::IdentityType = (Matrix<3, T>::Identity), T value = T(1)): Matrix<3, T>(
inline constexpr Matrix3(typename Matrix<3, T>::IdentityType = (Matrix<3, T>::Identity), T value = T(1)): Matrix<3, T>(
value, T(0), T(0),
T(0), value, T(0),
T(0), T(0), value

2
src/Math/Matrix4.h

@ -176,7 +176,7 @@ template<class T> class Matrix4: public Matrix<4, T> {
inline constexpr explicit Matrix4(typename Matrix<4, T>::ZeroType): Matrix<4, T>(Matrix<4, T>::Zero) {}
/** @copydoc Matrix::Matrix(IdentityType, T) */
inline constexpr explicit Matrix4(typename Matrix<4, T>::IdentityType = (Matrix<4, T>::Identity), T value = T(1)): Matrix<4, T>(
inline constexpr Matrix4(typename Matrix<4, T>::IdentityType = (Matrix<4, T>::Identity), T value = T(1)): Matrix<4, T>(
value, T(0), T(0), T(0),
T(0), value, T(0), T(0),
T(0), T(0), value, T(0),

5
src/Math/Vector2.h

@ -70,8 +70,11 @@ template<class T> class Vector2: public Vector<2, T> {
*/
inline constexpr static Vector2<T> yScale(T scale) { return Vector2<T>(T(1), scale); }
/** @copydoc Vector::Vector() */
inline constexpr Vector2() {}
/** @copydoc Vector::Vector(T) */
inline constexpr explicit Vector2(T value = T()): Vector<2, T>(value, value) {}
inline constexpr explicit Vector2(T value): Vector<2, T>(value, value) {}
/** @brief Copy constructor */
inline constexpr Vector2(const RectangularMatrix<1, 2, T>& other): Vector<2, T>(other) {}

Loading…
Cancel
Save