mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-01 13:36:48 +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.bank = newSituation.getBank().value(CAngleUnit::deg()) * CFs9Sdk::bankMultiplier();
|
||||
// MSFS has inverted pitch and bank angles
|
||||
pbhstrct.pitch = -pbhstrct.pitch;
|
||||
pbhstrct.bank = -pbhstrct.bank;
|
||||
pbhstrct.pitch = ~pbhstrct.pitch;
|
||||
pbhstrct.bank = ~pbhstrct.bank;
|
||||
positionVelocity.pbh = pbhstrct.pbh;
|
||||
|
||||
// Ground velocity
|
||||
@@ -111,8 +111,8 @@ namespace BlackSimPlugin
|
||||
pbhstrct.pitch = situation.getPitch().value(CAngleUnit::deg()) * CFs9Sdk::pitchMultiplier();
|
||||
pbhstrct.bank = situation.getBank().value(CAngleUnit::deg()) * CFs9Sdk::bankMultiplier();
|
||||
// MSFS has inverted pitch and bank angles
|
||||
pbhstrct.pitch = -pbhstrct.pitch;
|
||||
pbhstrct.bank = -pbhstrct.bank;
|
||||
pbhstrct.pitch = ~pbhstrct.pitch;
|
||||
pbhstrct.bank = ~pbhstrct.bank;
|
||||
positionSlewMode.pbh = pbhstrct.pbh;
|
||||
|
||||
return positionSlewMode;
|
||||
|
||||
@@ -78,17 +78,17 @@ namespace BlackSimPlugin
|
||||
|
||||
FS_PBH pbhstrct;
|
||||
pbhstrct.pbh = positionVelocity.pbh;
|
||||
double pitch = pbhstrct.pitch / CFs9Sdk::pitchMultiplier();
|
||||
int pitch = pbhstrct.pitch / CFs9Sdk::pitchMultiplier();
|
||||
if (pitch > 180.0)
|
||||
pitch -= 360;
|
||||
|
||||
double bank = pbhstrct.bank / CFs9Sdk::bankMultiplier();
|
||||
int bank = pbhstrct.bank / CFs9Sdk::bankMultiplier();
|
||||
if (bank > 180.0)
|
||||
bank -= 360;
|
||||
|
||||
// MSFS has inverted pitch and bank angles
|
||||
pitch = -pitch;
|
||||
bank = -bank;
|
||||
pitch = ~pitch;
|
||||
bank = ~bank;
|
||||
situation.setPitch(CAngle(pitch, CAngleUnit::deg()));
|
||||
situation.setBank(CAngle(bank, CAngleUnit::deg()));
|
||||
situation.setHeading(CHeading(pbhstrct.hdg / CFs9Sdk::headingMultiplier(), CHeading::Magnetic, CAngleUnit::deg()));
|
||||
|
||||
@@ -359,8 +359,8 @@ namespace BlackSimPlugin
|
||||
|
||||
// speeds, situation
|
||||
// MSFS has inverted pitch and bank angles
|
||||
pitchRaw = -pitchRaw;
|
||||
bankRaw = -bankRaw;
|
||||
pitchRaw = ~pitchRaw;
|
||||
bankRaw = ~bankRaw;
|
||||
const double angleCorrectionFactor = 360.0 / 65536.0 / 65536.0; // see FSUIPC docu
|
||||
CAngle pitch = CAngle(pitchRaw * angleCorrectionFactor, CAngleUnit::deg());
|
||||
CAngle bank = CAngle(bankRaw * angleCorrectionFactor, CAngleUnit::deg());
|
||||
|
||||
Reference in New Issue
Block a user