]> git.mxchange.org Git - simgear.git/commitdiff
Avoid nuisance sounds in initial update loop.
authorThorstenB <brehmt@gmail.com>
Sat, 19 Mar 2011 13:48:58 +0000 (14:48 +0100)
committerThorstenB <brehmt@gmail.com>
Sat, 19 Mar 2011 13:48:58 +0000 (14:48 +0100)
Stop all "in-transit" sounds effects from triggering in the first update
loop when their initial property value is "1".

simgear/sound/xmlsound.cxx
simgear/sound/xmlsound.hxx

index 2ca9cdfa8f2f6379726149264e0e4309033a8ad8..0c54798f7562612a854a63bd2676bb4b816de321 100644 (file)
@@ -68,7 +68,8 @@ SGXmlSound::SGXmlSound()
     _dt_play(0.0),
     _dt_stop(0.0),
     _delay(0.0),
-    _stopping(0.0)
+    _stopping(0.0),
+    _initialized(false)
 {
 }
 
@@ -298,6 +299,13 @@ SGXmlSound::update (double dt)
    if (_property)
        curr_value = _property->getDoubleValue();
 
+   if (!_initialized)
+   {
+       // update initial value before detecting changes
+       _prev_value  = curr_value;
+       _initialized = true;
+   }
+
    // If a condition is defined, test whether it is FALSE,
    // else
    //   if a property is defined then test if it's value is FALSE
index f3635b08a705393d2c8180bc2a71aeeb9681904e..0b3f132a45b546237ff782ef862f2db5250789d8 100644 (file)
@@ -149,12 +149,12 @@ private:
   double _dt_play;
   double _dt_stop;
   double _delay;        // time after which the sound should be started (default: 0)
-  double _stopping;    // time after the sound should have stopped.
-                       // This is useful for lost packets in in-transit mode.
+  double _stopping;     // time after the sound should have stopped.
+                        // This is useful for lost packets in in-transit mode.
+  bool _initialized;
 
   std::vector<_snd_prop> _volume;
   std::vector<_snd_prop> _pitch;
-
 };
 
 #endif // _SG_SOUND_HXX