/////////////////////////////////////////////////////////////////////
| 532 | |
| 533 | ////////////////////////////////////////////////////////////////////////// |
| 534 | bool CSoundSystem::ProcessActiveSound( CSound *cs ) |
| 535 | { |
| 536 | FUNCTION_PROFILER( GetSystem(),PROFILE_SOUND ); |
| 537 | |
| 538 | bool bFadeoutFinished = false; |
| 539 | bool bIsSoundPotentiallyHearable = IsSoundPH(cs); |
| 540 | if (!bIsSoundPotentiallyHearable) |
| 541 | { |
| 542 | // decrease it as the player is leaving the room or moving from outdoor to indoor or viceversa. |
| 543 | bFadeoutFinished = cs->FadeOut(); |
| 544 | } |
| 545 | float fRatio = 1.0f; |
| 546 | if (cs->m_nFlags & FLAG_SOUND_RADIUS) |
| 547 | { |
| 548 | float fDist2=GetSquaredDistance(cs->m_RealPos,m_vPos); |
| 549 | if (fDist2 > cs->m_fMaxRadius2) |
| 550 | { |
| 551 | // Too far. |
| 552 | return false; |
| 553 | } |
| 554 | if (bFadeoutFinished) |
| 555 | { |
| 556 | return false; |
| 557 | } |
| 558 | if (fDist2 > cs->m_fMinRadius2) |
| 559 | { |
| 560 | //calc attenuation, cal sound ratio between min & max radius |
| 561 | if (!(cs->m_nFlags & FLAG_SOUND_NO_SW_ATTENUATION)) |
| 562 | { |
| 563 | fRatio=1.0f-((fDist2-cs->m_fMinRadius2)/cs->m_fMaxRadius2); |
| 564 | } |
| 565 | else |
| 566 | fRatio=1.0f; |
| 567 | } |
| 568 | } |
| 569 | if (bIsSoundPotentiallyHearable) |
| 570 | { |
| 571 | // check if the sound became hearable because of sound occlusion |
| 572 | cs->FadeIn(); |
| 573 | } |
| 574 | // if Steve doesnt want to change frequency and pan, this can be replaced just with set volume |
| 575 | cs->SetAttrib(cs->m_nMaxVolume,fRatio*cs->m_fCurrentFade*cs->m_fRatio,cs->m_nPan,1000,false); |
| 576 | return true; |
| 577 | } |
| 578 | |
| 579 | ////////////////////////////////////////////////////////////////////// |
| 580 | void CSoundSystem::Update() |