Bullet issues !?

mad
Posts: 4
Joined: Fri May 02, 2008 9:10 am

Bullet issues !?

Post by mad »

Hi! First of all thank for a great physics engine project!

I have just recently started looking at Bullet, previously I used PhysX, but I like the benefits of an open source physics engine capable of running on multiple platforms of course! Therefore I have added Bullet to my test project to evaluate and compare it with PhysX. However I have run into a few issues that I need to ask about before moving on. I use the latest SDK 2.68 and update everything with an iteration loop with a fixed timestep of 1/60.

I have simply created a collision plane and then create boxes that I drop from a certain height, about 50-100m.

- The first problem I have is that the boxes bounce a lot on impact. The restitution should be set to zero by default (right?), but I still get a lot more bounciness than compared to PhysX behaviour. Is there something wrong with my setup, do I have to create materials or something to correct this?
I also tried to modify the BasicDemo and moved the creation of the box-stack so that the entire stack falls down from a certain height and the same behaviour is there; the stack almost explodes on impact.

- The second problem is this: I can fly around with the camera in the world and point on objects and poke them around by adding forces where they are touched by the mouse. This works fine, until objects are deactivated, then they won't react at all when I apply forces to them! Waking up a sleeping body is however supported if I for instance throw another body at them so they collide.. but shouldn't the bodies wake up when forces are applied as well ?
Maybe this is also supported in another way or with another kind of setup, if so.. please tell me what to do :)

Sincerely
/ Mattias
User avatar
Erwin Coumans
Site Admin
Posts: 4221
Joined: Sun Jun 26, 2005 6:43 pm
Location: California, USA

Re: Bullet issues !?

Post by Erwin Coumans »

mad wrote: - The first problem I have is that the boxes bounce a lot on impact. The restitution should be set to zero by default (right?), but I still get a lot more bounciness than compared to PhysX behaviour. Is there something wrong with my setup, do I have to create materials or something to correct this?
I also tried to modify the BasicDemo and moved the creation of the box-stack so that the entire stack falls down from a certain height and the same behaviour is there; the stack almost explodes on impact.
There are some reasons that cause this bounciness, and this can be fixed. Separating the penetration depth correction from velocity correction will make reduce the effect mostly (split impulse). Another improvement is using a one-shot contact manifold generation. Both are on the roadmap, which is mainly driven by actual game projects using it.
This works fine, until objects are deactivated, then they won't react at all when I apply forces to them!
Indeed, Bullet requires the user to call body->activate() before applyImpulse/Force.

Thanks for the feedback,
Erwin
mad
Posts: 4
Joined: Fri May 02, 2008 9:10 am

Re: Bullet issues !?

Post by mad »

Great, now it works as it should! Thanks for the quick reply.

Looking forward to see the improved contact handling in the future! :)

/ Mattias
gjaegy
Posts: 178
Joined: Fri Apr 18, 2008 2:20 pm

Re: Bullet issues !?

Post by gjaegy »

Hi,

One question mad, have you managed to reduce the bounce effect ?

By increasing damping the bounce are reduced, however, objects falling speed is reduced as well, and thus not realistic anymore. Have you found another solution ?
mad
Posts: 4
Joined: Fri May 02, 2008 9:10 am

Re: Bullet issues !?

Post by mad »

Well, I have experimented some with damping forces, but as you mention this also affects the velocity of the body and just looks strange. So for now I'll settle with the bounciness :)

Another idea is of course to simply (?) modify the actual impulse being applied when contact occurs. I guess you could just scale down the impulse depending on impact velocity. I don't know if this is possible with Bullet though, but if so it could be worth investigating!

/ Mattias
Nathanael
Posts: 78
Joined: Mon Nov 13, 2006 1:44 am

Re: Bullet issues !?

Post by Nathanael »

As a quick fix, you can smooth out velocity drift correction by patching the method 'getDistance' in 'BulletCollision\NarrowPhaseCollision\btManifoldPoint.h' with that:

Code: Select all

btScalar getDistance() const
{
static const btScalar frames=16;
const btScalar		 factor=btMin<btScalar>(1,(m_lifeTime/frames));
return m_distance1*factor;
}
You can change 'frames' to suit your need.
Mind that not in anyway a complete solution, but it may help to reduce bouncing without requiring damping.

Hope it help.
Nathanael.
gjaegy
Posts: 178
Joined: Fri Apr 18, 2008 2:20 pm

Re: Bullet issues !?

Post by gjaegy »

I tried to apply the patch you gave, and the bounces are actually reduced. Thanks for that !

However, I am not a fan of this kind of "wild" patch (as it will be needed for each new version of bullet), I prefer not having to patch any external library if possible. Are there any plans to reduce the bouncing effect properly in a forthcoming version of the library ?

For my comprehension, what you did is that you reduced the penetration length, am I that right ? Could that have any side effect somewhere else in the library ?

Thanks once again for your answers !
Nathanael
Posts: 78
Joined: Mon Nov 13, 2006 1:44 am

Re: Bullet issues !?

Post by Nathanael »

gjaegy wrote:For my comprehension, what you did is that you reduced the penetration length, am I that right ? Could that have any side effect somewhere else in the library ?
Yes, you're right, basically, Bullet solve for velocities at contacts position such as velocityBodyA-velocityBodyB=-PenetrationDepth/Dt in the direction of the contact normal, that explain why even with restitution set zero, you get that bouncing effect which depend on penetration depth. What the patch does is 'spreading' that correction over 'x' frames.
As for side effects, yes, everywhere contacts are solved, i never said it was a subtle patch :wink:, but as i understand it, Bullet generate contacts in the future (unconstrained motion), so giving a chance to the solver to be 'right' for few frames isn't that bad, in some cases it may actually improve stacking for example.

Its not an trivial task to completely remove bouncing, unless CCD is used, in which case penetration depth is almost always zero.

Nathanael.
Last edited by Nathanael on Wed May 07, 2008 5:21 pm, edited 1 time in total.
gjaegy
Posts: 178
Joined: Fri Apr 18, 2008 2:20 pm

Re: Bullet issues !?

Post by gjaegy »

stupid question, I am new to bullet: is there a way to use CCD in current bullet version ?
User avatar
Erwin Coumans
Site Admin
Posts: 4221
Joined: Sun Jun 26, 2005 6:43 pm
Location: California, USA

Re: Bullet issues !?

Post by Erwin Coumans »

As I mentioned before, separating the penetration depth correction from velocity correction will avoid bounciness.
This is just a small change, and we will add this in a future release:
See http://code.google.com/p/bullet/issues/detail?id=55


Continuous collision detection is available through various queries, but there the continuous physics response is work in progress in Bullet/src/BulletDynamics/Dynamics/btContinuousDynamicsWorld. This is also on the roadmap.
See issue http://code.google.com/p/bullet/issues/detail?id=22

Thanks for the feedback,
Erwin
gjaegy
Posts: 178
Joined: Fri Apr 18, 2008 2:20 pm

Re: Bullet issues !?

Post by gjaegy »

Thanks a lot for your answer Erwin (and your work!).

So if I understood correctly, bounciness issue will certainly be solved in the next release, right ?

Any idea when it will be released ? Or a patch available for ? I will be glad to test it when available.

Thanks to everybody for the answers !
Greg
Nino
Posts: 3
Joined: Fri Apr 25, 2008 8:24 am

Re: Bullet issues !?

Post by Nino »

Erwin Coumans wrote:As I mentioned before, separating the penetration depth correction from velocity correction will avoid bounciness
Hi Erwin, I have the same problem for the bounciness.
When you say "separating the penetration depth correction from velocity correction", how do you do that ?

Could you show the code to do it please ? (functions we need to call, parameters...)

Thanks in advance,
Regards,
Nino
Bbilz
Posts: 26
Joined: Wed Feb 27, 2008 9:55 am

Re: Bullet issues !?

Post by Bbilz »

Just like to add that we would find this an extremely useful fix as well!

It would be really great to have a situation where the velocity of rebounding objects can be totally controlled by setting the restitution
User avatar
Erwin Coumans
Site Admin
Posts: 4221
Joined: Sun Jun 26, 2005 6:43 pm
Location: California, USA

Re: Bullet issues !?

Post by Erwin Coumans »

We just added split impulse support in Bullet repository, so it will be available in upcoming Bullet 2.69 (very soon).

You will be able to control some parameters as part of the btContactSolverInfo (src\BulletDynamics\ConstraintSolver\btContactSolverInfo.h).

Hope this helps,
Erwin
mad
Posts: 4
Joined: Fri May 02, 2008 9:10 am

Re: Bullet issues !?

Post by mad »

Awesome! Thanks a lot for the quick solution to this problem :)

Sincerely
/ Mattias