Unilateral collision response using masks.

lucaspcamargo
Posts: 3
Joined: Sat Dec 12, 2009 1:32 pm

Unilateral collision response using masks.

Post by lucaspcamargo »

Hi there

I'm a new Bullet user and I'm writing a 3d platforming game using bullet and ogre. In my game, when the player destroys stuff, i create lots of debris. I want the debris to bounce off when it collides with the player, but the world's debris shouldn't interfere with the player's trajectory in any way.
After reading the user manual, I thought bitwise masks were the solution. But they don't work as expected, and I'm sure the wall-spaceship-powerup example is wrong. If I put that example to practice, nor spaceships nor powerups would really bounce off that wall. If my player declares it won't collide with debris, debris also doesn't collide with it.
I know how to exclude broadphase collision pairs, using a callback, but what about the "unilateral response" problem? Is there an easy solution for it?

Sorry for the wall of text :wink:
Lucas.
Flix
Posts: 456
Joined: Tue Dec 25, 2007 1:06 pm

Re: Unilateral collision response using masks.

Post by Flix »

I would just assign a very low mass to the debris, so that they don't interfere with the player trajectory. Many times this simple solution works (I've tested it with my collision camera). You can assign a good damping factor or something like that to limit the debris speed due to collisions. Don't be afraid to try a very low mass.

Or, by iterating through the manifold points, you can understand (through user pointers or collision flags that are not excluding each other) when the player collides with the debris and develop your own logic as needed to tell who is the "collider" body between the two.

P.S. to me if object A collides with object B, object B collides with object A too. Then it's just a question of relative velocities... So in this prospective the Bullet collision masks work correctly.