13class [[nodiscard]] alignas(JPH_VECTOR_ALIGNMENT)
Vec4
19#if defined(JPH_USE_SSE)
21#elif defined(JPH_USE_NEON)
22 using Type = float32x4_t;
24 using Type =
struct {
float mData[4]; };
30 Vec4 & operator = (
const Vec4 &inRHS) =
default;
33 JPH_INLINE
Vec4(
Type inRHS) : mValue(inRHS) { }
36 JPH_INLINE
Vec4(
float inX,
float inY,
float inZ,
float inW);
39 static JPH_INLINE
Vec4 sZero();
42 static JPH_INLINE
Vec4 sNaN();
45 static JPH_INLINE
Vec4 sReplicate(
float inV);
48 static JPH_INLINE
Vec4 sLoadFloat4(
const Float4 *inV);
51 static JPH_INLINE
Vec4 sLoadFloat4Aligned(
const Float4 *inV);
54 template <const
int Scale>
95 static JPH_INLINE
void sSort4(
Vec4 &ioValue,
UVec4 &ioIndex);
99 static JPH_INLINE
void sSort4Reverse(
Vec4 &ioValue,
UVec4 &ioIndex);
102#if defined(JPH_USE_SSE)
103 JPH_INLINE
float GetX()
const {
return _mm_cvtss_f32(mValue); }
104 JPH_INLINE
float GetY()
const {
return mF32[1]; }
105 JPH_INLINE
float GetZ()
const {
return mF32[2]; }
106 JPH_INLINE
float GetW()
const {
return mF32[3]; }
107#elif defined(JPH_USE_NEON)
108 JPH_INLINE
float GetX()
const {
return vgetq_lane_f32(mValue, 0); }
109 JPH_INLINE
float GetY()
const {
return vgetq_lane_f32(mValue, 1); }
110 JPH_INLINE
float GetZ()
const {
return vgetq_lane_f32(mValue, 2); }
111 JPH_INLINE
float GetW()
const {
return vgetq_lane_f32(mValue, 3); }
113 JPH_INLINE
float GetX()
const {
return mF32[0]; }
114 JPH_INLINE
float GetY()
const {
return mF32[1]; }
115 JPH_INLINE
float GetZ()
const {
return mF32[2]; }
116 JPH_INLINE
float GetW()
const {
return mF32[3]; }
120 JPH_INLINE
void SetX(
float inX) { mF32[0] = inX; }
121 JPH_INLINE
void SetY(
float inY) { mF32[1] = inY; }
122 JPH_INLINE
void SetZ(
float inZ) { mF32[2] = inZ; }
123 JPH_INLINE
void SetW(
float inW) { mF32[3] = inW; }
126 JPH_INLINE
void Set(
float inX,
float inY,
float inZ,
float inW) { *
this =
Vec4(inX, inY, inZ, inW); }
129 JPH_INLINE
float operator [] (
uint inCoordinate)
const {
JPH_ASSERT(inCoordinate < 4);
return mF32[inCoordinate]; }
130 JPH_INLINE
float & operator [] (
uint inCoordinate) {
JPH_ASSERT(inCoordinate < 4);
return mF32[inCoordinate]; }
133 JPH_INLINE
bool operator == (
Vec4Arg inV2)
const;
134 JPH_INLINE
bool operator != (
Vec4Arg inV2)
const {
return !(*
this == inV2); }
137 JPH_INLINE
bool IsClose(
Vec4Arg inV2,
float inMaxDistSq = 1.0e-12f)
const;
140 JPH_INLINE
bool IsNormalized(
float inTolerance = 1.0e-6f)
const;
143 JPH_INLINE
bool IsNaN()
const;
155 JPH_INLINE
Vec4 operator / (
float inV2)
const;
158 JPH_INLINE
Vec4 & operator *= (
float inV2);
164 JPH_INLINE
Vec4 & operator /= (
float inV2);
173 JPH_INLINE
Vec4 operator - ()
const;
185 template<u
int32 SwizzleX, u
int32 SwizzleY, u
int32 SwizzleZ, u
int32 SwizzleW>
189 JPH_INLINE
Vec4 SplatX()
const;
192 JPH_INLINE
Vec4 SplatY()
const;
195 JPH_INLINE
Vec4 SplatZ()
const;
198 JPH_INLINE
Vec4 SplatW()
const;
201 JPH_INLINE
Vec4 Abs()
const;
204 JPH_INLINE
Vec4 Reciprocal()
const;
210 JPH_INLINE
float Dot(
Vec4Arg inV2)
const;
213 JPH_INLINE
float LengthSq()
const;
216 JPH_INLINE
float Length()
const;
219 JPH_INLINE
Vec4 Normalized()
const;
222 JPH_INLINE
void StoreFloat4(
Float4 *outV)
const;
225 JPH_INLINE
UVec4 ToInt()
const;
228 JPH_INLINE
UVec4 ReinterpretAsInt()
const;
231 JPH_INLINE
int GetSignBits()
const;
234 JPH_INLINE
float ReduceMin()
const;
237 JPH_INLINE
float ReduceMax()
const;
240 JPH_INLINE
Vec4 Sqrt()
const;
243 JPH_INLINE
Vec4 GetSign()
const;
246 inline void SinCos(
Vec4 &outSin,
Vec4 &outCos)
const;
266 friend ostream & operator << (ostream &inStream,
Vec4Arg inV)
268 inStream << inV.
mF32[0] <<
", " << inV.
mF32[1] <<
", " << inV.
mF32[2] <<
", " << inV.
mF32[3];
279static_assert(std::is_trivial<Vec4>(),
"Is supposed to be a trivial type!");
unsigned int uint
Definition Core.h:446
#define JPH_NAMESPACE_END
Definition Core.h:379
#define JPH_NAMESPACE_BEGIN
Definition Core.h:373
DVec3 operator*(double inV1, DVec3Arg inV2)
Definition DVec3.inl:451
#define JPH_ASSERT(...)
Definition IssueReporting.h:33
#define JPH_OVERRIDE_NEW_DELETE
Macro to override the new and delete functions.
Definition Memory.h:31
JPH_INLINE float Tan(float inX)
Tangent of x (input in radians)
Definition Trigonometry.h:28
JPH_INLINE float ACos(float inX)
Definition Trigonometry.h:42
JPH_INLINE float ASin(float inX)
Definition Trigonometry.h:35
JPH_INLINE float ATan(float inX)
Arc tangent of x (returns value in the range [-PI / 2, PI / 2])
Definition Trigonometry.h:68
Class that holds 4 float values. Convert to Vec4 to perform calculations.
Definition Float4.h:11
float mF32[4]
Definition Vec4.h:275
Vec4()=default
Constructor.
JPH_INLINE void SetW(float inW)
Definition Vec4.h:123
JPH_INLINE float GetW() const
Definition Vec4.h:116
JPH_INLINE Vec4(Type inRHS)
Definition Vec4.h:33
JPH_INLINE void SetZ(float inZ)
Definition Vec4.h:122
Vec4(const Vec4 &inRHS)=default
static JPH_INLINE Vec4 sGatherFloat4(const float *inBase, UVec4Arg inOffsets)
Gather 4 floats from memory at inBase + inOffsets[i] * Scale.
JPH_INLINE void SetY(float inY)
Definition Vec4.h:121
JPH_INLINE void SetX(float inX)
Set individual components.
Definition Vec4.h:120
JPH_INLINE float GetX() const
Get individual components.
Definition Vec4.h:113
{ float mData[4] Type
Definition Vec4.h:24
JPH_INLINE Vec4 Swizzle() const
Swizzle the elements in inV.
Type mValue
Definition Vec4.h:274
JPH_INLINE float GetZ() const
Definition Vec4.h:115
JPH_INLINE void Set(float inX, float inY, float inZ, float inW)
Set all components.
Definition Vec4.h:126
JPH_INLINE float GetY() const
Definition Vec4.h:114