Change collision response depending on collision normal

Spaddlewit
Posts: 28
Joined: Fri Sep 04, 2009 8:23 pm

Change collision response depending on collision normal

Post by Spaddlewit »

I have a btSphereShape colliding with a btBvhTriangleMesh. Depending on the normal of the collision compared to a value I have stored, I want to either bounce, or slide. What is the best way to go about doing this in bullet to alter the response upon a collision? Thanks.
Mako_energy02
Posts: 171
Joined: Sun Jan 17, 2010 4:47 am

Re: Change collision response depending on collision normal

Post by Mako_energy02 »

I'm not 100% sure on this, but I believe you want to create a callback for when a contact is added, as mentioned here. You'll want to set up the callback such that it adjusts the friction and restitution of the object based on the normal as you said, probably mostly just altering the restitution, and have it return true if you did change something. If you don't change anything, return false. Once implemented it looks like gContactAddedCallback is a global C-style function pointer you can just assign to which will get used by bullet during collision processing. You may need to include "BulletCollision/CollisionDispatch/btManifoldResult.h" in order to see that global pointer and assign to it.
Spaddlewit
Posts: 28
Joined: Fri Sep 04, 2009 8:23 pm

Re: Change collision response depending on collision normal

Post by Spaddlewit »

Thanks, this indeed looks like what I need!