than expected time, even when it could keep up. Changed the WM
timer logic a bit to always target the next frame time exactly,
double delta; /* time since previous step in seconds */
double ltime; /* internal, last time timer was activated */
double delta; /* time since previous step in seconds */
double ltime; /* internal, last time timer was activated */
+ double ntime; /* internal, next time we want to activate the timer */
+ double stime; /* internal, when the timer started */
int sleep; /* internal, put timers to sleep when needed */
} wmTimer;
int sleep; /* internal, put timers to sleep when needed */
} wmTimer;
* ***** END GPL LICENSE BLOCK *****
*/
* ***** END GPL LICENSE BLOCK *****
*/
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
wmTimer *wt;
for(wt= win->timers.first; wt; wt= wt->next) {
if(wt->sleep==0) {
wmTimer *wt;
for(wt= win->timers.first; wt; wt= wt->next) {
if(wt->sleep==0) {
- if(wt->timestep < time - wt->ltime) {
wmEvent event= *(win->eventstate);
wt->delta= time - wt->ltime;
wt->duration += wt->delta;
wt->ltime= time;
wmEvent event= *(win->eventstate);
wt->delta= time - wt->ltime;
wt->duration += wt->delta;
wt->ltime= time;
+ wt->ntime= wt->stime + wt->timestep*ceil(wt->duration/wt->timestep);
event.type= wt->event_type;
event.custom= EVT_DATA_TIMER;
event.type= wt->event_type;
event.custom= EVT_DATA_TIMER;
wt->event_type= event_type;
wt->ltime= PIL_check_seconds_timer();
wt->event_type= event_type;
wt->ltime= PIL_check_seconds_timer();
+ wt->ntime= wt->ltime + timestep;
+ wt->stime= wt->ltime;
wt->timestep= timestep;
BLI_addtail(&win->timers, wt);
wt->timestep= timestep;
BLI_addtail(&win->timers, wt);