diff options
author | Stanislaw Halik <sthalik@misaki.pl> | 2022-10-17 18:07:53 +0200 |
---|---|---|
committer | Stanislaw Halik <sthalik@misaki.pl> | 2022-10-17 18:07:53 +0200 |
commit | 6cadd1270b8ac5c5f49f5c07e74e7bd236dd0eb3 (patch) | |
tree | f705ecd3e5ff75fdc393daf59a20ae00dfb19bb3 /main/draw.cpp | |
parent | 5dd1ade46d1c21b840cfdd4acfaf3012a2955f7c (diff) |
a
Diffstat (limited to 'main/draw.cpp')
-rw-r--r-- | main/draw.cpp | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/main/draw.cpp b/main/draw.cpp index e2bcdd31..82c4efc9 100644 --- a/main/draw.cpp +++ b/main/draw.cpp @@ -7,8 +7,20 @@ namespace floormat { void app::drawEvent() { + + if (const float dt = timeline.previousFrameDuration(); dt > 0) + { + constexpr float RC = 0.5f; + const float alpha = dt/(dt + RC); + + if (_frame_time > 0) + _frame_time = _frame_time*(1-alpha) + alpha*dt; + else + _frame_time = dt; + } + { - const float dt = std::min(1.f/10, timeline.previousFrameDuration()); + const float dt = std::clamp(timeline.previousFrameDuration(), 1e-3f, 1e-1f); update(dt); } |