diff --git a/src/AIModel/AIAircraft.cxx b/src/AIModel/AIAircraft.cxx index d66eaa3ea..1ed6f7572 100644 --- a/src/AIModel/AIAircraft.cxx +++ b/src/AIModel/AIAircraft.cxx @@ -159,8 +159,28 @@ void FGAIAircraft::setPerformance(const std::string& acclass) { updateSecondaryTargetValues(); // target roll, vertical speed, pitch updateActualState(); UpdateRadar(manager); + checkVisibility(); } +void FGAIAircraft::checkVisibility() +{ + double visibility_meters = fgGetDouble("/environment/visibility-m"); + + FGViewer* vw = globals->get_current_view(); + double course, distance; + + SGWayPoint current(pos.getLongitudeDeg(), pos.getLatitudeDeg(), 0); + SGWayPoint view (vw->getLongitude_deg(), vw->getLatitude_deg(), 0); + view.CourseAndDistance(current, &course, &distance); + if (distance > visibility_meters) { + //aip.getSGLocation()->set_cur_elev_m(aptElev); + //return; + invisible = true; + } else { + invisible = false; + } +} + void FGAIAircraft::AccelTo(double speed) { diff --git a/src/AIModel/AIAircraft.hxx b/src/AIModel/AIAircraft.hxx index a179c9d7f..e391c6a45 100644 --- a/src/AIModel/AIAircraft.hxx +++ b/src/AIModel/AIAircraft.hxx @@ -126,6 +126,7 @@ private: void updatePitchAngleTarget(); void updateActualState(); void handleATCRequests(); + void checkVisibility(); double sign(double x);