Ref T185 Enable spline interpolation with only one position update,

by just copying it three times, so planes can be rendered without waiting for more updates.
This commit is contained in:
Mathew Sutcliffe
2017-11-08 21:32:14 +00:00
parent 2f54e00d65
commit e0d9fb9df1
7 changed files with 35 additions and 0 deletions

View File

@@ -22,5 +22,9 @@ namespace BlackMisc
CSequence<CAircraftParts>(other)
{ }
CAircraftPartsList::CAircraftPartsList(std::initializer_list<CAircraftParts> il) :
CSequence<CAircraftParts>(il)
{ }
} // namespace
} // namespace

View File

@@ -39,6 +39,9 @@ namespace BlackMisc
//! Construct from a base class object.
CAircraftPartsList(const CSequence<CAircraftParts> &other);
//! Construct from initializer list.
CAircraftPartsList(std::initializer_list<CAircraftParts> il);
};
} //namespace

View File

@@ -27,5 +27,9 @@ namespace BlackMisc
CSequence<CAircraftSituation>(other)
{ }
CAircraftSituationList::CAircraftSituationList(std::initializer_list<CAircraftSituation> il) :
CSequence<CAircraftSituation>(il)
{ }
} // namespace
} // namespace

View File

@@ -45,6 +45,8 @@ namespace BlackMisc
//! Construct from a base class object.
CAircraftSituationList(const CSequence<CAircraftSituation> &other);
//! Construct from initializer list.
CAircraftSituationList(std::initializer_list<CAircraftSituation> il);
};
} // namespace
} // namespace

View File

@@ -265,12 +265,26 @@ namespace BlackMisc
template <typename Derived>
void CInterpolator<Derived>::addAircraftSituation(const CAircraftSituation &situation)
{
if (m_aircraftSituations.isEmpty())
{
// make sure we have enough situations to do start interpolating immediately without waiting for more updates
m_aircraftSituations = { situation, situation };
m_aircraftSituations.back().addMsecs(-10000); // number here does
m_aircraftSituations.front().addMsecs(-5000); // not really matter
}
m_aircraftSituations.push_frontMaxElements(situation, IRemoteAircraftProvider::MaxSituationsPerCallsign);
}
template <typename Derived>
void CInterpolator<Derived>::addAircraftParts(const CAircraftParts &parts)
{
if (m_aircraftParts.isEmpty())
{
// make sure we have enough parts to do start interpolating immediately without waiting for more updates
m_aircraftParts = { parts, parts };
m_aircraftParts.back().addMsecs(-10000); // number here does
m_aircraftParts.front().addMsecs(-5000); // not really matter
}
m_aircraftParts.push_front(parts);
IRemoteAircraftProvider::removeOutdatedParts(m_aircraftParts);

View File

@@ -137,6 +137,11 @@ namespace BlackMisc
this->m_timestampMSecsSinceEpoch = QDateTime::currentMSecsSinceEpoch();
}
void ITimestampBased::addMsecs(qint64 ms)
{
this->m_timestampMSecsSinceEpoch += ms;
}
QString ITimestampBased::getFormattedUtcTimestampDhms() const
{
return this->hasValidTimestamp() ?

View File

@@ -86,6 +86,9 @@ namespace BlackMisc
//! Set the current time as timestamp
void setCurrentUtcTime();
//! Add the given number of milliseconds to the timestamp.
void addMsecs(qint64 ms);
//! Formatted timestamp
QString getFormattedUtcTimestampDhms() const;