MCPcopy Create free account
hub / github.com/StrongPC123/Far-Cry-1-Source-Full / RecomputeSoundOcclusion

Method RecomputeSoundOcclusion

CrySoundSystem/SoundSystem.cpp:1306–1354  ·  view source on GitHub ↗

/////////////////////////////////////////////////////////////////////

Source from the content-addressed store, hash-verified

1304
1305//////////////////////////////////////////////////////////////////////////
1306void CSoundSystem::RecomputeSoundOcclusion(bool bRecomputeListener,bool bForceRecompute,bool bReset)
1307{
1308 GUARD_HEAP;
1309 if (bReset)
1310 {
1311 m_pVisArea=NULL;
1312 return;
1313 }
1314 if (m_nMuteRefCnt>0)
1315 return; // don't do this during mute (usually during loading)
1316
1317 FUNCTION_PROFILER( GetSystem(),PROFILE_SOUND );
1318
1319 I3DEngine *p3dEngine=m_pISystem->GetI3DEngine();
1320 if (p3dEngine)
1321 {
1322 //check where the listener is
1323 IVisArea *pCurrArea=NULL;
1324 if (bRecomputeListener)
1325 {
1326 Vec3_tpl<float> vPos=m_cCam.GetPos();
1327 pCurrArea=p3dEngine->GetVisAreaFromPos(vPos);
1328 }
1329 else
1330 pCurrArea=m_pVisArea;
1331
1332 // avoid silly people to mess around with too many visareas
1333 int nMaxVis=(m_pCVarVisAreaProp->GetIVal() & (MAX_VIS_AREAS-1));
1334
1335 if ((pCurrArea!=m_pVisArea) || (bForceRecompute))
1336 {
1337 // listener has changed sector or has moved from indoor to outdoor or viceversa
1338 m_pVisArea=pCurrArea;
1339 memset(m_VisAreas,0,sizeof(m_VisAreas));
1340 if (m_pVisArea)
1341 {
1342 // if inside let's get a list of visible areas to use for sound occlusion
1343 int nAreas=m_pVisArea->GetVisAreaConnections(m_VisAreas,nMaxVis,true);
1344 // engine doesn't return the current area - be sure to add it or
1345 // all the sounds currently playing in the listener area will fade out
1346 if (nAreas<nMaxVis)
1347 m_VisAreas[nAreas]=m_pVisArea;
1348 else
1349 // override the first one - this one is more important
1350 m_VisAreas[0]=m_pVisArea;
1351 }
1352 }
1353 }
1354}
1355
1356//////////////////////////////////////////////////////////////////////
1357void CSoundSystem::RemoveReference(CSound *cs)

Callers 2

DoneMethod · 0.45
ActivatePortalMethod · 0.45

Calls 5

GetI3DEngineMethod · 0.80
GetIValMethod · 0.80
GetVisAreaConnectionsMethod · 0.80
GetPosMethod · 0.45
GetVisAreaFromPosMethod · 0.45

Tested by

no test coverage detected