Browse Source

Fixed Vector, Point and Color constructors from smaller types.

Currently, when accidentaly creating specialized Vector from smaller
number of components than required, the error message isn't really
helpful, as it stops on static assert on wrong number of arguments
passed to RectangularMatrix:

    Vector3(0, 1); // static assert: wrong number of arguments passed to
                   // RectangularMatrix<1, 2> -- wtf?!

Now the first argument is Vector2/Vector3 instead of Vector<2>/Vector<3>
and the error message now properly states that no matching constructor
was found.
pull/279/head
Vladimír Vondruš 14 years ago
parent
commit
6a2ebf5c3d
  1. 2
      src/Color.h
  2. 2
      src/Math/Point2D.h
  3. 2
      src/Math/Point3D.h
  4. 2
      src/Math/Vector3.h
  5. 2
      src/Math/Vector4.h

2
src/Color.h

@ -359,7 +359,7 @@ template<class T> class Color4: public Math::Vector4<T> {
*/
/* Not marked as explicit, because conversion from Color3 to Color4
is fairly common, nearly always with A set to 1 */
inline constexpr Color4(const Math::Vector<3, T>& rgb, T a = Implementation::defaultAlpha<T>()): Math::Vector4<T>(rgb[0], rgb[1], rgb[2], a) {}
inline constexpr Color4(const Math::Vector3<T>& rgb, T a = Implementation::defaultAlpha<T>()): Math::Vector4<T>(rgb[0], rgb[1], rgb[2], a) {}
inline T& r() { return Math::Vector4<T>::x(); } /**< @brief R component */
inline constexpr T r() const { return Math::Vector4<T>::x(); } /**< @overload */

2
src/Math/Point2D.h

@ -57,7 +57,7 @@ template<class T> class Point2D: public Vector3<T> {
* @param xy Two-component vector
* @param z Z component
*/
inline constexpr Point2D(const Vector<2, T>& xy, T z = T(1)): Vector3<T>(xy, z) {}
inline constexpr Point2D(const Vector2<T>& xy, T z = T(1)): Vector3<T>(xy, z) {}
/**
* @brief Vector part of the point

2
src/Math/Point3D.h

@ -58,7 +58,7 @@ template<class T> class Point3D: public Vector4<T> {
* @param xyz Three-component vector
* @param w W component
*/
inline constexpr Point3D(const Vector<3, T>& xyz, T w = T(1)): Vector4<T>(xyz, w) {}
inline constexpr Point3D(const Vector3<T>& xyz, T w = T(1)): Vector4<T>(xyz, w) {}
/**
* @brief Vector part of the point

2
src/Math/Vector3.h

@ -124,7 +124,7 @@ template<class T> class Vector3: public Vector<3, T> {
* @param xy Two-component vector
* @param z Z component
*/
inline constexpr Vector3(const Vector<2, T>& xy, T z): Vector<3, T>(xy[0], xy[1], z) {}
inline constexpr Vector3(const Vector2<T>& xy, T z): Vector<3, T>(xy[0], xy[1], z) {}
inline T& x() { return (*this)[0]; } /**< @brief X component */
inline constexpr T x() const { return (*this)[0]; } /**< @overload */

2
src/Math/Vector4.h

@ -56,7 +56,7 @@ template<class T> class Vector4: public Vector<4, T> {
* @param xyz Three-component vector
* @param w W component
*/
inline constexpr Vector4(const Vector<3, T>& xyz, T w): Vector<4, T>(xyz[0], xyz[1], xyz[2], w) {}
inline constexpr Vector4(const Vector3<T>& xyz, T w): Vector<4, T>(xyz[0], xyz[1], xyz[2], w) {}
inline T& x() { return (*this)[0]; } /**< @brief X component */
inline constexpr T x() const { return (*this)[0]; } /**< @overload */

Loading…
Cancel
Save