mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-21 04:45:31 +08:00
Add experimental X-Plane CG offset fetching
ref T231
This commit is contained in:
committed by
Klaus Basan
parent
72497fdefc
commit
09de945242
@@ -1024,7 +1024,10 @@ namespace BlackSimPlugin
|
|||||||
|
|
||||||
CInterpolationHints &hints = m_hints[callsign];
|
CInterpolationHints &hints = m_hints[callsign];
|
||||||
hints.setElevationPlane(elevation); // update elevation
|
hints.setElevationPlane(elevation); // update elevation
|
||||||
hints.setCGAboveGround({ modelVerticalOffset, CLengthUnit::ft() }); // normally never changing, but if user changes ModelMatching update possible
|
// The entire vertical offset (CG offset) is still very experimental in X-Plane. Libxplanemp simply calculates the lowest Y
|
||||||
|
// value from all the OpenGL model vertices. I assume its in meters.
|
||||||
|
// The unit of modelVerticalOffset is still very unknown. This needs to be confirmed.
|
||||||
|
hints.setCGAboveGround({ modelVerticalOffset, CLengthUnit::m() });
|
||||||
|
|
||||||
// set it in the remote aircraft provider
|
// set it in the remote aircraft provider
|
||||||
this->updateAircraftGroundElevation(callsign, elevation);
|
this->updateAircraftGroundElevation(callsign, elevation);
|
||||||
|
|||||||
@@ -18,6 +18,7 @@
|
|||||||
#include "blackmisc/simulation/interpolationhints.h"
|
#include "blackmisc/simulation/interpolationhints.h"
|
||||||
#include "blackmisc/aviation/callsign.h"
|
#include "blackmisc/aviation/callsign.h"
|
||||||
#include "XPMPMultiplayer.h"
|
#include "XPMPMultiplayer.h"
|
||||||
|
#include "XPMPPlaneRenderer.h"
|
||||||
#include <XPLM/XPLMProcessing.h>
|
#include <XPLM/XPLMProcessing.h>
|
||||||
#include <XPLM/XPLMUtilities.h>
|
#include <XPLM/XPLMUtilities.h>
|
||||||
#include <QDateTime>
|
#include <QDateTime>
|
||||||
@@ -31,8 +32,10 @@
|
|||||||
namespace XSwiftBus
|
namespace XSwiftBus
|
||||||
{
|
{
|
||||||
|
|
||||||
CTraffic::Plane::Plane(void *id_, QString callsign_, QString aircraftIcao_, QString airlineIcao_, QString livery_)
|
CTraffic::Plane::Plane(void *id_, QString callsign_, QString aircraftIcao_, QString airlineIcao_, QString livery_, QString modelName_)
|
||||||
: id(id_), callsign(callsign_), aircraftIcao(aircraftIcao_), airlineIcao(airlineIcao_), livery(livery_), interpolator(callsign)
|
: id(id_), callsign(callsign_), aircraftIcao(aircraftIcao_), airlineIcao(airlineIcao_), livery(livery_), modelName(modelName_),
|
||||||
|
interpolator(callsign)
|
||||||
|
|
||||||
{
|
{
|
||||||
std::memset(static_cast<void *>(&surfaces), 0, sizeof(surfaces));
|
std::memset(static_cast<void *>(&surfaces), 0, sizeof(surfaces));
|
||||||
surfaces.lights.bcnLights = surfaces.lights.landLights = surfaces.lights.navLights = surfaces.lights.strbLights = 1;
|
surfaces.lights.bcnLights = surfaces.lights.landLights = surfaces.lights.navLights = surfaces.lights.strbLights = 1;
|
||||||
@@ -225,7 +228,7 @@ namespace XSwiftBus
|
|||||||
|
|
||||||
if (id)
|
if (id)
|
||||||
{
|
{
|
||||||
auto plane = new Plane(id, callsign, aircraftIcao, airlineIcao, livery);
|
auto plane = new Plane(id, callsign, aircraftIcao, airlineIcao, livery, modelName);
|
||||||
m_planesByCallsign[callsign] = plane;
|
m_planesByCallsign[callsign] = plane;
|
||||||
m_planesById[id] = plane;
|
m_planesById[id] = plane;
|
||||||
}
|
}
|
||||||
@@ -391,7 +394,8 @@ namespace XSwiftBus
|
|||||||
double elevation = plane->position.elevation;
|
double elevation = plane->position.elevation;
|
||||||
double groundElevation = plane->terrainProbe.getElevation(lat, lon, elevation);
|
double groundElevation = plane->terrainProbe.getElevation(lat, lon, elevation);
|
||||||
if (std::isnan(groundElevation)) { groundElevation = 0.0; }
|
if (std::isnan(groundElevation)) { groundElevation = 0.0; }
|
||||||
constexpr double fudgeFactor = 3.0; //! \fixme Value should be different for each plane, derived from the CSL model geometry
|
double fudgeFactor = 3.0;
|
||||||
|
actualVertOffsetInfo(qPrintable(plane->modelName), nullptr, &fudgeFactor);
|
||||||
emit remoteAircraftData(plane->callsign, lat, lon, groundElevation, fudgeFactor);
|
emit remoteAircraftData(plane->callsign, lat, lon, groundElevation, fudgeFactor);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -148,6 +148,7 @@ namespace XSwiftBus
|
|||||||
QString aircraftIcao;
|
QString aircraftIcao;
|
||||||
QString airlineIcao;
|
QString airlineIcao;
|
||||||
QString livery;
|
QString livery;
|
||||||
|
QString modelName;
|
||||||
bool hasSurfaces = false;
|
bool hasSurfaces = false;
|
||||||
bool hasXpdr = false;
|
bool hasXpdr = false;
|
||||||
char label[32] {};
|
char label[32] {};
|
||||||
@@ -160,7 +161,7 @@ namespace XSwiftBus
|
|||||||
qint64 prevSurfacesLerpTime = 0;
|
qint64 prevSurfacesLerpTime = 0;
|
||||||
XPMPPlaneRadar_t xpdr;
|
XPMPPlaneRadar_t xpdr;
|
||||||
XPMPPlanePosition_t position;
|
XPMPPlanePosition_t position;
|
||||||
Plane(void *id_, QString callsign_, QString aircraftIcao_, QString airlineIcao_, QString livery_);
|
Plane(void *id_, QString callsign_, QString aircraftIcao_, QString airlineIcao_, QString livery_, QString modelName_);
|
||||||
};
|
};
|
||||||
QHash<QString, Plane *> m_planesByCallsign;
|
QHash<QString, Plane *> m_planesByCallsign;
|
||||||
QHash<void *, Plane *> m_planesById;
|
QHash<void *, Plane *> m_planesById;
|
||||||
|
|||||||
Reference in New Issue
Block a user