32#include "foundation/Px.h"
33#include "foundation/PxIntrinsics.h"
34#include "foundation/PxVec3.h"
35#include "foundation/PxVec4.h"
36#include "foundation/PxMat33.h"
37#include "foundation/PxUnionCast.h"
49#if !defined(PX_SIMD_DISABLED)
50#if PX_INTEL_FAMILY && (!defined(__EMSCRIPTEN__) || defined(__SSE2__))
51 #define COMPILE_VECTOR_INTRINSICS 1
53 #define COMPILE_VECTOR_INTRINSICS 1
55 #define COMPILE_VECTOR_INTRINSICS 0
58 #define COMPILE_VECTOR_INTRINSICS 0
61#if COMPILE_VECTOR_INTRINSICS && PX_INTEL_FAMILY && PX_UNIX_FAMILY
64 #include <emmintrin.h>
66 #include <xmmintrin.h>
69#if COMPILE_VECTOR_INTRINSICS
72 #include "PxVecMathAoSScalar.h"
124PX_FORCE_INLINE Vec4V V4LoadXYZW(
const PxF32& x,
const PxF32& y,
const PxF32& z,
const PxF32& w);
156PX_FORCE_INLINE QuatV QuatVLoadXYZW(
const PxF32 x,
const PxF32 y,
const PxF32 z,
const PxF32 w);
159Vec4V Vec4V_From_PxVec3_WUndefined(
const PxVec3& v);
247namespace vecMathTests
250PX_FORCE_INLINE bool allElementsEqualFloatV(
const FloatV a,
const FloatV b);
251PX_FORCE_INLINE bool allElementsEqualVec3V(
const Vec3V a,
const Vec3V b);
252PX_FORCE_INLINE bool allElementsEqualVec4V(
const Vec4V a,
const Vec4V b);
253PX_FORCE_INLINE bool allElementsEqualBoolV(
const BoolV a,
const BoolV b);
254PX_FORCE_INLINE bool allElementsEqualVecU32V(
const VecU32V a,
const VecU32V b);
255PX_FORCE_INLINE bool allElementsEqualVecI32V(
const VecI32V a,
const VecI32V b);
257PX_FORCE_INLINE bool allElementsEqualMat33V(
const Mat33V& a,
const Mat33V& b)
259 return (allElementsEqualVec3V(a.col0, b.col0) && allElementsEqualVec3V(a.col1, b.col1) &&
260 allElementsEqualVec3V(a.col2, b.col2));
262PX_FORCE_INLINE bool allElementsEqualMat34V(
const Mat34V& a,
const Mat34V& b)
264 return (allElementsEqualVec3V(a.col0, b.col0) && allElementsEqualVec3V(a.col1, b.col1) &&
265 allElementsEqualVec3V(a.col2, b.col2) && allElementsEqualVec3V(a.col3, b.col3));
267PX_FORCE_INLINE bool allElementsEqualMat44V(
const Mat44V& a,
const Mat44V& b)
269 return (allElementsEqualVec4V(a.col0, b.col0) && allElementsEqualVec4V(a.col1, b.col1) &&
270 allElementsEqualVec4V(a.col2, b.col2) && allElementsEqualVec4V(a.col3, b.col3));
273PX_FORCE_INLINE bool allElementsNearEqualFloatV(
const FloatV a,
const FloatV b);
274PX_FORCE_INLINE bool allElementsNearEqualVec3V(
const Vec3V a,
const Vec3V b);
275PX_FORCE_INLINE bool allElementsNearEqualVec4V(
const Vec4V a,
const Vec4V b);
276PX_FORCE_INLINE bool allElementsNearEqualMat33V(
const Mat33V& a,
const Mat33V& b)
278 return (allElementsNearEqualVec3V(a.col0, b.col0) && allElementsNearEqualVec3V(a.col1, b.col1) &&
279 allElementsNearEqualVec3V(a.col2, b.col2));
281PX_FORCE_INLINE bool allElementsNearEqualMat34V(
const Mat34V& a,
const Mat34V& b)
283 return (allElementsNearEqualVec3V(a.col0, b.col0) && allElementsNearEqualVec3V(a.col1, b.col1) &&
284 allElementsNearEqualVec3V(a.col2, b.col2) && allElementsNearEqualVec3V(a.col3, b.col3));
286PX_FORCE_INLINE bool allElementsNearEqualMat44V(
const Mat44V& a,
const Mat44V& b)
288 return (allElementsNearEqualVec4V(a.col0, b.col0) && allElementsNearEqualVec4V(a.col1, b.col1) &&
289 allElementsNearEqualVec4V(a.col2, b.col2) && allElementsNearEqualVec4V(a.col3, b.col3));
338PX_FORCE_INLINE FloatV FScaleAdd(
const FloatV a,
const FloatV b,
const FloatV c);
340PX_FORCE_INLINE FloatV FNegScaleSub(
const FloatV a,
const FloatV b,
const FloatV c);
344PX_FORCE_INLINE FloatV FSel(
const BoolV c,
const FloatV a,
const FloatV b);
356PX_FORCE_INLINE FloatV FClamp(
const FloatV a,
const FloatV minV,
const FloatV maxV);
365PX_FORCE_INLINE PxU32 FOutOfBounds(
const FloatV a,
const FloatV min,
const FloatV max);
367PX_FORCE_INLINE PxU32 FInBounds(
const FloatV a,
const FloatV min,
const FloatV max);
369PX_FORCE_INLINE PxU32 FOutOfBounds(
const FloatV a,
const FloatV bounds);
388PX_FORCE_INLINE Vec3V V3Merge(
const FloatVArg x,
const FloatVArg y,
const FloatVArg z);
429PX_FORCE_INLINE Vec3V V3ColX(
const Vec3V a,
const Vec3V b,
const Vec3V c);
431PX_FORCE_INLINE Vec3V V3ColY(
const Vec3V a,
const Vec3V b,
const Vec3V c);
433PX_FORCE_INLINE Vec3V V3ColZ(
const Vec3V a,
const Vec3V b,
const Vec3V c);
468PX_FORCE_INLINE Vec3V V3ScaleAdd(
const Vec3V a,
const FloatV b,
const Vec3V c);
470PX_FORCE_INLINE Vec3V V3NegScaleSub(
const Vec3V a,
const FloatV b,
const Vec3V c);
472PX_FORCE_INLINE Vec3V V3MulAdd(
const Vec3V a,
const Vec3V b,
const Vec3V c);
474PX_FORCE_INLINE Vec3V V3NegMulSub(
const Vec3V a,
const Vec3V b,
const Vec3V c);
498PX_FORCE_INLINE Vec3V V3NormalizeSafe(
const Vec3V a,
const Vec3V unsafeReturnValue);
504PX_FORCE_INLINE Vec3V V3Sel(
const BoolV c,
const Vec3V a,
const Vec3V b);
525PX_FORCE_INLINE Vec3V V3Clamp(
const Vec3V a,
const Vec3V minV,
const Vec3V maxV);
542PX_FORCE_INLINE PxU32 V3OutOfBounds(
const Vec3V a,
const Vec3V min,
const Vec3V max);
545PX_FORCE_INLINE PxU32 V3InBounds(
const Vec3V a,
const Vec3V min,
const Vec3V max);
574PX_FORCE_INLINE Vec3V V3Perm_Zero_1Z_0Y(
const Vec3V v0,
const Vec3V v1);
576PX_FORCE_INLINE Vec3V V3Perm_0Z_Zero_1X(
const Vec3V v0,
const Vec3V v1);
578PX_FORCE_INLINE Vec3V V3Perm_1Y_0X_Zero(
const Vec3V v0,
const Vec3V v1);
582PX_FORCE_INLINE void V3Transpose(Vec3V& col0, Vec3V& col1, Vec3V& col2);
594PX_FORCE_INLINE Vec4V V4Merge(
const FloatVArg x,
const FloatVArg y,
const FloatVArg z,
const FloatVArg w);
596PX_FORCE_INLINE Vec4V V4MergeW(
const Vec4VArg x,
const Vec4VArg y,
const Vec4VArg z,
const Vec4VArg w);
598PX_FORCE_INLINE Vec4V V4MergeZ(
const Vec4VArg x,
const Vec4VArg y,
const Vec4VArg z,
const Vec4VArg w);
600PX_FORCE_INLINE Vec4V V4MergeY(
const Vec4VArg x,
const Vec4VArg y,
const Vec4VArg z,
const Vec4VArg w);
602PX_FORCE_INLINE Vec4V V4MergeX(
const Vec4VArg x,
const Vec4VArg y,
const Vec4VArg z,
const Vec4VArg w);
640template <
int elementIndex>
698PX_FORCE_INLINE Vec4V V4ScaleAdd(
const Vec4V a,
const FloatV b,
const Vec4V c);
700PX_FORCE_INLINE Vec4V V4NegScaleSub(
const Vec4V a,
const FloatV b,
const Vec4V c);
702PX_FORCE_INLINE Vec4V V4MulAdd(
const Vec4V a,
const Vec4V b,
const Vec4V c);
704PX_FORCE_INLINE Vec4V V4NegMulSub(
const Vec4V a,
const Vec4V b,
const Vec4V c);
726PX_FORCE_INLINE Vec4V V4NormalizeSafe(
const Vec4V a,
const Vec4V unsafeReturnValue);
731PX_FORCE_INLINE Vec4V V4Sel(
const BoolV c,
const Vec4V a,
const Vec4V b);
748PX_FORCE_INLINE Vec4V V4Clamp(
const Vec4V a,
const Vec4V minV,
const Vec4V maxV);
783template <PxU8 x, PxU8 y, PxU8 z, PxU8 w>
789PX_FORCE_INLINE void V3Transpose(Vec3V& col0, Vec3V& col1, Vec3V& col2);
792PX_FORCE_INLINE QuatV QuatV_From_RotationAxisAngle(
const Vec3V u,
const FloatV a);
808PX_FORCE_INLINE void QuatGetMat33V(
const QuatVArg q, Vec3V& column0, Vec3V& column1, Vec3V& column2);
834PX_FORCE_INLINE QuatV QuatMerge(
const FloatVArg x,
const FloatVArg y,
const FloatVArg z,
const FloatVArg w);
897template <
int elementIndex>
951PX_FORCE_INLINE VecI32V VecI32V_LeftShift(
const VecI32VArg a,
const VecShiftVArg shift);
956PX_FORCE_INLINE VecI32V VecI32V_RightShift(
const VecI32VArg a,
const VecShiftVArg shift);
958PX_FORCE_INLINE VecI32V VecI32V_Add(
const VecI32VArg a,
const VecI32VArg b);
960PX_FORCE_INLINE VecI32V VecI32V_Or(
const VecI32VArg a,
const VecI32VArg b);
970PX_FORCE_INLINE VecI32V VecI32V_Sub(
const VecI32VArg a,
const VecI32VArg b);
972PX_FORCE_INLINE BoolV VecI32V_IsGrtr(
const VecI32VArg a,
const VecI32VArg b);
974PX_FORCE_INLINE BoolV VecI32V_IsEq(
const VecI32VArg a,
const VecI32VArg b);
976PX_FORCE_INLINE VecI32V V4I32Sel(
const BoolV c,
const VecI32V a,
const VecI32V b);
988PX_FORCE_INLINE VecU32V V4U32Sel(
const BoolV c,
const VecU32V a,
const VecU32V b);
1004 return Mat33V(Vec3V_From_Vec4V(V4LoadU(&m.column0.x)),
1005 Vec3V_From_Vec4V(V4LoadU(&m.column1.x)), V3LoadU(m.column2));
1010PX_FORCE_INLINE Vec3V M33MulV3AddV3(
const Mat33V& A,
const Vec3V b,
const Vec3V c);
1172 reinterpret_cast<PxVec3&
>(v).x = f;
1177 reinterpret_cast<PxVec3&
>(v).y = f;
1182 reinterpret_cast<PxVec3&
>(v).z = f;
1187 reinterpret_cast<PxVec3&
>(v) = f;
1192 return reinterpret_cast<const PxVec3&
>(v).x;
1197 return reinterpret_cast<const PxVec3&
>(v).y;
1202 return reinterpret_cast<const PxVec3&
>(v).z;
1207 return reinterpret_cast<const PxVec3&
>(v);
1212 reinterpret_cast<PxVec4&
>(v).x = f;
1217 reinterpret_cast<PxVec4&
>(v).y = f;
1222 reinterpret_cast<PxVec4&
>(v).z = f;
1227 reinterpret_cast<PxVec4&
>(v).w = f;
1232 reinterpret_cast<PxVec3&
>(v) = f;
1237 return reinterpret_cast<const PxVec4&
>(v).x;
1242 return reinterpret_cast<const PxVec4&
>(v).y;
1247 return reinterpret_cast<const PxVec4&
>(v).z;
1252 return reinterpret_cast<const PxVec4&
>(v).w;
1257 return reinterpret_cast<const PxVec3&
>(v);
1261#define PX_TRANSPOSE_44_34(inA, inB, inC, inD, outA, outB, outC) \
1262outA = V4UnpackXY(inA, inC); \
1263inA = V4UnpackZW(inA, inC); \
1264inC = V4UnpackXY(inB, inD); \
1265inB = V4UnpackZW(inB, inD); \
1266outB = V4UnpackZW(outA, inC); \
1267outA = V4UnpackXY(outA, inC); \
1268outC = V4UnpackXY(inA, inB);
1271#define PX_TRANSPOSE_34_44(inA, inB, inC, outA, outB, outC, outD) \
1272 outA = V4UnpackXY(inA, inC); \
1273 inA = V4UnpackZW(inA, inC); \
1274 outC = V4UnpackXY(inB, inB); \
1275 inC = V4UnpackZW(inB, inB); \
1276 outB = V4UnpackZW(outA, outC); \
1277 outA = V4UnpackXY(outA, outC); \
1278 outC = V4UnpackXY(inA, inC); \
1279 outD = V4UnpackZW(inA, inC);
1281#define PX_TRANSPOSE_44(inA, inB, inC, inD, outA, outB, outC, outD) \
1282 outA = V4UnpackXY(inA, inC); \
1283 inA = V4UnpackZW(inA, inC); \
1284 inC = V4UnpackXY(inB, inD); \
1285 inB = V4UnpackZW(inB, inD); \
1286 outB = V4UnpackZW(outA, inC); \
1287 outA = V4UnpackXY(outA, inC); \
1288 outC = V4UnpackXY(inA, inB); \
1289 outD = V4UnpackZW(inA, inB);
1299PX_FORCE_INLINE Vec4V V3Dot4(
const Vec3VArg a0,
const Vec3VArg b0,
const Vec3VArg a1,
const Vec3VArg b1,
1300 const Vec3VArg a2,
const Vec3VArg b2,
const Vec3VArg a3,
const Vec3VArg b3)
1302 Vec4V a0b0 = Vec4V_From_Vec3V(V3Mul(a0, b0));
1303 Vec4V a1b1 = Vec4V_From_Vec3V(V3Mul(a1, b1));
1304 Vec4V a2b2 = Vec4V_From_Vec3V(V3Mul(a2, b2));
1305 Vec4V a3b3 = Vec4V_From_Vec3V(V3Mul(a3, b3));
1307 Vec4V aTrnsps, bTrnsps, cTrnsps;
1309 PX_TRANSPOSE_44_34(a0b0, a1b1, a2b2, a3b3, aTrnsps, bTrnsps, cTrnsps);
1311 return V4Add(V4Add(aTrnsps, bTrnsps), cTrnsps);
1317 return Vec3V_From_Vec4V(V4LoadU(&f.x));
1326#if COMPILE_VECTOR_INTRINSICS
1327#include "PxInlineAoS.h"
1329#include "PxVecMathAoSScalarInline.h"
1331#include "PxVecQuat.h"
#define PX_RESTRICT
Definition PxPreprocessor.h:355
#define PX_FORCE_INLINE
Definition PxPreprocessor.h:335
Sorts an array of objects in ascending order, assuming that the predicate implements the < operator:
Definition PxBoxController.h:39