Sort AudioCollision functions into original order

This commit is contained in:
Sergeanur 2021-07-27 22:02:25 +03:00
parent c0488b3190
commit 782d38c6b7
3 changed files with 230 additions and 225 deletions

View File

@ -10,20 +10,39 @@
const int CollisionSoundIntensity = 60; const int CollisionSoundIntensity = 60;
cAudioCollisionManager::cAudioCollisionManager() void
cAudioManager::ReportCollision(CEntity *entity1, CEntity *entity2, uint8 surface1, uint8 surface2, float collisionPower,
float velocity)
{ {
m_sQueue.m_pEntity1 = nil; float distSquared;
m_sQueue.m_pEntity2 = nil; CVector v1;
m_sQueue.m_bSurface1 = SURFACE_DEFAULT; CVector v2;
m_sQueue.m_bSurface2 = SURFACE_DEFAULT;
m_sQueue.m_fIntensity2 = 0.0f;
m_sQueue.m_fIntensity1 = 0.0f;
m_sQueue.m_vecPosition = CVector(0.0f, 0.0f, 0.0f);
for (int i = 0; i < NUMAUDIOCOLLISIONS; i++) if(!m_bIsInitialised || m_nCollisionEntity < 0 || m_nUserPause ||
m_bIndicesTable[i] = NUMAUDIOCOLLISIONS; (velocity < 0.0016f && collisionPower < 0.01f))
return;
m_bCollisionsInQueue = 0; if(entity1->IsBuilding()) {
v1 = v2 = entity2->GetPosition();
} else if(entity2->IsBuilding()) {
v1 = v2 = entity1->GetPosition();
} else {
v1 = entity1->GetPosition();
v2 = entity2->GetPosition();
}
CVector pos = (v1 + v2) * 0.5f;
distSquared = GetDistanceSquared(pos);
if(distSquared < SQR(CollisionSoundIntensity)) {
m_sCollisionManager.m_sQueue.m_pEntity1 = entity1;
m_sCollisionManager.m_sQueue.m_pEntity2 = entity2;
m_sCollisionManager.m_sQueue.m_bSurface1 = surface1;
m_sCollisionManager.m_sQueue.m_bSurface2 = surface2;
m_sCollisionManager.m_sQueue.m_fIntensity1 = collisionPower;
m_sCollisionManager.m_sQueue.m_fIntensity2 = velocity;
m_sCollisionManager.m_sQueue.m_vecPosition = pos;
m_sCollisionManager.m_sQueue.m_fDistance = distSquared;
m_sCollisionManager.AddCollisionToRequestedQueue();
}
} }
void void
@ -55,135 +74,71 @@ cAudioCollisionManager::AddCollisionToRequestedQueue()
m_bIndicesTable[i] = collisionsIndex; m_bIndicesTable[i] = collisionsIndex;
} }
float
cAudioManager::GetCollisionLoopingRatio(uint32 a, uint32 b, float c) const
{
return GetCollisionRatio(c, 0.0f, 0.02f, 0.02f);
}
float
cAudioManager::GetCollisionOneShotRatio(int32 a, float b) const
{
float result;
switch(a) {
case SURFACE_DEFAULT:
case SURFACE_TARMAC:
case SURFACE_PAVEMENT:
case SURFACE_STEEP_CLIFF:
case SURFACE_TRANSPARENT_STONE:
case SURFACE_CONCRETE_BEACH: result = GetCollisionRatio(b, 10.f, 60.f, 50.f); break;
case SURFACE_GRASS:
case SURFACE_GRAVEL:
case SURFACE_MUD_DRY:
case SURFACE_CARDBOARDBOX: result = GetCollisionRatio(b, 0.f, 2.f, 2.f); break;
case SURFACE_CAR: result = GetCollisionRatio(b, 6.f, 50.f, 44.f); break;
case SURFACE_GLASS:
case SURFACE_METAL_CHAIN_FENCE: result = GetCollisionRatio(b, 0.1f, 10.f, 9.9f); break;
case SURFACE_TRANSPARENT_CLOTH:
case SURFACE_THICK_METAL_PLATE: result = GetCollisionRatio(b, 30.f, 130.f, 100.f); break;
case SURFACE_GARAGE_DOOR: result = GetCollisionRatio(b, 20.f, 100.f, 80.f); break;
case SURFACE_CAR_PANEL: result = GetCollisionRatio(b, 0.f, 4.f, 4.f); break;
case SURFACE_SCAFFOLD_POLE:
case SURFACE_METAL_GATE:
case SURFACE_LAMP_POST: result = GetCollisionRatio(b, 1.f, 10.f, 9.f); break;
case SURFACE_FIRE_HYDRANT: result = GetCollisionRatio(b, 1.f, 15.f, 14.f); break;
case SURFACE_GIRDER: result = GetCollisionRatio(b, 8.f, 50.f, 42.f); break;
case SURFACE_PED: result = GetCollisionRatio(b, 0.f, 20.f, 20.f); break;
case SURFACE_SAND:
case SURFACE_WATER:
case SURFACE_RUBBER:
case SURFACE_WHEELBASE:
case SURFACE_SAND_BEACH: result = GetCollisionRatio(b, 0.f, 10.f, 10.f); break;
case SURFACE_WOOD_CRATES: result = GetCollisionRatio(b, 1.f, 4.f, 3.f); break;
case SURFACE_WOOD_BENCH: result = GetCollisionRatio(b, 0.1f, 5.f, 4.9f); break;
case SURFACE_WOOD_SOLID: result = GetCollisionRatio(b, 0.1f, 40.f, 39.9f); break;
case SURFACE_PLASTIC: result = GetCollisionRatio(b, 0.1f, 4.f, 3.9f); break;
case SURFACE_HEDGE: result = GetCollisionRatio(b, 0.f, 0.5f, 0.5f); break;
case SURFACE_CONTAINER: result = GetCollisionRatio(b, 4.f, 40.f, 36.f); break;
case SURFACE_NEWS_VENDOR: result = GetCollisionRatio(b, 0.f, 5.f, 5.f); break;
default: result = 0.f; break;
}
return result;
}
float
cAudioManager::GetCollisionRatio(float a, float b, float c, float d) const
{
float e;
e = a;
if(a <= b) return 0.0f;
if(c <= a) e = c;
return (e - b) / d;
}
uint32
cAudioManager::SetLoopingCollisionRequestedSfxFreqAndGetVol(const cAudioCollision &audioCollision)
{
uint8 surface1 = audioCollision.m_bSurface1;
uint8 surface2 = audioCollision.m_bSurface2;
int32 vol;
float ratio;
if(surface1 == SURFACE_GRASS || surface2 == SURFACE_GRASS || surface1 == SURFACE_HEDGE ||
surface2 == SURFACE_HEDGE) {
ratio = GetCollisionRatio(audioCollision.m_fIntensity2, 0.0001f, 0.09f, 0.0899f);
m_sQueueSample.m_nSampleIndex = SFX_RAIN;
m_sQueueSample.m_nFrequency = 13000.f * ratio + 35000;
vol = 50.f * ratio;
} else if(surface1 == SURFACE_WATER || surface2 == SURFACE_WATER) {
ratio = GetCollisionRatio(audioCollision.m_fIntensity2, 0.0001f, 0.09f, 0.0899f);
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 || 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;
vol = 50.f * ratio;
} else if(surface1 == SURFACE_PED || surface2 == SURFACE_PED) {
return 0;
} else {
ratio = GetCollisionRatio(audioCollision.m_fIntensity2, 0.0001f, 0.09f, 0.0899f);
m_sQueueSample.m_nSampleIndex = SFX_SCRAPE_CAR_1;
m_sQueueSample.m_nFrequency = 10000.f * ratio + 10000;
vol = 40.f * ratio;
}
if(audioCollision.m_nBaseVolume < 2) vol = audioCollision.m_nBaseVolume * vol / 2;
return vol;
}
void void
cAudioManager::SetUpLoopingCollisionSound(const cAudioCollision &col, uint8 counter) cAudioManager::ServiceCollisions()
{ {
bool8 distCalculated = FALSE; int i, j;
if(col.m_fIntensity2 > 0.0016f) { bool8 abRepeatedCollision1[NUMAUDIOCOLLISIONS];
uint8 emittingVol = SetLoopingCollisionRequestedSfxFreqAndGetVol(col); bool8 abRepeatedCollision2[NUMAUDIOCOLLISIONS];
if(emittingVol) {
CalculateDistance(distCalculated, m_sQueueSample.m_fDistance); m_sQueueSample.m_nEntityIndex = m_nCollisionEntity;
m_sQueueSample.m_nVolume = ComputeVolume(emittingVol, CollisionSoundIntensity, m_sQueueSample.m_fDistance);
if(m_sQueueSample.m_nVolume) { for(int i = 0; i < NUMAUDIOCOLLISIONS; i++)
m_sQueueSample.m_nCounter = counter; abRepeatedCollision1[i] = abRepeatedCollision2[i] = FALSE;
m_sQueueSample.m_vecPos = col.m_vecPosition;
m_sQueueSample.m_nBankIndex = SFX_BANK_0; for(i = 0; i < m_sCollisionManager.m_bCollisionsInQueue; i++) {
m_sQueueSample.m_bIs2D = FALSE; for(j = 0; j < NUMAUDIOCOLLISIONS; j++) {
m_sQueueSample.m_nReleasingVolumeModificator = 7; int index = m_sCollisionManager.m_bIndicesTable[i];
m_sQueueSample.m_nLoopCount = 0; if ((m_sCollisionManager.m_asCollisions1[index].m_pEntity1 == m_sCollisionManager.m_asCollisions2[j].m_pEntity1)
m_sQueueSample.m_nEmittingVolume = emittingVol; && (m_sCollisionManager.m_asCollisions1[index].m_pEntity2 == m_sCollisionManager.m_asCollisions2[j].m_pEntity2)
SET_LOOP_OFFSETS(m_sQueueSample.m_nSampleIndex) && (m_sCollisionManager.m_asCollisions1[index].m_bSurface1 == m_sCollisionManager.m_asCollisions2[j].m_bSurface1)
m_sQueueSample.m_fSpeedMultiplier = 4.0f; && (m_sCollisionManager.m_asCollisions1[index].m_bSurface2 == m_sCollisionManager.m_asCollisions2[j].m_bSurface2)
m_sQueueSample.m_fSoundIntensity = CollisionSoundIntensity; ) {
m_sQueueSample.m_bReleasingSoundFlag = FALSE; abRepeatedCollision1[index] = TRUE;
m_sQueueSample.m_nReleasingVolumeDivider = 5; abRepeatedCollision2[j] = TRUE;
m_sQueueSample.m_bReverbFlag = TRUE; m_sCollisionManager.m_asCollisions1[index].m_nBaseVolume = ++m_sCollisionManager.m_asCollisions2[j].m_nBaseVolume;
m_sQueueSample.m_bRequireReflection = FALSE; SetUpLoopingCollisionSound(m_sCollisionManager.m_asCollisions1[index], j);
AddSampleToRequestedQueue(); break;
} }
} }
} }
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;
m_sCollisionManager.m_asCollisions2[i].m_bSurface2 = SURFACE_DEFAULT;
m_sCollisionManager.m_asCollisions2[i].m_fIntensity2 = 0.0f;
m_sCollisionManager.m_asCollisions2[i].m_fIntensity1 = 0.0f;
m_sCollisionManager.m_asCollisions2[i].m_vecPosition = CVector(0.0f, 0.0f, 0.0f);
m_sCollisionManager.m_asCollisions2[i].m_fDistance = 0.0f;
}
}
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]) {
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;
m_sCollisionManager.m_asCollisions2[j].m_bSurface1 = m_sCollisionManager.m_asCollisions1[index].m_bSurface1;
m_sCollisionManager.m_asCollisions2[j].m_bSurface2 = m_sCollisionManager.m_asCollisions1[index].m_bSurface2;
break;
}
}
SetUpOneShotCollisionSound(m_sCollisionManager.m_asCollisions1[index]);
SetUpLoopingCollisionSound(m_sCollisionManager.m_asCollisions1[index], j);
}
}
for(int i = 0; i < NUMAUDIOCOLLISIONS; i++)
m_sCollisionManager.m_bIndicesTable[i] = NUMAUDIOCOLLISIONS;
m_sCollisionManager.m_bCollisionsInQueue = 0;
} }
static const int32 gOneShotCol[] = {SFX_COL_TARMAC_1, static const int32 gOneShotCol[] = {SFX_COL_TARMAC_1,
SFX_COL_TARMAC_1, SFX_COL_TARMAC_1,
SFX_COL_GRASS_1, SFX_COL_GRASS_1,
@ -325,100 +280,131 @@ cAudioManager::SetUpOneShotCollisionSound(const cAudioCollision &col)
} }
void void
cAudioManager::ServiceCollisions() cAudioManager::SetUpLoopingCollisionSound(const cAudioCollision &col, uint8 counter)
{ {
int i, j; bool8 distCalculated = FALSE;
bool8 abRepeatedCollision1[NUMAUDIOCOLLISIONS]; if(col.m_fIntensity2 > 0.0016f) {
bool8 abRepeatedCollision2[NUMAUDIOCOLLISIONS]; uint8 emittingVol = SetLoopingCollisionRequestedSfxFreqAndGetVol(col);
if(emittingVol) {
m_sQueueSample.m_nEntityIndex = m_nCollisionEntity; CalculateDistance(distCalculated, m_sQueueSample.m_fDistance);
m_sQueueSample.m_nVolume = ComputeVolume(emittingVol, CollisionSoundIntensity, m_sQueueSample.m_fDistance);
for (int i = 0; i < NUMAUDIOCOLLISIONS; i++) abRepeatedCollision1[i] = abRepeatedCollision2[i] = FALSE; if(m_sQueueSample.m_nVolume) {
m_sQueueSample.m_nCounter = counter;
for (i = 0; i < m_sCollisionManager.m_bCollisionsInQueue; i++) { m_sQueueSample.m_vecPos = col.m_vecPosition;
for (j = 0; j < NUMAUDIOCOLLISIONS; j++) { m_sQueueSample.m_nBankIndex = SFX_BANK_0;
int index = m_sCollisionManager.m_bIndicesTable[i]; m_sQueueSample.m_bIs2D = FALSE;
if ((m_sCollisionManager.m_asCollisions1[index].m_pEntity1 == m_sCollisionManager.m_asCollisions2[j].m_pEntity1) m_sQueueSample.m_nReleasingVolumeModificator = 7;
&& (m_sCollisionManager.m_asCollisions1[index].m_pEntity2 == m_sCollisionManager.m_asCollisions2[j].m_pEntity2) m_sQueueSample.m_nLoopCount = 0;
&& (m_sCollisionManager.m_asCollisions1[index].m_bSurface1 == m_sCollisionManager.m_asCollisions2[j].m_bSurface1) m_sQueueSample.m_nEmittingVolume = emittingVol;
&& (m_sCollisionManager.m_asCollisions1[index].m_bSurface2 == m_sCollisionManager.m_asCollisions2[j].m_bSurface2) SET_LOOP_OFFSETS(m_sQueueSample.m_nSampleIndex)
) { m_sQueueSample.m_fSpeedMultiplier = 4.0f;
abRepeatedCollision1[index] = TRUE; m_sQueueSample.m_fSoundIntensity = CollisionSoundIntensity;
abRepeatedCollision2[j] = TRUE; m_sQueueSample.m_bReleasingSoundFlag = FALSE;
m_sCollisionManager.m_asCollisions1[index].m_nBaseVolume = ++m_sCollisionManager.m_asCollisions2[j].m_nBaseVolume; m_sQueueSample.m_nReleasingVolumeDivider = 5;
SetUpLoopingCollisionSound(m_sCollisionManager.m_asCollisions1[index], j); m_sQueueSample.m_bReverbFlag = TRUE;
break; m_sQueueSample.m_bRequireReflection = FALSE;
AddSampleToRequestedQueue();
} }
} }
} }
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;
m_sCollisionManager.m_asCollisions2[i].m_bSurface2 = SURFACE_DEFAULT;
m_sCollisionManager.m_asCollisions2[i].m_fIntensity2 = 0.0f;
m_sCollisionManager.m_asCollisions2[i].m_fIntensity1 = 0.0f;
m_sCollisionManager.m_asCollisions2[i].m_vecPosition = CVector(0.0f, 0.0f, 0.0f);
m_sCollisionManager.m_asCollisions2[i].m_fDistance = 0.0f;
}
}
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]) {
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;
m_sCollisionManager.m_asCollisions2[j].m_bSurface1 = m_sCollisionManager.m_asCollisions1[index].m_bSurface1;
m_sCollisionManager.m_asCollisions2[j].m_bSurface2 = m_sCollisionManager.m_asCollisions1[index].m_bSurface2;
break;
}
}
SetUpOneShotCollisionSound(m_sCollisionManager.m_asCollisions1[index]);
SetUpLoopingCollisionSound(m_sCollisionManager.m_asCollisions1[index], j);
}
}
for (int i = 0; i < NUMAUDIOCOLLISIONS; i++)
m_sCollisionManager.m_bIndicesTable[i] = NUMAUDIOCOLLISIONS;
m_sCollisionManager.m_bCollisionsInQueue = 0;
} }
void uint32
cAudioManager::ReportCollision(CEntity *entity1, CEntity *entity2, uint8 surface1, uint8 surface2, float collisionPower, cAudioManager::SetLoopingCollisionRequestedSfxFreqAndGetVol(const cAudioCollision &audioCollision)
float velocity)
{ {
float distSquared; uint8 surface1 = audioCollision.m_bSurface1;
CVector v1; uint8 surface2 = audioCollision.m_bSurface2;
CVector v2; int32 vol;
float ratio;
if(!m_bIsInitialised || m_nCollisionEntity < 0 || m_nUserPause || if(surface1 == SURFACE_GRASS || surface2 == SURFACE_GRASS || surface1 == SURFACE_HEDGE ||
(velocity < 0.0016f && collisionPower < 0.01f)) surface2 == SURFACE_HEDGE) {
return; ratio = GetCollisionRatio(audioCollision.m_fIntensity2, 0.0001f, 0.09f, 0.0899f);
m_sQueueSample.m_nSampleIndex = SFX_RAIN;
if(entity1->IsBuilding()) { m_sQueueSample.m_nFrequency = 13000.f * ratio + 35000;
v1 = v2 = entity2->GetPosition(); vol = 50.f * ratio;
} else if(entity2->IsBuilding()) { } else if(surface1 == SURFACE_WATER || surface2 == SURFACE_WATER) {
v1 = v2 = entity1->GetPosition(); ratio = GetCollisionRatio(audioCollision.m_fIntensity2, 0.0001f, 0.09f, 0.0899f);
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 || 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;
vol = 50.f * ratio;
} else if(surface1 == SURFACE_PED || surface2 == SURFACE_PED) {
return 0;
} else { } else {
v1 = entity1->GetPosition(); ratio = GetCollisionRatio(audioCollision.m_fIntensity2, 0.0001f, 0.09f, 0.0899f);
v2 = entity2->GetPosition(); m_sQueueSample.m_nSampleIndex = SFX_SCRAPE_CAR_1;
} m_sQueueSample.m_nFrequency = 10000.f * ratio + 10000;
CVector pos = (v1 + v2) * 0.5f; vol = 40.f * ratio;
distSquared = GetDistanceSquared(pos);
if(distSquared < SQR(CollisionSoundIntensity)) {
m_sCollisionManager.m_sQueue.m_pEntity1 = entity1;
m_sCollisionManager.m_sQueue.m_pEntity2 = entity2;
m_sCollisionManager.m_sQueue.m_bSurface1 = surface1;
m_sCollisionManager.m_sQueue.m_bSurface2 = surface2;
m_sCollisionManager.m_sQueue.m_fIntensity1 = collisionPower;
m_sCollisionManager.m_sQueue.m_fIntensity2 = velocity;
m_sCollisionManager.m_sQueue.m_vecPosition = pos;
m_sCollisionManager.m_sQueue.m_fDistance = distSquared;
m_sCollisionManager.AddCollisionToRequestedQueue();
} }
if(audioCollision.m_nBaseVolume < 2) vol = audioCollision.m_nBaseVolume * vol / 2;
return vol;
}
float
cAudioManager::GetCollisionOneShotRatio(int32 a, float b)
{
float result;
switch(a) {
case SURFACE_DEFAULT:
case SURFACE_TARMAC:
case SURFACE_PAVEMENT:
case SURFACE_STEEP_CLIFF:
case SURFACE_TRANSPARENT_STONE:
case SURFACE_CONCRETE_BEACH: return GetCollisionRatio(b, 10.f, 60.f, 50.f);
case SURFACE_GRASS:
case SURFACE_GRAVEL:
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);
case SURFACE_TRANSPARENT_CLOTH:
case SURFACE_THICK_METAL_PLATE: return GetCollisionRatio(b, 30.f, 130.f, 100.f);
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_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);
case SURFACE_PED: return GetCollisionRatio(b, 0.f, 20.f, 20.f);
case SURFACE_SAND:
case SURFACE_WATER:
case SURFACE_RUBBER:
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);
case SURFACE_PLASTIC: return GetCollisionRatio(b, 0.1f, 4.f, 3.9f);
case SURFACE_HEDGE: return GetCollisionRatio(b, 0.f, 0.5f, 0.5f);
case SURFACE_CONTAINER: return GetCollisionRatio(b, 4.f, 40.f, 36.f);
case SURFACE_NEWS_VENDOR: return GetCollisionRatio(b, 0.f, 5.f, 5.f);
default: break;
}
return 0.f;
}
float
cAudioManager::GetCollisionLoopingRatio(uint32 a, uint32 b, float c)
{
return GetCollisionRatio(c, 0.0f, 0.02f, 0.02f);
}
float
cAudioManager::GetCollisionRatio(float a, float b, float c, float d)
{
float e;
e = a;
if(a <= b) return 0.0f;
if(c <= a) e = c;
return (e - b) / d;
} }

View File

@ -17,7 +17,18 @@ public:
float m_fDistance; float m_fDistance;
int32 m_nBaseVolume; int32 m_nBaseVolume;
// no methods cAudioCollision() { Reset(); }
void Reset()
{
m_pEntity1 = nil;
m_pEntity2 = nil;
m_bSurface1 = 0;
m_bSurface2 = 0;
m_fIntensity1 = m_fIntensity2 = 0.0f;
m_vecPosition = CVector(0.0f, 0.0f, 0.0f);
m_fDistance = 0.0f;
}
}; };
VALIDATE_SIZE(cAudioCollision, 40); VALIDATE_SIZE(cAudioCollision, 40);
@ -31,7 +42,15 @@ public:
uint8 m_bCollisionsInQueue; uint8 m_bCollisionsInQueue;
cAudioCollision m_sQueue; cAudioCollision m_sQueue;
cAudioCollisionManager(); cAudioCollisionManager()
{
m_sQueue.Reset();
for(int i = 0; i < NUMAUDIOCOLLISIONS; i++)
m_bIndicesTable[i] = NUMAUDIOCOLLISIONS;
m_bCollisionsInQueue = 0;
}
void AddCollisionToRequestedQueue(); void AddCollisionToRequestedQueue();
}; };

View File

@ -384,9 +384,9 @@ public:
char GetCDAudioDriveLetter() const; char GetCDAudioDriveLetter() const;
int8 GetCurrent3DProviderIndex() const; int8 GetCurrent3DProviderIndex() const;
int8 AutoDetect3DProviders() const; int8 AutoDetect3DProviders() const;
float GetCollisionLoopingRatio(uint32 a, uint32 b, float c) const; // not used float GetCollisionLoopingRatio(uint32 a, uint32 b, float c); // not used
float GetCollisionOneShotRatio(int32 a, float b) const; float GetCollisionOneShotRatio(int32 a, float b);
float GetCollisionRatio(float a, float b, float c, float d) const; // inlined in vc float GetCollisionRatio(float a, float b, float c, float d); // inlined in vc
float GetDistanceSquared(const CVector &v) const; // inlined in vc float GetDistanceSquared(const CVector &v) const; // inlined in vc
int32 GetJumboTaxiFreq() const; // inlined in vc int32 GetJumboTaxiFreq() const; // inlined in vc
uint8 GetMissionAudioLoadingStatus(uint8 slot) const; uint8 GetMissionAudioLoadingStatus(uint8 slot) const;