]> git.mxchange.org Git - flightgear.git/blobdiff - src/Sound/fg_fx.cxx
Fix the temperature computation.
[flightgear.git] / src / Sound / fg_fx.cxx
index 6df4505d3fd8bbc8b921e7b50ab6a28d937409d8..caff002e224a8e41a9754cb32040e254877e2517 100644 (file)
@@ -103,7 +103,7 @@ FGFX::init()
                             globals->get_soundmgr(), globals->get_fg_root());
   
                 _sound.push_back(sound);
-            } catch ( sg_io_exception &e ) {
+            } catch ( sg_exception &e ) {
                 SG_LOG(SG_GENERAL, SG_ALERT, e.getFormattedMessage());
                 delete sound;
             }
@@ -140,8 +140,8 @@ FGFX::update (double dt)
 #if 0
     // moved back to the mainloop to prevent audio problems
     smgr->update(dt);
-#endif
     update_pos_and_orientation(smgr, dt);
+#endif
 
     // command sound manger
     bool pause = _pause->getBoolValue();
@@ -202,13 +202,12 @@ FGFX::play_message( SGSoundSample *_sample )
 void
 FGFX::play_message( const string path, const string fname, double volume )
 {
-    if (globals->get_soundmgr()->is_working() == false) {
-        return;
+    if (globals->get_soundmgr()->is_working() == true) {
+        SGSoundSample *sample;
+        sample = new SGSoundSample( path.c_str(), fname.c_str() );
+        sample->set_volume( volume );
+        play_message( sample );
     }
-    SGSoundSample *sample;
-    sample = new SGSoundSample( path.c_str(), fname.c_str() );
-    sample->set_volume( volume );
-    play_message( sample );
 }
 
 void
@@ -226,9 +225,8 @@ FGFX::update_pos_and_orientation(SGSoundMgr *smgr, double dt)
 
     // get the orientation
     const SGQuatd view_or = observer->getViewOrientation();
-    SGQuatd surf_or = SGQuatd::fromLonLatDeg(
-                                observer->getLongitude_deg(),
-                                observer->getLatitude_deg());
+    SGQuatd surf_or = SGQuatd::fromLonLat(observer->getPosition());
+    
     SGQuatd model_or = SGQuatd::fromYawPitchRollDeg(
                                 model->getHeadingDeg(),
                                 model->getPitchDeg(),
@@ -251,7 +249,7 @@ FGFX::update_pos_and_orientation(SGSoundMgr *smgr, double dt)
 
     // get the location data for the primary FDM (now hardcoded to ac model)...
     // EMH: to add multiple sound sources this should be replaced
-    SGLocation *acmodel_loc = (SGLocation *)model->getSGLocation();
+    SGVec3d absolute_view_pos = SGVec3d::fromGeod(model->getPosition());
 
     // calculate speed of visitor and model
     sgVec3 listener_vel, model_vel;
@@ -271,8 +269,8 @@ FGFX::update_pos_and_orientation(SGSoundMgr *smgr, double dt)
                     ));
     sgSetVec3(listener_vel, SGV3d_help[0], SGV3d_help[1], SGV3d_help[2]);
 
-    sgdSubVec3(sgdv3_help, last_model_pos,acmodel_loc->get_absolute_view_pos());
-    sgdAddVec3(last_model_pos, sgdv3_null,acmodel_loc->get_absolute_view_pos());
+    sgdSubVec3(sgdv3_help, last_model_pos, absolute_view_pos.data());
+    sgdAddVec3(last_model_pos, sgdv3_null, absolute_view_pos.data());
 
     SGV3d_help = model_or.rotateBack(
                     surf_or.rotateBack(
@@ -304,7 +302,7 @@ FGFX::update_pos_and_orientation(SGSoundMgr *smgr, double dt)
     sgdVec3 dsource_pos_offset;
     sgdSubVec3( dsource_pos_offset,
                 (double*) &observer->get_view_pos(),
-                acmodel_loc->get_absolute_view_pos() );
+                absolute_view_pos.data() );
     SGVec3d sgv_dsource_pos_offset;
     sgv_dsource_pos_offset = model_or.rotateBack(
                                 surf_or.rotateBack(