diff options
author | Erwin Coumans <blender@erwincoumans.com> | 2007-07-06 07:12:31 +0400 |
---|---|---|
committer | Erwin Coumans <blender@erwincoumans.com> | 2007-07-06 07:12:31 +0400 |
commit | 376be529bb932f867b01466592c33899ee5ec2c8 (patch) | |
tree | e89c72da658f04ed4aa816ada6adabfb5d938b74 /extern/bullet2/src/LinearMath | |
parent | cff039bc58fe2ed54d4dad0828f5dede0b26a206 (diff) |
synchronized to latest version of Bullet. added btConeTwistConstraint (useful for ragdolls etc)
Diffstat (limited to 'extern/bullet2/src/LinearMath')
-rw-r--r-- | extern/bullet2/src/LinearMath/btMatrix3x3.h | 15 | ||||
-rw-r--r-- | extern/bullet2/src/LinearMath/btQuaternion.h | 31 | ||||
-rw-r--r-- | extern/bullet2/src/LinearMath/btQuickprof.h | 22 | ||||
-rw-r--r-- | extern/bullet2/src/LinearMath/btScalar.h | 22 | ||||
-rw-r--r-- | extern/bullet2/src/LinearMath/btTransform.h | 13 |
5 files changed, 94 insertions, 9 deletions
diff --git a/extern/bullet2/src/LinearMath/btMatrix3x3.h b/extern/bullet2/src/LinearMath/btMatrix3x3.h index fda348b42ab..94f53c3c0a5 100644 --- a/extern/bullet2/src/LinearMath/btMatrix3x3.h +++ b/extern/bullet2/src/LinearMath/btMatrix3x3.h @@ -45,6 +45,21 @@ class btMatrix3x3 { zx, zy, zz); } + SIMD_FORCE_INLINE btMatrix3x3 (const btMatrix3x3& other) + { + m_el[0] = other.m_el[0]; + m_el[1] = other.m_el[1]; + m_el[2] = other.m_el[2]; + } + + SIMD_FORCE_INLINE btMatrix3x3& operator=(const btMatrix3x3& other) + { + m_el[0] = other.m_el[0]; + m_el[1] = other.m_el[1]; + m_el[2] = other.m_el[2]; + return *this; + } + SIMD_FORCE_INLINE btVector3 getColumn(int i) const { return btVector3(m_el[0][i],m_el[1][i],m_el[2][i]); diff --git a/extern/bullet2/src/LinearMath/btQuaternion.h b/extern/bullet2/src/LinearMath/btQuaternion.h index d5a7913b742..50334970ba6 100644 --- a/extern/bullet2/src/LinearMath/btQuaternion.h +++ b/extern/bullet2/src/LinearMath/btQuaternion.h @@ -212,6 +212,7 @@ public: SIMD_FORCE_INLINE const btScalar& getW() const { return m_unusedW; } + }; @@ -283,6 +284,36 @@ slerp(const btQuaternion& q1, const btQuaternion& q2, const btScalar& t) return q1.slerp(q2, t); } +SIMD_FORCE_INLINE btVector3 +quatRotate(btQuaternion& rotation, btVector3& v) +{ + btQuaternion q = rotation * v; + q *= rotation.inverse(); + return btVector3(q.getX(),q.getY(),q.getZ()); +} + +SIMD_FORCE_INLINE btQuaternion +shortestArcQuat(btVector3& v0,btVector3& v1) // Game Programming Gems 2.10. make sure v0,v1 are normalized +{ + btVector3 c = v0.cross(v1); + btScalar d = v0.dot(v1); + + if (d < -1.0 + SIMD_EPSILON) + return btQuaternion(0.0f,1.0f,0.0f,0.0f); // just pick any vector + + btScalar s = btSqrt((1.0f + d) * 2.0f); + btScalar rs = 1.0f / s; + + return btQuaternion(c.getX()*rs,c.getY()*rs,c.getZ()*rs,s * 0.5f); +} + +SIMD_FORCE_INLINE btQuaternion +shortestArcQuatNormalize(btVector3& v0,btVector3& v1) +{ + v0.normalize(); + v1.normalize(); + return shortestArcQuat(v0,v1); +} #endif diff --git a/extern/bullet2/src/LinearMath/btQuickprof.h b/extern/bullet2/src/LinearMath/btQuickprof.h index 9389fcd8156..a885967c5fa 100644 --- a/extern/bullet2/src/LinearMath/btQuickprof.h +++ b/extern/bullet2/src/LinearMath/btQuickprof.h @@ -32,7 +32,7 @@ subject to the following restrictions: #define USE_BT_CLOCK 1 #ifdef USE_BT_CLOCK -#ifdef __PPU__ +#ifdef __CELLOS_LV2__ #include <sys/sys_time.h> #include <stdio.h> typedef uint64_t __int64; @@ -49,8 +49,13 @@ typedef uint64_t __int64; #define NOWINRES #define NOMCX #define NOIME +#ifdef _XBOX + #include <Xtl.h> +#else #include <windows.h> +#endif #include <time.h> + #else #include <sys/time.h> #endif @@ -81,7 +86,7 @@ class btClock mStartTick = GetTickCount(); mPrevElapsedTime = 0; #else -#ifdef __PPU__ +#ifdef __CELLOS_LV2__ typedef uint64_t __int64; typedef __int64 ClockSize; @@ -134,7 +139,7 @@ class btClock return msecTicks; #else -#ifdef __PPU__ +#ifdef __CELLOS_LV2__ __int64 freq=sys_time_get_timebase_frequency(); double dFreq=((double) freq) / 1000.0; typedef uint64_t __int64; @@ -149,7 +154,7 @@ class btClock gettimeofday(¤tTime, 0); return (currentTime.tv_sec - mStartTime.tv_sec) * 1000 + (currentTime.tv_usec - mStartTime.tv_usec) / 1000; -#endif //__PPU__ +#endif //__CELLOS_LV2__ #endif } @@ -192,7 +197,7 @@ class btClock return usecTicks; #else -#ifdef __PPU__ +#ifdef __CELLOS_LV2__ __int64 freq=sys_time_get_timebase_frequency(); double dFreq=((double) freq)/ 1000000.0; typedef uint64_t __int64; @@ -207,7 +212,7 @@ class btClock gettimeofday(¤tTime, 0); return (currentTime.tv_sec - mStartTime.tv_sec) * 1000000 + (currentTime.tv_usec - mStartTime.tv_usec); -#endif//__PPU__ +#endif//__CELLOS_LV2__ #endif } @@ -218,12 +223,12 @@ class btClock LONGLONG mPrevElapsedTime; LARGE_INTEGER mStartTime; #else -#ifdef __PPU__ +#ifdef __CELLOS_LV2__ uint64_t mStartTime; #else struct timeval mStartTime; #endif -#endif //__PPU__ +#endif //__CELLOS_LV2__ }; @@ -704,3 +709,4 @@ std::string btProfiler::createStatsString(BlockTimingMethod method) #endif //QUICK_PROF_H + diff --git a/extern/bullet2/src/LinearMath/btScalar.h b/extern/bullet2/src/LinearMath/btScalar.h index 222315c1c74..01ad93e786a 100644 --- a/extern/bullet2/src/LinearMath/btScalar.h +++ b/extern/bullet2/src/LinearMath/btScalar.h @@ -35,6 +35,11 @@ subject to the following restrictions: #pragma warning(disable:4786) #define SIMD_FORCE_INLINE __forceinline #define ATTRIBUTE_ALIGNED16(a) __declspec(align(16)) a + #ifdef _XBOX + #define BT_USE_VMX128 + #else + #define BT_USE_SSE + #endif #endif //__MINGW32__ #include <assert.h> @@ -115,7 +120,6 @@ SIMD_FORCE_INLINE btScalar btPow(btScalar x,btScalar y) { return powf(x,y); } #endif - #define SIMD_2_PI btScalar(6.283185307179586232) #define SIMD_PI (SIMD_2_PI * btScalar(0.5)) #define SIMD_HALF_PI (SIMD_2_PI * btScalar(0.25)) @@ -130,6 +134,22 @@ SIMD_FORCE_INLINE btScalar btPow(btScalar x,btScalar y) { return powf(x,y); } #define SIMD_INFINITY FLT_MAX #endif +SIMD_FORCE_INLINE btScalar btAtan2Fast(btScalar y, btScalar x) +{ + btScalar coeff_1 = SIMD_PI / 4.0f; + btScalar coeff_2 = 3.0f * coeff_1; + btScalar abs_y = btFabs(y); + btScalar angle; + if (x >= 0.0f) { + btScalar r = (x - abs_y) / (x + abs_y); + angle = coeff_1 - coeff_1 * r; + } else { + btScalar r = (x + abs_y) / (abs_y - x); + angle = coeff_2 - coeff_1 * r; + } + return (y < 0.0f) ? -angle : angle; +} + SIMD_FORCE_INLINE bool btFuzzyZero(btScalar x) { return btFabs(x) < SIMD_EPSILON; } SIMD_FORCE_INLINE bool btEqual(btScalar a, btScalar eps) { diff --git a/extern/bullet2/src/LinearMath/btTransform.h b/extern/bullet2/src/LinearMath/btTransform.h index b1f3dfca492..2d55fec83a4 100644 --- a/extern/bullet2/src/LinearMath/btTransform.h +++ b/extern/bullet2/src/LinearMath/btTransform.h @@ -42,6 +42,19 @@ public: m_origin(c) {} + SIMD_FORCE_INLINE btTransform (const btTransform& other) + : m_basis(other.m_basis), + m_origin(other.m_origin) + { + } + + SIMD_FORCE_INLINE btTransform& operator=(const btTransform& other) + { + m_basis = other.m_basis; + m_origin = other.m_origin; + return *this; + } + SIMD_FORCE_INLINE void mult(const btTransform& t1, const btTransform& t2) { m_basis = t1.m_basis * t2.m_basis; |