Make Vector4 construction from Vector3 take any type
This commit is contained in:
parent
65e6616e5f
commit
6927dee9d7
1 changed files with 12 additions and 14 deletions
|
@ -57,8 +57,8 @@ struct Vector {
|
||||||
template<class T>
|
template<class T>
|
||||||
struct Vector<2, T> {
|
struct Vector<2, T> {
|
||||||
constexpr Vector(const T x_, const T y_) {
|
constexpr Vector(const T x_, const T y_) {
|
||||||
data[0] = x_;
|
x = x_;
|
||||||
data[1] = y_;
|
y = y_;
|
||||||
}
|
}
|
||||||
|
|
||||||
DEFINE_OPERATORS(2)
|
DEFINE_OPERATORS(2)
|
||||||
|
@ -72,14 +72,12 @@ struct Vector<2, T> {
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
using Vector2 = Vector<2, float>;
|
|
||||||
|
|
||||||
template<class T>
|
template<class T>
|
||||||
struct Vector<3, T> {
|
struct Vector<3, T> {
|
||||||
constexpr Vector(const T x_, const T y_, const T z_) {
|
constexpr Vector(const T x_, const T y_, const T z_) {
|
||||||
data[0] = x_;
|
x = x_;
|
||||||
data[1] = y_;
|
y = y_;
|
||||||
data[2] = z_;
|
z = z_;
|
||||||
}
|
}
|
||||||
|
|
||||||
DEFINE_OPERATORS(3)
|
DEFINE_OPERATORS(3)
|
||||||
|
@ -93,18 +91,16 @@ struct Vector<3, T> {
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
using Vector3 = Vector<3, float>;
|
|
||||||
|
|
||||||
template<class T>
|
template<class T>
|
||||||
struct alignas(16) Vector<4, T> {
|
struct alignas(16) Vector<4, T> {
|
||||||
constexpr Vector(const T x_, const T y_, const T z_, const T w_) {
|
constexpr Vector(const T x_, const T y_, const T z_, const T w_) {
|
||||||
data[0] = x_;
|
x = x_;
|
||||||
data[1] = y_;
|
y = y_;
|
||||||
data[2] = z_;
|
z = z_;
|
||||||
data[3] = w_;
|
w = w_;
|
||||||
}
|
}
|
||||||
|
|
||||||
constexpr Vector(const Vector3& v, const float w = 0.0f) : x(v.x), y(v.y), z(v.z), w(w) {}
|
constexpr Vector(const Vector<3, T>& v, const float w = 0.0f) : x(v.x), y(v.y), z(v.z), w(w) {}
|
||||||
|
|
||||||
DEFINE_OPERATORS(4)
|
DEFINE_OPERATORS(4)
|
||||||
|
|
||||||
|
@ -122,6 +118,8 @@ struct alignas(16) Vector<4, T> {
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
using Vector2 = Vector<2, float>;
|
||||||
|
using Vector3 = Vector<3, float>;
|
||||||
using Vector4 = Vector<4, float>;
|
using Vector4 = Vector<4, float>;
|
||||||
|
|
||||||
template<std::size_t N, class T>
|
template<std::size_t N, class T>
|
||||||
|
|
Reference in a new issue