From 569946a96ffad7a2528d637ed61cee0a77e02990 Mon Sep 17 00:00:00 2001 From: "erwin.coumans" Date: Thu, 11 Sep 2008 18:44:30 +0000 Subject: [PATCH] added some debugging variable for CCD motion clamping --- Demos/OpenGL/DemoApplication.cpp | 12 ++++++++++++ .../Dynamics/btDiscreteDynamicsWorld.cpp | 5 +++++ 2 files changed, 17 insertions(+) diff --git a/Demos/OpenGL/DemoApplication.cpp b/Demos/OpenGL/DemoApplication.cpp index 0237e0f11..49737e328 100644 --- a/Demos/OpenGL/DemoApplication.cpp +++ b/Demos/OpenGL/DemoApplication.cpp @@ -39,8 +39,11 @@ btTransform startTransforms[maxNumObjects]; btCollisionShape* gShapePtr[maxNumObjects];//1 rigidbody has 1 shape (no re-use of shapes) #define SHOW_NUM_DEEP_PENETRATIONS 1 +extern int gNumClampedCcdMotions; + #ifdef SHOW_NUM_DEEP_PENETRATIONS extern int gNumDeepPenetrationChecks; + extern int gNumSplitImpulseRecoveries; extern int gNumGjkChecks; extern int gNumAlignedAllocs; @@ -541,6 +544,9 @@ void DemoApplication::shootBox(const btVector3& destination) body->getWorldTransform().setRotation(btQuaternion(0,0,0,1)); body->setLinearVelocity(linVel); body->setAngularVelocity(btVector3(0,0,0)); + body->setCcdSquareMotionThreshold(3600);//1600);//40ms/sec for 60 hertz gives 0.66 m/frame. 40*40=1600 + body->setCcdSweptSphereRadius(0.2f); + } } @@ -1154,6 +1160,11 @@ void DemoApplication::renderme() sprintf(buf,"gNumGjkChecks= %d",gNumGjkChecks); BMF_DrawString(BMF_GetFont(BMF_kHelvetica10),buf); yStart += yIncr; + + glRasterPos3f(xOffset,yStart,0); + sprintf(buf,"gNumClampedCcdMotions = %d",gNumClampedCcdMotions); + BMF_DrawString(BMF_GetFont(BMF_kHelvetica10),buf); + yStart += yIncr; glRasterPos3f(xOffset,yStart,0); sprintf(buf,"gNumSplitImpulseRecoveries= %d",gNumSplitImpulseRecoveries); @@ -1218,6 +1229,7 @@ void DemoApplication::clientResetScene() gNumGjkChecks = 0; #endif //SHOW_NUM_DEEP_PENETRATIONS + gNumClampedCcdMotions = 0; int numObjects = 0; if (m_dynamicsWorld) { diff --git a/src/BulletDynamics/Dynamics/btDiscreteDynamicsWorld.cpp b/src/BulletDynamics/Dynamics/btDiscreteDynamicsWorld.cpp index b0bcbbd7f..88a418b97 100644 --- a/src/BulletDynamics/Dynamics/btDiscreteDynamicsWorld.cpp +++ b/src/BulletDynamics/Dynamics/btDiscreteDynamicsWorld.cpp @@ -707,6 +707,7 @@ void btDiscreteDynamicsWorld::calculateSimulationIslands() } + #include "BulletCollision/BroadphaseCollision/btCollisionAlgorithm.h" class btClosestNotMeConvexResultCallback : public btCollisionWorld::ClosestConvexResultCallback @@ -775,6 +776,9 @@ public: }; +///internal debugging variable. this value shouldn't be too high +int gNumClampedCcdMotions=0; + //#include "stdio.h" void btDiscreteDynamicsWorld::integrateTransforms(btScalar timeStep) { @@ -796,6 +800,7 @@ void btDiscreteDynamicsWorld::integrateTransforms(btScalar timeStep) BT_PROFILE("CCD motion clamping"); if (body->getCollisionShape()->isConvex()) { + gNumClampedCcdMotions++; body->predictIntegratedTransform(timeStep, predictedTrans); btClosestNotMeConvexResultCallback sweepResults(body,body->getWorldTransform().getOrigin(),predictedTrans.getOrigin(),getBroadphase()->getOverlappingPairCache()); btConvexShape* convexShape = static_cast(body->getCollisionShape());