Plasma Engine  2.0
Loading...
Searching...
No Matches
SimdVec4f.h
1#pragma once
2
3#include <Foundation/SimdMath/SimdFloat.h>
4#include <Foundation/SimdMath/SimdVec4b.h>
5
7class PL_FOUNDATION_DLL plSimdVec4f
8{
9public:
10 PL_DECLARE_POD_TYPE();
11
12 plSimdVec4f(); // [tested]
13
14 explicit plSimdVec4f(float fXyzw); // [tested]
15
16 explicit plSimdVec4f(const plSimdFloat& fXyzw); // [tested]
17
18 plSimdVec4f(float x, float y, float z, float w = 1.0f); // [tested]
19
21
23 [[nodiscard]] static plSimdVec4f MakeZero(); // [tested]
24
26 [[nodiscard]] static plSimdVec4f MakeNaN(); // [tested]
27
28 void Set(float fXyzw); // [tested]
29
30 void Set(float x, float y, float z, float w); // [tested]
31
32 void SetX(const plSimdFloat& f); // [tested]
33 void SetY(const plSimdFloat& f); // [tested]
34 void SetZ(const plSimdFloat& f); // [tested]
35 void SetW(const plSimdFloat& f); // [tested]
36
37 void SetZero(); // [tested]
38
39 template <int N>
40 void Load(const float* pFloats); // [tested]
41
42 template <int N>
43 void Store(float* pFloats) const; // [tested]
44
45public:
46 template <plMathAcc::Enum acc = plMathAcc::FULL>
47 plSimdVec4f GetReciprocal() const; // [tested]
48
49 template <plMathAcc::Enum acc = plMathAcc::FULL>
50 plSimdVec4f GetSqrt() const; // [tested]
51
52 template <plMathAcc::Enum acc = plMathAcc::FULL>
53 plSimdVec4f GetInvSqrt() const; // [tested]
54
55 template <int N, plMathAcc::Enum acc = plMathAcc::FULL>
56 plSimdFloat GetLength() const; // [tested]
57
58 template <int N, plMathAcc::Enum acc = plMathAcc::FULL>
59 plSimdFloat GetInvLength() const; // [tested]
60
61 template <int N>
62 plSimdFloat GetLengthSquared() const; // [tested]
63
64 template <int N, plMathAcc::Enum acc = plMathAcc::FULL>
65 plSimdFloat GetLengthAndNormalize(); // [tested]
66
67 template <int N, plMathAcc::Enum acc = plMathAcc::FULL>
68 plSimdVec4f GetNormalized() const; // [tested]
69
70 template <int N, plMathAcc::Enum acc = plMathAcc::FULL>
71 void Normalize(); // [tested]
72
73 template <int N, plMathAcc::Enum acc = plMathAcc::FULL>
74 void NormalizeIfNotZero(const plSimdFloat& fEpsilon = plMath::SmallEpsilon<float>()); // [tested]
75
76 template <int N>
77 bool IsZero() const; // [tested]
78
79 template <int N>
80 bool IsZero(const plSimdFloat& fEpsilon) const; // [tested]
81
82 template <int N>
83 bool IsNormalized(const plSimdFloat& fEpsilon = plMath::HugeEpsilon<float>()) const; // [tested]
84
85 template <int N>
86 bool IsNaN() const; // [tested]
87
88 template <int N>
89 bool IsValid() const; // [tested]
90
91public:
92 template <int N>
93 plSimdFloat GetComponent() const; // [tested]
94
95 plSimdFloat GetComponent(int i) const; // [tested]
96
97 plSimdFloat x() const; // [tested]
98 plSimdFloat y() const; // [tested]
99 plSimdFloat z() const; // [tested]
100 plSimdFloat w() const; // [tested]
101
102 template <plSwizzle::Enum s>
103 plSimdVec4f Get() const; // [tested]
104
106 template <plSwizzle::Enum s>
107 [[nodiscard]] plSimdVec4f GetCombined(const plSimdVec4f& other) const; // [tested]
108
109public:
110 [[nodiscard]] plSimdVec4f operator-() const; // [tested]
111 [[nodiscard]] plSimdVec4f operator+(const plSimdVec4f& v) const; // [tested]
112 [[nodiscard]] plSimdVec4f operator-(const plSimdVec4f& v) const; // [tested]
113
114 [[nodiscard]] plSimdVec4f operator*(const plSimdFloat& f) const; // [tested]
115 [[nodiscard]] plSimdVec4f operator/(const plSimdFloat& f) const; // [tested]
116
117 [[nodiscard]] plSimdVec4f CompMul(const plSimdVec4f& v) const; // [tested]
118
119 template <plMathAcc::Enum acc = plMathAcc::FULL>
120 [[nodiscard]] plSimdVec4f CompDiv(const plSimdVec4f& v) const; // [tested]
121
122 [[nodiscard]] plSimdVec4f CompMin(const plSimdVec4f& rhs) const; // [tested]
123 [[nodiscard]] plSimdVec4f CompMax(const plSimdVec4f& rhs) const; // [tested]
124
125 [[nodiscard]] plSimdVec4f Abs() const; // [tested]
126 [[nodiscard]] plSimdVec4f Round() const; // [tested]
127 [[nodiscard]] plSimdVec4f Floor() const; // [tested]
128 [[nodiscard]] plSimdVec4f Ceil() const; // [tested]
129 [[nodiscard]] plSimdVec4f Trunc() const; // [tested]
130 [[nodiscard]] plSimdVec4f Fraction() const; // [tested]
131
132 [[nodiscard]] plSimdVec4f FlipSign(const plSimdVec4b& vCmp) const; // [tested]
133
134 [[nodiscard]] static plSimdVec4f Select(const plSimdVec4b& vCmp, const plSimdVec4f& vTrue, const plSimdVec4f& vFalse); // [tested]
135
136 [[nodiscard]] static plSimdVec4f Lerp(const plSimdVec4f& a, const plSimdVec4f& b, const plSimdVec4f& t);
137
138 plSimdVec4f& operator+=(const plSimdVec4f& v); // [tested]
139 plSimdVec4f& operator-=(const plSimdVec4f& v); // [tested]
140
141 plSimdVec4f& operator*=(const plSimdFloat& f); // [tested]
142 plSimdVec4f& operator/=(const plSimdFloat& f); // [tested]
143
144 plSimdVec4b IsEqual(const plSimdVec4f& rhs, const plSimdFloat& fEpsilon) const; // [tested]
145
146 [[nodiscard]] plSimdVec4b operator==(const plSimdVec4f& v) const; // [tested]
147 [[nodiscard]] plSimdVec4b operator!=(const plSimdVec4f& v) const; // [tested]
148 [[nodiscard]] plSimdVec4b operator<=(const plSimdVec4f& v) const; // [tested]
149 [[nodiscard]] plSimdVec4b operator<(const plSimdVec4f& v) const; // [tested]
150 [[nodiscard]] plSimdVec4b operator>=(const plSimdVec4f& v) const; // [tested]
151 [[nodiscard]] plSimdVec4b operator>(const plSimdVec4f& v) const; // [tested]
152
153 template <int N>
154 [[nodiscard]] plSimdFloat HorizontalSum() const; // [tested]
155
156 template <int N>
157 [[nodiscard]] plSimdFloat HorizontalMin() const; // [tested]
158
159 template <int N>
160 [[nodiscard]] plSimdFloat HorizontalMax() const; // [tested]
161
162 template <int N>
163 [[nodiscard]] plSimdFloat Dot(const plSimdVec4f& v) const; // [tested]
164
166 [[nodiscard]] plSimdVec4f CrossRH(const plSimdVec4f& v) const; // [tested]
167
169 [[nodiscard]] plSimdVec4f GetOrthogonalVector() const; // [tested]
170
171 [[nodiscard]] static plSimdVec4f MulAdd(const plSimdVec4f& a, const plSimdVec4f& b, const plSimdVec4f& c); // [tested]
172 [[nodiscard]] static plSimdVec4f MulAdd(const plSimdVec4f& a, const plSimdFloat& b, const plSimdVec4f& c); // [tested]
173
174 [[nodiscard]] static plSimdVec4f MulSub(const plSimdVec4f& a, const plSimdVec4f& b, const plSimdVec4f& c); // [tested]
175 [[nodiscard]] static plSimdVec4f MulSub(const plSimdVec4f& a, const plSimdFloat& b, const plSimdVec4f& c); // [tested]
176
177 [[nodiscard]] static plSimdVec4f CopySign(const plSimdVec4f& vMagnitude, const plSimdVec4f& vSign); // [tested]
178
179public:
181};
182
183#include <Foundation/SimdMath/Implementation/SimdVec4f_inl.h>
184
185#if PL_SIMD_IMPLEMENTATION == PL_SIMD_IMPLEMENTATION_SSE
186# include <Foundation/SimdMath/Implementation/SSE/SSEVec4f_inl.h>
187#elif PL_SIMD_IMPLEMENTATION == PL_SIMD_IMPLEMENTATION_FPU
188# include <Foundation/SimdMath/Implementation/FPU/FPUVec4f_inl.h>
189#elif PL_SIMD_IMPLEMENTATION == PL_SIMD_IMPLEMENTATION_NEON
190# include <Foundation/SimdMath/Implementation/NEON/NEONVec4f_inl.h>
191#else
192# error "Unknown SIMD implementation."
193#endif
Definition SimdFloat.h:7
Definition SimdVec4b.h:7
A 4-component SIMD vector class.
Definition SimdVec4f.h:8
plSimdVec4f GetCombined(const plSimdVec4f &other) const
x = this[s0], y = this[s1], z = other[s2], w = other[s3]