fixup! Add velocity extrapolator

[skip ci]
This commit is contained in:
Lars Toenning
2022-12-22 12:11:27 +01:00
parent 6fe2dc8037
commit 4c07beb2bf

View File

@@ -186,19 +186,31 @@ namespace BlackMisc::Simulation
CInterpolatorVelocity::CInterpolant CInterpolatorVelocity::getInterpolant(SituationLog &log) CInterpolatorVelocity::CInterpolant CInterpolatorVelocity::getInterpolant(SituationLog &log)
{ {
CAircraftSituation current = *m_currentSituations.begin();
// adjust ground if required
if (!current.canLikelySkipNearGroundInterpolation() && !current.hasGroundElevation())
{
// The elevation needs to be requested again when we do not receive any velocity updates of an aircraft
// for some time and the elevation is therefore discarded from the cache.
// This happens when the aircraft is not moving and we only receive a #ST packet once.
const CElevationPlane planeOld = this->findClosestElevationWithinRangeOrRequest(current, CElevationPlane::singlePointRadius(), current.getCallsign());
current.setGroundElevationChecked(planeOld, CAircraftSituation::FromCache);
}
if(!m_interpolant.isValid()) if(!m_interpolant.isValid())
{ {
m_interpolant = CInterpolant{ *m_currentSituations.begin() }; m_interpolant = CInterpolant{ current };
m_lastSituation = *m_currentSituations.begin(); m_lastSituation = current;
} }
else if (m_lastSituation == *m_currentSituations.begin()) else if (m_lastSituation == current)
{ {
m_interpolant.update(m_currentTimeMsSinceEpoch); m_interpolant.update(m_currentTimeMsSinceEpoch);
} }
else else
{ {
m_interpolant = CInterpolant{ m_interpolant, *m_currentSituations.begin() }; m_interpolant = CInterpolant{ m_interpolant, current };
m_lastSituation = *m_currentSituations.begin(); m_lastSituation = current;
} }
// Always changed (at least time) // Always changed (at least time)