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

Method _updateVolume

Engine/source/sfx/sfxSource.cpp:792–916  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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

Callers

nothing calls this directly

Calls 7

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