Understanding Internaltickcallback function

anshul.bhardwaj
Posts: 28
Joined: Mon Aug 29, 2011 11:02 am

Understanding Internaltickcallback function

Post by anshul.bhardwaj »

hi,
I am trying to implement the bullet physics in my own rendering engine.
In my rendering engine in every loop firstly i am calling a physicsupdate function then a render function.
Now in physics update function i am calling stepsimulation bullet function with following parameters--

Code: Select all

m_dynamicsWorld->stepSimulation(et, maxsubsteps, internal_rate);
where et is time between two calls, maxsubsteps is 10, and internal_rate is 1/60
i am also using the internaltickcallback function as given below

Code: Select all

static void tick_callback(btDynamicsWorld * w, btScalar ts)
{
    cout<<"I AM IN TICK CALLBACK"<<endl;
}
and in rendering engine i am printing like

Code: Select all

Render()
{
 cout<<"RENDERING";
}
when i run my application its debug mode is showing like this

Code: Select all

RENDERING
I AM IN TICK CALLBACK
I AM IN TICK CALLBACK
I AM IN TICK CALLBACK
I AM IN TICK CALLBACK
I AM IN TICK CALLBACK
RENDERING
I AM IN TICK CALLBACK
I AM IN TICK CALLBACK
I AM IN TICK CALLBACK
I AM IN TICK CALLBACK
RENDERING
I AM IN TICK CALLBACK
I AM IN TICK CALLBACK
I AM IN TICK CALLBACK
I AM IN TICK CALLBACK
I AM IN TICK CALLBACK
I AM IN TICK CALLBACK
I AM IN TICK CALLBACK
I AM IN TICK CALLBACK
I AM IN TICK CALLBACK
I AM IN TICK CALLBACK
RENDERING
I AM IN TICK CALLBACK
...
now i am totally confused.

What does this mean, the step simulation is calling tickcallback when it computes its physics step.
it means in a single rendering call the physics simulation is called many times.
if this is the case then how can i make the physics step calls according to my frames per seconds of the rendering engine?
User avatar
Dr.Shepherd
Posts: 168
Joined: Tue Jan 04, 2011 11:47 pm

Re: Understanding Internaltickcallback function

Post by Dr.Shepherd »

I think the output is right.

your internal-tick call back will be called every tick, but every frame will consist of several substeps/ticks. So each time you render an image, the internal ticks in bullet has actually been called for several times.

check this two links on tutorial pages:
http://www.bulletphysics.org/Bullet/php ... 483#p25483
http://bulletphysics.org/mediawiki-1.5. ... _the_World

you may need to think about whether you want a internal tick call back or frame callback.

Cheers
anshul.bhardwaj
Posts: 28
Joined: Mon Aug 29, 2011 11:02 am

Re: Understanding Internaltickcallback function

Post by anshul.bhardwaj »

Thanks,....i got it...its totally right..