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]; };
45 JPH_INLINE
DVec3(
double inX,
double inY,
double inZ);
51 static JPH_INLINE
DVec3 sZero();
59 static JPH_INLINE
DVec3 sReplicate(
double inV);
62 static JPH_INLINE
DVec3 sNaN();
65 static JPH_INLINE
DVec3 sLoadDouble3Unsafe(
const Double3 &inV);
68 JPH_INLINE
void StoreDouble3(
Double3 *outV)
const;
71 JPH_INLINE
explicit operator Vec3()
const;
74 JPH_INLINE
DVec3 PrepareRoundToZero()
const;
77 JPH_INLINE
DVec3 PrepareRoundToInf()
const;
80 JPH_INLINE
Vec3 ToVec3RoundDown()
const;
83 JPH_INLINE
Vec3 ToVec3RoundUp()
const;
125 JPH_INLINE
int GetTrues()
const;
128 JPH_INLINE
bool TestAnyTrue()
const;
131 JPH_INLINE
bool TestAllTrue()
const;
134#if defined(JPH_USE_AVX)
135 JPH_INLINE
double GetX()
const {
return _mm_cvtsd_f64(_mm256_castpd256_pd128(mValue)); }
136 JPH_INLINE
double GetY()
const {
return mF64[1]; }
137 JPH_INLINE
double GetZ()
const {
return mF64[2]; }
138#elif defined(JPH_USE_SSE)
139 JPH_INLINE
double GetX()
const {
return _mm_cvtsd_f64(mValue.mLow); }
140 JPH_INLINE
double GetY()
const {
return mF64[1]; }
141 JPH_INLINE
double GetZ()
const {
return _mm_cvtsd_f64(mValue.mHigh); }
142#elif defined(JPH_USE_NEON)
143 JPH_INLINE
double GetX()
const {
return vgetq_lane_f64(mValue.val[0], 0); }
144 JPH_INLINE
double GetY()
const {
return vgetq_lane_f64(mValue.val[0], 1); }
145 JPH_INLINE
double GetZ()
const {
return vgetq_lane_f64(mValue.val[1], 0); }
147 JPH_INLINE
double GetX()
const {
return mF64[0]; }
148 JPH_INLINE
double GetY()
const {
return mF64[1]; }
149 JPH_INLINE
double GetZ()
const {
return mF64[2]; }
153 JPH_INLINE
void SetX(
double inX) { mF64[0] = inX; }
154 JPH_INLINE
void SetY(
double inY) { mF64[1] = inY; }
155 JPH_INLINE
void SetZ(
double inZ) { mF64[2] = mF64[3] = inZ; }
158 JPH_INLINE
void Set(
double inX,
double inY,
double inZ) { *
this =
DVec3(inX, inY, inZ); }
161 JPH_INLINE
double operator [] (
uint inCoordinate)
const {
JPH_ASSERT(inCoordinate < 3);
return mF64[inCoordinate]; }
164 JPH_INLINE
void SetComponent(
uint inCoordinate,
double inValue) {
JPH_ASSERT(inCoordinate < 3); mF64[inCoordinate] = inValue; mValue = sFixW(mValue); }
167 JPH_INLINE
bool operator == (
DVec3Arg inV2)
const;
168 JPH_INLINE
bool operator != (
DVec3Arg inV2)
const {
return !(*
this == inV2); }
171 JPH_INLINE
bool IsClose(
DVec3Arg inV2,
double inMaxDistSq = 1.0e-24)
const;
174 JPH_INLINE
bool IsNearZero(
double inMaxDistSq = 1.0e-24)
const;
177 JPH_INLINE
bool IsNormalized(
double inTolerance = 1.0e-12)
const;
180 JPH_INLINE
bool IsNaN()
const;
192 JPH_INLINE
DVec3 operator / (
double inV2)
const;
195 JPH_INLINE
DVec3 & operator *= (
double inV2);
201 JPH_INLINE
DVec3 & operator /= (
double inV2);
216 JPH_INLINE
DVec3 operator - ()
const;
234 JPH_INLINE
DVec3 Abs()
const;
237 JPH_INLINE
DVec3 Reciprocal()
const;
243 JPH_INLINE
double Dot(
DVec3Arg inV2)
const;
246 JPH_INLINE
double LengthSq()
const;
249 JPH_INLINE
double Length()
const;
252 JPH_INLINE
DVec3 Normalized()
const;
255 JPH_INLINE
DVec3 Sqrt()
const;
258 JPH_INLINE
DVec3 GetSign()
const;
261 friend ostream & operator << (ostream &inStream,
DVec3Arg inV)
263 inStream << inV.
mF64[0] <<
", " << inV.
mF64[1] <<
", " << inV.
mF64[2];
268 JPH_INLINE
void CheckW()
const;
271 static JPH_INLINE Type sFixW(TypeArg inValue);
274 inline static const double cTrue = BitCast<double>(~
uint64(0));
275 inline static const double cFalse = 0.0;
284static_assert(std::is_trivial<DVec3>(),
"Is supposed to be a trivial type!");
std::uint64_t uint64
Definition Core.h:450
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
const DVec3 & DVec3Arg
Definition MathTypes.h:23
#define JPH_OVERRIDE_NEW_DELETE
Macro to override the new and delete functions.
Definition Memory.h:31
double mF64[4]
Definition DVec3.h:280
{ double mData[4] Type
Definition DVec3.h:29
static JPH_INLINE DVec3 sAxisY()
Definition DVec3.h:55
JPH_INLINE DVec3(TypeArg inRHS)
Definition DVec3.h:42
Type mValue
Definition DVec3.h:279
const Type & TypeArg
Definition DVec3.h:30
JPH_INLINE void SetComponent(uint inCoordinate, double inValue)
Set double component by index.
Definition DVec3.h:164
JPH_INLINE void Set(double inX, double inY, double inZ)
Set all components.
Definition DVec3.h:158
static JPH_INLINE DVec3 sAxisX()
Vectors with the principal axis.
Definition DVec3.h:54
JPH_INLINE void SetY(double inY)
Definition DVec3.h:154
JPH_INLINE double GetZ() const
Definition DVec3.h:149
DVec3()=default
Constructor.
static JPH_INLINE DVec3 sAxisZ()
Definition DVec3.h:56
JPH_INLINE DVec3(Vec3Arg inRHS)
JPH_INLINE void SetZ(double inZ)
Definition DVec3.h:155
JPH_INLINE double GetY() const
Definition DVec3.h:148
DVec3(const DVec3 &inRHS)=default
JPH_INLINE void SetX(double inX)
Set individual components.
Definition DVec3.h:153
JPH_INLINE double GetX() const
Get individual components.
Definition DVec3.h:147
Class that holds 3 doubles. Used as a storage class. Convert to DVec3 for calculations.
Definition Double3.h:13