diff options
author | Stanislaw Halik <sthalik@misaki.pl> | 2018-03-10 17:29:38 +0100 |
---|---|---|
committer | Stanislaw Halik <sthalik@misaki.pl> | 2018-03-10 18:35:13 +0100 |
commit | 6286bffbf988ed5ec47462a92a11c902e4d9669f (patch) | |
tree | 91f20c48fd8783226f707a916120fd596ed77807 | |
parent | 130715a4209c0f0efb5b35659eb76911a0bc6bbb (diff) |
logic/pipeline: smoothen transition for reltrans not aiming
Requested by: HOPPING_PONY on the Russian IL-2 Sturmovik forum.
-rw-r--r-- | logic/pipeline.cpp | 14 | ||||
-rw-r--r-- | logic/pipeline.hpp | 6 |
2 files changed, 19 insertions, 1 deletions
diff --git a/logic/pipeline.cpp b/logic/pipeline.cpp index c5dfe2d7..7774b02e 100644 --- a/logic/pipeline.cpp +++ b/logic/pipeline.cpp @@ -88,6 +88,8 @@ Pose reltrans::apply_pipeline(reltrans_state state, const Pose& value, //qDebug() << "reltrans-interp: START" << tcomp_in_zone_; cur = true; interp_timer.start(); + interp_phase_timer.start(); + RC_phase = 0; } in_zone = tcomp_in_zone_; @@ -114,10 +116,20 @@ Pose reltrans::apply_pipeline(reltrans_state state, const Pose& value, if (cur) { + static constexpr double RC_phases[] = { 2, 1, .5, .1, }; + static constexpr double RC_time_deltas[] = { 1, .25, 25., }; + const double dt = interp_timer.elapsed_seconds(); interp_timer.start(); - constexpr double RC = .1; + if (RC_phase + 1 != std::size(RC_phases) && + interp_phase_timer.elapsed_seconds() > RC_time_deltas[RC_phase]) + { + RC_phase++; + interp_phase_timer.start(); + } + + const double RC = RC_phases[RC_phase]; const double alpha = dt/(dt+RC); constexpr double eps = .05; diff --git a/logic/pipeline.hpp b/logic/pipeline.hpp index 7f618ea1..82a339a3 100644 --- a/logic/pipeline.hpp +++ b/logic/pipeline.hpp @@ -42,6 +42,12 @@ class reltrans { euler_t interp_pos, last_value; Timer interp_timer; + + // this implements smooth transition into reltrans mode + // once not aiming anymore. see `apply_pipeline()'. + Timer interp_phase_timer; + unsigned RC_phase; + bool cur = false; bool in_zone = false; |