15class [[nodiscard]] alignas(JPH_VECTOR_ALIGNMENT)
Vec3
21#if defined(JPH_USE_SSE)
23#elif defined(JPH_USE_NEON)
24 using Type = float32x4_t;
35 Vec3 & operator = (
const Vec3 &inRHS) =
default;
37 JPH_INLINE
Vec3(
Type inRHS) : mValue(inRHS) { CheckW(); }
43 JPH_INLINE
Vec3(
float inX,
float inY,
float inZ);
46 static JPH_INLINE
Vec3 sZero();
49 static JPH_INLINE
Vec3 sNaN();
57 static JPH_INLINE
Vec3 sReplicate(
float inV);
60 static JPH_INLINE
Vec3 sLoadFloat3Unsafe(
const Float3 &inV);
104 static JPH_INLINE
Vec3 sUnitSpherical(
float inTheta,
float inPhi);
110 template <
class Random>
111 static inline Vec3 sRandom(Random &inRandom);
114#if defined(JPH_USE_SSE)
115 JPH_INLINE
float GetX()
const {
return _mm_cvtss_f32(mValue); }
116 JPH_INLINE
float GetY()
const {
return mF32[1]; }
117 JPH_INLINE
float GetZ()
const {
return mF32[2]; }
118#elif defined(JPH_USE_NEON)
119 JPH_INLINE
float GetX()
const {
return vgetq_lane_f32(mValue, 0); }
120 JPH_INLINE
float GetY()
const {
return vgetq_lane_f32(mValue, 1); }
121 JPH_INLINE
float GetZ()
const {
return vgetq_lane_f32(mValue, 2); }
123 JPH_INLINE
float GetX()
const {
return mF32[0]; }
124 JPH_INLINE
float GetY()
const {
return mF32[1]; }
125 JPH_INLINE
float GetZ()
const {
return mF32[2]; }
129 JPH_INLINE
void SetX(
float inX) { mF32[0] = inX; }
130 JPH_INLINE
void SetY(
float inY) { mF32[1] = inY; }
131 JPH_INLINE
void SetZ(
float inZ) { mF32[2] = mF32[3] = inZ; }
134 JPH_INLINE
void Set(
float inX,
float inY,
float inZ) { *
this =
Vec3(inX, inY, inZ); }
137 JPH_INLINE
float operator [] (
uint inCoordinate)
const {
JPH_ASSERT(inCoordinate < 3);
return mF32[inCoordinate]; }
140 JPH_INLINE
void SetComponent(
uint inCoordinate,
float inValue) {
JPH_ASSERT(inCoordinate < 3); mF32[inCoordinate] = inValue; mValue = sFixW(mValue); }
143 JPH_INLINE
bool operator == (
Vec3Arg inV2)
const;
144 JPH_INLINE
bool operator != (
Vec3Arg inV2)
const {
return !(*
this == inV2); }
147 JPH_INLINE
bool IsClose(
Vec3Arg inV2,
float inMaxDistSq = 1.0e-12f)
const;
150 JPH_INLINE
bool IsNearZero(
float inMaxDistSq = 1.0e-12f)
const;
153 JPH_INLINE
bool IsNormalized(
float inTolerance = 1.0e-6f)
const;
156 JPH_INLINE
bool IsNaN()
const;
168 JPH_INLINE
Vec3 operator / (
float inV2)
const;
171 JPH_INLINE
Vec3 & operator *= (
float inV2);
177 JPH_INLINE
Vec3 & operator /= (
float inV2);
186 JPH_INLINE
Vec3 operator - ()
const;
198 template<u
int32 SwizzleX, u
int32 SwizzleY, u
int32 SwizzleZ>
202 JPH_INLINE
Vec4 SplatX()
const;
205 JPH_INLINE
Vec4 SplatY()
const;
208 JPH_INLINE
Vec4 SplatZ()
const;
211 JPH_INLINE
int GetLowestComponentIndex()
const;
214 JPH_INLINE
int GetHighestComponentIndex()
const;
217 JPH_INLINE
Vec3 Abs()
const;
220 JPH_INLINE
Vec3 Reciprocal()
const;
232 JPH_INLINE
float Dot(
Vec3Arg inV2)
const;
235 JPH_INLINE
float LengthSq()
const;
238 JPH_INLINE
float Length()
const;
241 JPH_INLINE
Vec3 Normalized()
const;
244 JPH_INLINE
Vec3 NormalizedOr(
Vec3Arg inZeroValue)
const;
247 JPH_INLINE
void StoreFloat3(
Float3 *outV)
const;
250 JPH_INLINE
UVec4 ToInt()
const;
253 JPH_INLINE
UVec4 ReinterpretAsInt()
const;
256 JPH_INLINE
float ReduceMin()
const;
259 JPH_INLINE
float ReduceMax()
const;
262 JPH_INLINE
Vec3 Sqrt()
const;
265 JPH_INLINE
Vec3 GetNormalizedPerpendicular()
const;
268 JPH_INLINE
Vec3 GetSign()
const;
271 friend ostream & operator << (ostream &inStream,
Vec3Arg inV)
273 inStream << inV.
mF32[0] <<
", " << inV.
mF32[1] <<
", " << inV.
mF32[2];
290static_assert(is_trivial<Vec3>(),
"Is supposed to be a trivial type!");
#define JPH_EXPORT
Definition: Core.h:227
unsigned int uint
Definition: Core.h:439
#define JPH_NAMESPACE_END
Definition: Core.h:367
#define JPH_NAMESPACE_BEGIN
Definition: Core.h:361
DVec3 operator*(double inV1, DVec3Arg inV2)
Definition: DVec3.inl:447
#define JPH_ASSERT(...)
Definition: IssueReporting.h:33
const Vec3 Vec3Arg
Definition: MathTypes.h:20
#define JPH_OVERRIDE_NEW_DELETE
Macro to override the new and delete functions.
Definition: Memory.h:29
Class that holds 3 floats. Used as a storage class. Convert to Vec3 for calculations.
Definition: Float3.h:13
static JPH_INLINE Type sFixW(Type inValue)
Internal helper function that ensures that the Z component is replicated to the W component to preven...
Vec4::Type Type
Definition: Vec3.h:26
static JPH_INLINE Vec3 sAxisX()
Vectors with the principal axis.
Definition: Vec3.h:52
JPH_INLINE void SetComponent(uint inCoordinate, float inValue)
Set float component by index.
Definition: Vec3.h:140
Vec3(const Vec3 &inRHS)=default
static JPH_INLINE Vec3 sAxisY()
Definition: Vec3.h:53
JPH_INLINE float GetX() const
Get individual components.
Definition: Vec3.h:123
static JPH_EXPORT const std::vector< Vec3 > sUnitSphere
A set of vectors uniformly spanning the surface of a unit sphere, usable for debug purposes.
Definition: Vec3.h:107
JPH_INLINE void SetY(float inY)
Definition: Vec3.h:130
JPH_INLINE Vec3(Type inRHS)
Definition: Vec3.h:37
JPH_INLINE void SetZ(float inZ)
Definition: Vec3.h:131
JPH_INLINE void CheckW() const
Internal helper function that checks that W is equal to Z, so e.g. dividing by it should not generate...
static JPH_INLINE Vec3 sAxisZ()
Definition: Vec3.h:54
JPH_INLINE void SetX(float inX)
Set individual components.
Definition: Vec3.h:129
Type mValue
Definition: Vec3.h:285
JPH_INLINE float GetY() const
Definition: Vec3.h:124
float mF32[4]
Definition: Vec3.h:286
JPH_INLINE void Set(float inX, float inY, float inZ)
Set all components.
Definition: Vec3.h:134
JPH_INLINE float GetZ() const
Definition: Vec3.h:125
Vec3()=default
Constructor.
JPH_INLINE Vec3 Swizzle() const
Swizzle the elements in inV.
{ float mData[4] Type
Definition: Vec4.h:24