Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorErwin Coumans <blender@erwincoumans.com>2008-09-13 11:06:43 +0400
committerErwin Coumans <blender@erwincoumans.com>2008-09-13 11:06:43 +0400
commit7f293488d12b5d5076b4bbf3d6c9248867c447a0 (patch)
tree977ac9f1063de48615e8f294bfbcadb2a3b645f6 /extern/bullet2/src/LinearMath
parent206cfe7955683ac166201e417977e933fd98f7b3 (diff)
Upgrade to latest Bullet trunk, that is in sync with Blender/extern/bullet2. (except for one define 'WIN32_AVOID_SSE_WHEN_EMBEDDED_INSIDE_BLENDER')
In case someone reads those SVN logs: you can enable some extra broadphase SSE optimizations by replacing WIN32_AVOID_SSE_WHEN_EMBEDDED_INSIDE_BLENDER by WIN32 in extern/bullet2/src/BulletCollision/BroadphaseCollision/btDbvt.h Thanks to Benoit Bolsee for the upstream patch/contribution. Removed some obsolete files, they were just intended for comparison/testing.
Diffstat (limited to 'extern/bullet2/src/LinearMath')
-rw-r--r--extern/bullet2/src/LinearMath/CMakeLists.txt29
-rw-r--r--extern/bullet2/src/LinearMath/btAabbUtil2.h34
-rw-r--r--extern/bullet2/src/LinearMath/btMatrix3x3.h85
-rw-r--r--extern/bullet2/src/LinearMath/btScalar.h25
4 files changed, 166 insertions, 7 deletions
diff --git a/extern/bullet2/src/LinearMath/CMakeLists.txt b/extern/bullet2/src/LinearMath/CMakeLists.txt
index 207eed94a3e..02ffaad7228 100644
--- a/extern/bullet2/src/LinearMath/CMakeLists.txt
+++ b/extern/bullet2/src/LinearMath/CMakeLists.txt
@@ -4,7 +4,32 @@ ${BULLET_PHYSICS_SOURCE_DIR}/src }
)
ADD_LIBRARY(LibLinearMath
-btQuickprof.cpp
-btGeometryUtil.cpp
+ btAlignedObjectArray.h
+ btList.h
+ btPoolAllocator.h
+ btRandom.h
+ btVector3.h
+ btDefaultMotionState.h
+ btMatrix3x3.h
+ btQuadWord.h
+ btHashMap.h
+ btScalar.h
+ btAabbUtil2.h
+ btConvexHull.h
+ btConvexHull.cpp
+ btMinMax.h
+ btQuaternion.h
+ btStackAlloc.h
+ btGeometryUtil.h
+ btMotionState.h
+ btTransform.h
+ btAlignedAllocator.h
+ btIDebugDraw.h
+ btPoint3.h
+ btQuickprof.h
+ btTransformUtil.h
+ btQuickprof.cpp
+ btGeometryUtil.cpp
+ btAlignedAllocator.cpp
)
diff --git a/extern/bullet2/src/LinearMath/btAabbUtil2.h b/extern/bullet2/src/LinearMath/btAabbUtil2.h
index 8bb6b3af7c3..275c4914628 100644
--- a/extern/bullet2/src/LinearMath/btAabbUtil2.h
+++ b/extern/bullet2/src/LinearMath/btAabbUtil2.h
@@ -17,6 +17,7 @@ subject to the following restrictions:
#ifndef AABB_UTIL2
#define AABB_UTIL2
+#include "btTransform.h"
#include "btVector3.h"
#include "btMinMax.h"
@@ -163,6 +164,39 @@ SIMD_FORCE_INLINE bool btRayAabb(const btVector3& rayFrom,
}
+
+SIMD_FORCE_INLINE void btTransformAabb(const btVector3& halfExtents, btScalar margin,const btTransform& t,btVector3& aabbMinOut,btVector3& aabbMaxOut)
+{
+ btVector3 halfExtentsWithMargin = halfExtents+btVector3(margin,margin,margin);
+ btMatrix3x3 abs_b = t.getBasis().absolute();
+ btVector3 center = t.getOrigin();
+ btVector3 extent = btVector3(abs_b[0].dot(halfExtentsWithMargin),
+ abs_b[1].dot(halfExtentsWithMargin),
+ abs_b[2].dot(halfExtentsWithMargin));
+ aabbMinOut = center - extent;
+ aabbMaxOut = center + extent;
+}
+
+
+SIMD_FORCE_INLINE void btTransformAabb(const btVector3& localAabbMin,const btVector3& localAabbMax, btScalar margin,const btTransform& trans,btVector3& aabbMinOut,btVector3& aabbMaxOut)
+{
+ btAssert(localAabbMin.getX() <= localAabbMax.getX());
+ btAssert(localAabbMin.getY() <= localAabbMax.getY());
+ btAssert(localAabbMin.getZ() <= localAabbMax.getZ());
+ btVector3 localHalfExtents = btScalar(0.5)*(localAabbMax-localAabbMin);
+ localHalfExtents+=btVector3(margin,margin,margin);
+
+ btVector3 localCenter = btScalar(0.5)*(localAabbMax+localAabbMin);
+ btMatrix3x3 abs_b = trans.getBasis().absolute();
+ btVector3 center = trans(localCenter);
+ btVector3 extent = btVector3(abs_b[0].dot(localHalfExtents),
+ abs_b[1].dot(localHalfExtents),
+ abs_b[2].dot(localHalfExtents));
+ aabbMinOut = center-extent;
+ aabbMaxOut = center+extent;
+}
+
+
#endif
diff --git a/extern/bullet2/src/LinearMath/btMatrix3x3.h b/extern/bullet2/src/LinearMath/btMatrix3x3.h
index ca1a801402f..14aa4ae2348 100644
--- a/extern/bullet2/src/LinearMath/btMatrix3x3.h
+++ b/extern/bullet2/src/LinearMath/btMatrix3x3.h
@@ -284,6 +284,91 @@ class btMatrix3x3 {
}
+ ///diagonalizes this matrix by the Jacobi method. rot stores the rotation
+ ///from the coordinate system in which the matrix is diagonal to the original
+ ///coordinate system, i.e., old_this = rot * new_this * rot^T. The iteration
+ ///stops when all off-diagonal elements are less than the threshold multiplied
+ ///by the sum of the absolute values of the diagonal, or when maxSteps have
+ ///been executed. Note that this matrix is assumed to be symmetric.
+ void diagonalize(btMatrix3x3& rot, btScalar threshold, int maxSteps)
+ {
+ rot.setIdentity();
+ for (int step = maxSteps; step > 0; step--)
+ {
+ // find off-diagonal element [p][q] with largest magnitude
+ int p = 0;
+ int q = 1;
+ int r = 2;
+ btScalar max = btFabs(m_el[0][1]);
+ btScalar v = btFabs(m_el[0][2]);
+ if (v > max)
+ {
+ q = 2;
+ r = 1;
+ max = v;
+ }
+ v = btFabs(m_el[1][2]);
+ if (v > max)
+ {
+ p = 1;
+ q = 2;
+ r = 0;
+ max = v;
+ }
+
+ btScalar t = threshold * (btFabs(m_el[0][0]) + btFabs(m_el[1][1]) + btFabs(m_el[2][2]));
+ if (max <= t)
+ {
+ if (max <= SIMD_EPSILON * t)
+ {
+ return;
+ }
+ step = 1;
+ }
+
+ // compute Jacobi rotation J which leads to a zero for element [p][q]
+ btScalar mpq = m_el[p][q];
+ btScalar theta = (m_el[q][q] - m_el[p][p]) / (2 * mpq);
+ btScalar theta2 = theta * theta;
+ btScalar cos;
+ btScalar sin;
+ if (theta2 * theta2 < btScalar(10 / SIMD_EPSILON))
+ {
+ t = (theta >= 0) ? 1 / (theta + btSqrt(1 + theta2))
+ : 1 / (theta - btSqrt(1 + theta2));
+ cos = 1 / btSqrt(1 + t * t);
+ sin = cos * t;
+ }
+ else
+ {
+ // approximation for large theta-value, i.e., a nearly diagonal matrix
+ t = 1 / (theta * (2 + btScalar(0.5) / theta2));
+ cos = 1 - btScalar(0.5) * t * t;
+ sin = cos * t;
+ }
+
+ // apply rotation to matrix (this = J^T * this * J)
+ m_el[p][q] = m_el[q][p] = 0;
+ m_el[p][p] -= t * mpq;
+ m_el[q][q] += t * mpq;
+ btScalar mrp = m_el[r][p];
+ btScalar mrq = m_el[r][q];
+ m_el[r][p] = m_el[p][r] = cos * mrp - sin * mrq;
+ m_el[r][q] = m_el[q][r] = cos * mrq + sin * mrp;
+
+ // apply rotation to rot (rot = rot * J)
+ for (int i = 0; i < 3; i++)
+ {
+ btVector3& row = rot[i];
+ mrp = row[p];
+ mrq = row[q];
+ row[p] = cos * mrp - sin * mrq;
+ row[q] = cos * mrq + sin * mrp;
+ }
+ }
+ }
+
+
protected:
btScalar cofac(int r1, int c1, int r2, int c2) const
diff --git a/extern/bullet2/src/LinearMath/btScalar.h b/extern/bullet2/src/LinearMath/btScalar.h
index 1fee626d0c0..3c96857d4eb 100644
--- a/extern/bullet2/src/LinearMath/btScalar.h
+++ b/extern/bullet2/src/LinearMath/btScalar.h
@@ -24,7 +24,7 @@ subject to the following restrictions:
#include <cfloat>
#include <float.h>
-#define BT_BULLET_VERSION 271
+#define BT_BULLET_VERSION 272
inline int btGetVersion()
{
@@ -65,7 +65,11 @@ inline int btGetVersion()
#endif //__MINGW32__
#include <assert.h>
+#if defined(DEBUG) || defined (_DEBUG)
#define btAssert assert
+#else
+ #define btAssert(x)
+#endif
//btFullAssert is optional, slows down a lot
#define btFullAssert(x)
@@ -116,7 +120,13 @@ inline int btGetVersion()
#ifndef assert
#include <assert.h>
#endif
+
+#if defined(DEBUG) || defined (_DEBUG)
#define btAssert assert
+#else
+ #define btAssert(x)
+#endif
+
//btFullAssert is optional, slows down a lot
#define btFullAssert(x)
#define btLikely(_c) _c
@@ -145,11 +155,16 @@ typedef float btScalar;
#endif
+
#define BT_DECLARE_ALIGNED_ALLOCATOR() \
- SIMD_FORCE_INLINE void* operator new(size_t sizeInBytes) { return btAlignedAlloc(sizeInBytes,16); } \
- SIMD_FORCE_INLINE void operator delete(void* ptr) { btAlignedFree(ptr); } \
- SIMD_FORCE_INLINE void* operator new(size_t, void* ptr) { return ptr; } \
- SIMD_FORCE_INLINE void operator delete(void*, void*) { } \
+ SIMD_FORCE_INLINE void* operator new(size_t sizeInBytes) { return btAlignedAlloc(sizeInBytes,16); } \
+ SIMD_FORCE_INLINE void operator delete(void* ptr) { btAlignedFree(ptr); } \
+ SIMD_FORCE_INLINE void* operator new(size_t, void* ptr) { return ptr; } \
+ SIMD_FORCE_INLINE void operator delete(void*, void*) { } \
+ SIMD_FORCE_INLINE void* operator new[](size_t sizeInBytes) { return btAlignedAlloc(sizeInBytes,16); } \
+ SIMD_FORCE_INLINE void operator delete[](void* ptr) { btAlignedFree(ptr); } \
+ SIMD_FORCE_INLINE void* operator new[](size_t, void* ptr) { return ptr; } \
+ SIMD_FORCE_INLINE void operator delete[](void*, void*) { } \