MCPcopy Create free account
hub / github.com/bfbbdecomp/bfbb / xSFXUpdateEnvironmentalStreamSounds

Function xSFXUpdateEnvironmentalStreamSounds

src/SB/Core/x/xSFX.cpp:24–95  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

22}
23
24void xSFXUpdateEnvironmentalStreamSounds(xSFX* pSFXList, U32 numSounds)
25{
26 static xSFX* bestSFX[1];
27 static F32 bestDist2[1];
28
29 for (U32 i = 0; i < numSounds; i++)
30 {
31 xSFXUpdate(&pSFXList[i]);
32 }
33
34 memset(bestSFX, 0, sizeof(bestSFX));
35
36 for (U32 j = 0; j < numSounds; j++)
37 {
38 if (!(pSFXList[j].asset->flagsSFX & 0x200) || !(pSFXList[j].asset->flagsSFX & 0x1000))
39 {
40 continue;
41 }
42
43 xVec3 playPos;
44 xSndProcessSoundPos(&pSFXList[j].asset->pos, &playPos);
45
46 xVec3 delta = gSnd.pos - playPos;
47
48 F32 dist = xVec3Length2(&delta);
49 if (dist > pSFXList[j].cachedOuterDistSquared)
50 {
51 break;
52 }
53
54 if (bestSFX == NULL)
55 {
56 *bestSFX = &pSFXList[j];
57 *bestDist2 = dist;
58 }
59 else if ((*bestSFX)->asset->priority < pSFXList[j].asset->priority)
60 {
61 *bestSFX = &pSFXList[j];
62 *bestDist2 = dist;
63 }
64 else if ((*bestSFX)->asset->priority == pSFXList[j].asset->priority && dist > *bestDist2)
65 {
66 *bestSFX = &pSFXList[j];
67 *bestDist2 = dist;
68 }
69 }
70
71 bool found = false;
72 if (*s_managedEnvSFX == *bestSFX)
73 {
74 *bestSFX = NULL;
75 found = true;
76 }
77
78 if (!found && *s_managedEnvSFX != NULL)
79 {
80 xSFXStop(*s_managedEnvSFX);
81 s_managedEnvSFX[0]->id = 0x0;

Callers 1

zSceneUpdateSFXWidgetsFunction · 0.50

Calls 6

xSFXUpdateFunction · 0.85
memsetFunction · 0.85
xSndProcessSoundPosFunction · 0.85
xVec3Length2Function · 0.85
xSFXStopFunction · 0.85
xSFXPlayFunction · 0.70

Tested by

no test coverage detected