internal timing

You are an experienced programmer and have a problem with the engine, shaders, or advanced effects? Here you'll get answers.
No questions about C++ programming or topics which are answered in the tutorials!
Post Reply
AReichl
Posts: 269
Joined: Wed Jul 13, 2011 2:34 pm

internal timing

Post by AReichl »

If you run one of the demos (e.g. LoadIrrFile, PerPixelLighting, SpecialFX), then switch to another window, so the action in the main window stops, then back to the main window, you can see "jumps" in the particles and the animated objects.

This probably happens because internally a time difference is taken between REAL times.

Question: is there something like an ENGINE TIME (which runs independently of the outer real time)?

There is a setSpeed(...) function ( with which you can simulate slow motion ), which in my opinion can only work, if you already have a "virtual" engine time.
hendu
Posts: 2600
Joined: Sat Dec 18, 2010 12:53 pm

Re: internal timing

Post by hendu »

Yes, there is "engine time", and you can stop, start, set it, and set the rate. Read the ITimer docs.
AReichl
Posts: 269
Joined: Wed Jul 13, 2011 2:34 pm

Re: internal timing

Post by AReichl »

fine - but still this would mean that the particles and animators (and maybe also animations) internally DON'T use the "engine time".
hendu
Posts: 2600
Joined: Sat Dec 18, 2010 12:53 pm

Re: internal timing

Post by hendu »

They do.
AReichl
Posts: 269
Joined: Wed Jul 13, 2011 2:34 pm

Re: internal timing

Post by AReichl »

I believe you!
But i get "jumpy" behaviour when using the timer functions.
And i cannot stop the timer if the timer speed is smaller than 1.0.
And if i start the timer again all movements are reset.
mongoose7
Posts: 1227
Joined: Wed Apr 06, 2011 12:13 pm

Re: internal timing

Post by mongoose7 »

I just tried:

Code: Select all

    while(device->run())
    if (device->isWindowActive())
    {
        if (stopped)
        {
            stopped = 0;
            device->getTimer()->start();
        }
<snip>
    }
    else if (!stopped)
    {
        stopped = 1;
        device->getTimer()->stop();
    }
and it worked. The animation (a rotation animator) stops and starts as expected.
AReichl
Posts: 269
Joined: Wed Jul 13, 2011 2:34 pm

Re: internal timing

Post by AReichl »

Try the FlyCircleAnimator or the FlyStraightAnimator.
Take example "Movement", extend it by adding

while( device->run() )
{
-> if( ! device->isWindowActive() )
-> continue;

then run it, fetch the dos windows to front and back again and you see what i mean.
Same goes for examples with a particle system.
hendu
Posts: 2600
Joined: Sat Dec 18, 2010 12:53 pm

Re: internal timing

Post by hendu »

Uh, in that case the timer continues to run.
mongoose7
Posts: 1227
Joined: Wed Apr 06, 2011 12:13 pm

Re: internal timing

Post by mongoose7 »

But where's the call to stop()?
AReichl
Posts: 269
Joined: Wed Jul 13, 2011 2:34 pm

Re: internal timing

Post by AReichl »

Ahhh - i see!
with

bool bTimerRunning = true;

while( device->run() )
{
if( ! device->isWindowActive() ) {
if( bTimerRunning ) { device->getTimer()->stop(); bTimerRunning = false; }
continue;
} else {
if( ! bTimerRunning ) { device->getTimer()->start(); bTimerRunning = true; }
}

...

it works perfectly. Same with particle systems.
Didn't know that device->run() triggers the internal timer, but of course it's logical.
Post Reply