mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-03 15:45:46 +08:00
Ref T270, interpolator optimization by passing aircraft number
Rational: Except for FS9 we interpolate all aircraft in one loop at the same time. This can cause that some steps are always done at the same time for all aircraft of that loop. By passing the number we can more equally distribute such tasks, avoiding peaks.
This commit is contained in:
@@ -421,6 +421,7 @@ namespace BlackSimPlugin
|
||||
void CSimulatorEmulated::fetchFromInterpolator()
|
||||
{
|
||||
const qint64 now = QDateTime::currentMSecsSinceEpoch();
|
||||
int aircraftNumber = 0;
|
||||
for (const CSimulatedAircraft &aircraft : m_renderedAircraft)
|
||||
{
|
||||
const CCallsign cs = aircraft.getCallsign();
|
||||
@@ -428,7 +429,7 @@ namespace BlackSimPlugin
|
||||
const CInterpolationAndRenderingSetupPerCallsign setup = this->getInterpolationSetupPerCallsignOrDefault(cs); // threadsafe copy
|
||||
CInterpolatorMulti *im = m_interpolators[cs];
|
||||
Q_ASSERT_X(im, Q_FUNC_INFO, "interpolator missing");
|
||||
CInterpolationResult result = im->getInterpolation(now, setup);
|
||||
const CInterpolationResult result = im->getInterpolation(now, setup, aircraftNumber++);
|
||||
const CAircraftSituation s = result;
|
||||
const CAircraftParts p = result;
|
||||
m_countInterpolatedParts++;
|
||||
|
||||
@@ -174,7 +174,7 @@ namespace BlackSimPlugin
|
||||
|
||||
if (m_clientStatus == Disconnected) { return; }
|
||||
const CInterpolationAndRenderingSetupPerCallsign setup = this->simulator()->getInterpolationSetupConsolidated(m_callsign);
|
||||
const CInterpolationResult result = m_interpolator.getInterpolation(QDateTime::currentMSecsSinceEpoch(), setup);
|
||||
const CInterpolationResult result = m_interpolator.getInterpolation(QDateTime::currentMSecsSinceEpoch(), setup, 0);
|
||||
|
||||
// Test only for successful position. FS9 requires constant positions
|
||||
if (!result.getInterpolationStatus().hasValidSituation()) { return; }
|
||||
|
||||
@@ -118,10 +118,10 @@ namespace BlackSimPlugin
|
||||
return m_interpolator->attachLogger(logger);
|
||||
}
|
||||
|
||||
CInterpolationResult CSimConnectObject::getInterpolation(qint64 currentTimeSinceEpoc, const CInterpolationAndRenderingSetupPerCallsign &setup) const
|
||||
CInterpolationResult CSimConnectObject::getInterpolation(qint64 currentTimeSinceEpoc, const CInterpolationAndRenderingSetupPerCallsign &setup, int aircraftNumber) const
|
||||
{
|
||||
if (!m_interpolator) { CInterpolationResult result; result.reset(); return result; }
|
||||
return m_interpolator->getInterpolation(currentTimeSinceEpoc, setup);
|
||||
return m_interpolator->getInterpolation(currentTimeSinceEpoc, setup, aircraftNumber);
|
||||
}
|
||||
|
||||
const CAircraftSituation &CSimConnectObject::getLastInterpolatedSituation(CInterpolationAndRenderingSetupBase::InterpolatorMode mode) const
|
||||
|
||||
@@ -167,7 +167,7 @@ namespace BlackSimPlugin
|
||||
void attachInterpolatorLogger(BlackMisc::Simulation::CInterpolationLogger *logger) const;
|
||||
|
||||
//! \copydoc BlackMisc::Simulation::CInterpolator::getInterpolation
|
||||
BlackMisc::Simulation::CInterpolationResult getInterpolation(qint64 currentTimeSinceEpoc, const BlackMisc::Simulation::CInterpolationAndRenderingSetupPerCallsign &setup) const;
|
||||
BlackMisc::Simulation::CInterpolationResult getInterpolation(qint64 currentTimeSinceEpoc, const BlackMisc::Simulation::CInterpolationAndRenderingSetupPerCallsign &setup, int aircraftNumber) const;
|
||||
|
||||
//! \copydoc BlackMisc::Simulation::CInterpolator::getLastInterpolatedSituation
|
||||
const BlackMisc::Aviation::CAircraftSituation &getLastInterpolatedSituation(BlackMisc::Simulation::CInterpolationAndRenderingSetupBase::InterpolatorMode mode) const;
|
||||
|
||||
@@ -1254,6 +1254,7 @@ namespace BlackSimPlugin
|
||||
// interpolation for all remote aircraft
|
||||
const QList<CSimConnectObject> simObjects(m_simConnectObjects.values());
|
||||
|
||||
int simObjectNumber = 0;
|
||||
for (const CSimConnectObject &simObject : simObjects)
|
||||
{
|
||||
// happening if aircraft is not yet added to simulator or to be deleted
|
||||
@@ -1270,7 +1271,7 @@ namespace BlackSimPlugin
|
||||
const bool sendGround = setup.isSendingGndFlagToSimulator();
|
||||
|
||||
// Interpolated situation
|
||||
const CInterpolationResult result = simObject.getInterpolation(currentTimestamp, setup);
|
||||
const CInterpolationResult result = simObject.getInterpolation(currentTimestamp, setup, simObjectNumber++);
|
||||
if (result.getInterpolationStatus().hasValidSituation())
|
||||
{
|
||||
// update situation
|
||||
|
||||
@@ -711,6 +711,7 @@ namespace BlackSimPlugin
|
||||
PlanesPositions planesPositions;
|
||||
PlanesSurfaces planesSurfaces;
|
||||
|
||||
int aircraftNumber = 0;
|
||||
for (const CXPlaneMPAircraft &xplaneAircraft : xplaneAircraftList)
|
||||
{
|
||||
const CCallsign callsign(xplaneAircraft.getCallsign());
|
||||
@@ -720,7 +721,7 @@ namespace BlackSimPlugin
|
||||
const CInterpolationAndRenderingSetupPerCallsign setup = this->getInterpolationSetupConsolidated(callsign);
|
||||
|
||||
// interpolated situation/parts
|
||||
const CInterpolationResult result = xplaneAircraft.getInterpolation(currentTimestamp, setup);
|
||||
const CInterpolationResult result = xplaneAircraft.getInterpolation(currentTimestamp, setup, aircraftNumber++);
|
||||
if (result.getInterpolationStatus().hasValidSituation())
|
||||
{
|
||||
const CAircraftSituation interpolatedSituation(result);
|
||||
@@ -767,7 +768,7 @@ namespace BlackSimPlugin
|
||||
|
||||
} // all callsigns
|
||||
|
||||
if (! planesPositions.isEmpty())
|
||||
if (!planesPositions.isEmpty())
|
||||
{
|
||||
m_trafficProxy->setPlanesPositions(planesPositions);
|
||||
}
|
||||
|
||||
@@ -48,10 +48,10 @@ namespace BlackSimPlugin
|
||||
return m_interpolator->attachLogger(logger);
|
||||
}
|
||||
|
||||
CInterpolationResult CXPlaneMPAircraft::getInterpolation(qint64 currentTimeSinceEpoc, const CInterpolationAndRenderingSetupPerCallsign &setup) const
|
||||
CInterpolationResult CXPlaneMPAircraft::getInterpolation(qint64 currentTimeSinceEpoc, const CInterpolationAndRenderingSetupPerCallsign &setup, int aircraftNumber) const
|
||||
{
|
||||
Q_ASSERT(m_interpolator);
|
||||
return m_interpolator->getInterpolation(currentTimeSinceEpoc, setup);
|
||||
return m_interpolator->getInterpolation(currentTimeSinceEpoc, setup, aircraftNumber);
|
||||
}
|
||||
|
||||
CCallsignSet CXPlaneMPAircraftObjects::getAllCallsigns() const
|
||||
|
||||
@@ -62,6 +62,7 @@ namespace BlackSimPlugin
|
||||
void setSituationAsSent(const BlackMisc::Aviation::CAircraftSituation &position) { m_situationAsSent = position; }
|
||||
|
||||
//! Same as sent
|
||||
//! \deprecated KB T273
|
||||
bool isSameAsSent(const BlackMisc::Aviation::CAircraftSituation &position) const;
|
||||
|
||||
//! VTOL?
|
||||
@@ -77,7 +78,7 @@ namespace BlackSimPlugin
|
||||
void attachInterpolatorLogger(BlackMisc::Simulation::CInterpolationLogger *logger) const;
|
||||
|
||||
//! \copydoc BlackMisc::Simulation::CInterpolator::getInterpolation
|
||||
BlackMisc::Simulation::CInterpolationResult getInterpolation(qint64 currentTimeSinceEpoc, const BlackMisc::Simulation::CInterpolationAndRenderingSetupPerCallsign &setup) const;
|
||||
BlackMisc::Simulation::CInterpolationResult getInterpolation(qint64 currentTimeSinceEpoc, const BlackMisc::Simulation::CInterpolationAndRenderingSetupPerCallsign &setup, int aircraftNumber) const;
|
||||
|
||||
//! Interpolator
|
||||
BlackMisc::Simulation::CInterpolatorMulti *getInterpolator() const { return m_interpolator.data(); }
|
||||
|
||||
Reference in New Issue
Block a user