3PL_ALWAYS_INLINE plSimdVec4f::plSimdVec4f() =
default;
5PL_ALWAYS_INLINE plSimdVec4f::plSimdVec4f(
float xyzw)
10PL_ALWAYS_INLINE plSimdVec4f::plSimdVec4f(
const plSimdFloat& xyzw)
15PL_ALWAYS_INLINE plSimdVec4f::plSimdVec4f(
float x,
float y,
float z,
float w)
20PL_ALWAYS_INLINE
void plSimdVec4f::Set(
float xyzw)
25PL_ALWAYS_INLINE
void plSimdVec4f::Set(
float x,
float y,
float z,
float w)
30PL_ALWAYS_INLINE
void plSimdVec4f::SetX(
const plSimdFloat& f)
35PL_ALWAYS_INLINE
void plSimdVec4f::SetY(
const plSimdFloat& f)
40PL_ALWAYS_INLINE
void plSimdVec4f::SetZ(
const plSimdFloat& f)
45PL_ALWAYS_INLINE
void plSimdVec4f::SetW(
const plSimdFloat& f)
50PL_ALWAYS_INLINE
void plSimdVec4f::SetZero()
56PL_ALWAYS_INLINE
void plSimdVec4f::Load(
const float* pFloats)
59 for (
int i = 0; i < N; ++i)
61 (&m_v.x)[i] = pFloats[i];
66PL_ALWAYS_INLINE
void plSimdVec4f::Store(
float* pFloats)
const
68 for (
int i = 0; i < N; ++i)
70 pFloats[i] = (&m_v.x)[i];
74template <plMathAcc::Enum acc>
75PL_ALWAYS_INLINE
plSimdVec4f plSimdVec4f::GetReciprocal()
const
80template <plMathAcc::Enum acc>
81PL_ALWAYS_INLINE
plSimdVec4f plSimdVec4f::GetSqrt()
const
92template <plMathAcc::Enum acc>
104template <
int N, plMathAcc::Enum acc>
105void plSimdVec4f::NormalizeIfNotZero(
const plSimdFloat& fEpsilon)
108 m_v *= sqLength.GetInvSqrt<acc>();
113PL_ALWAYS_INLINE
bool plSimdVec4f::IsZero()
const
115 for (
int i = 0; i < N; ++i)
117 if ((&m_v.x)[i] != 0.0f)
125PL_ALWAYS_INLINE
bool plSimdVec4f::IsZero(
const plSimdFloat& fEpsilon)
const
127 for (
int i = 0; i < N; ++i)
137PL_ALWAYS_INLINE
bool plSimdVec4f::IsNaN()
const
139 for (
int i = 0; i < N; ++i)
141 if (plMath::IsNaN((&m_v.x)[i]))
149PL_ALWAYS_INLINE
bool plSimdVec4f::IsValid()
const
151 for (
int i = 0; i < N; ++i)
153 if (!plMath::IsFinite((&m_v.x)[i]))
161PL_ALWAYS_INLINE
plSimdFloat plSimdVec4f::GetComponent()
const
186template <plSwizzle::Enum s>
187PL_ALWAYS_INLINE
plSimdVec4f plSimdVec4f::Get()
const
191 const float* v = &m_v.x;
192 result.m_v.x = v[(s & 0x3000) >> 12];
193 result.m_v.y = v[(s & 0x0300) >> 8];
194 result.m_v.z = v[(s & 0x0030) >> 4];
195 result.m_v.w = v[(s & 0x0003)];
200template <plSwizzle::Enum s>
205 const float* v = &m_v.x;
206 const float* o = &other.m_v.x;
207 result.m_v.x = v[(s & 0x3000) >> 12];
208 result.m_v.y = v[(s & 0x0300) >> 8];
209 result.m_v.z = o[(s & 0x0030) >> 4];
210 result.m_v.w = o[(s & 0x0003)];
215PL_ALWAYS_INLINE
plSimdVec4f plSimdVec4f::operator-()
const
233 return m_v * f.m_v.x;
238 return m_v / f.m_v.x;
246template <plMathAcc::Enum acc>
262PL_ALWAYS_INLINE
plSimdVec4f plSimdVec4f::Abs()
const
267PL_ALWAYS_INLINE
plSimdVec4f plSimdVec4f::Round()
const
278PL_ALWAYS_INLINE
plSimdVec4f plSimdVec4f::Floor()
const
281 result.m_v.x = plMath::Floor(m_v.x);
282 result.m_v.y = plMath::Floor(m_v.y);
283 result.m_v.z = plMath::Floor(m_v.z);
284 result.m_v.w = plMath::Floor(m_v.w);
289PL_ALWAYS_INLINE
plSimdVec4f plSimdVec4f::Ceil()
const
292 result.m_v.x = plMath::Ceil(m_v.x);
293 result.m_v.y = plMath::Ceil(m_v.y);
294 result.m_v.z = plMath::Ceil(m_v.z);
295 result.m_v.w = plMath::Ceil(m_v.w);
300PL_ALWAYS_INLINE
plSimdVec4f plSimdVec4f::Trunc()
const
314 result.m_v.x = cmp.m_v.x ? -m_v.x : m_v.x;
315 result.m_v.y = cmp.m_v.y ? -m_v.y : m_v.y;
316 result.m_v.z = cmp.m_v.z ? -m_v.z : m_v.z;
317 result.m_v.w = cmp.m_v.w ? -m_v.w : m_v.w;
326 result.m_v.x = cmp.m_v.x ? ifTrue.m_v.x : ifFalse.m_v.x;
327 result.m_v.y = cmp.m_v.y ? ifTrue.m_v.y : ifFalse.m_v.y;
328 result.m_v.z = cmp.m_v.z ? ifTrue.m_v.z : ifFalse.m_v.z;
329 result.m_v.w = cmp.m_v.w ? ifTrue.m_v.w : ifFalse.m_v.w;
361 result[0] = m_v.x == v.m_v.x;
362 result[1] = m_v.y == v.m_v.y;
363 result[2] = m_v.z == v.m_v.z;
364 result[3] = m_v.w == v.m_v.w;
366 return plSimdVec4b(result[0], result[1], result[2], result[3]);
371 return !(*
this == v);
382 result[0] = m_v.x < v.m_v.x;
383 result[1] = m_v.y < v.m_v.y;
384 result[2] = m_v.z < v.m_v.z;
385 result[3] = m_v.w < v.m_v.w;
387 return plSimdVec4b(result[0], result[1], result[2], result[3]);
398 result[0] = m_v.x > v.m_v.x;
399 result[1] = m_v.y > v.m_v.y;
400 result[2] = m_v.z > v.m_v.z;
401 result[3] = m_v.w > v.m_v.w;
403 return plSimdVec4b(result[0], result[1], result[2], result[3]);
407PL_ALWAYS_INLINE
plSimdFloat plSimdVec4f::HorizontalSum<2>()
const
409 return m_v.x + m_v.y;
413PL_ALWAYS_INLINE
plSimdFloat plSimdVec4f::HorizontalSum<3>()
const
415 return (
float)HorizontalSum<2>() + m_v.z;
419PL_ALWAYS_INLINE
plSimdFloat plSimdVec4f::HorizontalSum<4>()
const
421 return (
float)HorizontalSum<3>() + m_v.w;
425PL_ALWAYS_INLINE
plSimdFloat plSimdVec4f::HorizontalMin<2>()
const
431PL_ALWAYS_INLINE
plSimdFloat plSimdVec4f::HorizontalMin<3>()
const
433 return plMath::Min((
float)HorizontalMin<2>(), m_v.z);
437PL_ALWAYS_INLINE
plSimdFloat plSimdVec4f::HorizontalMin<4>()
const
439 return plMath::Min((
float)HorizontalMin<3>(), m_v.w);
443PL_ALWAYS_INLINE
plSimdFloat plSimdVec4f::HorizontalMax<2>()
const
449PL_ALWAYS_INLINE
plSimdFloat plSimdVec4f::HorizontalMax<3>()
const
451 return plMath::Max((
float)HorizontalMax<2>(), m_v.z);
455PL_ALWAYS_INLINE
plSimdFloat plSimdVec4f::HorizontalMax<4>()
const
457 return plMath::Max((
float)HorizontalMax<3>(), m_v.w);
465 for (
int i = 0; i < N; ++i)
467 result += (&m_v.x)[i] * (&v.m_v.x)[i];
482 return plVec4(-m_v.z, 0.0f, m_v.x, 0.0f);
486 return plVec4(0.0f, m_v.z, -m_v.y, 0.0f);
493 return a.CompMul(b) + c;
505 return a.CompMul(b) - c;
518 result.m_v.x = sign.m_v.x < 0.0f ? -magnitude.m_v.x : magnitude.m_v.x;
519 result.m_v.y = sign.m_v.y < 0.0f ? -magnitude.m_v.y : magnitude.m_v.y;
520 result.m_v.z = sign.m_v.z < 0.0f ? -magnitude.m_v.z : magnitude.m_v.z;
521 result.m_v.w = sign.m_v.w < 0.0f ? -magnitude.m_v.w : magnitude.m_v.w;
A 4-component SIMD vector class.
Definition SimdVec4f.h:8
plSimdVec4f CrossRH(const plSimdVec4f &v) const
3D cross product, w is ignored.
Definition FPUVec4f_inl.h:473
plSimdVec4f GetOrthogonalVector() const
Generates an arbitrary vector such that Dot<3>(GetOrthogonalVector()) == 0.
Definition FPUVec4f_inl.h:478
plSimdVec4f GetCombined(const plSimdVec4f &other) const
x = this[s0], y = this[s1], z = other[s2], w = other[s3]
const plVec3Template< Type > CrossRH(const plVec3Template< Type > &rhs) const
Returns the Cross-product of the two vectors (NOT commutative, order DOES matter)
Definition Vec3_inl.h:299
const plVec4Template< Type > GetAsVec4(Type w) const
Returns an plVec4Template with x,y,z from this vector and w set to the parameter.
Definition Vec4_inl.h:35
const plVec4Template< Type > CompMin(const plVec4Template< Type > &rhs) const
Returns the component-wise minimum of *this and rhs.
Definition Vec4_inl.h:327
const plVec4Template< Type > CompDiv(const plVec4Template< Type > &rhs) const
Returns the component-wise division of *this and rhs.
Definition Vec4_inl.h:366
void SetZero()
Sets the vector to all zero.
Definition Vec4_inl.h:139
const plVec3Template< Type > GetAsVec3() const
Returns an plVec3Template with x,y and z from this vector.
Definition Vec4_inl.h:112
const plVec4Template< Type > Abs() const
brief Returns the component-wise absolute of *this.
Definition Vec4_inl.h:376
static plVec4Template< float > MakeZero()
Definition Vec4.h:41
void Set(Type xyzw)
Sets all 4 components to this value.
Definition Vec4_inl.h:121
const plVec4Template< Type > CompMul(const plVec4Template< Type > &rhs) const
Returns the component-wise multiplication of *this and rhs.
Definition Vec4_inl.h:355
const plVec4Template< Type > CompMax(const plVec4Template< Type > &rhs) const
Returns the component-wise maximum of *this and rhs.
Definition Vec4_inl.h:336
constexpr PL_ALWAYS_INLINE T Min(T f1, T f2)
Returns the smaller value, f1 or f2.
Definition Math_inl.h:27
PL_ALWAYS_INLINE double Round(double f)
Rounds f to the next integer.
Definition MathDouble_inl.h:35
PL_ALWAYS_INLINE double Sqrt(double f)
Returns the square root of f.
Definition MathDouble_inl.h:99
bool IsZero(Type f, Type fEpsilon)
Checks whether the given number is close to zero.
Definition Math_inl.h:288
PL_ALWAYS_INLINE Type Trunc(Type f)
Returns the integer-part of f (removes the fraction).
Definition Math_inl.h:296
constexpr PL_ALWAYS_INLINE T Abs(T f)
Returns the absolute value of f.
Definition Math_inl.h:21
constexpr PL_ALWAYS_INLINE T Max(T f1, T f2)
Returns the greater value, f1 or f2.
Definition Math_inl.h:39