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

Method play

Engine/source/sfx/sfxSource.cpp:485–577  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

483//-----------------------------------------------------------------------------
484
485void SFXSource::play( F32 fadeInTime )
486{
487 SFXStatus status = getStatus();
488
489 // Return if the source is already playing.
490
491 if( status == SFXStatusPlaying )
492 {
493 // Revert fade-out if there is one.
494
495 if( mFadeSegmentType != FadeSegmentNone && mFadeSegmentType != FadeSegmentPlay )
496 {
497 // Let easing curve remain in place. Otherwise we would have to
498 // search the fade-in's easing curve for the point matching the
499 // current fade volume in order to prevent volume pops.
500
501 mFadeSegmentType = FadeSegmentPlay;
502 }
503
504 return;
505 }
506
507 // First check the parent source. If it is not playing,
508 // only save our non-inherited state and return.
509
510 SFXSource* sourceGroup = getSourceGroup();
511 if( sourceGroup != NULL && !sourceGroup->isPlaying() )
512 {
513 mSavedStatus = SFXStatusPlaying;
514 mSavedFadeTime = fadeInTime;
515
516 return;
517 }
518
519 // Add fades, if required.
520
521 if( fadeInTime == -1.f )
522 fadeInTime = mFadeInTime;
523
524 if( status == SFXStatusPaused && fadeInTime > 0.f )
525 {
526 // Source is paused. Set up temporary fade-in segment.
527
528 mFadeSegmentEase = &mDescription->mFadeInEase;
529 mFadeSegmentType = FadeSegmentPlay;
530 mFadeSegmentStartPoint = getElapsedPlayTimeCurrentCycle();
531 mFadeSegmentEndPoint = mFadeSegmentStartPoint + fadeInTime;
532 }
533 else if( fadeInTime > 0.f )
534 {
535 mFadeInPoint = fadeInTime;
536
537 // Add fade-out if play-time of the source is finite and
538 // if it is either not looping or has fading enabled on loops.
539
540 F32 totalPlayTime = getTotalPlayTime();
541 if( !mIsInf_F( totalPlayTime ) && mDescription->mFadeOutTime > 0.f && ( !mDescription->mIsLooping || mDescription->mFadeLoops ) )
542 {

Callers 2

_playMethod · 0.45
sfxSource.cppFile · 0.45

Calls 3

mIsInf_FFunction · 0.85
isPlayingMethod · 0.45
resetMethod · 0.45

Tested by

no test coverage detected