ITickable: interpoateTick() vs advanceTime()
by Edward Rotberg · in Torque 3D Professional · 12/31/2009 (2:31 am) · 5 replies
Other than the ability to suppress calls to interpolateTick(), what is the difference between this call and advanceTime()? From the documentation it appears that both are called once per frame, and passed the delta-time since the last call. Why would I want to use the one versus the other (besides the suppression ability)? I should add that this is for a custom RenderDelegate, and I'm trying to find the best way to smoothly manage animations.
Currently I manage my own elapsed time in my preRenderImage() function, using (float)Platform::getRealMilliseconds()/1000.f in order to generate a floating point current time value in seconds, which is working fine. What advantages are there for inheriting from ITickable and using the "approved" methods mentioned in the first paragraph rather than the admittedly rough-handed approach I am already taking?
Thanks in advance,
= Ed =
Currently I manage my own elapsed time in my preRenderImage() function, using (float)Platform::getRealMilliseconds()/1000.f in order to generate a floating point current time value in seconds, which is working fine. What advantages are there for inheriting from ITickable and using the "approved" methods mentioned in the first paragraph rather than the admittedly rough-handed approach I am already taking?
Thanks in advance,
= Ed =
About the author
#2
AdvanceTime is called every frame on both server and client.
InterpolateTick is called every frame on client only.
12/31/2009 (7:31 am)
ProcessTick is called every tick (32ms) on both server and client.AdvanceTime is called every frame on both server and client.
InterpolateTick is called every frame on client only.
#3
But I still don't see what advantages going this route has over my method of directly calling Platform::getRealMilliseconds() from within my preRenderImage() function and doing my animation update from there.
Anyone?
= Ed =
12/31/2009 (12:38 pm)
Thanks Guy. That pretty much answered my question. I know I'm not at all interested in processTick() and I thought I'd indicated that. Davide seems to indicate that interpolateTick() is called every 32 ms, but that is not my understanding, which correlates more closely to your explanation. Since this for animation only, I suppose that I would use the interpolateTick() call as I have no need for the animation code to run server-side.But I still don't see what advantages going this route has over my method of directly calling Platform::getRealMilliseconds() from within my preRenderImage() function and doing my animation update from there.
Anyone?
= Ed =
#4
Also interpolateTick() is done regardless of visibility of the rendered object. Where doing it in prepRenderImage() would have it only happen if the object is rendered.
But of course you can work around all these things with the right tests.
12/31/2009 (2:04 pm)
@Ed - Well for one interpolateTick() is only called once per-rendered frame. Where prepRenderImage() may be called several times... multiple passes, shadows, reflections, etc.Also interpolateTick() is done regardless of visibility of the rendered object. Where doing it in prepRenderImage() would have it only happen if the object is rendered.
But of course you can work around all these things with the right tests.
#5
Thanks again!
= Ed =
12/31/2009 (3:06 pm)
Thanks Tom. Yeah, I'm already bailing out of prepRenderImage() unless isDiffusePass() is true. Looks like my current method is probably optimal.Thanks again!
= Ed =
Torque Owner Davide Archetti
Default Studio Name
Because if you go in the source file of the iTickable class it is explained well.
I don't have the sources here, but basically interpolateTick is called every tick, that is every 0.032s, while advanceTime is called at frame rate interval and for this reason it has the dt parameter. So if your application is running at 200fps advanceTime is called every 1/200 sec while processTick is always called every 0.032s .