aboutsummaryrefslogtreecommitdiff
path: root/core/src/Utils/Vector.hpp
diff options
context:
space:
mode:
authorrtk0c <[email protected]>2022-06-27 18:27:13 -0700
committerrtk0c <[email protected]>2022-06-27 18:27:13 -0700
commit8f0dda5eab181b0f14f2652b4e984aaaae3f258c (patch)
tree4b825dc642cb6eb9a060e54bf8d69288fbee4904 /core/src/Utils/Vector.hpp
parentfad6a88a13ab1f888ab25ad0aae19c1d63aa0623 (diff)
Start from a clean slate
Diffstat (limited to 'core/src/Utils/Vector.hpp')
-rw-r--r--core/src/Utils/Vector.hpp144
1 files changed, 0 insertions, 144 deletions
diff --git a/core/src/Utils/Vector.hpp b/core/src/Utils/Vector.hpp
deleted file mode 100644
index 4d3f3b3..0000000
--- a/core/src/Utils/Vector.hpp
+++ /dev/null
@@ -1,144 +0,0 @@
-#pragma once
-
-#include "Utils/IO/DataStream.hpp"
-
-template <class T>
-struct Vec2
-{
- T x = 0;
- T y = 0;
-
- template <class TTarget>
- Vec2<TTarget> Cast() const
- {
- return {
- static_cast<TTarget>(x),
- static_cast<TTarget>(y),
- };
- }
-
- void ReadFromDataStream(InputDataStream& stream)
- {
- stream.Value(x);
- stream.Value(y);
- }
-
- void WriteToDataStream(OutputDataStream& stream) const
- {
- stream.Value(x);
- stream.Value(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 }; }
- friend constexpr Vec2 operator-(const Vec2& a, const Vec2& b) { return { a.x - b.x, a.y - b.y }; }
- friend constexpr Vec2 operator*(const Vec2& a, const Vec2& b) { return { a.x * b.x, a.y * b.y }; }
- friend constexpr Vec2 operator/(const Vec2& a, const Vec2& b) { return { a.x / b.x, a.y / b.y }; }
-
- friend constexpr Vec2 operator+(const Vec2& a, T n) { return { a.x + n, a.y + n }; }
- friend constexpr Vec2 operator-(const Vec2& a, T n) { return { a.x - n, a.y - n }; }
- friend constexpr Vec2 operator*(const Vec2& a, T n) { return { a.x * n, a.y * n }; }
- friend constexpr Vec2 operator/(const Vec2& a, T n) { return { a.x / n, a.y / n }; }
-};
-
-using Vec2i = Vec2<int>;
-using Vec2f = Vec2<float>;
-
-template <class T>
-struct Vec3
-{
- T x = 0;
- T y = 0;
- T z = 0;
-
- template <class TTarget>
- Vec3<TTarget> Cast() const
- {
- return {
- static_cast<TTarget>(x),
- static_cast<TTarget>(y),
- static_cast<TTarget>(z),
- };
- }
-
- void ReadFromDataStream(InputDataStream& stream)
- {
- stream.Value(x);
- stream.Value(y);
- stream.Value(z);
- }
-
- void WriteToDataStream(OutputDataStream& stream) const
- {
- stream.Value(x);
- stream.Value(y);
- stream.Value(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 }; }
- friend constexpr Vec3 operator-(const Vec3& a, const Vec3& b) { return { a.x - b.x, a.y - b.y, a.z - b.z }; }
- friend constexpr Vec3 operator*(const Vec3& a, const Vec3& b) { return { a.x * b.x, a.y * b.y, a.z * b.z }; }
- friend constexpr Vec3 operator/(const Vec3& a, const Vec3& b) { return { a.x / b.x, a.y / b.y, a.z / b.z }; }
-
- friend constexpr Vec3 operator+(const Vec3& a, T n) { return { a.x + n, a.y + n, a.z + n }; }
- friend constexpr Vec3 operator-(const Vec3& a, T n) { return { a.x - n, a.y - n, a.z - n }; }
- friend constexpr Vec3 operator*(const Vec3& a, T n) { return { a.x * n, a.y * n, a.z * n }; }
- friend constexpr Vec3 operator/(const Vec3& a, T n) { return { a.x / n, a.y / n, a.z / n }; }
-};
-
-using Vec3i = Vec3<int>;
-using Vec3f = Vec3<float>;
-
-template <class T>
-struct Vec4
-{
- T x = 0;
- T y = 0;
- T z = 0;
- T w = 0;
-
- template <class TTarget>
- Vec4<TTarget> Cast() const
- {
- return {
- static_cast<TTarget>(x),
- static_cast<TTarget>(y),
- static_cast<TTarget>(z),
- static_cast<TTarget>(w),
- };
- }
-
- void ReadFromDataStream(InputDataStream& stream)
- {
- stream.Value(x);
- stream.Value(y);
- stream.Value(z);
- stream.Value(w);
- }
-
- void WriteToDataStream(OutputDataStream& stream) const
- {
- stream.Value(x);
- stream.Value(y);
- stream.Value(z);
- stream.Value(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 }; }
- 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 }; }
- 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 }; }
- 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 }; }
-
- friend constexpr Vec4 operator+(const Vec4& a, T n) { return { a.x + n, a.y + n, a.z + n, a.w + n }; }
- friend constexpr Vec4 operator-(const Vec4& a, T n) { return { a.x - n, a.y - n, a.z - n, a.w - n }; }
- friend constexpr Vec4 operator*(const Vec4& a, T n) { return { a.x * n, a.y * n, a.z * n, a.w * n }; }
- friend constexpr Vec4 operator/(const Vec4& a, T n) { return { a.x / n, a.y / n, a.z / n, a.w / n }; }
-};
-
-using Vec4i = Vec4<int>;
-using Vec4f = Vec4<float>;