Browse Source

Explicit default Matrix constructor.

Nothing like this should ever happen:

    1*Vector3::yAxis() // 1 converted to true, converted to Matrix3.
vectorfields
Vladimír Vondruš 14 years ago
parent
commit
8b69969fbf
  1. 2
      src/Math/Matrix.h
  2. 2
      src/Math/Matrix3.h
  3. 2
      src/Math/Matrix4.h

2
src/Math/Matrix.h

@ -56,7 +56,7 @@ template<class T, size_t size> class Matrix {
* @brief Default constructor
* @param identity Create identity matrix instead of zero matrix.
*/
inline Matrix(bool identity = true): _data() {
inline explicit Matrix(bool identity = true): _data() {
/** @todo constexpr how? */
if(identity) for(size_t i = 0; i != size; ++i)
_data[size*i+i] = static_cast<T>(1);

2
src/Math/Matrix3.h

@ -38,7 +38,7 @@ template<class T> class Matrix3: public Matrix<T, 3> {
}
/** @copydoc Matrix::Matrix(bool) */
inline constexpr Matrix3(bool identity = true): Matrix<T, 3>{
inline constexpr explicit Matrix3(bool identity = true): Matrix<T, 3>{
/** @todo Make this in Matrix itself, after it will be constexpr */
identity ? 1.0f : 0.0f, 0.0f, 0.0f,
0.0f, identity ? 1.0f : 0.0f, 0.0f,

2
src/Math/Matrix4.h

@ -106,7 +106,7 @@ template<class T> class Matrix4: public Matrix<T, 4> {
}
/** @copydoc Matrix::Matrix(bool) */
inline constexpr Matrix4(bool identity = true): Matrix<T, 4>{
inline constexpr explicit Matrix4(bool identity = true): Matrix<T, 4>{
/** @todo Make this in Matrix itself, after it will be constexpr */
identity ? 1.0f : 0.0f, 0.0f, 0.0f, 0.0f,
0.0f, identity ? 1.0f : 0.0f, 0.0f, 0.0f,

Loading…
Cancel
Save