diff --git a/src/Math/Vector.h b/src/Math/Vector.h index 3e781883b..41c8e512b 100644 --- a/src/Math/Vector.h +++ b/src/Math/Vector.h @@ -72,6 +72,15 @@ template class Vector { template inline constexpr Vector(T first, U&&... next); #endif + /** + * @brief Constructor + * @param value Value for all fields + */ + inline explicit Vector(T value) { + for(size_t i = 0; i != size; ++i) + _data[i] = value; + } + /** @brief Copy constructor */ inline constexpr Vector(const Vector& other) = default; diff --git a/src/Math/Vector2.h b/src/Math/Vector2.h index c99c4083c..7dbba24f4 100644 --- a/src/Math/Vector2.h +++ b/src/Math/Vector2.h @@ -36,8 +36,8 @@ template class Vector2: public Vector { return *reinterpret_cast*>(data); } - /** @copydoc Vector::Vector */ - inline constexpr Vector2() {} + /** @copydoc Vector::Vector(T) */ + inline constexpr explicit Vector2(T value = T()): Vector(value, value) {} /** @copydoc Vector::Vector(const Vector&) */ inline constexpr Vector2(const Vector& other): Vector(other) {} diff --git a/src/Math/Vector3.h b/src/Math/Vector3.h index 61aa55770..8c92a5215 100644 --- a/src/Math/Vector3.h +++ b/src/Math/Vector3.h @@ -52,8 +52,8 @@ template class Vector3: public Vector { a[0]*b[1]-a[1]*b[0]); } - /** @copydoc Vector::Vector */ - inline constexpr Vector3() {} + /** @copydoc Vector::Vector(T) */ + inline constexpr explicit Vector3(T value = T()): Vector(value, value, value) {} /** @copydoc Vector::Vector(const Vector&) */ inline constexpr Vector3(const Vector& other): Vector(other) {} diff --git a/src/Math/Vector4.h b/src/Math/Vector4.h index 48491bcec..403e08332 100644 --- a/src/Math/Vector4.h +++ b/src/Math/Vector4.h @@ -43,6 +43,9 @@ template class Vector4: public Vector { */ inline constexpr Vector4(): Vector(T(0), T(0), T(0), T(1)) {} + /** @copydoc Vector::Vector(T) */ + inline constexpr explicit Vector4(T value): Vector(value, value, value, value) {} + /** @copydoc Vector::Vector(const Vector&) */ inline constexpr Vector4(const Vector& other): Vector(other) {}