why is my btCollisionWorld slower than btDynamicsWorld?

FarnhamBach
Posts: 2
Joined: Fri Sep 14, 2007 2:37 am

why is my btCollisionWorld slower than btDynamicsWorld?

Post by FarnhamBach »

I have my app set up for two modes--using bullet with dynamics, or just using bullet's collision detection. I can load the same rigid body model files for either mode, it's just in collision-only I obviously ignore mass info, etc.

But for some reason, the test model (which is comprised of RigidBodies in the 1st mode, and CollisionObjects in the 2nd mode) runs _slower_ just collision-only. We're talking 6-7 times slower.

I was expecting it to run way faster than Dynamics, since dynamics does the collision detection + the physics sim.

Code: Select all

btCollisionDispatcher* dispatcher = new btCollisionDispatcher();
btVector3 worldAabbMin(-50,-50,-50);
btVector3 worldAabbMax(50,50,50);

// omitted--register some custom collision algorithms (doesn't seem to affect performance much)

 const int maxProxies = 32766;  
 btOverlappingPairCache* broadphase = new btAxisSweep3(worldAabbMin,worldAabbMax,maxProxies);
 m_CollisionWorld = new btCollisionWorld(dispatcher,broadphase); 
I make collision objects like this:

Code: Select all

btCollisionObject* obj = new btCollisionObject();
        btMatrix3x3 basis;
        basis.setIdentity();
        obj->getWorldTransform().setBasis(basis);
        obj->setCollisionShape(shape);
        m_CollisionWorld->addCollisionObject(obj);
WHen I iterate, (I time 1000 iterations), I do:

Code: Select all

m_CollisionWorld->performDiscreteCollisionDetection();
int numManifolds = m_CollisionWorld->getDispatcher()->getNumManifolds();
return (numManifolds > 0) ? true : false;
I did a gprof profile, and in the collision only mode, the #1 time-burner was
gjkepa_impl::EPA::EvaluatePD(float)
followed by gjkepa_impl::EPA::BuildHorizon(....)

but in dynamics mode, the #1 time-burner is btCapsuleShape::localGetSupportingVertexWithoutMargin(btVector3 const&) const

Anybody have any ideas?
FarnhamBach
Posts: 2
Joined: Fri Sep 14, 2007 2:37 am

Re: why is my btCollisionWorld slower than btDynamicsWorld?

Post by FarnhamBach »

Well it seems that it is partly a problem of the origins of my collision objects. If they start out intersecting, the time rises drastically. But if they start out all not intersecting or touching, my collision world mode does run way faster than full dynamics mode (0.002 ms vs. 0.160 ms for my particular test). Not sure how bad the slow-downs will be during intersections of moving objects.