Don't Repeatedly Calculate Same Guiderate Value

Doing so works reduces the impact of the damping factor.
This commit is contained in:
Bård Skaflestad 2020-09-02 11:45:33 +02:00
parent 7649df53a2
commit 8a87914740

View File

@ -252,14 +252,19 @@ void GuideRate::assign_grvalue(const std::string& wgname,
const GuideRateModel& model,
GuideRateValue&& value)
{
using std::swap;
auto& v = this->values[wgname];
if (v == nullptr) {
v = std::make_unique<GRValState>();
}
if (value.sim_time > v->curr.sim_time) {
// We've advanced in time since we previously calculated/stored this
// guiderate value. Push current value into the past and prepare to
// capture new value.
using std::swap;
swap(v->prev, v->curr);
}
v->curr = std::move(value);