]> git.mxchange.org Git - flightgear.git/blobdiff - src/AIModel/AIManager.cxx
Merge branch 'merge-requests/1555' into next
[flightgear.git] / src / AIModel / AIManager.cxx
index 4190981124242bea13257c082babf70a59c18b60..731983f25dc710c4ced8042edbc7e1ebf4b85f13 100644 (file)
 #include "AIGroundVehicle.hxx"
 #include "AIEscort.hxx"
 
-FGAIManager::FGAIManager() {
+FGAIManager::FGAIManager() :
+    cb_ai_bare(SGPropertyChangeCallback<FGAIManager>(this,&FGAIManager::updateLOD,
+               fgGetNode("/sim/rendering/static-lod/ai-bare", true))),
+    cb_ai_detailed(SGPropertyChangeCallback<FGAIManager>(this,&FGAIManager::updateLOD,
+                   fgGetNode("/sim/rendering/static-lod/ai-detailed", true)))
+{
     _dt = 0.0;
     mNumAiModels = 0;
 
@@ -141,7 +146,7 @@ FGAIManager::update(double dt) {
     if (!enabled)
         return;
 
-    FGTrafficManager *tmgr = (FGTrafficManager*) globals->get_subsystem("Traffic Manager");
+    FGTrafficManager *tmgr = (FGTrafficManager*) globals->get_subsystem("traffic-manager");
     _dt = dt;
 
     ai_list_iterator ai_list_itr = ai_list.begin();
@@ -181,6 +186,18 @@ FGAIManager::update(double dt) {
     thermal_lift_node->setDoubleValue( strength );  // for thermals
 }
 
+/** update LOD settings of all AI/MP models */
+void
+FGAIManager::updateLOD(SGPropertyNode* node)
+{
+    ai_list_iterator ai_list_itr = ai_list.begin();
+    while(ai_list_itr != ai_list.end())
+    {
+        (*ai_list_itr)->updateLOD();
+        ++ai_list_itr;
+    }
+}
+
 void
 FGAIManager::attach(FGAIBase *model)
 {
@@ -358,9 +375,9 @@ FGAIManager::loadScenarioFile(const std::string& filename)
         SGPropertyNode_ptr root = new SGPropertyNode;
         readProperties(path.str(), root);
         return root;
-    } catch (const sg_exception &) {
-        SG_LOG(SG_GENERAL, SG_DEBUG, "Incorrect path specified for AI "
-            "scenario: \"" << path.str() << "\"");
+    } catch (const sg_exception &t) {
+        SG_LOG(SG_GENERAL, SG_ALERT, "Failed to load scenario '"
+            << path.str() << "': " << t.getFormattedMessage());
         return 0;
     }
 }