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

Method _updateVolume

Engine/source/sfx/sfxSource.cpp:793–920  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

791//-----------------------------------------------------------------------------
792
793void SFXSource::_updateVolume( const MatrixF& listener )
794{
795 if (!mDescription)
796 return;
797
798 // Handle fades (compute mFadedVolume).
799
800 mFadedVolume = mPreFadeVolume;
801 if( mFadeSegmentType != FadeSegmentNone )
802 {
803 // We have a temporary fade segment.
804
805 F32 elapsed;
806 if( mDescription->mIsLooping && !mDescription->mFadeLoops )
807 elapsed = getElapsedPlayTime();
808 else
809 elapsed = getElapsedPlayTimeCurrentCycle();
810
811 if( elapsed < mFadeSegmentEndPoint )
812 {
813 const F32 duration = mFadeSegmentEndPoint - mFadeSegmentStartPoint;
814
815 if( mFadeSegmentType == FadeSegmentPlay )
816 {
817 const F32 time = elapsed - mFadeSegmentStartPoint;
818 mFadedVolume = mFadeSegmentEase->getValue
819 ( time, 0.f, mPreFadeVolume, duration );
820 }
821 else
822 {
823 // If the end-point to the ease functions is 0,
824 // we'll always get out the start point. Thus do the whole
825 // thing backwards here.
826
827 const F32 time = mFadeSegmentEndPoint - elapsed;
828 mFadedVolume = mFadeSegmentEase->getValue
829 ( time, 0.f, mPreFadeVolume, duration );
830 }
831 }
832 else
833 {
834 // The fade segment has played. Remove it.
835
836 switch( mFadeSegmentType )
837 {
838 case FadeSegmentStop:
839 stop( 0.f );
840 break;
841
842 case FadeSegmentPause:
843 pause( 0.f );
844 break;
845
846 case FadeSegmentPlay: // Nothing to do.
847 default:
848 break;
849 }
850

Callers

nothing calls this directly

Calls 8

stopFunction · 0.85
SFXDistanceAttenuationFunction · 0.85
getAttenuatedVolumeMethod · 0.80
getColumnMethod · 0.80
getDistanceModelMethod · 0.80
getValueMethod · 0.45
lenMethod · 0.45
getRolloffFactorMethod · 0.45

Tested by

no test coverage detected