mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-02 23:25:53 +08:00
Ref T261, further unify interpolator handling
* return interpolation results parts/situation in one step * base class init for each interpolation step, less redundant code * removed old interpolation/parts function * adjusted unit tests and simulator objects (such as SimObject)
This commit is contained in:
committed by
Roland Winklmeier
parent
bac3d14d50
commit
0808cdb223
@@ -112,37 +112,16 @@ namespace BlackSimPlugin
|
||||
return m_interpolator->getInterpolatorInfo(mode);
|
||||
}
|
||||
|
||||
void CSimConnectObject::attachInterpolatorLogger(CInterpolationLogger *logger)
|
||||
void CSimConnectObject::attachInterpolatorLogger(CInterpolationLogger *logger) const
|
||||
{
|
||||
Q_ASSERT(m_interpolator);
|
||||
return m_interpolator->attachLogger(logger);
|
||||
}
|
||||
|
||||
CAircraftSituation CSimConnectObject::getInterpolatedSituation(
|
||||
qint64 currentTimeSinceEpoc,
|
||||
const CInterpolationAndRenderingSetupPerCallsign &setup,
|
||||
CInterpolationStatus &status) const
|
||||
CInterpolationResult CSimConnectObject::getInterpolation(qint64 currentTimeSinceEpoc, const CInterpolationAndRenderingSetupPerCallsign &setup) const
|
||||
{
|
||||
Q_ASSERT(m_interpolator);
|
||||
return m_interpolator->getInterpolatedSituation(currentTimeSinceEpoc, setup, status);
|
||||
}
|
||||
|
||||
CAircraftParts CSimConnectObject::getInterpolatedParts(
|
||||
qint64 currentTimeSinceEpoc,
|
||||
const CInterpolationAndRenderingSetupPerCallsign &setup,
|
||||
CPartsStatus &partsStatus, bool log) const
|
||||
{
|
||||
Q_ASSERT(m_interpolator);
|
||||
return m_interpolator->getInterpolatedParts(currentTimeSinceEpoc, setup, partsStatus, log);
|
||||
}
|
||||
|
||||
CAircraftParts CSimConnectObject::getInterpolatedOrGuessedParts(
|
||||
qint64 currentTimeSinceEpoc,
|
||||
const CInterpolationAndRenderingSetupPerCallsign &setup,
|
||||
CPartsStatus &partsStatus, bool log) const
|
||||
{
|
||||
Q_ASSERT(m_interpolator);
|
||||
return m_interpolator->getInterpolatedOrGuessedParts(currentTimeSinceEpoc, setup, partsStatus, log);
|
||||
if (!m_interpolator) { CInterpolationResult result; result.reset(); return result; }
|
||||
return m_interpolator->getInterpolation(currentTimeSinceEpoc, setup);
|
||||
}
|
||||
|
||||
const CAircraftSituation &CSimConnectObject::getLastInterpolatedSituation(CInterpolationAndRenderingSetupBase::InterpolatorMode mode) const
|
||||
|
||||
@@ -160,34 +160,16 @@ namespace BlackSimPlugin
|
||||
//! Was the object really added to simulator
|
||||
bool hasValidRequestAndObjectId() const;
|
||||
|
||||
//! \copydoc BlackMisc::Simulation::CInterpolatorMulti::toggleMode
|
||||
void toggleInterpolatorMode();
|
||||
|
||||
//! \copydoc BlackMisc::Simulation::CInterpolator::getInterpolatorInfo
|
||||
QString getInterpolatorInfo(BlackMisc::Simulation::CInterpolationAndRenderingSetupBase::InterpolatorMode mode) const;
|
||||
|
||||
//! \copydoc BlackMisc::Simulation::CInterpolator::attachLogger
|
||||
void attachInterpolatorLogger(BlackMisc::Simulation::CInterpolationLogger *logger);
|
||||
void attachInterpolatorLogger(BlackMisc::Simulation::CInterpolationLogger *logger) const;
|
||||
|
||||
//! \copydoc BlackMisc::Simulation::CInterpolator::getInterpolatedSituation
|
||||
BlackMisc::Aviation::CAircraftSituation getInterpolatedSituation(
|
||||
qint64 currentTimeSinceEpoc,
|
||||
const BlackMisc::Simulation::CInterpolationAndRenderingSetupPerCallsign &setup,
|
||||
BlackMisc::Simulation::CInterpolationStatus &status) const;
|
||||
//! \copydoc BlackMisc::Simulation::CInterpolator::getInterpolation
|
||||
BlackMisc::Simulation::CInterpolationResult getInterpolation(qint64 currentTimeSinceEpoc, const BlackMisc::Simulation::CInterpolationAndRenderingSetupPerCallsign &setup) const;
|
||||
|
||||
//! \copydoc BlackMisc::Simulation::CInterpolator::getInterpolatedParts
|
||||
BlackMisc::Aviation::CAircraftParts getInterpolatedParts(
|
||||
qint64 currentTimeSinceEpoc,
|
||||
const BlackMisc::Simulation::CInterpolationAndRenderingSetupPerCallsign &setup,
|
||||
BlackMisc::Simulation::CPartsStatus &partsStatus, bool log) const;
|
||||
|
||||
//! \copydoc BlackMisc::Simulation::CInterpolator::getInterpolatedOrGuessedParts
|
||||
BlackMisc::Aviation::CAircraftParts getInterpolatedOrGuessedParts(
|
||||
qint64 currentTimeSinceEpoc,
|
||||
const BlackMisc::Simulation::CInterpolationAndRenderingSetupPerCallsign &setup,
|
||||
BlackMisc::Simulation::CPartsStatus &partsStatus, bool log) const;
|
||||
|
||||
//! Last interpolated situation
|
||||
//! \copydoc BlackMisc::Simulation::CInterpolator::getLastInterpolatedSituation
|
||||
const BlackMisc::Aviation::CAircraftSituation &getLastInterpolatedSituation(BlackMisc::Simulation::CInterpolationAndRenderingSetupBase::InterpolatorMode mode) const;
|
||||
|
||||
//! Interpolator
|
||||
|
||||
@@ -1260,17 +1260,14 @@ namespace BlackSimPlugin
|
||||
|
||||
// setup
|
||||
const CInterpolationAndRenderingSetupPerCallsign setup = this->getInterpolationSetupConsolidated(callsign);
|
||||
const bool logInterpolationAndParts = setup.logInterpolation();
|
||||
const bool sendGround = setup.sendGndFlagToSimulator();
|
||||
|
||||
// Interpolated situation
|
||||
CInterpolationStatus interpolatorStatus;
|
||||
const CAircraftSituation interpolatedSituation = simObject.getInterpolatedSituation(currentTimestamp, setup, interpolatorStatus);
|
||||
|
||||
if (interpolatorStatus.hasValidSituation())
|
||||
const CInterpolationResult result = simObject.getInterpolation(currentTimestamp, setup);
|
||||
if (result.getInterpolationStatus().hasValidSituation())
|
||||
{
|
||||
// update situation
|
||||
SIMCONNECT_DATA_INITPOSITION position = this->aircraftSituationToFsxPosition(interpolatedSituation, sendGround);
|
||||
SIMCONNECT_DATA_INITPOSITION position = this->aircraftSituationToFsxPosition(result, sendGround);
|
||||
if (!simObject.isSameAsSent(position))
|
||||
{
|
||||
m_simConnectObjects[simObject.getCallsign()].setPositionAsSent(position);
|
||||
@@ -1290,13 +1287,11 @@ namespace BlackSimPlugin
|
||||
else
|
||||
{
|
||||
static const QString so("SimObject id: %1");
|
||||
CLogMessage(this).warning(this->getInvalidSituationLogMessage(callsign, interpolatorStatus, so.arg(simObject.getObjectId())));
|
||||
CLogMessage(this).warning(this->getInvalidSituationLogMessage(callsign, result.getInterpolationStatus(), so.arg(simObject.getObjectId())));
|
||||
}
|
||||
|
||||
// Interpolated parts
|
||||
CPartsStatus partsStatus;
|
||||
const CAircraftParts parts = simObject.getInterpolatedOrGuessedParts(currentTimestamp, setup, partsStatus, logInterpolationAndParts);
|
||||
this->updateRemoteAircraftParts(simObject, parts, partsStatus);
|
||||
this->updateRemoteAircraftParts(simObject, result);
|
||||
|
||||
} // all callsigns
|
||||
|
||||
@@ -1306,10 +1301,12 @@ namespace BlackSimPlugin
|
||||
m_statsUpdateAircraftTimeAvgMs = m_statsUpdateAircraftTimeTotalMs / m_statsUpdateAircraftCountMs;
|
||||
}
|
||||
|
||||
bool CSimulatorFsxCommon::updateRemoteAircraftParts(const CSimConnectObject &simObject, const CAircraftParts &parts, const CPartsStatus &partsStatus)
|
||||
bool CSimulatorFsxCommon::updateRemoteAircraftParts(const CSimConnectObject &simObject, const CInterpolationResult &result)
|
||||
{
|
||||
if (!simObject.hasValidRequestAndObjectId()) { return false; }
|
||||
if (parts.getPartsDetails() != CAircraftParts::GuessedParts && !partsStatus.isSupportingParts()) { return false; }
|
||||
|
||||
const CAircraftParts parts = result;
|
||||
if (parts.getPartsDetails() != CAircraftParts::GuessedParts && !result.getPartsStatus().isSupportingParts()) { return false; }
|
||||
|
||||
DataDefinitionRemoteAircraftPartsWithoutLights ddRemoteAircraftPartsWithoutLights(parts); // no init, all values will be set
|
||||
return this->sendRemoteAircraftPartsToSimulator(simObject, ddRemoteAircraftPartsWithoutLights, parts.getAdjustedLights());
|
||||
|
||||
@@ -272,8 +272,7 @@ namespace BlackSimPlugin
|
||||
void updateRemoteAircraft();
|
||||
|
||||
//! Update remote aircraft parts (send to FSX)
|
||||
bool updateRemoteAircraftParts(const CSimConnectObject &simObject,
|
||||
const BlackMisc::Aviation::CAircraftParts &parts, const BlackMisc::Simulation::CPartsStatus &partsStatus);
|
||||
bool updateRemoteAircraftParts(const CSimConnectObject &simObject, const BlackMisc::Simulation::CInterpolationResult &result);
|
||||
|
||||
//! Send parts to simulator
|
||||
bool sendRemoteAircraftPartsToSimulator(const CSimConnectObject &simObject, DataDefinitionRemoteAircraftPartsWithoutLights &ddRemoteAircraftParts, const BlackMisc::Aviation::CAircraftLights &lights);
|
||||
|
||||
Reference in New Issue
Block a user