123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102 |
- #ifndef TIMER_SYNC_H
- #define TIMER_SYNC_H
- #include "core/engine.h"
- struct MainFrameTime {
- float idle_step;
- int physics_steps;
- void clamp_idle(float min_idle_step, float max_idle_step);
- };
- class MainTimerSync {
-
- uint64_t last_cpu_ticks_usec;
- uint64_t current_cpu_ticks_usec;
-
- float time_accum;
-
- float time_deficit;
-
-
-
-
- static const int CONTROL_STEPS = 12;
-
- int accumulated_physics_steps[CONTROL_STEPS];
-
- int typical_physics_steps[CONTROL_STEPS];
- int fixed_fps;
- protected:
-
-
-
- float get_physics_jitter_fix();
-
-
- int get_average_physics_steps(float &p_min, float &p_max);
-
- MainFrameTime advance_core(float p_frame_slice, int p_iterations_per_second, float p_idle_step);
-
- MainFrameTime advance_checked(float p_frame_slice, int p_iterations_per_second, float p_idle_step);
-
- float get_cpu_idle_step();
- public:
- MainTimerSync();
-
- void init(uint64_t p_cpu_ticks_usec);
-
- void set_cpu_ticks_usec(uint64_t p_cpu_ticks_usec);
-
- void set_fixed_fps(int p_fixed_fps);
-
- MainFrameTime advance(float p_frame_slice, int p_iterations_per_second);
- };
- #endif
|