25#ifdef BT_USE_DOUBLE_PRECISION
26#define btVector3Data btVector3DoubleData
27#define btVector3DataName "btVector3DoubleData"
29#define btVector3Data btVector3FloatData
30#define btVector3DataName "btVector3FloatData"
38#pragma warning(disable: 4556)
42#define BT_SHUFFLE(x,y,z,w) ((w)<<6 | (z)<<4 | (y)<<2 | (x))
44#define bt_pshufd_ps( _a, _mask ) _mm_shuffle_ps((_a), (_a), (_mask) )
45#define bt_splat3_ps( _a, _i ) bt_pshufd_ps((_a), BT_SHUFFLE(_i,_i,_i, 3) )
46#define bt_splat_ps( _a, _i ) bt_pshufd_ps((_a), BT_SHUFFLE(_i,_i,_i,_i) )
48#define btv3AbsiMask (_mm_set_epi32(0x00000000, 0x7FFFFFFF, 0x7FFFFFFF, 0x7FFFFFFF))
49#define btvAbsMask (_mm_set_epi32( 0x7FFFFFFF, 0x7FFFFFFF, 0x7FFFFFFF, 0x7FFFFFFF))
50#define btvFFF0Mask (_mm_set_epi32(0x00000000, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF))
51#define btv3AbsfMask btCastiTo128f(btv3AbsiMask)
52#define btvFFF0fMask btCastiTo128f(btvFFF0Mask)
53#define btvxyzMaskf btvFFF0fMask
54#define btvAbsfMask btCastiTo128f(btvAbsMask)
57#define btvMzeroMask (_mm_set_ps(-0.0f, -0.0f, -0.0f, -0.0f))
58#define v1110 (_mm_set_ps(0.0f, 1.0f, 1.0f, 1.0f))
59#define vHalf (_mm_set_ps(0.5f, 0.5f, 0.5f, 0.5f))
60#define v1_5 (_mm_set_ps(1.5f, 1.5f, 1.5f, 1.5f))
73 static_cast<int32_t>(0xFFFFFFFF),
static_cast<int32_t>(0xFFFFFFFF), 0x0};
89#if defined (__SPU__) && defined (__CELLOS_LV2__)
98 #if defined (BT_USE_SSE) || defined(BT_USE_NEON)
139#if (defined (BT_USE_SSE_IN_API) && defined (BT_USE_SSE) )|| defined (BT_USE_NEON)
166#if defined(BT_USE_SSE_IN_API) && defined (BT_USE_SSE)
168#elif defined(BT_USE_NEON)
183#if defined(BT_USE_SSE_IN_API) && defined (BT_USE_SSE)
185#elif defined(BT_USE_NEON)
199#if defined(BT_USE_SSE_IN_API) && defined (BT_USE_SSE)
203#elif defined(BT_USE_NEON)
237#if defined BT_USE_SIMD_VECTOR3 && defined (BT_USE_SSE_IN_API) && defined (BT_USE_SSE)
244#elif defined(BT_USE_NEON)
250 return m_floats[0] * v.
m_floats[0] +
314#if defined(BT_USE_SSE_IN_API) && defined (BT_USE_SSE)
375#if defined BT_USE_SIMD_VECTOR3 && defined (BT_USE_SSE_IN_API) && defined (BT_USE_SSE)
377#elif defined(BT_USE_NEON)
391#if defined(BT_USE_SSE_IN_API) && defined (BT_USE_SSE)
403#elif defined(BT_USE_NEON)
430#if defined BT_USE_SIMD_VECTOR3 && defined (BT_USE_SSE_IN_API) && defined (BT_USE_SSE)
449#elif defined(BT_USE_NEON)
482 return m_floats[0] < m_floats[1] ? (m_floats[0] <m_floats[2] ? 0 : 2) : (m_floats[1] <m_floats[2] ? 1 : 2);
489 return m_floats[0] < m_floats[1] ? (m_floats[1] <m_floats[2] ? 2 : 1) : (m_floats[0] <m_floats[2] ? 2 : 0);
494 return absolute().minAxis();
499 return absolute().maxAxis();
505#if defined(BT_USE_SSE_IN_API) && defined (BT_USE_SSE)
515#elif defined(BT_USE_NEON)
534#if defined(BT_USE_SSE_IN_API) && defined (BT_USE_SSE)
542#elif defined(BT_USE_NEON)
551 m_floats[1] + (v.
m_floats[1] - m_floats[1]) *
t,
552 m_floats[2] + (v.
m_floats[2] - m_floats[2]) *
t);
560#if defined(BT_USE_SSE_IN_API) && defined (BT_USE_SSE)
562#elif defined(BT_USE_NEON)
603#if defined(BT_USE_SSE_IN_API) && defined (BT_USE_SSE)
606 return ((m_floats[3]==other.
m_floats[3]) &&
615 return !(*
this == other);
623#if defined(BT_USE_SSE_IN_API) && defined (BT_USE_SSE)
625#elif defined(BT_USE_NEON)
640#if defined(BT_USE_SSE_IN_API) && defined (BT_USE_SSE)
642#elif defined(BT_USE_NEON)
662#if defined BT_USE_SIMD_VECTOR3 && defined (BT_USE_SSE_IN_API) && defined (BT_USE_SSE)
685#if defined(BT_USE_SSE_IN_API) && defined (BT_USE_SSE)
687#elif defined(BT_USE_NEON)
733#if defined BT_USE_SIMD_VECTOR3 && defined (BT_USE_SSE_IN_API) && defined (BT_USE_SSE)
747#elif defined(BT_USE_NEON)
767#if defined(BT_USE_SSE_IN_API) && defined (BT_USE_SSE)
769#elif defined(BT_USE_NEON)
783#if defined(BT_USE_SSE_IN_API) && defined (BT_USE_SSE)
785#elif defined(BT_USE_NEON)
799#if defined BT_USE_SIMD_VECTOR3 && (defined(BT_USE_SSE_IN_API) && defined(BT_USE_SSE))
804#elif defined(BT_USE_NEON)
819#if defined BT_USE_SIMD_VECTOR3 && (defined(BT_USE_SSE_IN_API) && defined (BT_USE_SSE))
822#elif defined(BT_USE_NEON)
833#if defined(BT_USE_SSE_IN_API) && defined (BT_USE_SSE)
837#elif defined(BT_USE_NEON)
873#if defined BT_USE_SIMD_VECTOR3 && (defined(BT_USE_SSE_IN_API)&& defined (BT_USE_SSE))
877#elif defined(BT_USE_NEON)
949 return v1.
lerp(v2,
t);
961 return (v - *
this).length();
975#if defined BT_USE_SIMD_VECTOR3 && defined (BT_USE_SSE_IN_API) && defined (BT_USE_SSE)
1015#if (defined BT_USE_SSE && defined BT_USE_SIMD_VECTOR3 && defined BT_USE_SSE_IN_API) || defined (BT_USE_NEON)
1016 #if defined _WIN32 || defined (BT_USE_SSE)
1019 #elif defined BT_USE_NEON
1043#if (defined BT_USE_SSE && defined BT_USE_SIMD_VECTOR3 && defined BT_USE_SSE_IN_API) || defined (BT_USE_NEON)
1050#if (defined BT_USE_SSE && defined BT_USE_SIMD_VECTOR3 && defined BT_USE_SSE_IN_API) || defined (BT_USE_NEON)
1051 #if defined BT_USE_SSE
1054 #elif defined BT_USE_NEON
1058 #error unhandled arch!
1083#if (defined BT_USE_SSE && defined BT_USE_SIMD_VECTOR3 && defined BT_USE_SSE_IN_API) || defined (BT_USE_NEON)
1102#if (defined (BT_USE_SSE_IN_API)&& defined (BT_USE_SSE)) || defined (BT_USE_NEON)
1123#if defined BT_USE_SIMD_VECTOR3 && defined(BT_USE_SSE_IN_API) && defined (BT_USE_SSE)
1125#elif defined(BT_USE_NEON)
1240 #ifdef BT_USE_DOUBLE_PRECISION
1263 for (
int i=0;i<4;i++)
1275 for (
int i=0;i<4;i++)
1287 btScalar a = n[1]*n[1] + n[2]*n[2];
1299 btScalar a = n[0]*n[0] + n[1]*n[1];
1326 for (
int i=0;i<4;i++)
1332 for (
int i=0;i<4;i++)
1340 for (
int i=0;i<4;i++)
1346 for (
int i=0;i<4;i++)
1354 for (
int i=0;i<4;i++)
1360 for (
int i=0;i<4;i++)
void btSetMin(T &a, const T &b)
const T & btMax(const T &a, const T &b)
void btSetMax(T &a, const T &b)
btScalar dot(const btQuaternion &q1, const btQuaternion &q2)
Calculate the dot product between two quaternions.
btScalar length(const btQuaternion &q)
Return the length of a quaternion.
float btScalar
The btScalar type abstracts floating point numbers, to easily switch between double and single floati...
#define ATTRIBUTE_ALIGNED16(a)
btScalar btSqrt(btScalar y)
btScalar btSin(btScalar x)
btScalar btFabs(btScalar x)
#define SIMD_FORCE_INLINE
btScalar btCos(btScalar x)
btScalar btAcos(btScalar x)
btScalar btDistance(const btVector3 &v1, const btVector3 &v2)
Return the distance between two vectors.
void btSwapVector3Endian(const btVector3 &sourceVec, btVector3 &destVec)
btSwapVector3Endian swaps vector endianness, useful for network and cross-platform serialization
btVector3 operator*(const btVector3 &v1, const btVector3 &v2)
Return the elementwise product of two vectors.
btScalar btDistance2(const btVector3 &v1, const btVector3 &v2)
Return the distance squared between two vectors.
btVector3 operator/(const btVector3 &v, const btScalar &s)
Return the vector inversely scaled by s.
void btPlaneSpace1(const T &n, T &p, T &q)
btScalar btDot(const btVector3 &v1, const btVector3 &v2)
Return the dot product between two vectors.
btVector3 btCross(const btVector3 &v1, const btVector3 &v2)
Return the cross product of two vectors.
btScalar btAngle(const btVector3 &v1, const btVector3 &v2)
Return the angle between two vectors.
btScalar btTriple(const btVector3 &v1, const btVector3 &v2, const btVector3 &v3)
void btSwapScalarEndian(const btScalar &sourceVal, btScalar &destVal)
btSwapVector3Endian swaps vector endianness, useful for network and cross-platform serialization
btVector3 operator+(const btVector3 &v1, const btVector3 &v2)
Return the sum of two vectors (Point symantics)
btVector3 operator-(const btVector3 &v1, const btVector3 &v2)
Return the difference between two vectors.
btVector3 lerp(const btVector3 &v1, const btVector3 &v2, const btScalar &t)
Return the linear interpolation between two vectors.
void btUnSwapVector3Endian(btVector3 &vector)
btUnSwapVector3Endian swaps vector endianness, useful for network and cross-platform serialization
btVector3 can be used to represent 3D points and vectors.
btVector3(const btScalar &_x, const btScalar &_y, const btScalar &_z)
Constructor from scalars.
const btScalar & getZ() const
Return the z value.
btScalar safeNorm() const
Return the norm (length) of the vector.
void setMax(const btVector3 &other)
Set each element to the max of the current values and the values of another btVector3.
void setZ(btScalar _z)
Set the z value.
long minDot(const btVector3 *array, long array_count, btScalar &dotOut) const
returns index of minimum dot product between this and vectors in array[]
void setInterpolate3(const btVector3 &v0, const btVector3 &v1, btScalar rt)
const btScalar & w() const
Return the w value.
const btScalar & z() const
Return the z value.
btVector3 rotate(const btVector3 &wAxis, const btScalar angle) const
Return a rotated version of this vector.
btVector3 & safeNormalize()
btScalar length() const
Return the length of the vector.
bool operator==(const btVector3 &other) const
btVector3 cross(const btVector3 &v) const
Return the cross product between this and another vector.
btScalar angle(const btVector3 &v) const
Return the angle between this and another vector.
int minAxis() const
Return the axis with the smallest value Note return values are 0,1,2 for x, y, or z.
btVector3 & operator+=(const btVector3 &v)
Add a vector to this one.
btScalar dot(const btVector3 &v) const
Return the dot product.
void deSerializeFloat(const struct btVector3FloatData &dataIn)
btScalar distance(const btVector3 &v) const
Return the distance between the ends of this and another vector This is symantically treating the vec...
void getSkewSymmetricMatrix(btVector3 *v0, btVector3 *v1, btVector3 *v2) const
btScalar norm() const
Return the norm (length) of the vector.
void deSerialize(const struct btVector3Data &dataIn)
BT_DECLARE_ALIGNED_ALLOCATOR()
btVector3()
No initialization constructor.
btVector3 & operator*=(const btVector3 &v)
Elementwise multiply this vector by the other.
btVector3 dot3(const btVector3 &v0, const btVector3 &v1, const btVector3 &v2) const
void serializeFloat(struct btVector3FloatData &dataOut) const
btVector3 absolute() const
Return a vector will the absolute values of each element.
void setValue(const btScalar &_x, const btScalar &_y, const btScalar &_z)
btVector3 & operator*=(const btScalar &s)
Scale the vector.
btVector3 normalized() const
Return a normalized version of this vector.
void deSerializeDouble(const struct btVector3DoubleData &dataIn)
void setY(btScalar _y)
Set the y value.
void setX(btScalar _x)
Set the x value.
void setW(btScalar _w)
Set the w value.
btScalar triple(const btVector3 &v1, const btVector3 &v2) const
btVector3 & operator-=(const btVector3 &v)
Subtract a vector from this one.
void serializeDouble(struct btVector3DoubleData &dataOut) const
long maxDot(const btVector3 *array, long array_count, btScalar &dotOut) const
returns index of maximum dot product between this and vectors in array[]
bool operator!=(const btVector3 &other) const
btScalar length2() const
Return the length of the vector squared.
const btScalar & getY() const
Return the y value.
const btScalar & x() const
Return the x value.
int maxAxis() const
Return the axis with the largest value Note return values are 0,1,2 for x, y, or z.
btVector3 lerp(const btVector3 &v, const btScalar &t) const
Return the linear interpolation between this and another vector.
btScalar distance2(const btVector3 &v) const
Return the distance squared between the ends of this and another vector This is symantically treating...
btVector3 & operator/=(const btScalar &s)
Inversely scale the vector.
void serialize(struct btVector3Data &dataOut) const
void setMin(const btVector3 &other)
Set each element to the min of the current values and the values of another btVector3.
btVector3 & normalize()
Normalize this vector x^2 + y^2 + z^2 = 1.
const btScalar & getX() const
Return the x value.
const btScalar & y() const
Return the y value.
btVector4 absolute4() const
btVector4(const btScalar &_x, const btScalar &_y, const btScalar &_z, const btScalar &_w)
void setValue(const btScalar &_x, const btScalar &_y, const btScalar &_z, const btScalar &_w)
Set x,y,z and zero w.