13class [[nodiscard]] alignas(JPH_DVECTOR_ALIGNMENT)
DVec3
19#if defined(JPH_USE_AVX)
22#elif defined(JPH_USE_SSE)
23 using Type =
struct { __m128d mLow, mHigh; };
25#elif defined(JPH_USE_NEON)
26 using Type = float64x2x2_t;
29 using Type =
struct {
double mData[4]; };
44 JPH_INLINE
DVec3(
double inX,
double inY,
double inZ);
50 static JPH_INLINE
DVec3 sZero();
58 static JPH_INLINE
DVec3 sReplicate(
double inV);
61 static JPH_INLINE
DVec3 sNaN();
64 static JPH_INLINE
DVec3 sLoadDouble3Unsafe(
const Double3 &inV);
67 JPH_INLINE
void StoreDouble3(
Double3 *outV)
const;
70 JPH_INLINE
explicit operator Vec3()
const;
73 JPH_INLINE
DVec3 PrepareRoundToZero()
const;
76 JPH_INLINE
DVec3 PrepareRoundToInf()
const;
79 JPH_INLINE
Vec3 ToVec3RoundDown()
const;
82 JPH_INLINE
Vec3 ToVec3RoundUp()
const;
124 JPH_INLINE
int GetTrues()
const;
127 JPH_INLINE
bool TestAnyTrue()
const;
130 JPH_INLINE
bool TestAllTrue()
const;
133#if defined(JPH_USE_AVX)
134 JPH_INLINE
double GetX()
const {
return _mm_cvtsd_f64(_mm256_castpd256_pd128(mValue)); }
135 JPH_INLINE
double GetY()
const {
return mF64[1]; }
136 JPH_INLINE
double GetZ()
const {
return mF64[2]; }
137#elif defined(JPH_USE_SSE)
138 JPH_INLINE
double GetX()
const {
return _mm_cvtsd_f64(mValue.mLow); }
139 JPH_INLINE
double GetY()
const {
return mF64[1]; }
140 JPH_INLINE
double GetZ()
const {
return _mm_cvtsd_f64(mValue.mHigh); }
141#elif defined(JPH_USE_NEON)
142 JPH_INLINE
double GetX()
const {
return vgetq_lane_f64(mValue.val[0], 0); }
143 JPH_INLINE
double GetY()
const {
return vgetq_lane_f64(mValue.val[0], 1); }
144 JPH_INLINE
double GetZ()
const {
return vgetq_lane_f64(mValue.val[1], 0); }
146 JPH_INLINE
double GetX()
const {
return mF64[0]; }
147 JPH_INLINE
double GetY()
const {
return mF64[1]; }
148 JPH_INLINE
double GetZ()
const {
return mF64[2]; }
152 JPH_INLINE
void SetX(
double inX) { mF64[0] = inX; }
153 JPH_INLINE
void SetY(
double inY) { mF64[1] = inY; }
154 JPH_INLINE
void SetZ(
double inZ) { mF64[2] = mF64[3] = inZ; }
157 JPH_INLINE
double operator [] (
uint inCoordinate)
const {
JPH_ASSERT(inCoordinate < 3);
return mF64[inCoordinate]; }
160 JPH_INLINE
void SetComponent(
uint inCoordinate,
double inValue) {
JPH_ASSERT(inCoordinate < 3); mF64[inCoordinate] = inValue; mValue = sFixW(mValue); }
163 JPH_INLINE
bool operator == (
DVec3Arg inV2)
const;
164 JPH_INLINE
bool operator != (
DVec3Arg inV2)
const {
return !(*
this == inV2); }
167 JPH_INLINE
bool IsClose(
DVec3Arg inV2,
double inMaxDistSq = 1.0e-24)
const;
170 JPH_INLINE
bool IsNearZero(
double inMaxDistSq = 1.0e-24)
const;
173 JPH_INLINE
bool IsNormalized(
double inTolerance = 1.0e-12)
const;
176 JPH_INLINE
bool IsNaN()
const;
188 JPH_INLINE
DVec3 operator / (
double inV2)
const;
191 JPH_INLINE
DVec3 & operator *= (
double inV2);
197 JPH_INLINE
DVec3 & operator /= (
double inV2);
212 JPH_INLINE
DVec3 operator - ()
const;
230 JPH_INLINE
DVec3 Abs()
const;
233 JPH_INLINE
DVec3 Reciprocal()
const;
239 JPH_INLINE
double Dot(
DVec3Arg inV2)
const;
242 JPH_INLINE
double LengthSq()
const;
245 JPH_INLINE
double Length()
const;
248 JPH_INLINE
DVec3 Normalized()
const;
251 JPH_INLINE
DVec3 Sqrt()
const;
254 JPH_INLINE
DVec3 GetSign()
const;
257 friend ostream & operator << (ostream &inStream,
DVec3Arg inV)
259 inStream << inV.
mF64[0] <<
", " << inV.
mF64[1] <<
", " << inV.
mF64[2];
264 JPH_INLINE
void CheckW()
const;
267 static JPH_INLINE Type sFixW(TypeArg inValue);
270 inline static const double cTrue = BitCast<double>(~
uint64(0));
271 inline static const double cFalse = 0.0;
280static_assert(is_trivial<DVec3>(),
"Is supposed to be a trivial type!");
unsigned int uint
Definition Core.h:309
#define JPH_NAMESPACE_END
Definition Core.h:240
uint64_t uint64
Definition Core.h:313
#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
const DVec3 & DVec3Arg
Definition MathTypes.h:24
#define JPH_OVERRIDE_NEW_DELETE
Macro to override the new and delete functions.
Definition Memory.h:29
double mF64[4]
Definition DVec3.h:276
static JPH_INLINE DVec3 sAxisY()
Definition DVec3.h:54
JPH_INLINE DVec3(TypeArg inRHS)
Definition DVec3.h:41
Type mValue
Definition DVec3.h:275
const Type & TypeArg
Definition DVec3.h:30
JPH_INLINE void SetComponent(uint inCoordinate, double inValue)
Set double component by index.
Definition DVec3.h:160
static JPH_INLINE DVec3 sAxisX()
Vectors with the principal axis.
Definition DVec3.h:53
JPH_INLINE void SetY(double inY)
Definition DVec3.h:153
JPH_INLINE double GetZ() const
Definition DVec3.h:148
DVec3()=default
Constructor.
static JPH_INLINE DVec3 sAxisZ()
Definition DVec3.h:55
JPH_INLINE DVec3(Vec3Arg inRHS)
JPH_INLINE void SetZ(double inZ)
Definition DVec3.h:154
JPH_INLINE double GetY() const
Definition DVec3.h:147
DVec3(const DVec3 &inRHS)=default
struct { double mData[4];} Type
Definition DVec3.h:29
JPH_INLINE void SetX(double inX)
Set individual components.
Definition DVec3.h:152
JPH_INLINE double GetX() const
Get individual components.
Definition DVec3.h:146
Class that holds 3 doubles. Used as a storage class. Convert to DVec3 for calculations.
Definition Double3.h:13