Skip to content

Commit 466de3a

Browse files
committed
math: add vector conversion constructor
JJ: M include/math/seadVector.h
1 parent 7e748b7 commit 466de3a

1 file changed

Lines changed: 13 additions & 0 deletions

File tree

include/math/seadVector.h

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,10 @@ struct Vector2 : public Policies<T>::Vec2Base
1616
Vector2() {}
1717
Vector2(const Vector2& other) = default;
1818
Vector2(T x, T y);
19+
template <typename U>
20+
Vector2(const Vector2<U>& other) : Vector2((T)other.x, (T)other.y)
21+
{
22+
}
1923

2024
Vector2& operator=(const Vector2& other);
2125

@@ -88,6 +92,10 @@ struct Vector3 : public Policies<T>::Vec3Base
8892
Vector3() {}
8993
Vector3(const Vector3& other) = default;
9094
Vector3(T x, T y, T z);
95+
template <typename U>
96+
Vector3(const Vector3<U>& other) : Vector3((T)other.x, (T)other.y, (T)other.z)
97+
{
98+
}
9199

92100
Vector3& operator=(const Vector3& other);
93101
bool operator==(const Vector3& rhs) const;
@@ -143,6 +151,7 @@ struct Vector3 : public Policies<T>::Vec3Base
143151
friend Vector3 operator/(const Vector3& a, T t) { return {a.x / t, a.y / t, a.z / t}; }
144152

145153
Vector3 operator-() const { return {-this->x, -this->y, -this->z}; }
154+
Vector3 operator~() const { return {~this->x, ~this->y, ~this->z}; }
146155

147156
Vector3 cross(const Vector3& t) const
148157
{
@@ -204,6 +213,10 @@ struct Vector4 : public Policies<T>::Vec4Base
204213
Vector4() {}
205214
Vector4(const Vector4& other) = default;
206215
Vector4(T x, T y, T z, T w);
216+
template <typename U>
217+
Vector4(const Vector4<U>& other) : Vector4((T)other.x, (T)other.y, (T)other.z, (T)other.w)
218+
{
219+
}
207220

208221
Vector4& operator=(const Vector4& other);
209222

0 commit comments

Comments
 (0)