}
FGNasalSys* nasalSys = (FGNasalSys*) globals->get_subsystem("nasal");
+ if (!nasalSys)
+ return;
+
std::string moduleName = "scenario_" + _internalName;
if (!_unloadScript.empty()) {
nasalSys->createModule(moduleName.c_str(), moduleName.c_str(),
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
{