]> git.mxchange.org Git - flightgear.git/blobdiff - src/AIModel/AIBase.cxx
Interim windows build fix
[flightgear.git] / src / AIModel / AIBase.cxx
index 41ef040ae08dacc7d2b3882668233a63f625b7dc..339de5f27f17557dd42b435722d19b238b4b42e8 100644 (file)
 #include <simgear/props/props.hxx>
 
 #include <Main/globals.hxx>
+#include <Main/fg_props.hxx>
 #include <Scenery/scenery.hxx>
 #include <Scripting/NasalSys.hxx>
 #include <Scripting/NasalModelData.hxx>
 #include <Sound/fg_fx.hxx>
 
+#include "AIFlightPlan.hxx"
 #include "AIBase.hxx"
 #include "AIManager.hxx"
 
@@ -106,7 +108,6 @@ public:
     bool getInteriorLoaded(void) { return _interiorLoaded;}
     bool hasInteriorPath(void) { return _hasInteriorPath;}
     inline std::string& getInteriorPath() { return _interiorPath; }
-    
 private:
     std::auto_ptr<FGNasalModelDataProxy> _nasal;
     std::string _fxpath;
@@ -220,7 +221,7 @@ FGAIBase::removeModel()
         return;
 
     FGScenery* pSceneryManager = globals->get_scenery();
-    if (pSceneryManager)
+    if (pSceneryManager && pSceneryManager->get_models_branch())
     {
         osg::ref_ptr<osg::Object> temp = _model.get();
         pSceneryManager->get_models_branch()->removeChild(aip.getSceneGraph());
@@ -234,7 +235,9 @@ FGAIBase::removeModel()
     }
     else
     {
-        SG_LOG(SG_AI, SG_ALERT, "AIBase: Could not unload model. Missing scenery manager!");
+        aip.clear();
+        _model = 0;
+        _modeldata = 0;
     }
 }
 
@@ -336,7 +339,8 @@ void FGAIBase::updateInterior()
 void FGAIBase::updateLOD()
 {
     double maxRangeDetail = fgGetDouble("/sim/rendering/static-lod/ai-detailed", 10000.0);
-    double maxRangeBare   = fgGetDouble("/sim/rendering/static-lod/ai-bare", 20000.0);
+//    double maxRangeBare   = fgGetDouble("/sim/rendering/static-lod/ai-bare", 20000.0);
+
     _maxRangeInterior     = fgGetDouble("/sim/rendering/static-lod/ai-interior", 50.0);
     if (_model.valid())
     {
@@ -348,8 +352,14 @@ void FGAIBase::updateLOD()
         }
         else
         {
-            _model->setRange(0, 0.0, maxRangeDetail);
-            _model->setRange(1, maxRangeDetail,maxRangeBare);
+            if( fgGetBool("/sim/rendering/static-lod/ai-range-mode-pixel", false ) ) 
+            {
+                _model->setRangeMode( osg::LOD::PIXEL_SIZE_ON_SCREEN );
+                _model->setRange(0, maxRangeDetail, 100000 );
+            } else {
+                _model->setRangeMode( osg::LOD:: DISTANCE_FROM_EYE_POINT);
+                _model->setRange(0, 0.0, maxRangeDetail);
+            }
         }
     }
 }
@@ -925,5 +935,7 @@ int FGAIBase::_newAIModelID() {
     return id;
 }
 
-
-
+bool FGAIBase::isValid() { 
+       //Either no flightplan or it is valid
+       return !fp || fp->isValidPlan(); 
+}