Prevent rigid body moving into another rigid body

Post Reply
Posts: 5
Joined: Thu Apr 18, 2013 12:03 pm

Prevent rigid body moving into another rigid body

Post by haimat » Thu Apr 18, 2013 12:15 pm

Say I have three rigid bodies, two simple cubes A and B, and one ground plane, and all physics simulated by bullet. Using the mouse I can grab and move around those two boxes, I can also stack one box onto the other box. This all works fine.

In order to prevent that the user can move the two cubes into the ground plane, I check for a collision via bullet (as described on the bullet wiki). If such a collision occured, then I prevent that last user-initiated box movement programmatically. Thus the user can never move a box into the ground plane (or the other box). That works fine as well.

Now to my question. When I stack one box onto the other and then push the upper box down towards the ground plane, with the second box in between, then in most cases my collison check works fine between these two boxes, so that the user is not able to push the upper box down further. However, in some rare cases the user can "force" the upper box further down so that the other box (below the grabbed one) is pushed slightly into the ground plane.

Is there any way of telling bullet that no rigid body is ever allowed to be pushed into another body, so that they may never "overlap"? Or do I have to solve that in my application itself, without the help of bullet?

Thanks in advance for your help.
Kind regards, Matthias

Post Reply