Collision between btCapsuleShape and btBvhTriangleMeshShape

Post Reply
User avatar
EddieBytes
Posts: 22
Joined: Sun Jul 24, 2011 5:07 pm
Contact:

Collision between btCapsuleShape and btBvhTriangleMeshShape

Post 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?
kloplop321
Posts: 55
Joined: Sun Jan 01, 2012 7:37 pm

Re: Collision between btCapsuleShape and btBvhTriangleMeshSh

Post by kloplop321 »

That doesn't seem right, Have you checked to ensure that the collision flags are the same between debug and release?
User avatar
EddieBytes
Posts: 22
Joined: Sun Jul 24, 2011 5:07 pm
Contact:

Re: Collision between btCapsuleShape and btBvhTriangleMeshSh

Post 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
User avatar
EddieBytes
Posts: 22
Joined: Sun Jul 24, 2011 5:07 pm
Contact:

Re: Collision between btCapsuleShape and btBvhTriangleMeshSh

Post by EddieBytes »

Is there anything else that might cause this peculiar behavior?
User avatar
EddieBytes
Posts: 22
Joined: Sun Jul 24, 2011 5:07 pm
Contact:

Re: Collision between btCapsuleShape and btBvhTriangleMeshSh

Post 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.
Post Reply