Improved performance of convex collision shapes, cache local AABB instead of recomputation. This fixes issue with very slow performance in larger .bsp levels.

Moved some asserts into 'btFullAssert', which is disabled by default (see btScalar.h to enable them). This is to speed-up debugging.
This commit is contained in:
ejcoumans
2007-02-26 04:59:05 +00:00
parent 559c4e85d8
commit b73900bc60
18 changed files with 102 additions and 21 deletions

View File

@@ -45,12 +45,12 @@ class btMatrix3x3 {
zx, zy, zz);
}
btVector3 getColumn(int i) const
SIMD_FORCE_INLINE btVector3 getColumn(int i) const
{
return btVector3(m_el[0][i],m_el[1][i],m_el[2][i]);
}
const btVector3& getRow(int i) const
SIMD_FORCE_INLINE const btVector3& getRow(int i) const
{
return m_el[i];
}
@@ -58,13 +58,13 @@ class btMatrix3x3 {
SIMD_FORCE_INLINE btVector3& operator[](int i)
{
assert(0 <= i && i < 3);
btFullAssert(0 <= i && i < 3);
return m_el[i];
}
const btVector3& operator[](int i) const
SIMD_FORCE_INLINE const btVector3& operator[](int i) const
{
assert(0 <= i && i < 3);
btFullAssert(0 <= i && i < 3);
return m_el[i];
}
@@ -102,7 +102,7 @@ class btMatrix3x3 {
void setRotation(const btQuaternion& q)
{
btScalar d = q.length2();
assert(d != btScalar(0.0));
btFullAssert(d != btScalar(0.0));
btScalar s = btScalar(2.0) / d;
btScalar xs = q[0] * s, ys = q[1] * s, zs = q[2] * s;
btScalar wx = q[3] * xs, wy = q[3] * ys, wz = q[3] * zs;
@@ -323,7 +323,7 @@ class btMatrix3x3 {
{
btVector3 co(cofac(1, 1, 2, 2), cofac(1, 2, 2, 0), cofac(1, 0, 2, 1));
btScalar det = (*this)[0].dot(co);
assert(det != btScalar(0.0));
btFullAssert(det != btScalar(0.0));
btScalar s = btScalar(1.0) / det;
return btMatrix3x3(co[0] * s, cofac(0, 2, 2, 1) * s, cofac(0, 1, 1, 2) * s,
co[1] * s, cofac(0, 0, 2, 2) * s, cofac(0, 2, 1, 0) * s,

View File

@@ -38,6 +38,8 @@ subject to the following restrictions:
#include <assert.h>
#define btAssert assert
//btFullAssert is optional, slows down a lot
#define btFullAssert
#else
//non-windows systems
@@ -48,6 +50,8 @@ subject to the following restrictions:
#include <assert.h>
#endif
#define btAssert assert
//btFullAssert is optional, slows down a lot
#define btFullAssert
#endif
/// older compilers (gcc 3.x) and Sun needs double version of sqrt etc.

View File

@@ -74,9 +74,9 @@ public:
predictedTransform.setOrigin(curTrans.getOrigin() + linvel * timeStep);
// #define QUATERNION_DERIVATIVE
#ifdef QUATERNION_DERIVATIVE
btQuaternion orn = curTrans.getRotation();
orn += (angvel * orn) * (timeStep * btScalar(0.5));
orn.normalize();
btQuaternion predictedOrn = curTrans.getRotation();
predictedOrn += (angvel * predictedOrn) * (timeStep * btScalar(0.5));
predictedOrn.normalize();
#else
//exponential map
btVector3 axis;
@@ -101,6 +101,7 @@ public:
btQuaternion orn0 = curTrans.getRotation();
btQuaternion predictedOrn = dorn * orn0;
predictedOrn.normalize();
#endif
predictedTransform.setRotation(predictedOrn);
}

View File

@@ -64,7 +64,7 @@ public:
SIMD_FORCE_INLINE btVector3& operator/=(const btScalar& s)
{
assert(s != btScalar(0.0));
btFullAssert(s != btScalar(0.0));
return *this *= btScalar(1.0) / s;
}
@@ -99,7 +99,7 @@ public:
SIMD_FORCE_INLINE btScalar angle(const btVector3& v) const
{
btScalar s = btSqrt(length2() * v.length2());
assert(s != btScalar(0.0));
btFullAssert(s != btScalar(0.0));
return btAcos(dot(v) / s);
}
@@ -213,7 +213,7 @@ operator*(const btScalar& s, const btVector3& v)
SIMD_FORCE_INLINE btVector3
operator/(const btVector3& v, const btScalar& s)
{
assert(s != btScalar(0.0));
btFullAssert(s != btScalar(0.0));
return v * (btScalar(1.0) / s);
}