mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-05-06 02:16:04 +08:00
Ref T260, regenerate interpolant if situations have been updated (normally with elevation)
This commit is contained in:
committed by
Roland Winklmeier
parent
1b8383bee1
commit
51f7b5aeb7
@@ -105,15 +105,27 @@ namespace BlackMisc
|
|||||||
Q_UNUSED(setup);
|
Q_UNUSED(setup);
|
||||||
|
|
||||||
// recalculate derivatives only if they changed
|
// recalculate derivatives only if they changed
|
||||||
|
bool recalculate = currentTimeMsSinceEpoc > m_nextSampleAdjustedTime; // new step
|
||||||
|
const qint64 lastModified = this->situationsLastModified(m_callsign);
|
||||||
|
if (!recalculate && (lastModified > m_situationsLastModifiedUsed) && this->isAnySituationNearGroundRelevant())
|
||||||
|
{
|
||||||
|
recalculate = this->areAnyElevationsMissing();
|
||||||
|
}
|
||||||
|
|
||||||
int situationsSize = -1;
|
int situationsSize = -1;
|
||||||
if (currentTimeMsSinceEpoc > m_nextSampleAdjustedTime)
|
if (recalculate)
|
||||||
{
|
{
|
||||||
// with the latest updates of T243 the order and the offsets are supposed to be correct
|
// with the latest updates of T243 the order and the offsets are supposed to be correct
|
||||||
// so even mixing fast/slow updates shall work
|
// so even mixing fast/slow updates shall work
|
||||||
const CAircraftSituationList validSituations = this->remoteAircraftSituations(m_callsign);
|
const CAircraftSituationList validSituations = this->remoteAircraftSituations(m_callsign);
|
||||||
situationsSize = validSituations.size();
|
situationsSize = validSituations.size();
|
||||||
Q_ASSERT_X(validSituations.isSortedAdjustedLatestFirst(), Q_FUNC_INFO, "Wrong sort order");
|
m_situationsLastModifiedUsed = lastModified;
|
||||||
Q_ASSERT_X(validSituations.size() <= IRemoteAircraftProvider::MaxSituationsPerCallsign, Q_FUNC_INFO, "Wrong size");
|
|
||||||
|
if (!CBuildConfig::isReleaseBuild())
|
||||||
|
{
|
||||||
|
Q_ASSERT_X(validSituations.isSortedAdjustedLatestFirst(), Q_FUNC_INFO, "Wrong sort order");
|
||||||
|
Q_ASSERT_X(validSituations.size() <= IRemoteAircraftProvider::MaxSituationsPerCallsign, Q_FUNC_INFO, "Wrong size");
|
||||||
|
}
|
||||||
|
|
||||||
// find the first situation earlier than the current time
|
// find the first situation earlier than the current time
|
||||||
const auto pivot = std::partition_point(validSituations.begin(), validSituations.end(), [ = ](auto &&s) { return s.getAdjustedMSecsSinceEpoch() > currentTimeMsSinceEpoc; });
|
const auto pivot = std::partition_point(validSituations.begin(), validSituations.end(), [ = ](auto &&s) { return s.getAdjustedMSecsSinceEpoch() > currentTimeMsSinceEpoc; });
|
||||||
@@ -126,9 +138,9 @@ namespace BlackMisc
|
|||||||
|
|
||||||
const std::array<std::array<double, 3>, 3> normals {{ m_s[0].getPosition().normalVectorDouble(), m_s[1].getPosition().normalVectorDouble(), m_s[2].getPosition().normalVectorDouble() }};
|
const std::array<std::array<double, 3>, 3> normals {{ m_s[0].getPosition().normalVectorDouble(), m_s[1].getPosition().normalVectorDouble(), m_s[2].getPosition().normalVectorDouble() }};
|
||||||
PosArray pa;
|
PosArray pa;
|
||||||
pa.x = {{ normals[0][0], normals[1][0], normals[2][0] }}; // oldest
|
pa.x = {{ normals[0][0], normals[1][0], normals[2][0] }}; // oldest -> latest
|
||||||
pa.y = {{ normals[0][1], normals[1][1], normals[2][1] }};
|
pa.y = {{ normals[0][1], normals[1][1], normals[2][1] }};
|
||||||
pa.z = {{ normals[0][2], normals[1][2], normals[2][2] }}; // latest
|
pa.z = {{ normals[0][2], normals[1][2], normals[2][2] }};
|
||||||
pa.t = {{ static_cast<double>(m_s[0].getAdjustedMSecsSinceEpoch()), static_cast<double>(m_s[1].getAdjustedMSecsSinceEpoch()), static_cast<double>(m_s[2].getAdjustedMSecsSinceEpoch()) }};
|
pa.t = {{ static_cast<double>(m_s[0].getAdjustedMSecsSinceEpoch()), static_cast<double>(m_s[1].getAdjustedMSecsSinceEpoch()), static_cast<double>(m_s[2].getAdjustedMSecsSinceEpoch()) }};
|
||||||
|
|
||||||
pa.dx = getDerivatives(pa.t, pa.x);
|
pa.dx = getDerivatives(pa.t, pa.x);
|
||||||
|
|||||||
Reference in New Issue
Block a user