Hello, everyone, I am new to Bullet, but now I want to integrate bullet into my OpenGL project.
I check the wiki and demos, and I can almost understand the physics and graphics.
My question is that, should I put stepSimulation into glutDisplayFunc to start the Phyiscs iteration, or put into glutIdleFunc to start the Physics iteration?
I find some examples, they put stepSimulation into the glutDisplayFunc, others they put into glutIdleFunc? They are the same? or different?
Also my graphic fresh rate is about 30Hz, and I want my physics rate is at 100Hz, so I just set this function like: stepSimulation(1/100,1,1/60)? ok?
Thanks
How to put stepSimulation
-
- Posts: 463
- Joined: Fri Nov 30, 2012 4:50 am
Re: How to put stepSimulation
You don't want to do thatsmallping wrote: Also my graphic fresh rate is about 30Hz, and I want my physics rate is at 100Hz, so I just set this function like: stepSimulation(1/100,1,1/60)? ok?

It should be stepSimulation(elapsedTime, 3,1/100), where elapsed time is the time between step calls, 3 is a number large enough so that graphics lag doesn't mess with simulation rate (but small enough that if the computer isn't fast enough to handle it the accuracy will be reduced rather than spiral into oblivion), and then internal simulation step size (your 100hz simulation rate).
http://bulletphysics.org/mediawiki-1.5. ... _the_World explains this quite well.
-
- Posts: 11
- Joined: Fri Oct 19, 2012 3:37 am
Re: How to put stepSimulation
Dear Basroil, thanks for your information.
So I can just do like this
......
glutIdleFunc(main_idle);
......
void main_idle(void)
{
float dtime = g_time;
g_time = glutGet(GLUT_ELAPSED_TIME) / 1000.0;
dtime = g_time - dtime;
if(g_btDynamicsWorld)
g_btDynamicsWorld->stepSimulation(dtime, 10, 0.01);
glutPostRedisplay();
}
Is that right? I try and it works
So I can just do like this
......
glutIdleFunc(main_idle);
......
void main_idle(void)
{
float dtime = g_time;
g_time = glutGet(GLUT_ELAPSED_TIME) / 1000.0;
dtime = g_time - dtime;
if(g_btDynamicsWorld)
g_btDynamicsWorld->stepSimulation(dtime, 10, 0.01);
glutPostRedisplay();
}
Is that right? I try and it works
-
- Posts: 463
- Joined: Fri Nov 30, 2012 4:50 am
Re: How to put stepSimulation
Sounds about right, though there's a bullet timer built in that does the same thing too if you want more bullet in your program.