// AI manager. In this particular case, the AIAircraft is used to shadow the user's aircraft's behavior in the AI world.
// Since we perhaps don't want a radar entry of our own aircraft, the following conditional should probably be adequate
// enough
- if (manager)
+ if (manager){
UpdateRadar(manager);
- checkVisibility();
+ invisible = !manager->isVisible(pos);
+ }
}
-void FGAIAircraft::checkVisibility()
-{
- double visibility_meters = fgGetDouble("/environment/visibility-m");
- invisible = (SGGeodesy::distanceM(globals->get_view_position(), pos) > visibility_meters);
-}
-
-
void FGAIAircraft::AccelTo(double speed) {
tgt_speed = speed;
void updateActualState();
void updateModelProperties(double dt);
void handleATCRequests();
- void checkVisibility();
inline bool isStationary() { return ((fabs(speed)<=0.0001)&&(fabs(tgt_speed)<=0.0001));}
inline bool needGroundElevation() { if (!isStationary()) _needsGroundElevation=true;return _needsGroundElevation;}
globals->get_commands()->addCommand("load-scenario", this, &FGAIManager::loadScenarioCommand);
globals->get_commands()->addCommand("unload-scenario", this, &FGAIManager::unloadScenarioCommand);
+ _environmentVisiblity = fgGetNode("/environment/visibility-m");
}
void
}
ai_list.clear();
+ _environmentVisiblity.clear();
globals->get_commands()->removeCommand("load-scenario");
globals->get_commands()->removeCommand("unload-scenario");
p->setBoolValue("valid", true);
}
+bool FGAIManager::isVisible(const SGGeod& pos) const
+{
+ double visibility_meters = _environmentVisiblity->getDoubleValue();
+ return ( dist(globals->get_view_position_cart(), SGVec3d::fromGeod(pos)) ) <= visibility_meters;
+}
+
int
FGAIManager::getNumAiObjects() const
{
SGGeod& geodPos, double& hdng, SGVec3d& uvw);
FGAIBasePtr addObject(const SGPropertyNode* definition);
+ bool isVisible(const SGGeod& pos) const;
/**
* @brief given a reference to an /ai/models/<foo>[n] node, return the
SGPropertyNode_ptr user_speed_node;
SGPropertyNode_ptr wind_from_east_node;
SGPropertyNode_ptr wind_from_north_node;
+ SGPropertyNode_ptr _environmentVisiblity;
ai_list_type ai_list;