mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-28 11:45:40 +08:00
refs #916, interpolator mode for XP
This commit is contained in:
committed by
Mathew Sutcliffe
parent
e2849f171e
commit
304c552872
@@ -223,7 +223,6 @@ namespace XBus
|
||||
if (id)
|
||||
{
|
||||
auto plane = new Plane(id, callsign, aircraftIcao, airlineIcao, livery);
|
||||
plane->interpolator.setMode(m_interpolatorMode);
|
||||
m_planesByCallsign[callsign] = plane;
|
||||
m_planesById[id] = plane;
|
||||
}
|
||||
@@ -315,6 +314,20 @@ namespace XBus
|
||||
}
|
||||
}
|
||||
|
||||
void CTraffic::setInterpolatorMode(const QString &callsign, bool spline)
|
||||
{
|
||||
const auto plane = m_planesByCallsign.value(callsign, nullptr);
|
||||
if (plane)
|
||||
{
|
||||
plane->interpolator.setMode(spline ? BlackMisc::Simulation::CInterpolatorMulti::ModeSpline
|
||||
: BlackMisc::Simulation::CInterpolatorMulti::ModeLinear);
|
||||
}
|
||||
else if (callsign.isEmpty())
|
||||
{
|
||||
for (const auto &callsign : m_planesByCallsign.keys()) { setInterpolatorMode(callsign, spline); }
|
||||
}
|
||||
}
|
||||
|
||||
//! memcmp function which ignores the header ("size" member) and compares only the payload (the rest of the struct)
|
||||
template <typename T>
|
||||
int memcmpPayload(T *dst, T *src)
|
||||
@@ -391,19 +404,6 @@ namespace XBus
|
||||
}
|
||||
}
|
||||
|
||||
void CTraffic::toggleInterpolatorMode()
|
||||
{
|
||||
switch (m_interpolatorMode)
|
||||
{
|
||||
case BlackMisc::Simulation::CInterpolatorMulti::ModeLinear: m_interpolatorMode = BlackMisc::Simulation::CInterpolatorMulti::ModeSpline; break;
|
||||
case BlackMisc::Simulation::CInterpolatorMulti::ModeSpline: m_interpolatorMode = BlackMisc::Simulation::CInterpolatorMulti::ModeLinear; break;
|
||||
}
|
||||
for (auto plane : m_planesByCallsign)
|
||||
{
|
||||
plane->interpolator.setMode(m_interpolatorMode);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
//! \endcond
|
||||
|
||||
@@ -14,7 +14,6 @@
|
||||
|
||||
#include "datarefs.h"
|
||||
#include "terrainprobe.h"
|
||||
#include "command.h"
|
||||
#include "blackmisc/aviation/aircraftsituationlist.h"
|
||||
#include "blackmisc/aviation/aircraftpartslist.h"
|
||||
#include "blackmisc/simulation/interpolatormulti.h"
|
||||
@@ -115,6 +114,9 @@ namespace XBus
|
||||
//! Set the transponder of a traffic aircraft
|
||||
void setPlaneTransponder(const QString &callsign, int code, bool modeC, bool ident);
|
||||
|
||||
//! Set interpolation mode for a traffic aircraft
|
||||
void setInterpolatorMode(const QString &callsign, bool spline);
|
||||
|
||||
private:
|
||||
bool m_initialized = false;
|
||||
bool m_enabled = false;
|
||||
@@ -141,9 +143,6 @@ namespace XBus
|
||||
};
|
||||
QHash<QString, Plane *> m_planesByCallsign;
|
||||
QHash<void *, Plane *> m_planesById;
|
||||
BlackMisc::Simulation::CInterpolatorMulti::Mode m_interpolatorMode = BlackMisc::Simulation::CInterpolatorMulti::ModeSpline;
|
||||
CCommand m_interpolatorModeCommand { "org/swift-project/xbus/toggle_lerp_mode", "Toggle interpolation mode", [this] { toggleInterpolatorMode(); } };
|
||||
void toggleInterpolatorMode();
|
||||
|
||||
int getPlaneData(void *id, int dataType, void *io_data);
|
||||
static int getPlaneData(void *id, int dataType, void *io_data, void *self)
|
||||
|
||||
Reference in New Issue
Block a user