]> git.mxchange.org Git - flightgear.git/commitdiff
Code cleanup after fixing the sound position and orientation
authorErik Hofman <erik@ehofman.com>
Tue, 14 Jun 2016 12:11:12 +0000 (14:11 +0200)
committerRoland Haeder <roland@mxchange.org>
Thu, 22 Sep 2016 21:27:36 +0000 (23:27 +0200)
src/Sound/soundmanager.cxx
src/Sound/soundmanager.hxx

index 48277980c032f611da84ea5e69282905bdd0ede8..85d1c0cc0bfc97710ce373f3541d24ccc4c70ef7 100644 (file)
 
 #include "sample_queue.hxx"
 #include "soundmanager.hxx"
-#include "Main/globals.hxx"
-#include "Main/fg_props.hxx"
-#include "Viewer/view.hxx"
+#include <Main/globals.hxx>
+#include <Main/fg_props.hxx>
+#include <Viewer/view.hxx>
+
+#include <stdio.h>
 
 #include <vector>
 #include <string>
@@ -74,20 +76,10 @@ void FGSoundManager::init()
     _volume        = fgGetNode("/sim/sound/volume");
     _device_name   = fgGetNode("/sim/sound/device-name");
 
-    _currentView   = fgGetNode("sim/current-view");
-
-    _viewX = _currentView->getNode("viewer-x-m", true);
-    _viewY = _currentView->getNode("viewer-y-m", true);
-    _viewZ = _currentView->getNode("viewer-z-m", true);
-  
     _velocityNorthFPS = fgGetNode("velocities/speed-north-fps", true);
     _velocityEastFPS  = fgGetNode("velocities/speed-east-fps", true);
     _velocityDownFPS  = fgGetNode("velocities/speed-down-fps", true);
   
-    _viewXoffset      = _currentView->getNode("x-offset-m", true);
-    _viewYoffset      = _currentView->getNode("y-offset-m", true);
-    _viewZoffset      = _currentView->getNode("z-offset-m", true);
-
     SGPropertyNode_ptr scenery_loaded = fgGetNode("sim/sceneryloaded", true);
     scenery_loaded->addChangeListener(_listener.get());
 
@@ -161,9 +153,9 @@ bool FGSoundManager::stationaryView() const
 {
   // this is an ugly hack to decide if the *viewer* is stationary,
   // since we don't model the viewer velocity directly.
-  return (_viewXoffset->getDoubleValue() == 0.0) &&
-         (_viewYoffset->getDoubleValue() == 0.0) &&
-         (_viewZoffset->getDoubleValue() == 0.0);
+  flightgear::View* _view = globals->get_current_view();
+  return (_view->getXOffset_m () == 0.0 && _view->getYOffset_m () == 0.0 &&
+          _view->getZOffset_m () == 0.0);
 }
 
 // Update sound manager and propagate property values,
@@ -184,26 +176,9 @@ void FGSoundManager::update(double dt)
         }
         if (enabled)
         {
-#if 0
-            SGVec3d cartPos(_viewX->getDoubleValue(),
-                            _viewY->getDoubleValue(),
-                            _viewZ->getDoubleValue());
-            SGGeod geodPos = SGGeod::fromCart(cartPos);
-
-            set_position(cartPos, geodPos);
-
-            SGQuatd viewOrientation;
-            for (int i=0; i<4; ++i) {
-              viewOrientation[i] = _currentView->getChild("raw-orientation", i, true)->getDoubleValue();
-            }
-
-            set_orientation( viewOrientation );
-#else
-
-            set_position( globals->get_current_view()->getViewPosition(),
-                          globals->get_current_view()->getPosition() );
-            set_orientation( globals->get_current_view()->getViewOrientation() );
-#endif
+            flightgear::View* _view = globals->get_current_view();
+            set_position( _view->getViewPosition(), _view->getPosition() );
+            set_orientation( _view->getViewOrientation() );
 
             SGVec3d velocity(SGVec3d::zeros());
             if (!stationaryView()) {
index cebf34806cc515192f9d5a613069201e3342732c..8a9f6f5de9a4874d845303105956837d9429dee5 100644 (file)
@@ -59,10 +59,7 @@ private:
 
     bool _is_initialized, _enabled;
     SGPropertyNode_ptr _sound_working, _sound_enabled, _volume, _device_name;
-    SGPropertyNode_ptr _currentView;
-    SGPropertyNode_ptr _viewX, _viewY, _viewZ;
     SGPropertyNode_ptr _velocityNorthFPS, _velocityEastFPS, _velocityDownFPS;
-    SGPropertyNode_ptr _viewXoffset, _viewYoffset, _viewZoffset;
     std::auto_ptr<Listener> _listener;
 #if defined(ENABLE_FLITE)
     std::map<std::string,VoiceSynthesizer*> _synthesizers;