}
-bool FGAIAircraft::aiTrafficVisible() {
- SGGeod userPos(SGGeod::fromDeg(fgGetDouble("/position/longitude-deg"),
- fgGetDouble("/position/latitude-deg")));
-
- return (SGGeodesy::distanceNm(userPos, pos) <= TRAFFICTOAIDISTTODIE);
+bool FGAIAircraft::aiTrafficVisible()
+{
+ SGVec3d cartPos = SGVec3d::fromGeod(pos);
+ const double d2 = (TRAFFICTOAIDISTTODIE * SG_NM_TO_METER) *
+ (TRAFFICTOAIDISTTODIE * SG_NM_TO_METER);
+ return (distSqr(cartPos, globals->get_aircraft_positon_cart()) < d2);
}
throw sg_exception("Can't get aircraft position", "FGGlobals::get_aircraft_position()" );
}
+const SGVec3d&
+FGGlobals::get_aircraft_positon_cart() const
+{
+ return SGVec3d::fromGeod(get_aircraft_position());
+}
// Save the current state as the initial state.
const SGGeod & get_aircraft_position() const;
+ const SGVec3d& get_aircraft_positon_cart() const;
+
inline FGModelMgr *get_model_mgr () { return model_mgr; }
inline void set_model_mgr (FGModelMgr * mgr)