Skip to content

Commit

Permalink
#931 Correct for overshoot value when returning delta_system_time for…
Browse files Browse the repository at this point in the history
… interval systems
  • Loading branch information
SanderMertens committed Mar 27, 2023
1 parent 3c705ed commit 1c36f18
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 4 deletions.
5 changes: 3 additions & 2 deletions flecs.c
Original file line number Diff line number Diff line change
Expand Up @@ -18260,9 +18260,10 @@ void ProgressTimers(ecs_iter_t *it) {
t = 0;
}

timer[i].time = t; /* Initialize with remainder */
timer[i].time = t; /* Initialize with remainder */
tick_source[i].tick = true;
tick_source[i].time_elapsed = time_elapsed;
tick_source[i].time_elapsed = time_elapsed - timer[i].overshoot;
timer[i].overshoot = t;

if (timer[i].single_shot) {
timer[i].active = false;
Expand Down
1 change: 1 addition & 0 deletions flecs.h
Original file line number Diff line number Diff line change
Expand Up @@ -10067,6 +10067,7 @@ extern "C" {
typedef struct EcsTimer {
ecs_ftime_t timeout; /**< Timer timeout period */
ecs_ftime_t time; /**< Incrementing time value */
ecs_ftime_t overshoot; /**< Used to correct returned interval time */
int32_t fired_count; /**< Number of times ticked */
bool active; /**< Is the timer active or not */
bool single_shot; /**< Is this a single shot timer */
Expand Down
1 change: 1 addition & 0 deletions include/flecs/addons/timer.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ extern "C" {
typedef struct EcsTimer {
ecs_ftime_t timeout; /**< Timer timeout period */
ecs_ftime_t time; /**< Incrementing time value */
ecs_ftime_t overshoot; /**< Used to correct returned interval time */
int32_t fired_count; /**< Number of times ticked */
bool active; /**< Is the timer active or not */
bool single_shot; /**< Is this a single shot timer */
Expand Down
5 changes: 3 additions & 2 deletions src/addons/timer.c
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,10 @@ void ProgressTimers(ecs_iter_t *it) {
t = 0;
}

timer[i].time = t; /* Initialize with remainder */
timer[i].time = t; /* Initialize with remainder */
tick_source[i].tick = true;
tick_source[i].time_elapsed = time_elapsed;
tick_source[i].time_elapsed = time_elapsed - timer[i].overshoot;
timer[i].overshoot = t;

if (timer[i].single_shot) {
timer[i].active = false;
Expand Down

0 comments on commit 1c36f18

Please sign in to comment.