From: ThorstenB Date: Sat, 19 Mar 2011 13:48:58 +0000 (+0100) Subject: Avoid nuisance sounds in initial update loop. X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=92c83bc2804866ff0a402ed93553c6838d725809;p=simgear.git Avoid nuisance sounds in initial update loop. Stop all "in-transit" sounds effects from triggering in the first update loop when their initial property value is "1". --- diff --git a/simgear/sound/xmlsound.cxx b/simgear/sound/xmlsound.cxx index 2ca9cdfa..0c54798f 100644 --- a/simgear/sound/xmlsound.cxx +++ b/simgear/sound/xmlsound.cxx @@ -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 diff --git a/simgear/sound/xmlsound.hxx b/simgear/sound/xmlsound.hxx index f3635b08..0b3f132a 100644 --- a/simgear/sound/xmlsound.hxx +++ b/simgear/sound/xmlsound.hxx @@ -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