I have an undefined behavior in Bullet. Every time I leave the window or not touch anything for one minute; the step function gets called but no integration happens in that time. The physics system freezes while everything else gets updates (animation, input etc).
I am currently checking the timestep to see if thats the problem.
Please let me know if anyone had a problem like that before and how is it possible to solve it.
Thanks,
Gasim
Bullet Physics weird problem in Xcode + OSX
-
- Posts: 6
- Joined: Tue Dec 03, 2013 9:31 pm
Re: Bullet Physics weird problem in Xcode + OSX
The problem is on my timestep function. Now, need to find out how to fix it.
-
- Site Admin
- Posts: 4221
- Joined: Sun Jun 26, 2005 6:43 pm
- Location: California, USA
Re: Bullet Physics weird problem in Xcode + OSX
Does it also happen in the unmodified Bullet 2.82 demos?
You might want to clamp the maximum delta time, if your computer was idle/sleeping, don't pass a huge value to delta time.
This way, even if you pass a huge deltaTimeInSeconds, only 10 steps will be taken at maximum.
You might want to clamp the maximum delta time, if your computer was idle/sleeping, don't pass a huge value to delta time.
Code: Select all
int maxSimulationSubSteps = 10;
float fixedInternalTimeStep = 1./60.f;
world->stepSimulation(deltaTimeInSeconds, maxSimulationSubSteps, fixedInternalTimeStep);
-
- Posts: 6
- Joined: Tue Dec 03, 2013 9:31 pm
Re: Bullet Physics weird problem in Xcode + OSX
I don't quiet completely understand the time ticking thing. I will figure out some way to implement it correctly in my engine since I am updating my engine through abstract subsystems... But for now, passing a fixed value works ok. Thank you for the help!
-
- Posts: 6
- Joined: Tue Dec 03, 2013 9:31 pm
Re: Bullet Physics weird problem in Xcode + OSX
My simulation stops when the object slowly stops moving. I don't understand why. Here is my main loop:
and in physics
Is there anything else I should take into account here?
EDIT: Also, there is another problem I am facing. My object never stops moving. Whenever I key press it sets the linear velocity to Vector3(0,0,-1.5); and whenever key is released, the velocity becomes Vector3(0,0,0). but the object keeps moving. I am checking maybe the collision object is the problem.
Code: Select all
float gameTime = 0.f;
float timeAccumulator = 0.f;
const float frameTime = 1.f/60.f;
sf::Clock clock;
while(mRunning) {
float fTime = (clock.getElapsedTime().asMilliseconds())/1000.f;
clock.restart();
timeAccumulator += fTime;
gameTime += fTime;
mCurrentState->processInput();
while(timeAccumulator >= frameTime) {
mCurrentState->update(frameTime); // this is where the physics gets updated
timeAccumulator -= frameTime;
}
mRenderWindow.clear();
mRenderWindow.pushGLStates();
mCurrentState->render();
mRenderWindow.popGLStates();
mRenderWindow.display();
}
Code: Select all
mWorld->stepSimulation(dt,10);
EDIT: Also, there is another problem I am facing. My object never stops moving. Whenever I key press it sets the linear velocity to Vector3(0,0,-1.5); and whenever key is released, the velocity becomes Vector3(0,0,0). but the object keeps moving. I am checking maybe the collision object is the problem.