MCPcopy Create free account
hub / github.com/TorqueGameEngines/Torque3D / update

Method update

Engine/source/sfx/sfxSoundscape.cpp:109–216  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

107//-----------------------------------------------------------------------------
108
109void SFXSoundscapeManager::update()
110{
111 // Make sure the topmost reverb on the stack is active.
112
113 S32 reverbIndex = _findTopmostReverbOnStack( mStack );
114 if( mCurrentReverbIndex != reverbIndex )
115 {
116 if( reverbIndex == -1 )
117 {
118 // No ambience on the stack has reverb settings so reset
119 // to default.
120 SFX->setReverb( SFXReverbProperties() );
121 }
122 else
123 {
124 SFXAmbience* ambience = mStack[ reverbIndex ]->getAmbience();
125 AssertFatal( ambience->getEnvironment(), "SFXSoundscapeManager::update - Reverb lookup return ambience without reverb!" );
126
127 SFX->setRolloffFactor( ambience->getRolloffFactor() );
128 SFX->setDopplerFactor( ambience->getDopplerFactor() );
129 SFX->setReverb( ambience->getEnvironment()->getReverb() );
130 }
131
132 mCurrentReverbIndex = reverbIndex;
133 }
134
135 // Update the active soundscapes.
136
137 for( U32 i = 0; i < mStack.size(); ++ i )
138 {
139 SFXSoundscape* soundscape = mStack[ i ];
140
141 // If the soundscape's associated ambience has changed
142
143 if( soundscape->mDirtyBits.test( SFXSoundscape::AmbienceDirty ) )
144 {
145 SFXAmbience* ambience = soundscape->getAmbience();
146
147 // Start playing the ambient audio track if it isn't
148 // already playing and if the soundscape isn't overridden
149 // by an instance lower down the stack.
150
151 if( !soundscape->_isOverridden() )
152 {
153 SFXTrack* track = ambience->getSoundTrackProfile();
154 if( !soundscape->mSource || soundscape->mSource->getTrack() != track )
155 {
156 if( soundscape->mSource != NULL )
157 {
158 soundscape->mSource->stop();
159 soundscape->mSource = NULL;
160 }
161
162 if( track )
163 soundscape->mSource = SFX->playOnce( track );
164 }
165 else if( soundscape->mSource != NULL )
166 {

Callers

nothing calls this directly

Calls 15

SFXReverbPropertiesClass · 0.85
destructInPlaceFunction · 0.85
getEnvironmentMethod · 0.80
_isOverriddenMethod · 0.80
erase_fastMethod · 0.80
setReverbMethod · 0.45
getAmbienceMethod · 0.45
setRolloffFactorMethod · 0.45
getRolloffFactorMethod · 0.45
setDopplerFactorMethod · 0.45
getDopplerFactorMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected