diff options
Diffstat (limited to 'thirdparty/bullet/Bullet3Common/shared')
-rw-r--r-- | thirdparty/bullet/Bullet3Common/shared/b3Float4.h | 137 | ||||
-rw-r--r-- | thirdparty/bullet/Bullet3Common/shared/b3Int2.h | 15 | ||||
-rw-r--r-- | thirdparty/bullet/Bullet3Common/shared/b3Int4.h | 33 | ||||
-rw-r--r-- | thirdparty/bullet/Bullet3Common/shared/b3Mat3x3.h | 108 | ||||
-rw-r--r-- | thirdparty/bullet/Bullet3Common/shared/b3PlatformDefinitions.h | 10 | ||||
-rw-r--r-- | thirdparty/bullet/Bullet3Common/shared/b3Quat.h | 71 |
6 files changed, 172 insertions, 202 deletions
diff --git a/thirdparty/bullet/Bullet3Common/shared/b3Float4.h b/thirdparty/bullet/Bullet3Common/shared/b3Float4.h index 5e4b95bcee..d8a9f47411 100644 --- a/thirdparty/bullet/Bullet3Common/shared/b3Float4.h +++ b/thirdparty/bullet/Bullet3Common/shared/b3Float4.h @@ -4,94 +4,87 @@ #include "Bullet3Common/shared/b3PlatformDefinitions.h" #ifdef __cplusplus - #include "Bullet3Common/b3Vector3.h" - #define b3Float4 b3Vector3 - #define b3Float4ConstArg const b3Vector3& - #define b3Dot3F4 b3Dot - #define b3Cross3 b3Cross - #define b3MakeFloat4 b3MakeVector3 - inline b3Vector3 b3Normalized(const b3Vector3& vec) - { - return vec.normalized(); - } - - inline b3Float4 b3FastNormalized3(b3Float4ConstArg v) - { - return v.normalized(); - } - - inline b3Float4 b3MaxFloat4 (const b3Float4& a, const b3Float4& b) - { - b3Float4 tmp = a; - tmp.setMax(b); - return tmp; - } - inline b3Float4 b3MinFloat4 (const b3Float4& a, const b3Float4& b) - { - b3Float4 tmp = a; - tmp.setMin(b); - return tmp; - } +#include "Bullet3Common/b3Vector3.h" +#define b3Float4 b3Vector3 +#define b3Float4ConstArg const b3Vector3& +#define b3Dot3F4 b3Dot +#define b3Cross3 b3Cross +#define b3MakeFloat4 b3MakeVector3 +inline b3Vector3 b3Normalized(const b3Vector3& vec) +{ + return vec.normalized(); +} +inline b3Float4 b3FastNormalized3(b3Float4ConstArg v) +{ + return v.normalized(); +} +inline b3Float4 b3MaxFloat4(const b3Float4& a, const b3Float4& b) +{ + b3Float4 tmp = a; + tmp.setMax(b); + return tmp; +} +inline b3Float4 b3MinFloat4(const b3Float4& a, const b3Float4& b) +{ + b3Float4 tmp = a; + tmp.setMin(b); + return tmp; +} #else - typedef float4 b3Float4; - #define b3Float4ConstArg const b3Float4 - #define b3MakeFloat4 (float4) - float b3Dot3F4(b3Float4ConstArg v0,b3Float4ConstArg v1) - { - float4 a1 = b3MakeFloat4(v0.xyz,0.f); - float4 b1 = b3MakeFloat4(v1.xyz,0.f); - return dot(a1, b1); - } - b3Float4 b3Cross3(b3Float4ConstArg v0,b3Float4ConstArg v1) - { - float4 a1 = b3MakeFloat4(v0.xyz,0.f); - float4 b1 = b3MakeFloat4(v1.xyz,0.f); - return cross(a1, b1); - } - #define b3MinFloat4 min - #define b3MaxFloat4 max - - #define b3Normalized(a) normalize(a) +typedef float4 b3Float4; +#define b3Float4ConstArg const b3Float4 +#define b3MakeFloat4 (float4) +float b3Dot3F4(b3Float4ConstArg v0, b3Float4ConstArg v1) +{ + float4 a1 = b3MakeFloat4(v0.xyz, 0.f); + float4 b1 = b3MakeFloat4(v1.xyz, 0.f); + return dot(a1, b1); +} +b3Float4 b3Cross3(b3Float4ConstArg v0, b3Float4ConstArg v1) +{ + float4 a1 = b3MakeFloat4(v0.xyz, 0.f); + float4 b1 = b3MakeFloat4(v1.xyz, 0.f); + return cross(a1, b1); +} +#define b3MinFloat4 min +#define b3MaxFloat4 max -#endif +#define b3Normalized(a) normalize(a) +#endif - inline bool b3IsAlmostZero(b3Float4ConstArg v) { - if(b3Fabs(v.x)>1e-6 || b3Fabs(v.y)>1e-6 || b3Fabs(v.z)>1e-6) + if (b3Fabs(v.x) > 1e-6 || b3Fabs(v.y) > 1e-6 || b3Fabs(v.z) > 1e-6) return false; return true; } - -inline int b3MaxDot( b3Float4ConstArg vec, __global const b3Float4* vecArray, int vecLen, float* dotOut ) +inline int b3MaxDot(b3Float4ConstArg vec, __global const b3Float4* vecArray, int vecLen, float* dotOut) { - float maxDot = -B3_INFINITY; - int i = 0; - int ptIndex = -1; - for( i = 0; i < vecLen; i++ ) - { - float dot = b3Dot3F4(vecArray[i],vec); - - if( dot > maxDot ) - { - maxDot = dot; - ptIndex = i; - } - } - b3Assert(ptIndex>=0); - if (ptIndex<0) + float maxDot = -B3_INFINITY; + int i = 0; + int ptIndex = -1; + for (i = 0; i < vecLen; i++) + { + float dot = b3Dot3F4(vecArray[i], vec); + + if (dot > maxDot) + { + maxDot = dot; + ptIndex = i; + } + } + b3Assert(ptIndex >= 0); + if (ptIndex < 0) { ptIndex = 0; } - *dotOut = maxDot; - return ptIndex; + *dotOut = maxDot; + return ptIndex; } - - -#endif //B3_FLOAT4_H +#endif //B3_FLOAT4_H diff --git a/thirdparty/bullet/Bullet3Common/shared/b3Int2.h b/thirdparty/bullet/Bullet3Common/shared/b3Int2.h index f1d01f81a5..7b84de4436 100644 --- a/thirdparty/bullet/Bullet3Common/shared/b3Int2.h +++ b/thirdparty/bullet/Bullet3Common/shared/b3Int2.h @@ -20,11 +20,10 @@ subject to the following restrictions: struct b3UnsignedInt2 { - union - { + union { struct { - unsigned int x,y; + unsigned int x, y; }; struct { @@ -35,11 +34,10 @@ struct b3UnsignedInt2 struct b3Int2 { - union - { + union { struct { - int x,y; + int x, y; }; struct { @@ -51,7 +49,8 @@ struct b3Int2 inline b3Int2 b3MakeInt2(int x, int y) { b3Int2 v; - v.s[0] = x; v.s[1] = y; + v.s[0] = x; + v.s[1] = y; return v; } #else @@ -60,5 +59,5 @@ inline b3Int2 b3MakeInt2(int x, int y) #define b3Int2 int2 #define b3MakeInt2 (int2) -#endif //__cplusplus +#endif //__cplusplus #endif
\ No newline at end of file diff --git a/thirdparty/bullet/Bullet3Common/shared/b3Int4.h b/thirdparty/bullet/Bullet3Common/shared/b3Int4.h index aa02d6beef..f6a1754245 100644 --- a/thirdparty/bullet/Bullet3Common/shared/b3Int4.h +++ b/thirdparty/bullet/Bullet3Common/shared/b3Int4.h @@ -5,16 +5,15 @@ #include "Bullet3Common/b3Scalar.h" - -B3_ATTRIBUTE_ALIGNED16(struct) b3UnsignedInt4 +B3_ATTRIBUTE_ALIGNED16(struct) +b3UnsignedInt4 { B3_DECLARE_ALIGNED_ALLOCATOR(); - union - { + union { struct { - unsigned int x,y,z,w; + unsigned int x, y, z, w; }; struct { @@ -23,15 +22,15 @@ B3_ATTRIBUTE_ALIGNED16(struct) b3UnsignedInt4 }; }; -B3_ATTRIBUTE_ALIGNED16(struct) b3Int4 +B3_ATTRIBUTE_ALIGNED16(struct) +b3Int4 { B3_DECLARE_ALIGNED_ALLOCATOR(); - union - { + union { struct { - int x,y,z,w; + int x, y, z, w; }; struct { @@ -43,26 +42,30 @@ B3_ATTRIBUTE_ALIGNED16(struct) b3Int4 B3_FORCE_INLINE b3Int4 b3MakeInt4(int x, int y, int z, int w = 0) { b3Int4 v; - v.s[0] = x; v.s[1] = y; v.s[2] = z; v.s[3] = w; + v.s[0] = x; + v.s[1] = y; + v.s[2] = z; + v.s[3] = w; return v; } B3_FORCE_INLINE b3UnsignedInt4 b3MakeUnsignedInt4(unsigned int x, unsigned int y, unsigned int z, unsigned int w = 0) { b3UnsignedInt4 v; - v.s[0] = x; v.s[1] = y; v.s[2] = z; v.s[3] = w; + v.s[0] = x; + v.s[1] = y; + v.s[2] = z; + v.s[3] = w; return v; } #else - #define b3UnsignedInt4 uint4 #define b3Int4 int4 #define b3MakeInt4 (int4) #define b3MakeUnsignedInt4 (uint4) +#endif //__cplusplus -#endif //__cplusplus - -#endif //B3_INT4_H +#endif //B3_INT4_H diff --git a/thirdparty/bullet/Bullet3Common/shared/b3Mat3x3.h b/thirdparty/bullet/Bullet3Common/shared/b3Mat3x3.h index 7b1fef32f8..ce6482b5a6 100644 --- a/thirdparty/bullet/Bullet3Common/shared/b3Mat3x3.h +++ b/thirdparty/bullet/Bullet3Common/shared/b3Mat3x3.h @@ -4,7 +4,6 @@ #include "Bullet3Common/shared/b3Quat.h" - #ifdef __cplusplus #include "Bullet3Common/b3Matrix3x3.h" @@ -22,43 +21,41 @@ inline b3Mat3x3 b3AbsoluteMat3x3(b3Mat3x3ConstArg mat) return mat.absolute(); } -#define b3GetRow(m,row) m.getRow(row) +#define b3GetRow(m, row) m.getRow(row) -__inline -b3Float4 mtMul3(b3Float4ConstArg a, b3Mat3x3ConstArg b) +__inline b3Float4 mtMul3(b3Float4ConstArg a, b3Mat3x3ConstArg b) { - return b*a; + return b * a; } - #else typedef struct { b3Float4 m_row[3]; -}b3Mat3x3; +} b3Mat3x3; #define b3Mat3x3ConstArg const b3Mat3x3 -#define b3GetRow(m,row) (m.m_row[row]) +#define b3GetRow(m, row) (m.m_row[row]) inline b3Mat3x3 b3QuatGetRotationMatrix(b3Quat quat) { - b3Float4 quat2 = (b3Float4)(quat.x*quat.x, quat.y*quat.y, quat.z*quat.z, 0.f); + b3Float4 quat2 = (b3Float4)(quat.x * quat.x, quat.y * quat.y, quat.z * quat.z, 0.f); b3Mat3x3 out; - out.m_row[0].x=1-2*quat2.y-2*quat2.z; - out.m_row[0].y=2*quat.x*quat.y-2*quat.w*quat.z; - out.m_row[0].z=2*quat.x*quat.z+2*quat.w*quat.y; + out.m_row[0].x = 1 - 2 * quat2.y - 2 * quat2.z; + out.m_row[0].y = 2 * quat.x * quat.y - 2 * quat.w * quat.z; + out.m_row[0].z = 2 * quat.x * quat.z + 2 * quat.w * quat.y; out.m_row[0].w = 0.f; - out.m_row[1].x=2*quat.x*quat.y+2*quat.w*quat.z; - out.m_row[1].y=1-2*quat2.x-2*quat2.z; - out.m_row[1].z=2*quat.y*quat.z-2*quat.w*quat.x; + out.m_row[1].x = 2 * quat.x * quat.y + 2 * quat.w * quat.z; + out.m_row[1].y = 1 - 2 * quat2.x - 2 * quat2.z; + out.m_row[1].z = 2 * quat.y * quat.z - 2 * quat.w * quat.x; out.m_row[1].w = 0.f; - out.m_row[2].x=2*quat.x*quat.z-2*quat.w*quat.y; - out.m_row[2].y=2*quat.y*quat.z+2*quat.w*quat.x; - out.m_row[2].z=1-2*quat2.x-2*quat2.y; + out.m_row[2].x = 2 * quat.x * quat.z - 2 * quat.w * quat.y; + out.m_row[2].y = 2 * quat.y * quat.z + 2 * quat.w * quat.x; + out.m_row[2].z = 1 - 2 * quat2.x - 2 * quat2.y; out.m_row[2].w = 0.f; return out; @@ -73,27 +70,19 @@ inline b3Mat3x3 b3AbsoluteMat3x3(b3Mat3x3ConstArg matIn) return out; } +__inline b3Mat3x3 mtZero(); -__inline -b3Mat3x3 mtZero(); - -__inline -b3Mat3x3 mtIdentity(); +__inline b3Mat3x3 mtIdentity(); -__inline -b3Mat3x3 mtTranspose(b3Mat3x3 m); +__inline b3Mat3x3 mtTranspose(b3Mat3x3 m); -__inline -b3Mat3x3 mtMul(b3Mat3x3 a, b3Mat3x3 b); +__inline b3Mat3x3 mtMul(b3Mat3x3 a, b3Mat3x3 b); -__inline -b3Float4 mtMul1(b3Mat3x3 a, b3Float4 b); +__inline b3Float4 mtMul1(b3Mat3x3 a, b3Float4 b); -__inline -b3Float4 mtMul3(b3Float4 a, b3Mat3x3 b); +__inline b3Float4 mtMul3(b3Float4 a, b3Mat3x3 b); -__inline -b3Mat3x3 mtZero() +__inline b3Mat3x3 mtZero() { b3Mat3x3 m; m.m_row[0] = (b3Float4)(0.f); @@ -102,18 +91,16 @@ b3Mat3x3 mtZero() return m; } -__inline -b3Mat3x3 mtIdentity() +__inline b3Mat3x3 mtIdentity() { b3Mat3x3 m; - m.m_row[0] = (b3Float4)(1,0,0,0); - m.m_row[1] = (b3Float4)(0,1,0,0); - m.m_row[2] = (b3Float4)(0,0,1,0); + m.m_row[0] = (b3Float4)(1, 0, 0, 0); + m.m_row[1] = (b3Float4)(0, 1, 0, 0); + m.m_row[2] = (b3Float4)(0, 0, 1, 0); return m; } -__inline -b3Mat3x3 mtTranspose(b3Mat3x3 m) +__inline b3Mat3x3 mtTranspose(b3Mat3x3 m) { b3Mat3x3 out; out.m_row[0] = (b3Float4)(m.m_row[0].x, m.m_row[1].x, m.m_row[2].x, 0.f); @@ -122,58 +109,49 @@ b3Mat3x3 mtTranspose(b3Mat3x3 m) return out; } -__inline -b3Mat3x3 mtMul(b3Mat3x3 a, b3Mat3x3 b) +__inline b3Mat3x3 mtMul(b3Mat3x3 a, b3Mat3x3 b) { b3Mat3x3 transB; - transB = mtTranspose( b ); + transB = mtTranspose(b); b3Mat3x3 ans; // why this doesn't run when 0ing in the for{} a.m_row[0].w = 0.f; a.m_row[1].w = 0.f; a.m_row[2].w = 0.f; - for(int i=0; i<3; i++) + for (int i = 0; i < 3; i++) { -// a.m_row[i].w = 0.f; - ans.m_row[i].x = b3Dot3F4(a.m_row[i],transB.m_row[0]); - ans.m_row[i].y = b3Dot3F4(a.m_row[i],transB.m_row[1]); - ans.m_row[i].z = b3Dot3F4(a.m_row[i],transB.m_row[2]); + // a.m_row[i].w = 0.f; + ans.m_row[i].x = b3Dot3F4(a.m_row[i], transB.m_row[0]); + ans.m_row[i].y = b3Dot3F4(a.m_row[i], transB.m_row[1]); + ans.m_row[i].z = b3Dot3F4(a.m_row[i], transB.m_row[2]); ans.m_row[i].w = 0.f; } return ans; } -__inline -b3Float4 mtMul1(b3Mat3x3 a, b3Float4 b) +__inline b3Float4 mtMul1(b3Mat3x3 a, b3Float4 b) { b3Float4 ans; - ans.x = b3Dot3F4( a.m_row[0], b ); - ans.y = b3Dot3F4( a.m_row[1], b ); - ans.z = b3Dot3F4( a.m_row[2], b ); + ans.x = b3Dot3F4(a.m_row[0], b); + ans.y = b3Dot3F4(a.m_row[1], b); + ans.z = b3Dot3F4(a.m_row[2], b); ans.w = 0.f; return ans; } -__inline -b3Float4 mtMul3(b3Float4 a, b3Mat3x3 b) +__inline b3Float4 mtMul3(b3Float4 a, b3Mat3x3 b) { b3Float4 colx = b3MakeFloat4(b.m_row[0].x, b.m_row[1].x, b.m_row[2].x, 0); b3Float4 coly = b3MakeFloat4(b.m_row[0].y, b.m_row[1].y, b.m_row[2].y, 0); b3Float4 colz = b3MakeFloat4(b.m_row[0].z, b.m_row[1].z, b.m_row[2].z, 0); b3Float4 ans; - ans.x = b3Dot3F4( a, colx ); - ans.y = b3Dot3F4( a, coly ); - ans.z = b3Dot3F4( a, colz ); + ans.x = b3Dot3F4(a, colx); + ans.y = b3Dot3F4(a, coly); + ans.z = b3Dot3F4(a, colz); return ans; } - #endif - - - - - -#endif //B3_MAT3x3_H +#endif //B3_MAT3x3_H diff --git a/thirdparty/bullet/Bullet3Common/shared/b3PlatformDefinitions.h b/thirdparty/bullet/Bullet3Common/shared/b3PlatformDefinitions.h index 1c133fb088..b72bee9310 100644 --- a/thirdparty/bullet/Bullet3Common/shared/b3PlatformDefinitions.h +++ b/thirdparty/bullet/Bullet3Common/shared/b3PlatformDefinitions.h @@ -8,18 +8,18 @@ struct MyTest #ifdef __cplusplus //#define b3ConstArray(a) const b3AlignedObjectArray<a>& -#define b3ConstArray(a) const a* +#define b3ConstArray(a) const a * #define b3AtomicInc(a) ((*a)++) -inline int b3AtomicAdd (volatile int *p, int val) +inline int b3AtomicAdd(volatile int *p, int val) { int oldValue = *p; - int newValue = oldValue+val; + int newValue = oldValue + val; *p = newValue; return oldValue; } -#define __global +#define __global #define B3_STATIC static #else @@ -27,7 +27,7 @@ inline int b3AtomicAdd (volatile int *p, int val) #define B3_LARGE_FLOAT 1e18f #define B3_INFINITY 1e18f #define b3Assert(a) -#define b3ConstArray(a) __global const a* +#define b3ConstArray(a) __global const a * #define b3AtomicInc atomic_inc #define b3AtomicAdd atomic_add #define b3Fabs fabs diff --git a/thirdparty/bullet/Bullet3Common/shared/b3Quat.h b/thirdparty/bullet/Bullet3Common/shared/b3Quat.h index f262d5e08f..940610c77b 100644 --- a/thirdparty/bullet/Bullet3Common/shared/b3Quat.h +++ b/thirdparty/bullet/Bullet3Common/shared/b3Quat.h @@ -5,35 +5,34 @@ #include "Bullet3Common/shared/b3Float4.h" #ifdef __cplusplus - #include "Bullet3Common/b3Quaternion.h" - #include "Bullet3Common/b3Transform.h" +#include "Bullet3Common/b3Quaternion.h" +#include "Bullet3Common/b3Transform.h" - #define b3Quat b3Quaternion - #define b3QuatConstArg const b3Quaternion& - inline b3Quat b3QuatInverse(b3QuatConstArg orn) - { - return orn.inverse(); - } +#define b3Quat b3Quaternion +#define b3QuatConstArg const b3Quaternion& +inline b3Quat b3QuatInverse(b3QuatConstArg orn) +{ + return orn.inverse(); +} - inline b3Float4 b3TransformPoint(b3Float4ConstArg point, b3Float4ConstArg translation, b3QuatConstArg orientation) - { - b3Transform tr; - tr.setOrigin(translation); - tr.setRotation(orientation); - return tr(point); - } +inline b3Float4 b3TransformPoint(b3Float4ConstArg point, b3Float4ConstArg translation, b3QuatConstArg orientation) +{ + b3Transform tr; + tr.setOrigin(translation); + tr.setRotation(orientation); + return tr(point); +} #else - typedef float4 b3Quat; - #define b3QuatConstArg const b3Quat - - +typedef float4 b3Quat; +#define b3QuatConstArg const b3Quat + inline float4 b3FastNormalize4(float4 v) { - v = (float4)(v.xyz,0.f); + v = (float4)(v.xyz, 0.f); return fast_normalize(v); } - + inline b3Quat b3QuatMul(b3Quat a, b3Quat b); inline b3Quat b3QuatNormalized(b3QuatConstArg in); inline b3Quat b3QuatRotate(b3QuatConstArg q, b3QuatConstArg vec); @@ -43,20 +42,20 @@ inline b3Quat b3QuatInverse(b3QuatConstArg q); inline b3Quat b3QuatMul(b3QuatConstArg a, b3QuatConstArg b) { b3Quat ans; - ans = b3Cross3( a, b ); - ans += a.w*b+b.w*a; -// ans.w = a.w*b.w - (a.x*b.x+a.y*b.y+a.z*b.z); - ans.w = a.w*b.w - b3Dot3F4(a, b); + ans = b3Cross3(a, b); + ans += a.w * b + b.w * a; + // ans.w = a.w*b.w - (a.x*b.x+a.y*b.y+a.z*b.z); + ans.w = a.w * b.w - b3Dot3F4(a, b); return ans; } inline b3Quat b3QuatNormalized(b3QuatConstArg in) { b3Quat q; - q=in; + q = in; //return b3FastNormalize4(in); float len = native_sqrt(dot(q, q)); - if(len > 0.f) + if (len > 0.f) { q *= 1.f / len; } @@ -69,15 +68,13 @@ inline b3Quat b3QuatNormalized(b3QuatConstArg in) } inline float4 b3QuatRotate(b3QuatConstArg q, b3QuatConstArg vec) { - b3Quat qInv = b3QuatInvert( q ); + b3Quat qInv = b3QuatInvert(q); float4 vcpy = vec; vcpy.w = 0.f; - float4 out = b3QuatMul(b3QuatMul(q,vcpy),qInv); + float4 out = b3QuatMul(b3QuatMul(q, vcpy), qInv); return out; } - - inline b3Quat b3QuatInverse(b3QuatConstArg q) { return (b3Quat)(-q.xyz, q.w); @@ -90,14 +87,14 @@ inline b3Quat b3QuatInvert(b3QuatConstArg q) inline float4 b3QuatInvRotate(b3QuatConstArg q, b3QuatConstArg vec) { - return b3QuatRotate( b3QuatInvert( q ), vec ); + return b3QuatRotate(b3QuatInvert(q), vec); } -inline b3Float4 b3TransformPoint(b3Float4ConstArg point, b3Float4ConstArg translation, b3QuatConstArg orientation) +inline b3Float4 b3TransformPoint(b3Float4ConstArg point, b3Float4ConstArg translation, b3QuatConstArg orientation) { - return b3QuatRotate( orientation, point ) + (translation); + return b3QuatRotate(orientation, point) + (translation); } - -#endif -#endif //B3_QUAT_H +#endif + +#endif //B3_QUAT_H |