From: durk Date: Wed, 10 Dec 2008 16:04:10 +0000 (+0000) Subject: Minimize impact of distant AI models on the scene graph. X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=1fdac74f8e60e2c6edcbd69d16e07e68a3bdb520;p=flightgear.git Minimize impact of distant AI models on the scene graph. --- 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);