Simulation stopping

Baha
Posts: 4
Joined: Tue Jun 21, 2011 2:17 pm

Simulation stopping

Post by Baha »

Hi
first of all I hope that I didnt miss any previous posts if someone had the same problem before.

Im working on a game and want to simulate this "Wooden Labyrinth Puzzle" with a marble rolling through a labyrinth. I tried to wrap the physics in an own class and everything is somehow working fine....well except for the fact that if I dont provide any userinput for a few seconds the simulation simply stops. This can can stop the ball while moving immediately. As long as I keep spaming for example keyboard inputs the ball keeps rolling.
When the simulation stops the programm is still running. I checked the WorldTransform data after the simulation stop and they are simply constant. The display-callBack function is still beeing called frequently (working with glut). I have no idea why the simulation stops.

Since I wraped the objects and the physics in an own class its hard to proivde some code but if any1 has an idea and needs to verify this on concrete code I can try to give the code for this.
(Working with glut and bullet 2.78)

Thx for your help!
ologon
Posts: 5
Joined: Thu Jun 16, 2011 11:44 am

Re: Simulation stopping

Post by ologon »

Hi!

Rigid bodies which don't move for a certain amount of time get automatically disabled in bullet for performance optimization.

So when creating your ball body you have to call:

Code: Select all

body->setActivationState(DISABLE_DEACTIVATION);
In this way the ball will never enter in "sleeping" state :)
Baha
Posts: 4
Joined: Tue Jun 21, 2011 2:17 pm

Re: Simulation stopping

Post by Baha »

yay Thx for your fast help^^

Im glad you mentioned that because I never would ve noticed that <.<,

Everything is working fine now Thank you!
User avatar
dphil
Posts: 237
Joined: Tue Jun 29, 2010 10:27 pm

Re: Simulation stopping

Post by dphil »

For future reference, if you don't want to completely disable deactivation for your object (and in large/complex simulations, having deactivation enabled is often good for performance), but still need it to respond to manually applied forces, you can reactivate it right before force application by calling:

Code: Select all

body->activate()
Though in the case of a simple labyrinth game, ologon's solution should be fine (and easier, being a one-time call).