Unverified Commit 0dd33ee8 authored by Don Gagne's avatar Don Gagne Committed by GitHub

Merge pull request #6668 from DonLakeFlyer/TerrainCollision

Rework terrain collision display to prevent false positives
parents 2dfdda3e 83afdda9
......@@ -1459,10 +1459,16 @@ void MissionController::_recalcMissionFlightStatus()
if (altRange == 0.0) {
item->setAltPercent(0.0);
item->setTerrainPercent(qQNaN());
item->setTerrainCollision(false);
} else {
item->setAltPercent((absoluteAltitude - minAltSeen) / altRange);
if (!qIsNaN(item->terrainAltitude())) {
item->setTerrainPercent((item->terrainAltitude() - minAltSeen) / altRange);
double terrainAltitude = item->terrainAltitude();
if (qIsNaN(terrainAltitude)) {
item->setTerrainPercent(qQNaN());
item->setTerrainCollision(false);
} else {
item->setTerrainPercent((terrainAltitude - minAltSeen) / altRange);
item->setTerrainCollision(absoluteAltitude < terrainAltitude);
}
}
}
......
......@@ -32,6 +32,7 @@ VisualMissionItem::VisualMissionItem(Vehicle* vehicle, bool flyView, QObject* pa
, _altDifference (0.0)
, _altPercent (0.0)
, _terrainPercent (qQNaN())
, _terrainCollision (false)
, _azimuth (0.0)
, _distance (0.0)
, _missionGimbalYaw (qQNaN())
......@@ -52,6 +53,7 @@ VisualMissionItem::VisualMissionItem(const VisualMissionItem& other, bool flyVie
, _altDifference (0.0)
, _altPercent (0.0)
, _terrainPercent (qQNaN())
, _terrainCollision (false)
, _azimuth (0.0)
, _distance (0.0)
{
......@@ -133,6 +135,14 @@ void VisualMissionItem::setTerrainPercent(double terrainPercent)
}
}
void VisualMissionItem::setTerrainCollision(bool terrainCollision)
{
if (terrainCollision != _terrainCollision) {
_terrainCollision = terrainCollision;
emit terrainCollisionChanged(terrainCollision);
}
}
void VisualMissionItem::setAzimuth(double azimuth)
{
if (!qFuzzyCompare(_azimuth, azimuth)) {
......
......@@ -73,6 +73,7 @@ public:
Q_PROPERTY(double altDifference READ altDifference WRITE setAltDifference NOTIFY altDifferenceChanged) ///< Change in altitude from previous waypoint
Q_PROPERTY(double altPercent READ altPercent WRITE setAltPercent NOTIFY altPercentChanged) ///< Percent of total altitude change in mission altitude
Q_PROPERTY(double terrainPercent READ terrainPercent WRITE setTerrainPercent NOTIFY terrainPercentChanged) ///< Percent of terrain altitude in mission altitude
Q_PROPERTY(bool terrainCollision READ terrainCollision WRITE setTerrainCollision NOTIFY terrainCollisionChanged) ///< true: Item collides with terrain
Q_PROPERTY(double azimuth READ azimuth WRITE setAzimuth NOTIFY azimuthChanged) ///< Azimuth to previous waypoint
Q_PROPERTY(double distance READ distance WRITE setDistance NOTIFY distanceChanged) ///< Distance to previous waypoint
......@@ -84,6 +85,7 @@ public:
double altDifference (void) const { return _altDifference; }
double altPercent (void) const { return _altPercent; }
double terrainPercent (void) const { return _terrainPercent; }
bool terrainCollision (void) const { return _terrainCollision; }
double azimuth (void) const { return _azimuth; }
double distance (void) const { return _distance; }
bool isCurrentItem (void) const { return _isCurrentItem; }
......@@ -96,6 +98,7 @@ public:
void setAltDifference (double altDifference);
void setAltPercent (double altPercent);
void setTerrainPercent (double terrainPercent);
void setTerrainCollision(bool terrainCollision);
void setAzimuth (double azimuth);
void setDistance (double distance);
......@@ -166,6 +169,7 @@ signals:
void altDifferenceChanged (double altDifference);
void altPercentChanged (double altPercent);
void terrainPercentChanged (double terrainPercent);
void terrainCollisionChanged (double terrainCollision);
void azimuthChanged (double azimuth);
void commandDescriptionChanged (void);
void commandNameChanged (void);
......@@ -203,6 +207,7 @@ protected:
double _altDifference; ///< Difference in altitude from previous waypoint
double _altPercent; ///< Percent of total altitude change in mission
double _terrainPercent; ///< Percent of terrain altitude for coordinate
bool _terrainCollision; ///< true: item collides with terrain
double _azimuth; ///< Azimuth to previous waypoint
double _distance; ///< Distance to previous waypoint
QString _editorQml; ///< Qml resource for editing item
......
......@@ -85,7 +85,7 @@ Rectangle {
anchors.horizontalCenter: parent.horizontalCenter
width: indicator.width
height: _terrainAvailable ? Math.max(availableHeight * _terrainPercent, 1) : parent.height
color: _terrainAvailable ? (_terrainPercent > object.altPercent ? "red": qgcPal.text) : "yellow"
color: _terrainAvailable ? (object.terrainCollision ? "red": qgcPal.text) : "yellow"
visible: _coordValid
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment