mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-03-31 21:15:33 +08:00
refs #332 send slew mode position packet instead of the full one
This bypasses the physics engine inside FS9
This commit is contained in:
@@ -136,6 +136,35 @@ namespace BlackSimPlugin
|
||||
return positionVelocity;
|
||||
}
|
||||
|
||||
MPPositionSlewMode aircraftSituationtoFS9(const CAircraftSituation &situation)
|
||||
{
|
||||
MPPositionSlewMode positionSlewMode;
|
||||
|
||||
// Latitude - integer and decimal places
|
||||
double latitude = situation.getPosition().latitude().value(CAngleUnit::deg()) * 10001750.0 / 90.0;
|
||||
positionSlewMode.lat_i = static_cast<qint32>(latitude);
|
||||
positionSlewMode.lat_f = qAbs((latitude - positionSlewMode.lat_i) * 65536);
|
||||
|
||||
// Longitude - integer and decimal places
|
||||
double longitude = situation.getPosition().longitude().value(CAngleUnit::deg()) * ( 65536.0 * 65536.0) / 360.0;
|
||||
positionSlewMode.lon_hi = static_cast<qint32>(longitude);
|
||||
positionSlewMode.lon_lo = qAbs((longitude - positionSlewMode.lon_hi) * 65536);
|
||||
|
||||
// Altitude - integer and decimal places
|
||||
double altitude = situation.getAltitude().value(CLengthUnit::m());
|
||||
positionSlewMode.alt_i = static_cast<qint32>(altitude);
|
||||
positionSlewMode.alt_f = (altitude - positionSlewMode.alt_i) * 65536;
|
||||
|
||||
// Pitch, Bank and Heading
|
||||
FS_PBH pbhstrct;
|
||||
pbhstrct.hdg = situation.getHeading().value(CAngleUnit::deg()) * CFs9Sdk::headingMultiplier();
|
||||
pbhstrct.pitch = situation.getPitch().value(CAngleUnit::deg()) * CFs9Sdk::pitchMultiplier();
|
||||
pbhstrct.bank = situation.getBank().value(CAngleUnit::deg()) * CFs9Sdk::bankMultiplier();
|
||||
positionSlewMode.pbh = pbhstrct.pbh;
|
||||
|
||||
return positionSlewMode;
|
||||
}
|
||||
|
||||
HRESULT printDirectPlayError(HRESULT error)
|
||||
{
|
||||
switch(error)
|
||||
|
||||
@@ -55,6 +55,10 @@ namespace BlackSimPlugin
|
||||
const BlackMisc::Aviation::CAircraftSituation &newSituation,
|
||||
double updateInterval);
|
||||
|
||||
//! Convert an aircraft situation to a FS9 struct
|
||||
MPPositionSlewMode aircraftSituationtoFS9(const BlackMisc::Aviation::CAircraftSituation &situation);
|
||||
|
||||
|
||||
HRESULT printDirectPlayError(HRESULT error);
|
||||
|
||||
|
||||
|
||||
@@ -97,16 +97,14 @@ namespace BlackSimPlugin
|
||||
if (m_interpolator.hasEnoughAircraftSituations())
|
||||
{
|
||||
CAircraftSituation situation = m_interpolator.getCurrentSituation();
|
||||
MPPositionVelocity positionVelocity = aircraftSituationtoFS9(m_lastAircraftSituation,
|
||||
situation,
|
||||
m_updateInterval.value(CTimeUnit::s()));
|
||||
MPPositionSlewMode positionSlewMode = aircraftSituationtoFS9(situation);
|
||||
|
||||
QByteArray positionMessage;
|
||||
MultiPlayerPacketParser::writeType(positionMessage, CFs9Sdk::MULTIPLAYER_PACKET_ID_POSITION_VELOCITY);
|
||||
MultiPlayerPacketParser::writeSize(positionMessage, positionVelocity.size());
|
||||
positionVelocity.packet_index = m_packetIndex;
|
||||
MultiPlayerPacketParser::writeType(positionMessage, CFs9Sdk::MULTIPLAYER_PACKET_ID_POSITION_SLEWMODE);
|
||||
MultiPlayerPacketParser::writeSize(positionMessage, positionSlewMode.size());
|
||||
positionSlewMode.packet_index = m_packetIndex;
|
||||
++m_packetIndex;
|
||||
positionMessage = MultiPlayerPacketParser::writeMessage(positionMessage, positionVelocity);
|
||||
positionMessage = MultiPlayerPacketParser::writeMessage(positionMessage, positionSlewMode);
|
||||
|
||||
sendMessage(positionMessage);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user