mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-10 05:55:33 +08:00
Ref T180, CSimConnectObject improvements / added CSimConnectObject::getInterpolatedParts
This commit is contained in:
@@ -34,16 +34,32 @@ namespace BlackSimPlugin
|
||||
if (aircraft.getSituation().hasValidTimestamp()) { this->addAircraftSituation(aircraft.getSituation()); }
|
||||
}
|
||||
|
||||
CSimConnectObject::CSimConnectObject(const CAircraftSituation &situation) :
|
||||
m_interpolator(QSharedPointer<CInterpolatorMulti>::create(situation.getCallsign()))
|
||||
{
|
||||
if (situation.hasValidTimestamp()) { this->addAircraftSituation(situation); }
|
||||
}
|
||||
|
||||
CSimConnectObject::CSimConnectObject(const CAircraftParts &parts, const CCallsign &callsign) :
|
||||
m_interpolator(QSharedPointer<CInterpolatorMulti>::create(callsign))
|
||||
{
|
||||
if (parts.hasValidTimestamp()) { this->addAircraftParts(parts); }
|
||||
}
|
||||
|
||||
void CSimConnectObject::addAircraftParts(const CAircraftParts &parts)
|
||||
{
|
||||
Q_ASSERT(m_interpolator);
|
||||
Q_ASSERT(parts.hasValidTimestamp());
|
||||
m_interpolator->addAircraftParts(parts);
|
||||
m_aircraft.setParts(parts);
|
||||
}
|
||||
|
||||
void CSimConnectObject::addAircraftSituation(const CAircraftSituation &situation)
|
||||
{
|
||||
Q_ASSERT(m_interpolator);
|
||||
Q_ASSERT(situation.hasValidTimestamp());
|
||||
m_interpolator->addAircraftSituation(situation);
|
||||
m_aircraft.setSituation(situation); // update with last situation
|
||||
}
|
||||
|
||||
void CSimConnectObject::invalidatePartsAsSent()
|
||||
@@ -53,6 +69,12 @@ namespace BlackSimPlugin
|
||||
m_partsAsSent = dd;
|
||||
}
|
||||
|
||||
void CSimConnectObject::setObjectId(DWORD id)
|
||||
{
|
||||
m_objectId = id;
|
||||
m_validObjectId = true;
|
||||
}
|
||||
|
||||
bool CSimConnectObject::isPendingAdded() const
|
||||
{
|
||||
return !this->hasValidRequestAndObjectId() || !m_confirmedAdded;
|
||||
@@ -76,6 +98,20 @@ namespace BlackSimPlugin
|
||||
m_aircraft.setRendered(false);
|
||||
}
|
||||
|
||||
void CSimConnectObject::resetState()
|
||||
{
|
||||
m_pendingRemoved = false;
|
||||
m_confirmedAdded = false;
|
||||
m_currentLightsInSim = CAircraftLights();
|
||||
m_lightsAsSent = CAircraftLights();
|
||||
m_partsAsSent = DataDefinitionRemoteAircraftPartsWithoutLights {}; // init with 0s
|
||||
m_requestId = -1;
|
||||
m_objectId = -1;
|
||||
m_lightsRequestedAt = -1;
|
||||
m_validRequestId = false;
|
||||
m_validObjectId = false;
|
||||
}
|
||||
|
||||
bool CSimConnectObject::hasValidRequestAndObjectId() const
|
||||
{
|
||||
return this->hasValidRequestId() && this->hasValidObjectId();
|
||||
@@ -99,6 +135,12 @@ namespace BlackSimPlugin
|
||||
return m_interpolator->getInterpolatorInfo();
|
||||
}
|
||||
|
||||
void CSimConnectObject::attachInterpolatorLogger(CInterpolationLogger *logger)
|
||||
{
|
||||
Q_ASSERT(m_interpolator);
|
||||
return m_interpolator->attachLogger(logger);
|
||||
}
|
||||
|
||||
CAircraftSituation CSimConnectObject::getInterpolatedSituation(
|
||||
qint64 currentTimeSinceEpoc,
|
||||
const CInterpolationAndRenderingSetup &setup,
|
||||
@@ -108,6 +150,14 @@ namespace BlackSimPlugin
|
||||
return m_interpolator->getInterpolatedSituation(currentTimeSinceEpoc, setup, hints, status);
|
||||
}
|
||||
|
||||
CAircraftParts CSimConnectObject::getInterpolatedParts(
|
||||
qint64 currentTimeSinceEpoc, const CInterpolationAndRenderingSetup &setup,
|
||||
CPartsStatus &partsStatus, bool log) const
|
||||
{
|
||||
Q_ASSERT(m_interpolator);
|
||||
return m_interpolator->getInterpolatedParts(currentTimeSinceEpoc, setup, partsStatus, log);
|
||||
}
|
||||
|
||||
bool CSimConnectObjects::setSimConnectObjectIdForRequestId(DWORD requestId, DWORD objectId, bool resetSentParts)
|
||||
{
|
||||
// First check, if this request id belongs to us
|
||||
|
||||
@@ -33,6 +33,12 @@ namespace BlackSimPlugin
|
||||
DWORD requestId,
|
||||
BlackMisc::Simulation::CInterpolationLogger *logger);
|
||||
|
||||
//! Constructor providing initial situation
|
||||
CSimConnectObject(const BlackMisc::Aviation::CAircraftSituation &situation);
|
||||
|
||||
//! Constructor providing initial parts
|
||||
CSimConnectObject(const BlackMisc::Aviation::CAircraftParts &parts, const BlackMisc::Aviation::CCallsign &callsign);
|
||||
|
||||
//! Destructor
|
||||
~CSimConnectObject() {}
|
||||
|
||||
@@ -45,6 +51,9 @@ namespace BlackSimPlugin
|
||||
//! Simulated aircraft model string
|
||||
const QString &getAircraftModelString() const { return m_aircraft.getModelString(); }
|
||||
|
||||
//! Set the aircraft
|
||||
void setAircraft(const BlackMisc::Simulation::CSimulatedAircraft &aircraft) { m_aircraft = aircraft; }
|
||||
|
||||
//! Add parts for interpolator
|
||||
void addAircraftParts(const BlackMisc::Aviation::CAircraftParts &parts);
|
||||
|
||||
@@ -88,7 +97,7 @@ namespace BlackSimPlugin
|
||||
DWORD getRequestId() const { return m_requestId; }
|
||||
|
||||
//! Set Simconnect object id
|
||||
void setObjectId(DWORD id) { m_objectId = id; m_validObjectId = true; }
|
||||
void setObjectId(DWORD id);
|
||||
|
||||
//! Set Simconnect object id
|
||||
DWORD getObjectId() const { return m_objectId; }
|
||||
@@ -114,6 +123,9 @@ namespace BlackSimPlugin
|
||||
//! Marked as pending for removal
|
||||
void setPendingRemoved(bool pending);
|
||||
|
||||
//! Reset the state (like it was a new onject) without affecting interpolator and aircraft
|
||||
void resetState();
|
||||
|
||||
//! VTOL?
|
||||
bool isVtol() const { return m_aircraft.isVtol(); }
|
||||
|
||||
@@ -138,6 +150,12 @@ namespace BlackSimPlugin
|
||||
const BlackMisc::Simulation::CInterpolationAndRenderingSetup &setup,
|
||||
const BlackMisc::Simulation::CInterpolationHints &hints, BlackMisc::Simulation::CInterpolationStatus &status) const;
|
||||
|
||||
//! \copydoc BlackMisc::Simulation::CInterpolator::getInterpolatedParts
|
||||
BlackMisc::Aviation::CAircraftParts getInterpolatedParts(
|
||||
qint64 currentTimeSinceEpoc,
|
||||
const BlackMisc::Simulation::CInterpolationAndRenderingSetup &setup,
|
||||
BlackMisc::Simulation::CPartsStatus &partsStatus, bool log) const;
|
||||
|
||||
//! Interpolator
|
||||
BlackMisc::Simulation::CInterpolatorMulti *getInterpolator() const { return m_interpolator.data(); }
|
||||
|
||||
|
||||
@@ -1093,7 +1093,7 @@ namespace BlackSimPlugin
|
||||
const bool logInterpolationAndParts = callsignsToLog.contains(callsign);
|
||||
const CInterpolationAndRenderingSetup setup(this->getInterpolationAndRenderingSetup());
|
||||
CPartsStatus partsStatus(useAircraftParts);
|
||||
const CAircraftParts parts = useAircraftParts ? simObject.getInterpolator()->getInterpolatedParts(-1, setup, partsStatus, logInterpolationAndParts) : CAircraftParts();
|
||||
const CAircraftParts parts = useAircraftParts ? simObject.getInterpolatedParts(currentTimestamp, setup, partsStatus, logInterpolationAndParts) : CAircraftParts();
|
||||
|
||||
// get interpolated situation
|
||||
CInterpolationStatus interpolatorStatus;
|
||||
|
||||
Reference in New Issue
Block a user