13#define JPH_EL(r, c) mCol[c].mF32[r]
37 return Mat44(
Vec4(1, 0, 0, 0),
Vec4(0, 1, 0, 0),
Vec4(0, 0, 1, 0),
Vec4(0, 0, 0, 1));
48 for (
int c = 0;
c < 4; ++
c)
56 for (
int c = 0;
c < 4; ++
c)
65 float s =
sv.GetX(),
c =
cv.GetX();
66 return Mat44(
Vec4(1, 0, 0, 0),
Vec4(0,
c,
s, 0),
Vec4(0, -
s,
c, 0),
Vec4(0, 0, 0, 1));
73 float s =
sv.GetX(),
c =
cv.GetX();
74 return Mat44(
Vec4(
c, 0, -
s, 0),
Vec4(0, 1, 0, 0),
Vec4(
s, 0,
c, 0),
Vec4(0, 0, 0, 1));
81 float s =
sv.GetX(),
c =
cv.GetX();
82 return Mat44(
Vec4(
c,
s, 0, 0),
Vec4(-
s,
c, 0, 0),
Vec4(0, 0, 1, 0),
Vec4(0, 0, 0, 1));
135 Vec4(0.0f, 0.0f, 0.0f, 1.0f));
146 return Mat44(
Vec4(1, 0, 0, 0),
Vec4(0, 1, 0, 0),
Vec4(0, 0, 1, 0),
Vec4(
inV, 1));
152 m.SetTranslation(
inT);
159 m.SetTranslation(-
m.Multiply3x3(
inT));
165 return Mat44(
Vec4(
inScale, 0, 0, 0),
Vec4(0,
inScale, 0, 0),
Vec4(0, 0,
inScale, 0),
Vec4(0, 0, 0, 1));
170 return Mat44(
Vec4(
inV.GetX(), 0, 0, 0),
Vec4(0,
inV.GetY(), 0, 0),
Vec4(0, 0,
inV.GetZ(), 0),
Vec4(0, 0, 0, 1));
192 _mm_blend_ps(
_mm_shuffle_ps(
v,
v,
_MM_SHUFFLE(3, 3, 3, 1)),
_mm_shuffle_ps(
min_v,
min_v,
_MM_SHUFFLE(3, 3, 0, 3)), 0b0010),
195 float x =
inV.GetX();
196 float y =
inV.GetY();
197 float z =
inV.GetZ();
222 return Mat44(
Vec4(
width, 0.0f, 0.0f, 0.0f),
Vec4(0.0f,
height, 0.0f, 0.0f),
Vec4(0.0f, 0.0f,
range, -1.0f),
Vec4(0.0f, 0.0f,
range *
inNear, 0.0f));
235 for (
int i = 0;
i < 4; ++
i)
244#if defined(JPH_USE_SSE)
245 for (
int i = 0;
i < 4; ++
i)
254#elif defined(JPH_USE_NEON)
255 for (
int i = 0;
i < 4; ++
i)
265 for (
int i = 0;
i < 4; ++
i)
273#if defined(JPH_USE_SSE)
279#elif defined(JPH_USE_NEON)
295#if defined(JPH_USE_SSE)
301#elif defined(JPH_USE_NEON)
318#if defined(JPH_USE_SSE)
323#elif defined(JPH_USE_NEON)
338#if defined(JPH_USE_SSE4_1)
357#if defined(JPH_USE_SSE)
358 for (
int i = 0;
i < 3; ++
i)
366#elif defined(JPH_USE_NEON)
367 for (
int i = 0;
i < 3; ++
i)
376 for (
int i = 0;
i < 3; ++
i)
416 for (
int c = 0;
c < 4; ++
c)
423 for (
int c = 0;
c < 4; ++
c)
432 for (
int i = 0;
i < 4; ++
i)
440 for (
int i = 0;
i < 4; ++
i)
448 for (
int i = 0;
i < 4; ++
i)
455 for (
int c = 0;
c < 4; ++
c)
456 mCol[
c] +=
inM.mCol[
c];
463 for (
int c = 0;
c < 4; ++
c)
464 mCol[
c].StoreFloat4(
outV +
c);
469#if defined(JPH_USE_SSE)
481#elif defined(JPH_USE_NEON)
495 for (
int c = 0;
c < 4; ++
c)
496 for (
int r = 0; r < 4; ++r)
504#if defined(JPH_USE_SSE)
515#elif defined(JPH_USE_NEON)
527 for (
int c = 0;
c < 3; ++
c)
529 for (
int r = 0; r < 3; ++r)
540#if defined(JPH_USE_SSE)
619#elif defined(JPH_USE_NEON)
744 Vec4(
JPH_EL(1, 1),
JPH_EL(1, 2),
JPH_EL(1, 0), 0) *
Vec4(
JPH_EL(2, 2),
JPH_EL(2, 0),
JPH_EL(2, 1), 0)
745 -
Vec4(
JPH_EL(1, 2),
JPH_EL(1, 0),
JPH_EL(1, 1), 0) *
Vec4(
JPH_EL(2, 1),
JPH_EL(2, 2),
JPH_EL(2, 0), 0),
746 Vec4(
JPH_EL(0, 2),
JPH_EL(0, 0),
JPH_EL(0, 1), 0) *
Vec4(
JPH_EL(2, 1),
JPH_EL(2, 2),
JPH_EL(2, 0), 0)
747 -
Vec4(
JPH_EL(0, 1),
JPH_EL(0, 2),
JPH_EL(0, 0), 0) *
Vec4(
JPH_EL(2, 2),
JPH_EL(2, 0),
JPH_EL(2, 1), 0),
748 Vec4(
JPH_EL(0, 1),
JPH_EL(0, 2),
JPH_EL(0, 0), 0) *
Vec4(
JPH_EL(1, 2),
JPH_EL(1, 0),
JPH_EL(1, 1), 0)
749 -
Vec4(
JPH_EL(0, 2),
JPH_EL(0, 0),
JPH_EL(0, 1), 0) *
Vec4(
JPH_EL(1, 1),
JPH_EL(1, 2),
JPH_EL(1, 0), 0),
758 (
Vec4(
JPH_EL(1, 1),
JPH_EL(1, 2),
JPH_EL(1, 0), 0) *
Vec4(
JPH_EL(2, 2),
JPH_EL(2, 0),
JPH_EL(2, 1), 0)
759 -
Vec4(
JPH_EL(1, 2),
JPH_EL(1, 0),
JPH_EL(1, 1), 0) *
Vec4(
JPH_EL(2, 1),
JPH_EL(2, 2),
JPH_EL(2, 0), 0)) /
det,
760 (
Vec4(
JPH_EL(0, 2),
JPH_EL(0, 0),
JPH_EL(0, 1), 0) *
Vec4(
JPH_EL(2, 1),
JPH_EL(2, 2),
JPH_EL(2, 0), 0)
761 -
Vec4(
JPH_EL(0, 1),
JPH_EL(0, 2),
JPH_EL(0, 0), 0) *
Vec4(
JPH_EL(2, 2),
JPH_EL(2, 0),
JPH_EL(2, 1), 0)) /
det,
762 (
Vec4(
JPH_EL(0, 1),
JPH_EL(0, 2),
JPH_EL(0, 0), 0) *
Vec4(
JPH_EL(1, 2),
JPH_EL(1, 0),
JPH_EL(1, 1), 0)
763 -
Vec4(
JPH_EL(0, 2),
JPH_EL(0, 0),
JPH_EL(0, 1), 0) *
Vec4(
JPH_EL(1, 1),
JPH_EL(1, 2),
JPH_EL(1, 0), 0)) /
det,
769 float det =
inM.GetDeterminant3x3();
776 *
this =
inM.Adjointed3x3();
789 float s = sqrt(
tr + 1.0f);
792 (mCol[1].mF32[2] - mCol[2].mF32[1]) *
is,
793 (mCol[2].mF32[0] - mCol[0].mF32[2]) *
is,
794 (mCol[0].mF32[1] - mCol[1].mF32[0]) *
is,
800 if (mCol[1].mF32[1] > mCol[0].mF32[0])
i = 1;
801 if (mCol[2].mF32[2] > mCol[
i].mF32[
i])
i = 2;
805 float s = sqrt(mCol[0].mF32[0] - (mCol[1].mF32[1] + mCol[2].mF32[2]) + 1);
809 (mCol[1].mF32[0] + mCol[0].mF32[1]) *
is,
810 (mCol[0].mF32[2] + mCol[2].mF32[0]) *
is,
811 (mCol[1].mF32[2] - mCol[2].mF32[1]) *
is);
815 float s = sqrt(mCol[1].mF32[1] - (mCol[2].mF32[2] + mCol[0].mF32[0]) + 1);
818 (mCol[1].mF32[0] + mCol[0].mF32[1]) *
is,
820 (mCol[2].mF32[1] + mCol[1].mF32[2]) *
is,
821 (mCol[2].mF32[0] - mCol[0].mF32[2]) *
is);
827 float s = sqrt(mCol[2].mF32[2] - (mCol[0].mF32[0] + mCol[1].mF32[1]) + 1);
830 (mCol[0].mF32[2] + mCol[2].mF32[0]) *
is,
831 (mCol[2].mF32[1] + mCol[1].mF32[2]) *
is,
833 (mCol[0].mF32[1] - mCol[1].mF32[0]) *
is);
862 return Mat44(mCol[0], mCol[1], mCol[2],
Vec4(0, 0, 0, 1));
867#if defined(JPH_USE_AVX512)
872#elif defined(JPH_USE_SSE4_1)
878#elif defined(JPH_USE_NEON)
884 return Mat44(
Vec4(mCol[0].mF32[0], mCol[0].mF32[1], mCol[0].mF32[2], 0),
885 Vec4(mCol[1].mF32[0], mCol[1].mF32[1], mCol[1].mF32[2], 0),
886 Vec4(mCol[2].mF32[0], mCol[2].mF32[1], mCol[2].mF32[2], 0),
#define JPH_NAMESPACE_END
Definition Core.h:367
#define JPH_NAMESPACE_BEGIN
Definition Core.h:361
#define JPH_ASSERT(...)
Definition IssueReporting.h:33
#define JPH_EL(r, c)
Definition Mat44.inl:13
AllocateFunction Allocate
Definition Memory.cpp:59
@ SWIZZLE_Z
Use the Z component.
Definition Swizzle.h:14
@ SWIZZLE_W
Use the W component.
Definition Swizzle.h:15
@ SWIZZLE_X
Use the X component.
Definition Swizzle.h:12
@ SWIZZLE_Y
Use the Y component.
Definition Swizzle.h:13
JPH_INLINE float Tan(float inX)
Tangent of x (input in radians)
Definition Trigonometry.h:28
Class that holds 4 float values. Convert to Vec4 to perform calculations.
Definition Float4.h:11
Holds a 4x4 matrix of floats, but supports also operations on the 3x3 upper left part of the matrix.
Definition Mat44.h:13
JPH_INLINE Vec3 GetAxisY() const
Definition Mat44.h:148
JPH_INLINE Mat44 PostTranslated(Vec3Arg inTranslation) const
Post multiply by translation matrix: result = Mat44::sTranslation(inTranslation) * this (i....
Definition Mat44.inl:903
JPH_INLINE Mat44 PreTranslated(Vec3Arg inTranslation) const
Pre multiply by translation matrix: result = this * Mat44::sTranslation(inTranslation)
Definition Mat44.inl:898
JPH_INLINE Vec3 GetAxisZ() const
Definition Mat44.h:150
static JPH_INLINE Mat44 sIdentity()
Identity matrix.
Definition Mat44.inl:35
JPH_INLINE Mat44 Multiply3x3LeftTransposed(Mat44Arg inM) const
Multiply transpose of 3x3 matrix by 3x3 matrix ( )
Definition Mat44.inl:383
static JPH_INLINE Mat44 sZero()
Zero matrix.
Definition Mat44.inl:30
JPH_INLINE Quat GetQuaternion() const
Convert to quaternion.
Definition Mat44.inl:783
JPH_INLINE void StoreFloat4x4(Float4 *outV) const
Store matrix to memory.
Definition Mat44.inl:461
JPH_INLINE Mat44 operator-() const
Negate.
Definition Mat44.inl:437
static JPH_INLINE Mat44 sCrossProduct(Vec3Arg inV)
Get matrix that represents a cross product .
Definition Mat44.inl:179
JPH_INLINE Mat44 Transposed3x3() const
Transpose 3x3 subpart of matrix.
Definition Mat44.inl:502
JPH_INLINE Mat44 & operator*=(float inV)
Multiply matrix with float.
Definition Mat44.inl:421
JPH_INLINE float GetDeterminant3x3() const
Get the determinant of a 3x3 matrix.
Definition Mat44.inl:736
static JPH_INLINE Mat44 sQuatRightMultiply(QuatArg inQ)
Returns matrix MR so that (where p and q are quaternions)
Definition Mat44.inl:847
JPH_INLINE Mat44 Transposed() const
Transpose matrix.
Definition Mat44.inl:467
Vec4::Type Type
Definition Mat44.h:18
JPH_INLINE Mat44 Adjointed3x3() const
Get the adjoint of a 3x3 matrix.
Definition Mat44.inl:741
JPH_INLINE bool operator==(Mat44Arg inM2) const
Comparison.
Definition Mat44.inl:225
static JPH_INLINE Mat44 sRotationZ(float inZ)
Definition Mat44.inl:77
static JPH_INLINE Mat44 sLoadFloat4x4(const Float4 *inV)
Load 16 floats from memory.
Definition Mat44.inl:45
JPH_INLINE Vec3 Multiply3x3Transposed(Vec3Arg inV) const
Multiply vector by only 3x3 part of the transpose of the matrix ( )
Definition Mat44.inl:336
static JPH_INLINE Mat44 sOuterProduct(Vec3Arg inV1, Vec3Arg inV2)
Get outer product of inV and inV2 (equivalent to )
Definition Mat44.inl:173
static JPH_INLINE Mat44 sLookAt(Vec3Arg inPos, Vec3Arg inTarget, Vec3Arg inUp)
Definition Mat44.inl:207
JPH_INLINE Mat44 GetRotation() const
Get rotation part only (note: retains the first 3 values from the bottom row)
Definition Mat44.inl:856
JPH_INLINE Mat44 GetRotationSafe() const
Get rotation part only (note: also clears the bottom row)
Definition Mat44.inl:865
JPH_INLINE Mat44 Multiply3x3RightTransposed(Mat44Arg inM) const
Multiply 3x3 matrix by the transpose of a 3x3 matrix ( )
Definition Mat44.inl:397
static JPH_INLINE Mat44 sNaN()
Matrix filled with NaN's.
Definition Mat44.inl:40
JPH_INLINE Mat44 & operator+=(Mat44Arg inM)
Per element addition of matrix.
Definition Mat44.inl:453
JPH_INLINE Mat44 PostScaled(Vec3Arg inScale) const
Scale a matrix: result = Mat44::sScale(inScale) * this.
Definition Mat44.inl:913
JPH_INLINE bool IsClose(Mat44Arg inM2, float inMaxDistSq=1.0e-12f) const
Test if two matrices are close.
Definition Mat44.inl:233
JPH_INLINE bool SetInversed3x3(Mat44Arg inM)
*this = inM.Inversed3x3(), returns false if the matrix is singular in which case *this is unchanged
Definition Mat44.inl:767
static JPH_INLINE Mat44 sScale(float inScale)
Get matrix that scales uniformly.
Definition Mat44.inl:163
static JPH_INLINE Mat44 sLoadFloat4x4Aligned(const Float4 *inV)
Load 16 floats from memory, 16 bytes aligned.
Definition Mat44.inl:53
static JPH_INLINE Mat44 sTranslation(Vec3Arg inV)
Get matrix that translates.
Definition Mat44.inl:144
JPH_INLINE Vec4 GetColumn4(uint inCol) const
Definition Mat44.h:160
JPH_INLINE Mat44 Decompose(Vec3 &outScale) const
Definition Mat44.inl:919
JPH_INLINE Vec3 GetAxisX() const
Access to the columns.
Definition Mat44.h:146
JPH_INLINE Mat44 Inversed() const
Inverse 4x4 matrix.
Definition Mat44.inl:538
JPH_INLINE Vec3 Multiply3x3(Vec3Arg inV) const
Multiply vector by only 3x3 part of the matrix.
Definition Mat44.inl:316
static JPH_INLINE Mat44 sRotationTranslation(QuatArg inR, Vec3Arg inT)
Get matrix that rotates and translates.
Definition Mat44.inl:149
JPH_INLINE void SetRotation(Mat44Arg inRotation)
Updates the rotation part of this matrix (the first 3 columns)
Definition Mat44.inl:891
JPH_INLINE Vec3 GetTranslation() const
Definition Mat44.h:152
JPH_INLINE Mat44 operator+(Mat44Arg inM) const
Per element addition of matrix.
Definition Mat44.inl:429
static JPH_INLINE Mat44 sRotation(Vec3Arg inAxis, float inAngle)
Rotate around arbitrary axis.
Definition Mat44.inl:139
static JPH_INLINE Mat44 sInverseRotationTranslation(QuatArg inR, Vec3Arg inT)
Get inverse matrix of sRotationTranslation.
Definition Mat44.inl:156
Mat44()=default
Constructor.
JPH_INLINE Mat44 Inversed3x3() const
Inverse 3x3 matrix.
Definition Mat44.inl:753
static JPH_INLINE Mat44 sQuatLeftMultiply(QuatArg inQ)
Returns matrix ML so that (where p and q are quaternions)
Definition Mat44.inl:838
static JPH_INLINE Mat44 sPerspective(float inFovY, float inAspect, float inNear, float inFar)
Returns a right-handed perspective projection matrix.
Definition Mat44.inl:216
static JPH_INLINE Mat44 sRotationX(float inX)
Rotate around X, Y or Z axis (angle in radians)
Definition Mat44.inl:61
JPH_INLINE Mat44 InversedRotationTranslation() const
Inverse 4x4 matrix when it only contains rotation and translation.
Definition Mat44.inl:729
JPH_INLINE Mat44 PreScaled(Vec3Arg inScale) const
Scale a matrix: result = this * Mat44::sScale(inScale)
Definition Mat44.inl:908
static JPH_INLINE Mat44 sRotationY(float inY)
Definition Mat44.inl:69
friend JPH_INLINE Mat44 operator*(float inV, Mat44Arg inM)
Definition Mat44.h:128
static JPH_INLINE Quat sRotation(Vec3Arg inAxis, float inAngle)
Rotation from axis and angle.
Definition Quat.inl:74
JPH_INLINE bool TestAllTrue() const
Test if all components are true (true is when highest bit of component is set)
Definition UVec4.inl:400
static JPH_INLINE UVec4 sAnd(UVec4Arg inV1, UVec4Arg inV2)
Logical and (component wise)
Definition UVec4.inl:194
JPH_INLINE float Dot(Vec3Arg inV2) const
Dot product.
Definition Vec3.inl:637
static JPH_INLINE Type sFixW(Type inValue)
Internal helper function that ensures that the Z component is replicated to the W component to preven...
static JPH_INLINE Vec3 sAxisX()
Vectors with the principal axis.
Definition Vec3.h:52
JPH_INLINE Vec4 SplatX() const
Replicate the X component to all components.
Definition Vec3.inl:521
JPH_INLINE Vec3 Cross(Vec3Arg inV2) const
Cross product.
Definition Vec3.inl:582
JPH_INLINE float GetX() const
Get individual components.
Definition Vec3.h:123
JPH_INLINE Vec3 NormalizedOr(Vec3Arg inZeroValue) const
Normalize vector or return inZeroValue if the length of the vector is zero.
Definition Vec3.inl:708
JPH_INLINE Vec4 SplatZ() const
Replicate the Z component to all components.
Definition Vec3.inl:543
JPH_INLINE void SetZ(float inZ)
Definition Vec3.h:131
static JPH_INLINE Vec3 sAxisZ()
Definition Vec3.h:54
JPH_INLINE float GetY() const
Definition Vec3.h:124
JPH_INLINE Vec4 SplatY() const
Replicate the Y component to all components.
Definition Vec3.inl:532
JPH_INLINE float LengthSq() const
Squared length of vector.
Definition Vec3.inl:653
JPH_INLINE Vec3 Sqrt() const
Component wise square root.
Definition Vec3.inl:683
JPH_INLINE float GetZ() const
Definition Vec3.h:125
JPH_INLINE Vec4 SplatX() const
Replicate the X component to all components.
Definition Vec4.inl:547
float mF32[4]
Definition Vec4.h:275
static JPH_INLINE Vec4 sLoadFloat4Aligned(const Float4 *inV)
Load 4 floats from memory, 16 bytes aligned.
Definition Vec4.inl:101
static JPH_INLINE UVec4 sEquals(Vec4Arg inV1, Vec4Arg inV2)
Equals (component wise)
Definition Vec4.inl:166
JPH_INLINE Vec4 SplatY() const
Replicate the Y component to all components.
Definition Vec4.inl:558
JPH_INLINE Vec4 SplatZ() const
Replicate the Z component to all components.
Definition Vec4.inl:569
static JPH_INLINE Vec4 sLoadFloat4(const Float4 *inV)
Load 4 floats from memory.
Definition Vec4.inl:90
static JPH_INLINE Vec4 sZero()
Vector with all zeros.
Definition Vec4.inl:63
Type mValue
Definition Vec4.h:274
static JPH_INLINE Vec4 sNaN()
Vector with all NaN's.
Definition Vec4.inl:85
JPH_INLINE float GetZ() const
Definition Vec4.h:115
JPH_INLINE float GetY() const
Definition Vec4.h:114
static JPH_INLINE Vec4 sReplicate(float inV)
Replicate inV across all components.
Definition Vec4.inl:74
void SinCos(Vec4 &outSin, Vec4 &outCos) const
Calculate the sine and cosine for each element of this vector (input in radians)
Definition Vec4.inl:767