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]; };
32 JPH_INLINE
Vec4(
Type inRHS) : mValue(inRHS) { }
35 JPH_INLINE
Vec4(
float inX,
float inY,
float inZ,
float inW);
38 static JPH_INLINE
Vec4 sZero();
41 static JPH_INLINE
Vec4 sNaN();
44 static JPH_INLINE
Vec4 sReplicate(
float inV);
47 static JPH_INLINE
Vec4 sLoadFloat4(
const Float4 *inV);
50 static JPH_INLINE
Vec4 sLoadFloat4Aligned(
const Float4 *inV);
53 template <const
int Scale>
94 static JPH_INLINE
void sSort4(
Vec4 &ioValue,
UVec4 &ioIndex);
98 static JPH_INLINE
void sSort4Reverse(
Vec4 &ioValue,
UVec4 &ioIndex);
101#if defined(JPH_USE_SSE)
102 JPH_INLINE
float GetX()
const {
return _mm_cvtss_f32(mValue); }
103 JPH_INLINE
float GetY()
const {
return mF32[1]; }
104 JPH_INLINE
float GetZ()
const {
return mF32[2]; }
105 JPH_INLINE
float GetW()
const {
return mF32[3]; }
106#elif defined(JPH_USE_NEON)
107 JPH_INLINE
float GetX()
const {
return vgetq_lane_f32(mValue, 0); }
108 JPH_INLINE
float GetY()
const {
return vgetq_lane_f32(mValue, 1); }
109 JPH_INLINE
float GetZ()
const {
return vgetq_lane_f32(mValue, 2); }
110 JPH_INLINE
float GetW()
const {
return vgetq_lane_f32(mValue, 3); }
112 JPH_INLINE
float GetX()
const {
return mF32[0]; }
113 JPH_INLINE
float GetY()
const {
return mF32[1]; }
114 JPH_INLINE
float GetZ()
const {
return mF32[2]; }
115 JPH_INLINE
float GetW()
const {
return mF32[3]; }
119 JPH_INLINE
void SetX(
float inX) { mF32[0] = inX; }
120 JPH_INLINE
void SetY(
float inY) { mF32[1] = inY; }
121 JPH_INLINE
void SetZ(
float inZ) { mF32[2] = inZ; }
122 JPH_INLINE
void SetW(
float inW) { mF32[3] = inW; }
125 JPH_INLINE
float operator [] (
uint inCoordinate)
const {
JPH_ASSERT(inCoordinate < 4);
return mF32[inCoordinate]; }
126 JPH_INLINE
float & operator [] (
uint inCoordinate) {
JPH_ASSERT(inCoordinate < 4);
return mF32[inCoordinate]; }
129 JPH_INLINE
bool operator == (
Vec4Arg inV2)
const;
130 JPH_INLINE
bool operator != (
Vec4Arg inV2)
const {
return !(*
this == inV2); }
133 JPH_INLINE
bool IsClose(
Vec4Arg inV2,
float inMaxDistSq = 1.0e-12f)
const;
136 JPH_INLINE
bool IsNormalized(
float inTolerance = 1.0e-6f)
const;
139 JPH_INLINE
bool IsNaN()
const;
151 JPH_INLINE
Vec4 operator / (
float inV2)
const;
154 JPH_INLINE
Vec4 & operator *= (
float inV2);
160 JPH_INLINE
Vec4 & operator /= (
float inV2);
169 JPH_INLINE
Vec4 operator - ()
const;
181 template<u
int32 SwizzleX, u
int32 SwizzleY, u
int32 SwizzleZ, u
int32 SwizzleW>
185 JPH_INLINE
Vec4 SplatX()
const;
188 JPH_INLINE
Vec4 SplatY()
const;
191 JPH_INLINE
Vec4 SplatZ()
const;
194 JPH_INLINE
Vec4 SplatW()
const;
197 JPH_INLINE
Vec4 Abs()
const;
200 JPH_INLINE
Vec4 Reciprocal()
const;
206 JPH_INLINE
float Dot(
Vec4Arg inV2)
const;
209 JPH_INLINE
float LengthSq()
const;
212 JPH_INLINE
float Length()
const;
215 JPH_INLINE
Vec4 Normalized()
const;
218 JPH_INLINE
void StoreFloat4(
Float4 *outV)
const;
221 JPH_INLINE
UVec4 ToInt()
const;
224 JPH_INLINE
UVec4 ReinterpretAsInt()
const;
227 JPH_INLINE
int GetSignBits()
const;
230 JPH_INLINE
float ReduceMin()
const;
233 JPH_INLINE
float ReduceMax()
const;
236 JPH_INLINE
Vec4 Sqrt()
const;
239 JPH_INLINE
Vec4 GetSign()
const;
242 inline void SinCos(
Vec4 &outSin,
Vec4 &outCos)
const;
262 friend ostream & operator << (ostream &inStream,
Vec4Arg inV)
264 inStream << inV.
mF32[0] <<
", " << inV.
mF32[1] <<
", " << inV.
mF32[2] <<
", " << inV.
mF32[3];
275static_assert(is_trivial<Vec4>(),
"Is supposed to be a trivial type!");
unsigned int uint
Definition Core.h:309
#define JPH_NAMESPACE_END
Definition Core.h:240
#define JPH_NAMESPACE_BEGIN
Definition Core.h:234
DVec3 operator*(double inV1, DVec3Arg inV2)
Definition DVec3.inl:447
#define JPH_ASSERT(...)
Definition IssueReporting.h:33
#define JPH_OVERRIDE_NEW_DELETE
Macro to override the new and delete functions.
Definition Memory.h:29
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:48
Class that holds 4 float values. Convert to Vec4 to perform calculations.
Definition Float4.h:11
float mF32[4]
Definition Vec4.h:271
Vec4()=default
Constructor.
JPH_INLINE void SetW(float inW)
Definition Vec4.h:122
JPH_INLINE float GetW() const
Definition Vec4.h:115
JPH_INLINE Vec4(Type inRHS)
Definition Vec4.h:32
JPH_INLINE void SetZ(float inZ)
Definition Vec4.h:121
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:120
JPH_INLINE void SetX(float inX)
Set individual components.
Definition Vec4.h:119
JPH_INLINE float GetX() const
Get individual components.
Definition Vec4.h:112
JPH_INLINE Vec4 Swizzle() const
Swizzle the elements in inV.
struct { float mData[4];} Type
Definition Vec4.h:24
Type mValue
Definition Vec4.h:270
JPH_INLINE float GetZ() const
Definition Vec4.h:114
JPH_INLINE float GetY() const
Definition Vec4.h:113