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 sOne();
45 static JPH_INLINE
Vec4 sNaN();
48 static JPH_INLINE
Vec4 sReplicate(
float inV);
51 static JPH_INLINE
Vec4 sLoadFloat4(
const Float4 *inV);
54 static JPH_INLINE
Vec4 sLoadFloat4Aligned(
const Float4 *inV);
57 template <const
int Scale>
98 static JPH_INLINE
void sSort4(
Vec4 &ioValue,
UVec4 &ioIndex);
102 static JPH_INLINE
void sSort4Reverse(
Vec4 &ioValue,
UVec4 &ioIndex);
105#if defined(JPH_USE_SSE)
106 JPH_INLINE
float GetX()
const {
return _mm_cvtss_f32(mValue); }
107 JPH_INLINE
float GetY()
const {
return mF32[1]; }
108 JPH_INLINE
float GetZ()
const {
return mF32[2]; }
109 JPH_INLINE
float GetW()
const {
return mF32[3]; }
110#elif defined(JPH_USE_NEON)
111 JPH_INLINE
float GetX()
const {
return vgetq_lane_f32(mValue, 0); }
112 JPH_INLINE
float GetY()
const {
return vgetq_lane_f32(mValue, 1); }
113 JPH_INLINE
float GetZ()
const {
return vgetq_lane_f32(mValue, 2); }
114 JPH_INLINE
float GetW()
const {
return vgetq_lane_f32(mValue, 3); }
116 JPH_INLINE
float GetX()
const {
return mF32[0]; }
117 JPH_INLINE
float GetY()
const {
return mF32[1]; }
118 JPH_INLINE
float GetZ()
const {
return mF32[2]; }
119 JPH_INLINE
float GetW()
const {
return mF32[3]; }
123 JPH_INLINE
void SetX(
float inX) { mF32[0] = inX; }
124 JPH_INLINE
void SetY(
float inY) { mF32[1] = inY; }
125 JPH_INLINE
void SetZ(
float inZ) { mF32[2] = inZ; }
126 JPH_INLINE
void SetW(
float inW) { mF32[3] = inW; }
129 JPH_INLINE
void Set(
float inX,
float inY,
float inZ,
float inW) { *
this =
Vec4(inX, inY, inZ, inW); }
132 JPH_INLINE
float operator [] (
uint inCoordinate)
const {
JPH_ASSERT(inCoordinate < 4);
return mF32[inCoordinate]; }
133 JPH_INLINE
float & operator [] (
uint inCoordinate) {
JPH_ASSERT(inCoordinate < 4);
return mF32[inCoordinate]; }
136 JPH_INLINE
bool operator == (
Vec4Arg inV2)
const;
137 JPH_INLINE
bool operator != (
Vec4Arg inV2)
const {
return !(*
this == inV2); }
140 JPH_INLINE
bool IsClose(
Vec4Arg inV2,
float inMaxDistSq = 1.0e-12f)
const;
143 JPH_INLINE
bool IsNormalized(
float inTolerance = 1.0e-6f)
const;
146 JPH_INLINE
bool IsNaN()
const;
158 JPH_INLINE
Vec4 operator / (
float inV2)
const;
161 JPH_INLINE
Vec4 & operator *= (
float inV2);
167 JPH_INLINE
Vec4 & operator /= (
float inV2);
176 JPH_INLINE
Vec4 operator - ()
const;
188 template<u
int32 SwizzleX, u
int32 SwizzleY, u
int32 SwizzleZ, u
int32 SwizzleW>
192 JPH_INLINE
Vec4 SplatX()
const;
195 JPH_INLINE
Vec4 SplatY()
const;
198 JPH_INLINE
Vec4 SplatZ()
const;
201 JPH_INLINE
Vec4 SplatW()
const;
204 JPH_INLINE
Vec4 Abs()
const;
207 JPH_INLINE
Vec4 Reciprocal()
const;
213 JPH_INLINE
float Dot(
Vec4Arg inV2)
const;
216 JPH_INLINE
float LengthSq()
const;
219 JPH_INLINE
float Length()
const;
222 JPH_INLINE
Vec4 Normalized()
const;
225 JPH_INLINE
void StoreFloat4(
Float4 *outV)
const;
228 JPH_INLINE
UVec4 ToInt()
const;
231 JPH_INLINE
UVec4 ReinterpretAsInt()
const;
234 JPH_INLINE
int GetSignBits()
const;
237 JPH_INLINE
float ReduceMin()
const;
240 JPH_INLINE
float ReduceMax()
const;
243 JPH_INLINE
Vec4 Sqrt()
const;
246 JPH_INLINE
Vec4 GetSign()
const;
249 inline void SinCos(
Vec4 &outSin,
Vec4 &outCos)
const;
269 friend ostream & operator << (ostream &inStream,
Vec4Arg inV)
271 inStream << inV.
mF32[0] <<
", " << inV.
mF32[1] <<
", " << inV.
mF32[2] <<
", " << inV.
mF32[3];
282static_assert(std::is_trivial<Vec4>(),
"Is supposed to be a trivial type!");
unsigned int uint
Definition Core.h:481
#define JPH_NAMESPACE_END
Definition Core.h:414
#define JPH_NAMESPACE_BEGIN
Definition Core.h:408
DVec3 operator*(double inV1, DVec3Arg inV2)
Definition DVec3.inl:456
#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:278
Vec4()=default
Constructor.
JPH_INLINE void SetW(float inW)
Definition Vec4.h:126
JPH_INLINE float GetW() const
Definition Vec4.h:119
JPH_INLINE Vec4(Type inRHS)
Definition Vec4.h:33
JPH_INLINE void SetZ(float inZ)
Definition Vec4.h:125
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:124
JPH_INLINE void SetX(float inX)
Set individual components.
Definition Vec4.h:123
JPH_INLINE float GetX() const
Get individual components.
Definition Vec4.h:116
JPH_INLINE Vec4 Swizzle() const
Swizzle the elements in inV.
struct { float mData[4];} Type
Definition Vec4.h:24
Type mValue
Definition Vec4.h:277
JPH_INLINE float GetZ() const
Definition Vec4.h:118
JPH_INLINE void Set(float inX, float inY, float inZ, float inW)
Set all components.
Definition Vec4.h:129
JPH_INLINE float GetY() const
Definition Vec4.h:117