mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-20 04:25:42 +08:00
When dealing with pitch and bank as signed ints, it is desirable to
round down, rather than toward zero, to get a linear distribution. refs #790
This commit is contained in:
committed by
Klaus Basan
parent
f4d7474941
commit
b5dfd15d66
@@ -51,8 +51,8 @@ namespace BlackSimPlugin
|
|||||||
// Pitch, Bank and Heading
|
// Pitch, Bank and Heading
|
||||||
FS_PBH pbhstrct;
|
FS_PBH pbhstrct;
|
||||||
pbhstrct.hdg = newSituation.getHeading().value(CAngleUnit::deg()) * CFs9Sdk::headingMultiplier();
|
pbhstrct.hdg = newSituation.getHeading().value(CAngleUnit::deg()) * CFs9Sdk::headingMultiplier();
|
||||||
pbhstrct.pitch = newSituation.getPitch().value(CAngleUnit::deg()) * CFs9Sdk::pitchMultiplier();
|
pbhstrct.pitch = std::floor(newSituation.getPitch().value(CAngleUnit::deg()) * CFs9Sdk::pitchMultiplier());
|
||||||
pbhstrct.bank = newSituation.getBank().value(CAngleUnit::deg()) * CFs9Sdk::bankMultiplier();
|
pbhstrct.bank = std::floor(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;
|
||||||
@@ -108,8 +108,8 @@ namespace BlackSimPlugin
|
|||||||
// Pitch, Bank and Heading
|
// Pitch, Bank and Heading
|
||||||
FS_PBH pbhstrct;
|
FS_PBH pbhstrct;
|
||||||
pbhstrct.hdg = situation.getHeading().value(CAngleUnit::deg()) * CFs9Sdk::headingMultiplier();
|
pbhstrct.hdg = situation.getHeading().value(CAngleUnit::deg()) * CFs9Sdk::headingMultiplier();
|
||||||
pbhstrct.pitch = situation.getPitch().value(CAngleUnit::deg()) * CFs9Sdk::pitchMultiplier();
|
pbhstrct.pitch = std::floor(situation.getPitch().value(CAngleUnit::deg()) * CFs9Sdk::pitchMultiplier());
|
||||||
pbhstrct.bank = situation.getBank().value(CAngleUnit::deg()) * CFs9Sdk::bankMultiplier();
|
pbhstrct.bank = std::floor(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;
|
||||||
|
|||||||
@@ -78,9 +78,9 @@ namespace BlackSimPlugin
|
|||||||
|
|
||||||
FS_PBH pbhstrct;
|
FS_PBH pbhstrct;
|
||||||
pbhstrct.pbh = positionVelocity.pbh;
|
pbhstrct.pbh = positionVelocity.pbh;
|
||||||
int pitch = pbhstrct.pitch / CFs9Sdk::pitchMultiplier();
|
int pitch = std::floor(pbhstrct.pitch / CFs9Sdk::pitchMultiplier());
|
||||||
if (pitch < -90 || pitch > 89) { CLogMessage(nullptr).warning("FS9: Pitch value out of limits: %1") << pitch; }
|
if (pitch < -90 || pitch > 89) { CLogMessage(nullptr).warning("FS9: Pitch value out of limits: %1") << pitch; }
|
||||||
int bank = pbhstrct.bank / CFs9Sdk::bankMultiplier();
|
int bank = std::floor(pbhstrct.bank / CFs9Sdk::bankMultiplier());
|
||||||
|
|
||||||
// MSFS has inverted pitch and bank angles
|
// MSFS has inverted pitch and bank angles
|
||||||
pitch = ~pitch;
|
pitch = ~pitch;
|
||||||
|
|||||||
@@ -358,8 +358,8 @@ namespace BlackSimPlugin
|
|||||||
situation.setPosition(position);
|
situation.setPosition(position);
|
||||||
|
|
||||||
const double angleCorrectionFactor = 360.0 / 65536.0 / 65536.0; // see FSUIPC docu
|
const double angleCorrectionFactor = 360.0 / 65536.0 / 65536.0; // see FSUIPC docu
|
||||||
pitchRaw *= angleCorrectionFactor;
|
pitchRaw = std::floor(pitchRaw * angleCorrectionFactor);
|
||||||
bankRaw *= angleCorrectionFactor;
|
bankRaw = std::floor(bankRaw * angleCorrectionFactor);
|
||||||
|
|
||||||
// MSFS has inverted pitch and bank angles
|
// MSFS has inverted pitch and bank angles
|
||||||
pitchRaw = ~pitchRaw;
|
pitchRaw = ~pitchRaw;
|
||||||
|
|||||||
Reference in New Issue
Block a user