]> git.mxchange.org Git - flightgear.git/blobdiff - src/AIModel/AIBase.cxx
Make the sound-manager optional in a few places.
[flightgear.git] / src / AIModel / AIBase.cxx
index 0945a13e6f7308a5cb9e716709402ffe041b9164..7cfcfcb0a33418517ff24f767da13d599e186191 100644 (file)
@@ -34,7 +34,6 @@
 #include <osg/Node>
 #include <osgDB/FileUtils>
 
-#include <simgear/math/SGMath.hxx>
 #include <simgear/misc/sg_path.hxx>
 #include <simgear/scene/model/modellib.hxx>
 #include <simgear/scene/util/SGNodeMasks.hxx>
@@ -144,12 +143,17 @@ FGAIBase::~FGAIBase() {
             model_removed->setStringValue(props->getPath());
     }
 
+  // refID=0 is supposedley impossible, refID=1 is the special ai_ac aircaft
+  // representing the current user, in the ATCManager. Maybe both these
+  // tests could die?
     if (_fx && _refID != 0 && _refID !=  1) {
         SGSoundMgr *smgr = globals->get_soundmgr();
-        stringstream name; 
-        name <<  "aifx:";
-        name << _refID;
-        smgr->remove(name.str());
+        if (smgr) {
+          stringstream name;
+          name <<  "aifx:";
+          name << _refID;
+          smgr->remove(name.str());
+        }
     }
 
     if (fp)
@@ -246,11 +250,10 @@ void FGAIBase::update(double dt) {
                 props->setStringValue("sim/sound/path", fxpath.c_str());
 
                 // initialize the sound configuration
-                SGSoundMgr *smgr = globals->get_soundmgr();
                 stringstream name;
                 name <<  "aifx:";
                 name << _refID;
-                _fx = new FGFX(smgr, name.str(), props);
+                _fx = new FGFX(name.str(), props);
                 _fx->init();
             }
         }
@@ -351,11 +354,10 @@ bool FGAIBase::init(bool search_in_AI_path)
         aip.setVisible(true);
         invisible = false;
         globals->get_scenery()->get_scene_graph()->addChild(aip.getSceneGraph());
-
-        // Get the sound-path tag from the configuration file and store it
-        // in the property tree.
         _initialized = true;
 
+        SG_LOG(SG_AI, SG_DEBUG, "AIBase: Loaded model " << model_path);
+
     } else if (!model_path.empty()) {
         SG_LOG(SG_AI, SG_WARN, "AIBase: Could not load model " << model_path);
         // not properly installed...
@@ -609,7 +611,7 @@ SGVec3d FGAIBase::getCartPos() const {
 }
 
 bool FGAIBase::getGroundElevationM(const SGGeod& pos, double& elev,
-                                   const SGMaterial** material) const {
+                                   const simgear::BVHMaterial** material) const {
     return globals->get_scenery()->get_elevation_m(pos, elev, material,
                                                    _model.get());
 }
@@ -731,7 +733,7 @@ double FGAIBase::_getAltitude() const {
 
 double FGAIBase::_getAltitudeAGL(SGGeod inpos, double start){
     getGroundElevationM(SGGeod::fromGeodM(inpos, start),
-        _elevation_m, &_material);
+        _elevation_m, NULL);
     return inpos.getElevationFt() - _elevation_m * SG_METER_TO_FEET;
 }