Amerio.Stephane Posted March 19 Share Posted March 19 Hello, Could you precisely detail the differences with these different time API. Exactly how do they increase from example, and what would be the differences between them: #include <UnigineTimer.h> getSeconds() #include <UnigineGame.h> getTime() #include <plugins/UnigineIG.h> getInterpolationTime() Which one would be closer to the "wall clock"? Does it have millisecond precision? Link to comment
cash-metall Posted March 20 Share Posted March 20 Hello! Engine::getTime - time of application. It returns seconds as a float, so precision after the decimal point is not guaranteed. It deliberately does not account for any spikes and freezes in the application. You can use it e.g. for UI animation. Game::getTime - time if game. This method is the least accurate. based on Engine::time it also ignore spikes and freezes. Suitable for creating games. Moreover you can change speed of this timer using Game::setScale and Game::setEnabled. That is, after a game pause, the game state will remain where it was before the pause, without drifting far away, and animations will continue from the same position, etc. Timer::getSeconds method is the most accurate and closest to wall-clock time. It returns seconds as a double precision, allowing operation with microseconds/nanoseconds. It does not account any spikes and freezes (uses QueryPerformanceCounter for win; gettimeofday for unix inside). Can be used for any application independent time calculations. Syncker::getTime() method returns seconds with double precision. Based on Timer, it also ignores spikes but may be shifted forward or backward in case of synchronization disruption between master-slave. Should be used for critical animations and logic synchronized through syncker mechanisms. IG::Manager::getInterpolationTime() method can also be shifted forward or backward in case of synchronization loss between host-ig. Between host-frames, it uses Syncker::getTime, so it can also be shifted in case of master-slave synchronization disruption. This is used only for interpolating motion of entities obtained with timestamps from the host. 3 Link to comment
Amerio.Stephane Posted March 20 Author Share Posted March 20 Thanks a lot! All this would be a great addition to the doc as a summary for future reference 1 Link to comment
Recommended Posts