diff --git a/Source/Core/Common/Matrix.h b/Source/Core/Common/Matrix.h index b47e24f03d..ff4ab71c73 100644 --- a/Source/Core/Common/Matrix.h +++ b/Source/Core/Common/Matrix.h @@ -20,6 +20,11 @@ union TVec3 TVec3() = default; TVec3(T _x, T _y, T _z) : data{_x, _y, _z} {} + template + explicit TVec3(const TVec3& other) : TVec3(other.x, other.y, other.z) + { + } + TVec3 Cross(const TVec3& rhs) const { return {(y * rhs.z) - (rhs.y * z), (z * rhs.x) - (rhs.z * x), (x * rhs.y) - (rhs.x * y)}; @@ -98,6 +103,11 @@ TVec3 operator<(const TVec3& lhs, const TVec3& rhs) return lhs.Map(std::less{}, rhs); } +inline TVec3 operator!(const TVec3& vec) +{ + return {!vec.x, !vec.y, !vec.z}; +} + template auto operator+(const TVec3& lhs, const TVec3& rhs) -> TVec3 { @@ -197,6 +207,11 @@ union TVec2 TVec2() = default; TVec2(T _x, T _y) : data{_x, _y} {} + template + explicit TVec2(const TVec2& other) : TVec2(other.x, other.y) + { + } + T Cross(const TVec2& rhs) const { return (x * rhs.y) - (y * rhs.x); } T Dot(const TVec2& rhs) const { return (x * rhs.x) + (y * rhs.y); } T LengthSquared() const { return Dot(*this); } @@ -217,6 +232,20 @@ union TVec2 return *this; } + TVec2& operator*=(const TVec2& rhs) + { + x *= rhs.x; + y *= rhs.y; + return *this; + } + + TVec2& operator/=(const TVec2& rhs) + { + x /= rhs.x; + y /= rhs.y; + return *this; + } + TVec2& operator*=(T scalar) { x *= scalar; @@ -242,6 +271,17 @@ union TVec2 }; }; +template +TVec2 operator<(const TVec2& lhs, const TVec2& rhs) +{ + return {lhs.x < rhs.x, lhs.y < rhs.y}; +} + +inline TVec2 operator!(const TVec2& vec) +{ + return {!vec.x, !vec.y}; +} + template TVec2 operator+(TVec2 lhs, const TVec2& rhs) { @@ -255,15 +295,27 @@ TVec2 operator-(TVec2 lhs, const TVec2& rhs) } template -TVec2 operator*(TVec2 lhs, T scalar) +TVec2 operator*(TVec2 lhs, const TVec2& rhs) { - return lhs *= scalar; + return lhs *= rhs; } template -TVec2 operator/(TVec2 lhs, T scalar) +TVec2 operator/(TVec2 lhs, const TVec2& rhs) { - return lhs /= scalar; + return lhs /= rhs; +} + +template +auto operator*(TVec2 lhs, T2 scalar) +{ + return TVec2(lhs) *= scalar; +} + +template +auto operator/(TVec2 lhs, T2 scalar) +{ + return TVec2(lhs) /= scalar; } using Vec2 = TVec2;