From 085f25fa86c42ae4db0214c5048afa9be9f3319e Mon Sep 17 00:00:00 2001 From: Klaus Basan Date: Sat, 28 Jan 2017 19:59:27 +0100 Subject: [PATCH] refs #865, FSX: changed how elevation/CG is updated --- src/blackmisc/simulation/interpolationhints.h | 3 +++ src/plugins/simulator/fsx/simulatorfsx.cpp | 25 +++++++++---------- 2 files changed, 15 insertions(+), 13 deletions(-) diff --git a/src/blackmisc/simulation/interpolationhints.h b/src/blackmisc/simulation/interpolationhints.h index de1e54ae3..f89f4a9ba 100644 --- a/src/blackmisc/simulation/interpolationhints.h +++ b/src/blackmisc/simulation/interpolationhints.h @@ -59,6 +59,9 @@ namespace BlackMisc //! Get CG above ground const BlackMisc::PhysicalQuantities::CLength &getCGAboveGround() const { return m_cgAboveGround;} + //! Has CG above ground + bool hasCGAboveGround() const { return m_cgAboveGround.isNull(); } + //! Set CG above ground void setCGAboveGround(const BlackMisc::PhysicalQuantities::CLength &cgAboveGround) { m_cgAboveGround = cgAboveGround; } diff --git a/src/plugins/simulator/fsx/simulatorfsx.cpp b/src/plugins/simulator/fsx/simulatorfsx.cpp index 77406540b..1ffd3ba3e 100644 --- a/src/plugins/simulator/fsx/simulatorfsx.cpp +++ b/src/plugins/simulator/fsx/simulatorfsx.cpp @@ -484,20 +484,9 @@ namespace BlackSimPlugin void CSimulatorFsx::updateRemoteAircraftFromSimulator(const CSimConnectObject &simObject, const DataDefinitionRemoteAircraftSimData &remoteAircraftData) { - CInterpolationHints &hints = m_hints[simObject.getCallsign()]; - - // we only need elevation near ground, in other cases we ignore it + // Near ground we use faster updates if (remoteAircraftData.aboveGround() <= 100.0) { - CElevationPlane elevation(remoteAircraftData.latitude, remoteAircraftData.longitude, remoteAircraftData.elevation); - elevation.setSinglePointRadius(); - - // const QString debug(hints.debugInfo(elevation)); - hints.setElevation(elevation); // update elevation - hints.setCGAboveGround({ remoteAircraftData.cgToGround, CLengthUnit::ft() }); - - // set it in the remote aircraft provider - this->updateAircraftGroundElevation(simObject.getCallsign(), elevation); // switch to fast updates if (simObject.getSimDataPeriod() != SIMCONNECT_PERIOD_VISUAL_FRAME) { @@ -506,13 +495,23 @@ namespace BlackSimPlugin } else { - hints.resetElevation(); // switch to slow updates if (simObject.getSimDataPeriod() != SIMCONNECT_PERIOD_SECOND) { this->requestDataForSimObject(simObject, SIMCONNECT_PERIOD_SECOND); } } + + CElevationPlane elevation(remoteAircraftData.latitude, remoteAircraftData.longitude, remoteAircraftData.elevation); + elevation.setSinglePointRadius(); + + // const QString debug(hints.debugInfo(elevation)); + CInterpolationHints &hints = m_hints[simObject.getCallsign()]; + hints.setElevation(elevation); // update elevation + hints.setCGAboveGround({ remoteAircraftData.cgToGround, CLengthUnit::ft() }); // normally never changing, but if user changes ModelMatching + + // set it in the remote aircraft provider + this->updateAircraftGroundElevation(simObject.getCallsign(), elevation); } void CSimulatorFsx::updateOwnAircraftFromSimulator(const DataDefinitionClientAreaSb &sbDataArea)