Dawn/src/epoch/epoch.c

26 lines
635 B
C

/**
* Copyright (c) 2021 Dominic Masters
*
* This software is released under the MIT License.
* https://opensource.org/licenses/MIT
*/
#include "epoch.h"
void epochInit(epoch_t *epoch) {
epoch->delta = EPOCH_FIXED_STEP;
epoch->last = EPOCH_FIXED_STEP;
epoch->current = EPOCH_FIXED_STEP + EPOCH_FIXED_STEP;
}
void epochUpdate(epoch_t *epoch, float platformDelta) {
platformDelta = mathMax(
mathMin(platformDelta, EPOCH_FIXED_STEP),
0
);
epoch->last = epoch->current;
epoch->current = epoch->current + platformDelta;
epoch->delta = epoch->current - epoch->last;
epoch->fixedDelta = EPOCH_FIXED_STEP;
}