mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-17 10:55:32 +08:00
Use bitwise negation operator to invert integer pitch and bank angles
refs #790
This commit is contained in:
committed by
Klaus Basan
parent
5d7eff0797
commit
7f90652b2f
@@ -54,8 +54,8 @@ namespace BlackSimPlugin
|
|||||||
pbhstrct.pitch = newSituation.getPitch().value(CAngleUnit::deg()) * CFs9Sdk::pitchMultiplier();
|
pbhstrct.pitch = newSituation.getPitch().value(CAngleUnit::deg()) * CFs9Sdk::pitchMultiplier();
|
||||||
pbhstrct.bank = newSituation.getBank().value(CAngleUnit::deg()) * CFs9Sdk::bankMultiplier();
|
pbhstrct.bank = newSituation.getBank().value(CAngleUnit::deg()) * CFs9Sdk::bankMultiplier();
|
||||||
// MSFS has inverted pitch and bank angles
|
// MSFS has inverted pitch and bank angles
|
||||||
pbhstrct.pitch = -pbhstrct.pitch;
|
pbhstrct.pitch = ~pbhstrct.pitch;
|
||||||
pbhstrct.bank = -pbhstrct.bank;
|
pbhstrct.bank = ~pbhstrct.bank;
|
||||||
positionVelocity.pbh = pbhstrct.pbh;
|
positionVelocity.pbh = pbhstrct.pbh;
|
||||||
|
|
||||||
// Ground velocity
|
// Ground velocity
|
||||||
@@ -111,8 +111,8 @@ namespace BlackSimPlugin
|
|||||||
pbhstrct.pitch = situation.getPitch().value(CAngleUnit::deg()) * CFs9Sdk::pitchMultiplier();
|
pbhstrct.pitch = situation.getPitch().value(CAngleUnit::deg()) * CFs9Sdk::pitchMultiplier();
|
||||||
pbhstrct.bank = situation.getBank().value(CAngleUnit::deg()) * CFs9Sdk::bankMultiplier();
|
pbhstrct.bank = situation.getBank().value(CAngleUnit::deg()) * CFs9Sdk::bankMultiplier();
|
||||||
// MSFS has inverted pitch and bank angles
|
// MSFS has inverted pitch and bank angles
|
||||||
pbhstrct.pitch = -pbhstrct.pitch;
|
pbhstrct.pitch = ~pbhstrct.pitch;
|
||||||
pbhstrct.bank = -pbhstrct.bank;
|
pbhstrct.bank = ~pbhstrct.bank;
|
||||||
positionSlewMode.pbh = pbhstrct.pbh;
|
positionSlewMode.pbh = pbhstrct.pbh;
|
||||||
|
|
||||||
return positionSlewMode;
|
return positionSlewMode;
|
||||||
|
|||||||
@@ -78,17 +78,17 @@ namespace BlackSimPlugin
|
|||||||
|
|
||||||
FS_PBH pbhstrct;
|
FS_PBH pbhstrct;
|
||||||
pbhstrct.pbh = positionVelocity.pbh;
|
pbhstrct.pbh = positionVelocity.pbh;
|
||||||
double pitch = pbhstrct.pitch / CFs9Sdk::pitchMultiplier();
|
int pitch = pbhstrct.pitch / CFs9Sdk::pitchMultiplier();
|
||||||
if (pitch > 180.0)
|
if (pitch > 180.0)
|
||||||
pitch -= 360;
|
pitch -= 360;
|
||||||
|
|
||||||
double bank = pbhstrct.bank / CFs9Sdk::bankMultiplier();
|
int bank = pbhstrct.bank / CFs9Sdk::bankMultiplier();
|
||||||
if (bank > 180.0)
|
if (bank > 180.0)
|
||||||
bank -= 360;
|
bank -= 360;
|
||||||
|
|
||||||
// MSFS has inverted pitch and bank angles
|
// MSFS has inverted pitch and bank angles
|
||||||
pitch = -pitch;
|
pitch = ~pitch;
|
||||||
bank = -bank;
|
bank = ~bank;
|
||||||
situation.setPitch(CAngle(pitch, CAngleUnit::deg()));
|
situation.setPitch(CAngle(pitch, CAngleUnit::deg()));
|
||||||
situation.setBank(CAngle(bank, CAngleUnit::deg()));
|
situation.setBank(CAngle(bank, CAngleUnit::deg()));
|
||||||
situation.setHeading(CHeading(pbhstrct.hdg / CFs9Sdk::headingMultiplier(), CHeading::Magnetic, CAngleUnit::deg()));
|
situation.setHeading(CHeading(pbhstrct.hdg / CFs9Sdk::headingMultiplier(), CHeading::Magnetic, CAngleUnit::deg()));
|
||||||
|
|||||||
@@ -359,8 +359,8 @@ namespace BlackSimPlugin
|
|||||||
|
|
||||||
// speeds, situation
|
// speeds, situation
|
||||||
// MSFS has inverted pitch and bank angles
|
// MSFS has inverted pitch and bank angles
|
||||||
pitchRaw = -pitchRaw;
|
pitchRaw = ~pitchRaw;
|
||||||
bankRaw = -bankRaw;
|
bankRaw = ~bankRaw;
|
||||||
const double angleCorrectionFactor = 360.0 / 65536.0 / 65536.0; // see FSUIPC docu
|
const double angleCorrectionFactor = 360.0 / 65536.0 / 65536.0; // see FSUIPC docu
|
||||||
CAngle pitch = CAngle(pitchRaw * angleCorrectionFactor, CAngleUnit::deg());
|
CAngle pitch = CAngle(pitchRaw * angleCorrectionFactor, CAngleUnit::deg());
|
||||||
CAngle bank = CAngle(bankRaw * angleCorrectionFactor, CAngleUnit::deg());
|
CAngle bank = CAngle(bankRaw * angleCorrectionFactor, CAngleUnit::deg());
|
||||||
|
|||||||
Reference in New Issue
Block a user