Page 1 of 1

Collision between btCapsuleShape and btBvhTriangleMeshShape

Posted: Sat Feb 11, 2012 3:23 pm
by EddieBytes
Using bullet 2.79.

I have two objects: my character is the btCapsuleShape, and a 2D terrain (my game is a platformer) is a btBvhTriangleMeshShape.

The above collision works fine in Debug, however on Release the character just falls right through the terrain. Collisions get detected, my handler for collision points added gets called and outputs to my debug window informing me of the collisions. It's just that the forces are not there?

I can see the collision meshes in my game, I've implemented the btIDebugDraw. It's just that I have no idea where to start with the debugging.

Is collision between these two shapes not officially supported or something? Any suggestions as to how this might be debugged?

Re: Collision between btCapsuleShape and btBvhTriangleMeshSh

Posted: Sat Feb 11, 2012 5:26 pm
by kloplop321
That doesn't seem right, Have you checked to ensure that the collision flags are the same between debug and release?

Re: Collision between btCapsuleShape and btBvhTriangleMeshSh

Posted: Sat Feb 11, 2012 8:13 pm
by EddieBytes
Thanks!

Your suspicions might be correct. I printed to my debug output the values of getCollisionFlags for each rigid body. My character's body printed 0 and the terrain rigid body printed 1. But that's also true on Debug, not only Release, yet they still collide correctly. Nonetheless I used mRigidBody->setCollisionFlags(0); on my terrain object and still no change. Also, the terrain rigid body gets created with a collision flag of 1 from the start, not sure why. The char's body gets a 0 flag though. This is causing me such a headache :x

Re: Collision between btCapsuleShape and btBvhTriangleMeshSh

Posted: Sun Feb 12, 2012 8:06 am
by EddieBytes
Is there anything else that might cause this peculiar behavior?

Re: Collision between btCapsuleShape and btBvhTriangleMeshSh

Posted: Sun Feb 12, 2012 8:23 am
by EddieBytes
I found the cause. I didn't calculate the local inertia for the terrain.

Code: Select all

mCollisionShape->calculateLocalInertia(mass, fallInertia);
I probably don't understand local inertia right. What is it and why is it needed for static objects? Can't find anything in the documentation explaining it.

Also, it's very weird that on debug I can get away with not calculating it.

Can anyone point me to proper documentation, or at least explain in a few words what was happening?

Thank you!

LATER EDIT:
It wasn't needed. The debug had an assert preventing calls of calculateLocalInertia on concave shapes. I shouldn't have passed any inertia to btRigidBodyConstructionInfo at all when constructing the terrain.