diff options
Diffstat (limited to 'src/audio/AudioCollision.cpp')
-rw-r--r-- | src/audio/AudioCollision.cpp | 54 |
1 files changed, 29 insertions, 25 deletions
diff --git a/src/audio/AudioCollision.cpp b/src/audio/AudioCollision.cpp index 5af762f9..147db001 100644 --- a/src/audio/AudioCollision.cpp +++ b/src/audio/AudioCollision.cpp @@ -83,11 +83,11 @@ cAudioManager::ServiceCollisions() m_sQueueSample.m_nEntityIndex = m_nCollisionEntity; - for (int i = 0; i < NUMAUDIOCOLLISIONS; i++) + for(int i = 0; i < NUMAUDIOCOLLISIONS; i++) abRepeatedCollision1[i] = abRepeatedCollision2[i] = FALSE; - for (i = 0; i < m_sCollisionManager.m_bCollisionsInQueue; i++) { - for (j = 0; j < NUMAUDIOCOLLISIONS; j++) { + for(i = 0; i < m_sCollisionManager.m_bCollisionsInQueue; i++) { + for(j = 0; j < NUMAUDIOCOLLISIONS; j++) { int index = m_sCollisionManager.m_bIndicesTable[i]; if ((m_sCollisionManager.m_asCollisions1[index].m_pEntity1 == m_sCollisionManager.m_asCollisions2[j].m_pEntity1) && (m_sCollisionManager.m_asCollisions1[index].m_pEntity2 == m_sCollisionManager.m_asCollisions2[j].m_pEntity2) @@ -103,8 +103,8 @@ cAudioManager::ServiceCollisions() } } - for (i = 0; i < NUMAUDIOCOLLISIONS; i++) { - if (!abRepeatedCollision2[i]) { + for(i = 0; i < NUMAUDIOCOLLISIONS; i++) { + if(!abRepeatedCollision2[i]) { m_sCollisionManager.m_asCollisions2[i].m_pEntity1 = nil; m_sCollisionManager.m_asCollisions2[i].m_pEntity2 = nil; m_sCollisionManager.m_asCollisions2[i].m_bSurface1 = SURFACE_DEFAULT; @@ -116,11 +116,11 @@ cAudioManager::ServiceCollisions() } } - for (i = 0; i < m_sCollisionManager.m_bCollisionsInQueue; i++) { + for(i = 0; i < m_sCollisionManager.m_bCollisionsInQueue; i++) { int index = m_sCollisionManager.m_bIndicesTable[i]; - if (!abRepeatedCollision1[index]) { - for (j = 0; j < NUMAUDIOCOLLISIONS; j++) { - if (!abRepeatedCollision2[j]) { + if(!abRepeatedCollision1[index]) { + for(j = 0; j < NUMAUDIOCOLLISIONS; j++) { + if(!abRepeatedCollision2[j]) { m_sCollisionManager.m_asCollisions2[j].m_nBaseVolume = 1; m_sCollisionManager.m_asCollisions2[j].m_pEntity1 = m_sCollisionManager.m_asCollisions1[index].m_pEntity1; m_sCollisionManager.m_asCollisions2[j].m_pEntity2 = m_sCollisionManager.m_asCollisions1[index].m_pEntity2; @@ -134,7 +134,7 @@ cAudioManager::ServiceCollisions() } } - for (int i = 0; i < NUMAUDIOCOLLISIONS; i++) + for(int i = 0; i < NUMAUDIOCOLLISIONS; i++) m_sCollisionManager.m_bIndicesTable[i] = NUMAUDIOCOLLISIONS; m_sCollisionManager.m_bCollisionsInQueue = 0; } @@ -171,7 +171,9 @@ static const int32 gOneShotCol[] = {SFX_COL_TARMAC_1, SFX_TYRE_BUMP, SFX_COL_CARDBOARD_1, SFX_COL_TARMAC_1, - SFX_COL_GATE}; + SFX_COL_GATE, + SFX_COL_SAND_1, + SFX_COL_TARMAC_1 }; void cAudioManager::SetUpOneShotCollisionSound(const cAudioCollision &col) @@ -219,7 +221,7 @@ cAudioManager::SetUpOneShotCollisionSound(const cAudioCollision &col) m_sQueueSample.m_nSampleIndex += m_anRandomTable[3] % 4; break; case SFX_COL_PED_1: - m_sQueueSample.m_nSampleIndex += m_anRandomTable[4] % 5; + m_sQueueSample.m_nSampleIndex += m_anRandomTable[4] % 2; break; case SFX_COL_WOOD_CRATES_1: m_sQueueSample.m_nSampleIndex += m_anRandomTable[4] % 4; @@ -268,7 +270,7 @@ cAudioManager::SetUpOneShotCollisionSound(const cAudioCollision &col) m_sQueueSample.m_fSpeedMultiplier = 4.0f; m_sQueueSample.m_MaxDistance = CollisionSoundIntensity; m_sQueueSample.m_bStatic = TRUE; - m_sQueueSample.m_bReverb = TRUE; + SET_SOUND_REVERB(TRUE); SET_SOUND_REFLECTION(FALSE); AddSampleToRequestedQueue(); } @@ -279,12 +281,12 @@ cAudioManager::SetUpOneShotCollisionSound(const cAudioCollision &col) void cAudioManager::SetUpLoopingCollisionSound(const cAudioCollision &col, uint8 counter) { + bool8 distCalculated = FALSE; if(col.m_fIntensity2 > 0.0016f) { uint8 emittingVol = SetLoopingCollisionRequestedSfxFreqAndGetVol(col); if(emittingVol) { - m_sQueueSample.m_fDistance = Sqrt(col.m_fDistance); - m_sQueueSample.m_nVolume = - ComputeVolume(emittingVol, CollisionSoundIntensity, m_sQueueSample.m_fDistance); + CalculateDistance(distCalculated, m_sQueueSample.m_fDistance); + m_sQueueSample.m_nVolume = ComputeVolume(emittingVol, CollisionSoundIntensity, m_sQueueSample.m_fDistance); if(m_sQueueSample.m_nVolume > 0) { m_sQueueSample.m_nCounter = counter; m_sQueueSample.m_vecPos = col.m_vecPosition; @@ -293,12 +295,12 @@ cAudioManager::SetUpLoopingCollisionSound(const cAudioCollision &col, uint8 coun m_sQueueSample.m_nPriority = 7; m_sQueueSample.m_nLoopCount = 0; SET_EMITTING_VOLUME(emittingVol); - SET_LOOP_OFFSETS(m_sQueueSample.m_nSampleIndex); + SET_LOOP_OFFSETS(m_sQueueSample.m_nSampleIndex) m_sQueueSample.m_fSpeedMultiplier = 4.0f; m_sQueueSample.m_MaxDistance = CollisionSoundIntensity; m_sQueueSample.m_bStatic = FALSE; m_sQueueSample.m_nFramesToPlay = 5; - m_sQueueSample.m_bReverb = TRUE; + SET_SOUND_REVERB(TRUE); SET_SOUND_REFLECTION(FALSE); AddSampleToRequestedQueue(); } @@ -325,8 +327,8 @@ cAudioManager::SetLoopingCollisionRequestedSfxFreqAndGetVol(const cAudioCollisio m_sQueueSample.m_nSampleIndex = SFX_BOAT_WATER_LOOP; m_sQueueSample.m_nFrequency = 6050.f * ratio + 16000; vol = 30.f * ratio; - } else if(surface1 == SURFACE_GRAVEL || surface2 == SURFACE_GRAVEL || surface1 == SURFACE_MUD_DRY || - surface2 == SURFACE_MUD_DRY || surface1 == SURFACE_SAND || surface2 == SURFACE_SAND) { + } else if(surface1 == SURFACE_GRAVEL || surface2 == SURFACE_GRAVEL || surface1 == SURFACE_MUD_DRY || surface2 == SURFACE_MUD_DRY || + surface1 == SURFACE_SAND || surface2 == SURFACE_SAND || surface1 == SURFACE_SAND_BEACH || surface2 == SURFACE_SAND_BEACH) { ratio = GetCollisionRatio(audioCollision.m_fIntensity2, 0.0001f, 0.09f, 0.0899f); m_sQueueSample.m_nSampleIndex = SFX_GRAVEL_SKID; m_sQueueSample.m_nFrequency = 6000.f * ratio + 10000; @@ -351,11 +353,12 @@ cAudioManager::GetCollisionOneShotRatio(uint32 a, float b) case SURFACE_TARMAC: case SURFACE_PAVEMENT: case SURFACE_STEEP_CLIFF: - case SURFACE_TRANSPARENT_STONE: return GetCollisionRatio(b, 10.f, 60.f, 50.f); + case SURFACE_TRANSPARENT_STONE: + case SURFACE_CONCRETE_BEACH: return GetCollisionRatio(b, 10.f, 60.f, 50.f); case SURFACE_GRASS: - case SURFACE_CARDBOARDBOX: case SURFACE_GRAVEL: - case SURFACE_MUD_DRY: return GetCollisionRatio(b, 0.f, 2.f, 2.f); + case SURFACE_MUD_DRY: + case SURFACE_CARDBOARDBOX: return GetCollisionRatio(b, 0.f, 2.f, 2.f); case SURFACE_CAR: return GetCollisionRatio(b, 6.f, 50.f, 44.f); case SURFACE_GLASS: case SURFACE_METAL_CHAIN_FENCE: return GetCollisionRatio(b, 0.1f, 10.f, 9.9f); @@ -364,7 +367,7 @@ cAudioManager::GetCollisionOneShotRatio(uint32 a, float b) case SURFACE_GARAGE_DOOR: return GetCollisionRatio(b, 20.f, 100.f, 80.f); case SURFACE_CAR_PANEL: return GetCollisionRatio(b, 0.f, 4.f, 4.f); case SURFACE_SCAFFOLD_POLE: - case SURFACE_METAL_GATE: + case SURFACE_METAL_GATE: case SURFACE_LAMP_POST: return GetCollisionRatio(b, 1.f, 10.f, 9.f); case SURFACE_FIRE_HYDRANT: return GetCollisionRatio(b, 1.f, 15.f, 14.f); case SURFACE_GIRDER: return GetCollisionRatio(b, 8.f, 50.f, 42.f); @@ -372,7 +375,8 @@ cAudioManager::GetCollisionOneShotRatio(uint32 a, float b) case SURFACE_SAND: case SURFACE_WATER: case SURFACE_RUBBER: - case SURFACE_WHEELBASE: return GetCollisionRatio(b, 0.f, 10.f, 10.f); + case SURFACE_WHEELBASE: + case SURFACE_SAND_BEACH: return GetCollisionRatio(b, 0.f, 10.f, 10.f); case SURFACE_WOOD_CRATES: return GetCollisionRatio(b, 1.f, 4.f, 3.f); case SURFACE_WOOD_BENCH: return GetCollisionRatio(b, 0.1f, 5.f, 4.9f); case SURFACE_WOOD_SOLID: return GetCollisionRatio(b, 0.1f, 40.f, 39.9f); |