Fix memory leak, see http://bulletphysics.com/Bullet/phpBB3/viewtopic.php?f=9&t=3266
Change contact breaking threshold
Add 'needsResponse' test for CcdMotionClamping, see http://code.google.com/p/bullet/issues/detail?id=179
Updated user manual (needs lots more work)
Added autoexp.dat, enabled Microsoft Visual Studio debug visualization for btAlignedObjectArray and btVector3.
This commit is contained in:
erwin.coumans
2009-02-27 02:33:48 +00:00
parent 0066e41a92
commit 3548c01985
8 changed files with 132 additions and 49 deletions

Binary file not shown.

66
msvc/autoexp_dat.txt Normal file
View File

@@ -0,0 +1,66 @@
;------------------------------------------------------------------------------
; Microsoft Visual Studio Debug Visualization for Bullet btVector3 and btAlignedObjectArray
;
; Copy and paste the contents of this file to the end of autoexp.dat, usually located at
; C:\Program Files\Microsoft Visual Studio 8\Common7\Packages\Debugger\autoexp.dat
;------------------------------------------------------------------------------
[Visualizer]
;------------------------------------------------------------------------------
; btVector3
;------------------------------------------------------------------------------
btVector3{
children
(
#array
(
expr : ($c.m_floats)[$i],
size : 4
)
)
preview
(
#(
"[",
#array
(
expr : ($c.m_floats)[$i],
size : 4
),
"]"
)
)
}
;------------------------------------------------------------------------------
; btAlignedObjectArray
;------------------------------------------------------------------------------
btAlignedObjectArray<*>{
children
(
#array
(
expr : ($c.m_data)[$i],
size : $c.m_size
)
)
preview
(
#(
"[",
$c.m_size ,
"](",
#array
(
expr : ($c.m_data)[$i],
size : $c.m_size
),
")"
)
)
}

View File

@@ -79,7 +79,9 @@ btPersistentManifold* btCollisionDispatcher::getNewManifold(void* b0,void* b1)
btCollisionObject* body0 = (btCollisionObject*)b0; btCollisionObject* body0 = (btCollisionObject*)b0;
btCollisionObject* body1 = (btCollisionObject*)b1; btCollisionObject* body1 = (btCollisionObject*)b1;
btScalar contactBreakingThreshold = btMin(gContactBreakingThreshold,btMin(body0->getCollisionShape()->getContactBreakingThreshold(),body1->getCollisionShape()->getContactBreakingThreshold())); //test for Bullet 2.74: use a relative contact breaking threshold without clamping against 'gContactBreakingThreshold'
//btScalar contactBreakingThreshold = btMin(gContactBreakingThreshold,btMin(body0->getCollisionShape()->getContactBreakingThreshold(),body1->getCollisionShape()->getContactBreakingThreshold()));
btScalar contactBreakingThreshold = btMin(body0->getCollisionShape()->getContactBreakingThreshold(),body1->getCollisionShape()->getContactBreakingThreshold());
void* mem = 0; void* mem = 0;
@@ -146,7 +148,6 @@ btCollisionAlgorithm* btCollisionDispatcher::findAlgorithm(btCollisionObject* bo
bool btCollisionDispatcher::needsResponse(btCollisionObject* body0,btCollisionObject* body1) bool btCollisionDispatcher::needsResponse(btCollisionObject* body0,btCollisionObject* body1)
{ {
//here you can do filtering //here you can do filtering

View File

@@ -119,6 +119,39 @@ void btCollisionWorld::addCollisionObject(btCollisionObject* collisionObject,sho
void btCollisionWorld::updateSingleAabb(btCollisionObject* colObj)
{
btVector3 minAabb,maxAabb;
colObj->getCollisionShape()->getAabb(colObj->getWorldTransform(), minAabb,maxAabb);
//need to increase the aabb for contact thresholds
btVector3 contactThreshold(gContactBreakingThreshold,gContactBreakingThreshold,gContactBreakingThreshold);
minAabb -= contactThreshold;
maxAabb += contactThreshold;
btBroadphaseInterface* bp = (btBroadphaseInterface*)m_broadphasePairCache;
//moving objects should be moderately sized, probably something wrong if not
if ( colObj->isStaticObject() || ((maxAabb-minAabb).length2() < btScalar(1e12)))
{
bp->setAabb(colObj->getBroadphaseHandle(),minAabb,maxAabb, m_dispatcher1);
} else
{
//something went wrong, investigate
//this assert is unwanted in 3D modelers (danger of loosing work)
colObj->setActivationState(DISABLE_SIMULATION);
static bool reportMe = true;
if (reportMe && m_debugDrawer)
{
reportMe = false;
m_debugDrawer->reportErrorWarning("Overflow in AABB, object removed from simulation");
m_debugDrawer->reportErrorWarning("If you can reproduce this, please email bugs@continuousphysics.com\n");
m_debugDrawer->reportErrorWarning("Please include above information, your Platform, version of OS.\n");
m_debugDrawer->reportErrorWarning("Thanks.\n");
}
}
}
void btCollisionWorld::updateAabbs() void btCollisionWorld::updateAabbs()
{ {
BT_PROFILE("updateAabbs"); BT_PROFILE("updateAabbs");
@@ -131,38 +164,9 @@ void btCollisionWorld::updateAabbs()
//only update aabb of active objects //only update aabb of active objects
if (colObj->isActive()) if (colObj->isActive())
{ {
btVector3 minAabb,maxAabb; updateSingleAabb(colObj);
colObj->getCollisionShape()->getAabb(colObj->getWorldTransform(), minAabb,maxAabb);
//need to increase the aabb for contact thresholds
btVector3 contactThreshold(gContactBreakingThreshold,gContactBreakingThreshold,gContactBreakingThreshold);
minAabb -= contactThreshold;
maxAabb += contactThreshold;
btBroadphaseInterface* bp = (btBroadphaseInterface*)m_broadphasePairCache;
//moving objects should be moderately sized, probably something wrong if not
if ( colObj->isStaticObject() || ((maxAabb-minAabb).length2() < btScalar(1e12)))
{
bp->setAabb(colObj->getBroadphaseHandle(),minAabb,maxAabb, m_dispatcher1);
} else
{
//something went wrong, investigate
//this assert is unwanted in 3D modelers (danger of loosing work)
colObj->setActivationState(DISABLE_SIMULATION);
static bool reportMe = true;
if (reportMe && m_debugDrawer)
{
reportMe = false;
m_debugDrawer->reportErrorWarning("Overflow in AABB, object removed from simulation");
m_debugDrawer->reportErrorWarning("If you can reproduce this, please email bugs@continuousphysics.com\n");
m_debugDrawer->reportErrorWarning("Please include above information, your Platform, version of OS.\n");
m_debugDrawer->reportErrorWarning("Thanks.\n");
}
}
} }
} }
} }

View File

@@ -133,8 +133,9 @@ public:
return m_dispatcher1; return m_dispatcher1;
} }
virtual void updateAabbs(); void updateSingleAabb(btCollisionObject* colObj);
virtual void updateAabbs();
virtual void setDebugDrawer(btIDebugDraw* debugDrawer) virtual void setDebugDrawer(btIDebugDraw* debugDrawer)
{ {

View File

@@ -63,6 +63,7 @@ btPairCachingGhostObject::btPairCachingGhostObject()
btPairCachingGhostObject::~btPairCachingGhostObject() btPairCachingGhostObject::~btPairCachingGhostObject()
{ {
m_hashPairCache->~btHashedOverlappingPairCache();
btAlignedFree( m_hashPairCache ); btAlignedFree( m_hashPairCache );
} }

View File

@@ -16,6 +16,9 @@ subject to the following restrictions:
#include "BulletCollision/CollisionShapes/btCollisionShape.h" #include "BulletCollision/CollisionShapes/btCollisionShape.h"
btScalar gContactThresholdFactor=btScalar(0.02);
/* /*
Make sure this dummy function never changes so that it Make sure this dummy function never changes so that it
can be used by probes that are checking whether the can be used by probes that are checking whether the
@@ -44,8 +47,7 @@ void btCollisionShape::getBoundingSphere(btVector3& center,btScalar& radius) con
btScalar btCollisionShape::getContactBreakingThreshold() const btScalar btCollisionShape::getContactBreakingThreshold() const
{ {
///@todo make this 0.1 configurable return getAngularMotionDisc() * gContactThresholdFactor;
return getAngularMotionDisc() * btScalar(0.1);
} }
btScalar btCollisionShape::getAngularMotionDisc() const btScalar btCollisionShape::getAngularMotionDisc() const
{ {

View File

@@ -779,14 +779,16 @@ class btClosestNotMeConvexResultCallback : public btCollisionWorld::ClosestConve
btCollisionObject* m_me; btCollisionObject* m_me;
btScalar m_allowedPenetration; btScalar m_allowedPenetration;
btOverlappingPairCache* m_pairCache; btOverlappingPairCache* m_pairCache;
btDispatcher* m_dispatcher;
public: public:
btClosestNotMeConvexResultCallback (btCollisionObject* me,const btVector3& fromA,const btVector3& toA,btOverlappingPairCache* pairCache) : btClosestNotMeConvexResultCallback (btCollisionObject* me,const btVector3& fromA,const btVector3& toA,btOverlappingPairCache* pairCache,btDispatcher* dispatcher) :
btCollisionWorld::ClosestConvexResultCallback(fromA,toA), btCollisionWorld::ClosestConvexResultCallback(fromA,toA),
m_allowedPenetration(0.0f), m_allowedPenetration(0.0f),
m_me(me), m_me(me),
m_pairCache(pairCache) m_pairCache(pairCache),
m_dispatcher(dispatcher)
{ {
} }
@@ -821,20 +823,26 @@ public:
if (!ClosestConvexResultCallback::needsCollision(proxy0)) if (!ClosestConvexResultCallback::needsCollision(proxy0))
return false; return false;
///don't do CCD when there are already contact points (touching contact/penetration) btCollisionObject* otherObj = (btCollisionObject*) proxy0->m_clientObject;
btAlignedObjectArray<btPersistentManifold*> manifoldArray;
btBroadphasePair* collisionPair = m_pairCache->findPair(m_me->getBroadphaseHandle(),proxy0); //call needsResponse, see http://code.google.com/p/bullet/issues/detail?id=179
if (collisionPair) if (m_dispatcher->needsResponse(m_me,otherObj))
{ {
if (collisionPair->m_algorithm) ///don't do CCD when there are already contact points (touching contact/penetration)
btAlignedObjectArray<btPersistentManifold*> manifoldArray;
btBroadphasePair* collisionPair = m_pairCache->findPair(m_me->getBroadphaseHandle(),proxy0);
if (collisionPair)
{ {
manifoldArray.resize(0); if (collisionPair->m_algorithm)
collisionPair->m_algorithm->getAllContactManifolds(manifoldArray);
for (int j=0;j<manifoldArray.size();j++)
{ {
btPersistentManifold* manifold = manifoldArray[j]; manifoldArray.resize(0);
if (manifold->getNumContacts()>0) collisionPair->m_algorithm->getAllContactManifolds(manifoldArray);
return false; for (int j=0;j<manifoldArray.size();j++)
{
btPersistentManifold* manifold = manifoldArray[j];
if (manifold->getNumContacts()>0)
return false;
}
} }
} }
} }
@@ -872,7 +880,7 @@ void btDiscreteDynamicsWorld::integrateTransforms(btScalar timeStep)
{ {
gNumClampedCcdMotions++; gNumClampedCcdMotions++;
btClosestNotMeConvexResultCallback sweepResults(body,body->getWorldTransform().getOrigin(),predictedTrans.getOrigin(),getBroadphase()->getOverlappingPairCache()); btClosestNotMeConvexResultCallback sweepResults(body,body->getWorldTransform().getOrigin(),predictedTrans.getOrigin(),getBroadphase()->getOverlappingPairCache(),getDispatcher());
btConvexShape* convexShape = static_cast<btConvexShape*>(body->getCollisionShape()); btConvexShape* convexShape = static_cast<btConvexShape*>(body->getCollisionShape());
btSphereShape tmpSphere(body->getCcdSweptSphereRadius());//btConvexShape* convexShape = static_cast<btConvexShape*>(body->getCollisionShape()); btSphereShape tmpSphere(body->getCcdSweptSphereRadius());//btConvexShape* convexShape = static_cast<btConvexShape*>(body->getCollisionShape());