Don't Repeatedly Calculate Same Guiderate Value
Doing so works reduces the impact of the damping factor.
This commit is contained in:
parent
7649df53a2
commit
8a87914740
@ -252,14 +252,19 @@ void GuideRate::assign_grvalue(const std::string& wgname,
|
|||||||
const GuideRateModel& model,
|
const GuideRateModel& model,
|
||||||
GuideRateValue&& value)
|
GuideRateValue&& value)
|
||||||
{
|
{
|
||||||
using std::swap;
|
|
||||||
|
|
||||||
auto& v = this->values[wgname];
|
auto& v = this->values[wgname];
|
||||||
if (v == nullptr) {
|
if (v == nullptr) {
|
||||||
v = std::make_unique<GRValState>();
|
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);
|
swap(v->prev, v->curr);
|
||||||
|
}
|
||||||
|
|
||||||
v->curr = std::move(value);
|
v->curr = std::move(value);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user