mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-20 04:25:42 +08:00
refs #840, add support for interpolation hints
This commit is contained in:
committed by
Mathew Sutcliffe
parent
534b9fb09e
commit
46fafde7a0
@@ -30,7 +30,7 @@ namespace BlackMisc
|
||||
//! Properties by index
|
||||
enum ColumnIndex
|
||||
{
|
||||
IndexInterpolatorDebugMessages = BlackMisc::CPropertyIndex::GloablIndexInterpolatorSetup,
|
||||
IndexInterpolatorDebugMessages = BlackMisc::CPropertyIndex::GlobalIndexCInterpolatioRenderingSetup,
|
||||
IndexSimulatorDebugMessages,
|
||||
IndexForceFullInterpolation,
|
||||
IndexMaxRenderedAircraft,
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
|
||||
#include "interpolator.h"
|
||||
#include "blackmisc/aviation/callsign.h"
|
||||
#include "blackmisc/simulation/interpolationhints.h"
|
||||
|
||||
using namespace BlackMisc::Aviation;
|
||||
using namespace BlackMisc::Simulation;
|
||||
@@ -24,14 +25,14 @@ namespace BlackMisc
|
||||
}
|
||||
|
||||
BlackMisc::Aviation::CAircraftSituation IInterpolator::getInterpolatedSituation(const CCallsign &callsign, qint64 currentTimeSinceEpoc,
|
||||
bool isVtolAircraft, InterpolationStatus &status) const
|
||||
const CInterpolationHints &hints, InterpolationStatus &status) const
|
||||
{
|
||||
// has to be thread safe
|
||||
|
||||
status.reset();
|
||||
Q_ASSERT_X(!callsign.isEmpty(), Q_FUNC_INFO, "empty callsign");
|
||||
|
||||
auto currentSituation = this->getInterpolatedSituation(this->remoteAircraftSituations(callsign), currentTimeSinceEpoc, isVtolAircraft, status);
|
||||
auto currentSituation = this->getInterpolatedSituation(this->remoteAircraftSituations(callsign), currentTimeSinceEpoc, hints, status);
|
||||
currentSituation.setCallsign(callsign); // make sure callsign is correct
|
||||
return currentSituation;
|
||||
}
|
||||
@@ -67,6 +68,14 @@ namespace BlackMisc
|
||||
return m_setup;
|
||||
}
|
||||
|
||||
void IInterpolator::setGroundElevationFromHint(const CInterpolationHints &hints, CAircraftSituation &situation)
|
||||
{
|
||||
if (hints.getElevation().isNull()) return;
|
||||
if (situation.hasGroundElevation()) return;
|
||||
if (!hints.isWithinRange(situation)) return;
|
||||
situation.setGroundElevation(hints.getElevation().geodeticHeight());
|
||||
}
|
||||
|
||||
bool IInterpolator::InterpolationStatus::allTrue() const
|
||||
{
|
||||
return m_interpolationSucceeded && m_changedPosition;
|
||||
|
||||
@@ -25,6 +25,7 @@
|
||||
namespace BlackMisc
|
||||
{
|
||||
namespace Aviation { class CCallsign; }
|
||||
namespace Simulation { class CInterpolationHints; }
|
||||
|
||||
//! Interpolator, calculation inbetween positions
|
||||
class BLACKMISC_EXPORT IInterpolator :
|
||||
@@ -91,14 +92,14 @@ namespace BlackMisc
|
||||
//! \threadsafe
|
||||
virtual BlackMisc::Aviation::CAircraftSituation getInterpolatedSituation(
|
||||
const BlackMisc::Aviation::CCallsign &callsign, qint64 currentTimeSinceEpoc,
|
||||
bool isVtolAircraft, InterpolationStatus &status) const;
|
||||
const CInterpolationHints &hints, InterpolationStatus &status) const;
|
||||
|
||||
//! Current interpolated situation, to be implemented by subclass
|
||||
//! \threadsafe
|
||||
//! \remark public only for XP driver
|
||||
virtual BlackMisc::Aviation::CAircraftSituation getInterpolatedSituation(
|
||||
const BlackMisc::Aviation::CAircraftSituationList &situations, qint64 currentTimeSinceEpoc,
|
||||
bool isVtolAircraft, InterpolationStatus &status) const = 0;
|
||||
const CInterpolationHints &hints, InterpolationStatus &status) const = 0;
|
||||
|
||||
//! Parts before given offset time (aka pending parts)
|
||||
//! \threadsafe
|
||||
@@ -124,6 +125,9 @@ namespace BlackMisc
|
||||
//! \threadsafe
|
||||
CInterpolationAndRenderingSetup getInterpolatorSetup() const;
|
||||
|
||||
//! Set the ground elevation from hints, if possible and not already set
|
||||
static void setGroundElevationFromHint(const CInterpolationHints &hints, BlackMisc::Aviation::CAircraftSituation &situation);
|
||||
|
||||
CInterpolationAndRenderingSetup m_setup; //!< allows to disable debug messages
|
||||
mutable QReadWriteLock m_lock; //!< lock interpolator
|
||||
};
|
||||
|
||||
@@ -19,6 +19,7 @@
|
||||
#include "blackmisc/pq/physicalquantity.h"
|
||||
#include "blackmisc/pq/speed.h"
|
||||
#include "blackmisc/pq/units.h"
|
||||
#include "blackmisc/simulation/interpolationhints.h"
|
||||
#include "blackmisc/logmessage.h"
|
||||
#include "blackmisc/compare.h"
|
||||
#include "blackmisc/range.h"
|
||||
@@ -37,7 +38,7 @@ using namespace BlackMisc::Simulation;
|
||||
|
||||
namespace BlackMisc
|
||||
{
|
||||
CAircraftSituation CInterpolatorLinear::getInterpolatedSituation(const BlackMisc::Aviation::CAircraftSituationList &situations, qint64 currentTimeMsSinceEpoc, bool vtolAiracraft, InterpolationStatus &status) const
|
||||
CAircraftSituation CInterpolatorLinear::getInterpolatedSituation(const CAircraftSituationList &situations, qint64 currentTimeMsSinceEpoc, const CInterpolationHints &hints, InterpolationStatus &status) const
|
||||
{
|
||||
// has to be thread safe
|
||||
const CInterpolationAndRenderingSetup setup = this->getInterpolatorSetup();
|
||||
@@ -94,6 +95,13 @@ namespace BlackMisc
|
||||
Q_ASSERT(oldSituation.getAdjustedMSecsSinceEpoch() < newSituation.getAdjustedMSecsSinceEpoch());
|
||||
}
|
||||
|
||||
// take hint into account to calculate elevation and above ground level
|
||||
if (!hints.getElevation().isNull())
|
||||
{
|
||||
setGroundElevationFromHint(hints, oldSituation);
|
||||
setGroundElevationFromHint(hints, newSituation);
|
||||
}
|
||||
|
||||
CAircraftSituation currentSituation(oldSituation);
|
||||
CCoordinateGeodetic currentPosition;
|
||||
|
||||
@@ -125,15 +133,15 @@ namespace BlackMisc
|
||||
currentSituation.setPosition(currentPosition);
|
||||
|
||||
// Interpolate altitude: Alt = (AltB - AltA) * t + AltA
|
||||
const CAltitude oldAlt(oldSituation.getAltitude());
|
||||
const CAltitude newAlt(newSituation.getAltitude());
|
||||
const CAltitude oldAlt(oldSituation.getCorrectedAltitude(hints.getCGAboveGround()));
|
||||
const CAltitude newAlt(newSituation.getCorrectedAltitude(hints.getCGAboveGround()));
|
||||
Q_ASSERT_X(oldAlt.getReferenceDatum() == newAlt.getReferenceDatum(), Q_FUNC_INFO, "mismatch in reference"); // otherwise no calculation is possible
|
||||
currentSituation.setAltitude(CAltitude((newAlt - oldAlt)
|
||||
* simulationTimeFraction
|
||||
+ oldAlt,
|
||||
oldAlt.getReferenceDatum()));
|
||||
|
||||
if (!setup.isForcingFullInterpolation() && !vtolAiracraft && newVec == oldVec && oldAlt == newAlt)
|
||||
if (!setup.isForcingFullInterpolation() && !hints.isVtolAircraft() && newVec == oldVec && oldAlt == newAlt)
|
||||
{
|
||||
// stop interpolation here, does not work for VTOL aircraft. We need a flag for VTOL aircraft
|
||||
return currentSituation;
|
||||
|
||||
@@ -38,7 +38,7 @@ namespace BlackMisc
|
||||
using IInterpolator::getInterpolatedSituation;
|
||||
|
||||
//! \copydoc IInterpolator::getInterpolatedSituation
|
||||
virtual BlackMisc::Aviation::CAircraftSituation getInterpolatedSituation(const BlackMisc::Aviation::CAircraftSituationList &situations, qint64 currentTimeSinceEpoc, bool vtolAiracraft, InterpolationStatus &status) const override;
|
||||
virtual BlackMisc::Aviation::CAircraftSituation getInterpolatedSituation(const BlackMisc::Aviation::CAircraftSituationList &situations, qint64 currentTimeSinceEpoc, const BlackMisc::Simulation::CInterpolationHints &hints, InterpolationStatus &status) const override;
|
||||
|
||||
//! Log category
|
||||
static QString getLogCategory() { return "swift.interpolatorlinear"; }
|
||||
|
||||
@@ -109,6 +109,7 @@ namespace BlackMisc
|
||||
GlobalIndexICoordinateGeodetic = 5000,
|
||||
GlobalIndexICoordinateWithRelativePosition = 5100,
|
||||
GlobalIndexCCoordinateGeodetic = 5200,
|
||||
GlobalIndexCElevationPlane = 5300,
|
||||
GlobalIndexCClient = 6000,
|
||||
GlobalIndexClientCapabilities = 6100, //!< used with map key
|
||||
GlobalIndexCUser = 6200,
|
||||
@@ -142,7 +143,8 @@ namespace BlackMisc
|
||||
GlobalIndexCSettingsReaders = 14400,
|
||||
GlobalIndexCViewUpdateSettings = 14500,
|
||||
GlobalIndexCGeneralGuiSettings = 14600,
|
||||
GloablIndexInterpolatorSetup = 15000,
|
||||
GlobalIndexCInterpolatioRenderingSetup = 15000,
|
||||
GlobalIndexCInterpolationHints = 15100,
|
||||
GlobalIndexLineNumber = 20000, //!< pseudo index for line numbers
|
||||
};
|
||||
|
||||
|
||||
@@ -21,7 +21,6 @@
|
||||
#include "blackmisc/iconlist.h"
|
||||
#include "blackmisc/identifier.h"
|
||||
#include "blackmisc/identifierlist.h"
|
||||
#include "blackmisc/interpolationrenderingsetup.h"
|
||||
#include "blackmisc/input/registermetadatainput.h"
|
||||
#include "blackmisc/logcategory.h"
|
||||
#include "blackmisc/logcategorylist.h"
|
||||
@@ -89,7 +88,6 @@ namespace BlackMisc
|
||||
CVariant::registerMetadata();
|
||||
CVariantList::registerMetadata();
|
||||
CVariantMap::registerMetadata();
|
||||
CInterpolationAndRenderingSetup::registerMetadata();
|
||||
|
||||
// sub namespaces
|
||||
Audio::registerMetadata();
|
||||
|
||||
@@ -9,10 +9,6 @@
|
||||
|
||||
#include "registermetadatasimulation.h"
|
||||
#include "simulation.h"
|
||||
#include "blackmisc/simulation/simulatorsettings.h"
|
||||
#include "blackmisc/simulation/modelsettings.h"
|
||||
#include "blackmisc/valueobject.h"
|
||||
#include "blackmisc/variant.h"
|
||||
|
||||
using namespace BlackMisc::Simulation;
|
||||
using namespace BlackMisc::Simulation::Fsx;
|
||||
@@ -32,19 +28,21 @@ namespace BlackMisc
|
||||
CDistributor::registerMetadata();
|
||||
CDistributorList::registerMetadata();
|
||||
CDistributorListPreferences::registerMetadata();
|
||||
CInterpolationAndRenderingSetup::registerMetadata();
|
||||
CInterpolationHints::registerMetadata();
|
||||
CModelSettings::registerMetadata();
|
||||
CSimConnectUtilities::registerMetadata();
|
||||
CSimulatedAircraft::registerMetadata();
|
||||
CSimulatedAircraftList::registerMetadata();
|
||||
CSimulatorInfo::registerMetadata();
|
||||
CSimulatorInfoList::registerMetadata();
|
||||
CSimulatorInternals::registerMetadata();
|
||||
CSimulatorMessagesSettings::registerMetadata();
|
||||
CSimulatorPluginInfo::registerMetadata();
|
||||
CSimulatorPluginInfoList::registerMetadata();
|
||||
CSimulatorInternals::registerMetadata();
|
||||
CSimulatorSettings::registerMetadata();
|
||||
CVPilotModelRule::registerMetadata();
|
||||
CVPilotModelRuleSet::registerMetadata();
|
||||
CSimulatorSettings::registerMetadata();
|
||||
CModelSettings::registerMetadata();
|
||||
CSimulatorMessagesSettings::registerMetadata();
|
||||
}
|
||||
} // ns
|
||||
} // ns
|
||||
|
||||
Reference in New Issue
Block a user