mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-03-22 14:55:36 +08:00
Ref T709, check position for "follow aircraft"
This commit is contained in:
committed by
Mat Sutcliffe
parent
f9c87326fb
commit
01f90fc9bf
@@ -917,11 +917,16 @@ namespace XSwiftBus
|
||||
}
|
||||
else
|
||||
{
|
||||
auto planeIt = traffic->m_planesByCallsign.find(traffic->m_followPlaneViewCallsign);
|
||||
const auto planeIt = traffic->m_planesByCallsign.find(traffic->m_followPlaneViewCallsign);
|
||||
if (planeIt == traffic->m_planesByCallsign.end()) { return 0; }
|
||||
Plane *plane = planeIt->second;
|
||||
const Plane *plane = planeIt->second;
|
||||
|
||||
XPLMWorldToLocal(plane->position.lat, plane->position.lon, plane->position.elevation * kFtToMeters, &lx, &ly, &lz);
|
||||
if (!isValidPosition(plane->position))
|
||||
{
|
||||
INFO_LOG("Invalid follow aircraft position for " + plane->callsign);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
// Fill out the camera position info.
|
||||
@@ -969,6 +974,17 @@ namespace XSwiftBus
|
||||
* Returning 0 would consume the keystroke. */
|
||||
return 1;
|
||||
}
|
||||
|
||||
bool CTraffic::isValidPosition(const XPMPPlanePosition_t &position)
|
||||
{
|
||||
if (position.lat > 180.001 || position.lat < -180.001) { return false; }
|
||||
if (position.lon > 180.001 || position.lon < -180.001) { return false; }
|
||||
if (position.pitch > 180.001f || position.pitch < -180.001f) { return false; }
|
||||
if (position.heading > 180.001f || position.heading < -180.001f) { return false; }
|
||||
if (position.elevation < -2000.0 || position.elevation > 100000.0) { return false; }
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
//! \endcond
|
||||
|
||||
@@ -187,6 +187,9 @@ namespace XSwiftBus
|
||||
const std::string &livery_, const std::string &modelName_);
|
||||
};
|
||||
|
||||
//! Check the position if values are valid
|
||||
static bool isValidPosition(const XPMPPlanePosition_t &position);
|
||||
|
||||
std::unordered_map<std::string, Plane *> m_planesByCallsign;
|
||||
std::unordered_map<void *, Plane *> m_planesById;
|
||||
std::vector<std::string> m_followPlaneViewSequence;
|
||||
|
||||
Reference in New Issue
Block a user