Controlling penetration

plamen_t
Posts: 6
Joined: Wed Nov 12, 2008 8:58 pm

Controlling penetration

Post by plamen_t »

Hi all,

I have been using Bullet for awhile. Since I am using it in an application that requires relatively high level of accuracy I want to minimize the penetration as much as possible. Here is my understanding of how bullet works:
1. Find the forces that have to be applied on the body.
2. Using the information for the forces and the current orientation, velocity and so on of the body, find where the body will be after discrete amount of time (that is the timeStep in stepSimulation() method)
3. Detect collisions, recalculate forces, apply certain physic laws and so on and go to step 1.

So if the timeStep interval is too big it means bigger penetrations - if in the current frame there is no collision but the bodies are relatively close and if timeStep is big it means that in the next frame the bodies will be moved at long distance and thus there is a great chance to have bigger penetrations between them. The problem in my application is the performance - it uses few static bodies and one very big moving mesh so I can't decrease timeStep to be very small value. Now it is 0.01. If I set it to 0.001 there is almost no penetrations but it runs very slowly. I know that in these simulations there is a tradeoff between accuracy and speed. But I have one idea that might be already implemented in bullet but I don't know. So here is my idea. After applying forces and after finding the new positions of the bodies after timeStep interval to check if there are any penetrations. If there are some penetrations to return the bodies at their initial position before applying forces and to apply the forces for smaller timeStep - for example timeStep/2. Then to check if with the new timeStep there are penetrations and if there are still ones to try with timeStep/4 for example. And to repeat this loop for some predefined depth. It will slow down the algorithm but it will slow down it only in the situations where there are collisions between objects.
So in brief that's my idea. What do you think about that?

Thanks and Merry Christmass to all
Plamen