How to prevent floating inactive objects?

mreuvers
Posts: 69
Joined: Sat May 10, 2008 8:39 am

How to prevent floating inactive objects?

Post by mreuvers »

Hi there,

In our game we are stacking a number of object on each other and it is possible to hit them with a 'bullet'. Normally if you hit the lowest object, the stack will tumble and all objects will fall on the ground. That is, if you aim properly ;-)

Under certain circumstances however, it is possible to hit an object in such a way that objects that are stacked on top won't be affected by the impact. Effectively this means that it is possible to remove an object from the stack, while the others that are stacked on top of it stay untouched and in the air. We had several occasions of these magical floating objects. We also noticed constructions that aren't physically possible because one of the supporting beams was shot away, yet the structure 'magically' still stood there because the structure didn't 'wake up' from the impact.

With a bit of hackery I managed to cycle through all inactive objects, 'touching' one inactive object per frame by activating it for one frame. With 60 inactive objects that would mean that each object is at least awake once every second. If the collision response produced a situation as I described above (a floating object) at least that floating object is active once a second. And as soon as that object 'discovers' that it is floating in the air, it'll fall. It is hackery in its purest form, but hey... it worked... ;-)

However a major drawback from that approach is that the physics world is constantly active, and is also actively colliding. When activating an object in a group (island) ALL objects from that island are suddenly activated, which is a performance hit. But even worse, when we played a sound at a certain impulse threshold, we noticed that with the cycle approach some levels were constantly 'clicking'. Apparently when briefly activating the objects, they can collide and generate quite big impulses. These big impulses are still generated if the objects are stacked on each other for minutes: they never seem to really settle, as soon as you activate them they collide again.

That's when we decided to abandon the cycle and activate approach, we simply got too many bogus impulse results. But now we got our floating objects back :( Is there any way to get rid of this?

Help! ;-)

Cheers,


Martijn
sparkprime
Posts: 508
Joined: Fri May 30, 2008 2:51 am
Location: Ossining, New York

Re: How to prevent floating inactive objects?

Post by sparkprime »

Have you tried adjusting the rigid body sleep thresholds? It's possible they are too high.
mreuvers
Posts: 69
Joined: Sat May 10, 2008 8:39 am

Re: How to prevent floating inactive objects?

Post by mreuvers »

Those should be okay, sleep threshold is 1.5 seconds and the angular and linear sleep values are 0.3 and 1.0 respectively. It's not the sleeping thresholds I think: the object simply won't wake up to begin with.
User avatar
Erwin Coumans
Site Admin
Posts: 4221
Joined: Sun Jun 26, 2005 6:43 pm
Location: California, USA

Re: How to prevent floating inactive objects?

Post by Erwin Coumans »

If there is an activation issue when an object is removed from an deactivated island, you can force the island to activate using a custom pair callback. Just call body->activate on both bodies, in the removeOverlappingPair of this callback.

Code: Select all

m_broadphase->setOverlappingPairUserCallback(m_customPairCallback);
You can see an example implementation of a custom paircallback in Demos/CharacterDemo/CharacterDemo.cpp

Please let us know if that helps,
Thanks,
Erwin
User avatar
Erwin Coumans
Site Admin
Posts: 4221
Joined: Sun Jun 26, 2005 6:43 pm
Location: California, USA

Re: How to prevent floating inactive objects?

Post by Erwin Coumans »

This issue should be fixed now:

http://code.google.com/p/bullet/source/detail?r=1472

Thanks for the report,
Erwin
colinvella
Posts: 24
Joined: Sat Feb 09, 2008 2:38 pm
Location: Malta

Re: How to prevent floating inactive objects?

Post by colinvella »

Erwin,

What are the conditions in which you trigger activation? Is it just when an active body hits an inactive one, or do you handle separation as well?
secondwish
Posts: 11
Joined: Tue Sep 16, 2008 9:34 am

Re: How to prevent floating inactive objects?

Post by secondwish »

Hello,

I have another issue when implementing conveyors through a friction callback. Once they are stopped, I would like the objects to go to sleep to prevent a stack from hopping around or even destabilize.

Once the conveyor moves again, I need the whole island to be reactivated. Unfortunately, at the moment of conveyor reactivation, I only know the body of the conveyor, the other bodies are unknown.

Is there a function to tell a whole island, especially alle its bodies to wake up?

Thank you very much in advance!

Cheers, Georg.