Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 970 for code/branches/core2


Ignore:
Timestamp:
Apr 1, 2008, 11:21:24 PM (17 years ago)
Author:
landauf
Message:

enhanced timer: it's now possible to let a timer call a function 1000 times per second while having only 100 fps, because he'll then call the function 10 times per tick

File:
1 edited

Legend:

Unmodified
Added
Removed
  • code/branches/core2/src/orxonox/tools/Timer.h

    r957 r970  
    168168                            // It's time to call the function
    169169                            if (it->bLoop_)
     170                            {
    170171                                it->time_ += it->interval_; // Q: Why '+=' and not '='? A: Think about it. It's more accurate like that. Seriously.
     172                                while (it->time_ <= 0)
     173                                {
     174                                    // The interval was shorter than one tick, so execute the function more than once
     175                                    it->run();
     176                                    it->time_ += it->interval_;
     177                                }
     178                            }
    171179                            else
    172180                                it->stopTimer(); // Stop the timer if we don't want to loop
Note: See TracChangeset for help on using the changeset viewer.