From f957f4094a8d98ad0de294c3e6325ce9a860994e Mon Sep 17 00:00:00 2001 From: rtk0c Date: Wed, 26 May 2021 15:31:12 -0700 Subject: More work on TableTemplate --- core/src/Utils/Vector.hpp | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) (limited to 'core/src/Utils/Vector.hpp') diff --git a/core/src/Utils/Vector.hpp b/core/src/Utils/Vector.hpp index f49965e..7e71b73 100644 --- a/core/src/Utils/Vector.hpp +++ b/core/src/Utils/Vector.hpp @@ -6,6 +6,15 @@ struct Vec2 T x = 0; T y = 0; + template + Vec2 Cast() const + { + return { + static_cast(x), + static_cast(y), + }; + } + friend constexpr bool operator==(const Vec2& a, const Vec2& b) = default; friend constexpr Vec2 operator+(const Vec2& a, const Vec2& b) { return { a.x + b.x, a.y + b.y }; } @@ -29,6 +38,16 @@ struct Vec3 T y = 0; T z = 0; + template + Vec3 Cast() const + { + return { + static_cast(x), + static_cast(y), + static_cast(z), + }; + } + friend constexpr bool operator==(const Vec3& a, const Vec3& b) = default; friend constexpr Vec3 operator+(const Vec3& a, const Vec3& b) { return { a.x + b.x, a.y + b.y, a.z + b.z }; } @@ -53,6 +72,17 @@ struct Vec4 T z = 0; T w = 0; + template + Vec4 Cast() const + { + return { + static_cast(x), + static_cast(y), + static_cast(z), + static_cast(w), + }; + } + friend constexpr bool operator==(const Vec4& a, const Vec4& b) = default; friend constexpr Vec4 operator+(const Vec4& a, const Vec4& b) { return { a.x + b.x, a.y + b.y, a.z + b.z, a.w + b.w }; } -- cgit v1.2.3-70-g09d2