LkEngine 0.1.2
 
Loading...
Searching...
No Matches
Vector4.h
1#pragma once
2
3#include <type_traits>
4#include <ostream>
5
6#include <glm/glm.hpp>
7
9
10namespace LkEngine {
11
18 template<typename SizeType>
19 struct TVector4;
20
21 namespace Math::Internal::Vector4Impl
22 {
23 /* @todo */
24 }
25
30 template<typename SizeType>
31 struct TVector4
32 {
33 public:
34 TVector4()
35 : X(SizeType())
36 , Y(SizeType())
37 , Z(SizeType())
38 , W(SizeType())
39 {
40 }
41
42 TVector4(SizeType InX, SizeType InY, SizeType InZ, SizeType InW)
43 : X(InX)
44 , Y(InY)
45 , Z(InZ)
46 , W(InW)
47 {
48 }
49
50 TVector4(SizeType InXYZW)
51 : X(InXYZW)
52 , Y(InXYZW)
53 , Z(InXYZW)
54 , W(InXYZW)
55 {
56 }
57
58 TVector4(const TVector3<SizeType>& InVec3, SizeType InW)
59 : X(InVec3.X)
60 , Y(InVec3.Y)
61 , Z(InVec3.Z)
62 , W(InW)
63 {
64 }
65
66 TVector4(const glm::vec4& InVec)
67 : X(InVec.x)
68 , Y(InVec.y)
69 , Z(InVec.z)
70 , W(InVec.w)
71 {
72 }
73
74 TVector4(const ImVec4& InVec)
75 : X(InVec.x)
76 , Y(InVec.y)
77 , Z(InVec.z)
78 , W(InVec.w)
79 {
80 }
81
82 ~TVector4()
83 {
84 }
85
86 TVector4& operator+=(const TVector4 Other)
87 {
88 X += Other.X;
89 Y += Other.Y;
90 Z += Other.Z;
91 W += Other.W;
92 return *this;
93 }
94
95 TVector4& operator-=(const TVector4& Other)
96 {
97 X -= Other.X;
98 Y -= Other.Y;
99 Z -= Other.Z;
100 W -= Other.W;
101 return *this;
102 }
103
104 TVector4 operator-(const TVector4& Other) const
105 {
106 return TVector4((X - Other.X), (Y - Other.Y), (Z - Other.Z), (W - Other.W));
107 }
108
109 TVector4 operator+(const TVector4& Other) const
110 {
111 return TVector4((X + Other.X), (Y + Other.Y), (Z + Other.Z), (W + Other.W));
112 }
113
114 bool operator==(const TVector4& Other) const
115 {
116 return ((X == Other.X) && (Y == Other.Y) && (Z == Other.Z) && (W == Other.W));
117 }
118
119 bool operator!=(const TVector4& Other) const
120 {
121 return !(*this == Other);
122 }
123
124 static float Distance(const TVector4& A, const TVector4& B)
125 {
126 return 0.0f;
127 }
128
129 TVector4 Normalize()
130 {
131 return { };
132 }
133
134 std::string ToString() const
135 {
136 return LK_FMT_LIB::format("({:.2f}, {:.2f}, {:.2f}, {:.2f})", X, Y, Z, W);
137 }
138
139 friend std::ostream& operator<<(std::ostream& os, const TVector4& Vector)
140 {
141 os << *Vector.ToString();
142 return os;
143 }
144
145 operator glm::vec4() { return glm::vec4(X, Y, Z, W); }
146 operator ImVec4() { return ImVec4(X, Y, Z, W); }
147
148 static_assert(std::disjunction_v<
149 std::is_same<SizeType, int>,
150 std::is_same<SizeType, uint16_t>,
151 std::is_same<SizeType, uint32_t>,
152 std::is_same<SizeType, uint64_t>,
153 std::is_same<SizeType, int16_t>,
154 std::is_same<SizeType, int32_t>,
155 std::is_same<SizeType, int64_t>,
156 std::is_same<SizeType, float>,
157 std::is_same<SizeType, double>
158 >, "TVector4 can only be instantiated with int, float or double types");
159
160 public:
161 #if LK_VECTOR_ANONYMOUS_STRUCT
162 union
163 {
164 struct { SizeType X, Y, Z, W; };
165 struct { SizeType R, G, B, A; };
166 struct { SizeType S, T, P, Q; };
167 };
168 #else
169 union { SizeType X, R, S; };
170 union { SizeType Y, G, T; };
171 union { SizeType Z, B, P; };
172 union { SizeType W, A, Q; };
173 #endif
174 };
175
176}
Core macros used by the entire engine.
Definition Asset.h:11
Definition Vector3.h:676
Templated four-component vector.
Definition Vector4.h:32