|
@@ -112,20 +112,23 @@ struct PulseGenerator { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** Accumulates a timer when process() is called. */ |
|
|
/** Accumulates a timer when process() is called. */ |
|
|
struct Timer { |
|
|
|
|
|
float time = 0.f; |
|
|
|
|
|
|
|
|
template <typename T = float> |
|
|
|
|
|
struct TTimer { |
|
|
|
|
|
T time = 0.f; |
|
|
|
|
|
|
|
|
void reset() { |
|
|
void reset() { |
|
|
time = 0.f; |
|
|
time = 0.f; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
/** Returns the time since last reset or initialization. */ |
|
|
/** Returns the time since last reset or initialization. */ |
|
|
float process(float deltaTime) { |
|
|
|
|
|
|
|
|
T process(T deltaTime) { |
|
|
time += deltaTime; |
|
|
time += deltaTime; |
|
|
return time; |
|
|
return time; |
|
|
} |
|
|
} |
|
|
}; |
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
typedef TTimer<> Timer; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** Counts calls to process(), returning true every `division` calls. |
|
|
/** Counts calls to process(), returning true every `division` calls. |
|
|
Example: |
|
|
Example: |
|
|