summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSergeanur <s.anureev@yandex.ua>2020-05-07 13:32:00 +0200
committerSergeanur <s.anureev@yandex.ua>2020-05-07 13:32:00 +0200
commit1ac6bea590aa07af40edd2cc2346f16f334096c5 (patch)
tree84d50d27b3d057f0160e304fec0a7849485cf41a
parentFixed arguments for sound collisions (diff)
downloadre3-1ac6bea590aa07af40edd2cc2346f16f334096c5.tar
re3-1ac6bea590aa07af40edd2cc2346f16f334096c5.tar.gz
re3-1ac6bea590aa07af40edd2cc2346f16f334096c5.tar.bz2
re3-1ac6bea590aa07af40edd2cc2346f16f334096c5.tar.lz
re3-1ac6bea590aa07af40edd2cc2346f16f334096c5.tar.xz
re3-1ac6bea590aa07af40edd2cc2346f16f334096c5.tar.zst
re3-1ac6bea590aa07af40edd2cc2346f16f334096c5.zip
Diffstat (limited to '')
-rw-r--r--src/audio/AudioCollision.cpp2
-rw-r--r--src/audio/AudioManager.cpp56
-rw-r--r--src/audio/AudioManager.h4
3 files changed, 32 insertions, 30 deletions
diff --git a/src/audio/AudioCollision.cpp b/src/audio/AudioCollision.cpp
index 28d7f3cd..4eb74388 100644
--- a/src/audio/AudioCollision.cpp
+++ b/src/audio/AudioCollision.cpp
@@ -410,7 +410,7 @@ cAudioManager::ReportCollision(CEntity *entity1, CEntity *entity2, uint8 surface
v2 = entity2->GetPosition();
}
CVector pos = (v1 + v2) * 0.5f;
- distSquared = GetDistanceSquared(&pos);
+ distSquared = GetDistanceSquared(pos);
if(distSquared < SQR(CollisionSoundIntensity)) {
m_sCollisionManager.m_sQueue.m_pEntity1 = entity1;
m_sCollisionManager.m_sQueue.m_pEntity2 = entity2;
diff --git a/src/audio/AudioManager.cpp b/src/audio/AudioManager.cpp
index 88152f94..be68d40f 100644
--- a/src/audio/AudioManager.cpp
+++ b/src/audio/AudioManager.cpp
@@ -2951,10 +2951,10 @@ cAudioManager::GetCurrent3DProviderIndex() const
}
float
-cAudioManager::GetDistanceSquared(CVector *v) const
+cAudioManager::GetDistanceSquared(const CVector &v) const
{
const CVector &c = TheCamera.GetPosition();
- return sq(v->x - c.x) + sq(v->y - c.y) + sq((v->z - c.z) * 0.2f);
+ return sq(v.x - c.x) + sq(v.y - c.y) + sq((v.z - c.z) * 0.2f);
}
int32
@@ -3747,7 +3747,7 @@ cAudioManager::ProcessAirportScriptObject(uint8 sound)
default:
return;
}
- float distSquared = GetDistanceSquared(&m_sQueueSample.m_vecPos);
+ float distSquared = GetDistanceSquared(m_sQueueSample.m_vecPos);
if (distSquared < SQR(m_sQueueSample.m_fSoundIntensity)) {
m_sQueueSample.m_fDistance = Sqrt(distSquared);
m_sQueueSample.m_nVolume = ComputeVolume(110, m_sQueueSample.m_fSoundIntensity, m_sQueueSample.m_fDistance);
@@ -3970,7 +3970,7 @@ cAudioManager::ProcessBridge()
if (CBridge::pLiftRoad) {
m_sQueueSample.m_vecPos = CBridge::pLiftRoad->GetPosition();
- dist = GetDistanceSquared(&m_sQueueSample.m_vecPos);
+ dist = GetDistanceSquared(m_sQueueSample.m_vecPos);
if (dist < 202500.0f) {
CalculateDistance(distCalculated, dist);
switch (CBridge::State) {
@@ -4206,7 +4206,7 @@ cAudioManager::ProcessCinemaScriptObject(uint8 sound)
default:
return;
}
- float distSquared = GetDistanceSquared(&m_sQueueSample.m_vecPos);
+ float distSquared = GetDistanceSquared(m_sQueueSample.m_vecPos);
if (distSquared < SQR(m_sQueueSample.m_fSoundIntensity)) {
m_sQueueSample.m_fDistance = Sqrt(distSquared);
rand = m_anRandomTable[0] % 90 + 30;
@@ -4246,7 +4246,7 @@ cAudioManager::ProcessCrane()
if (crane->m_nCraneStatus == CCrane::ACTIVATED) {
if (crane->m_nCraneState != CCrane::IDLE) {
m_sQueueSample.m_vecPos = crane->m_pCraneEntity->GetPosition();
- distSquared = GetDistanceSquared(&this->m_sQueueSample.m_vecPos);
+ distSquared = GetDistanceSquared(m_sQueueSample.m_vecPos);
if (distSquared < SQR(intensity)) {
CalculateDistance(distCalculated, distSquared);
m_sQueueSample.m_nVolume = ComputeVolume(100, 80.f, m_sQueueSample.m_fDistance);
@@ -4306,7 +4306,7 @@ cAudioManager::ProcessDocksScriptObject(uint8 sound)
default:
return;
}
- distSquared = GetDistanceSquared(&m_sQueueSample.m_vecPos);
+ distSquared = GetDistanceSquared(m_sQueueSample.m_vecPos);
if (distSquared < SQR(m_sQueueSample.m_fSoundIntensity)) {
m_sQueueSample.m_fDistance = Sqrt(distSquared);
rand = m_anRandomTable[0] % 60 + 40;
@@ -4510,7 +4510,7 @@ cAudioManager::ProcessExplosions(int32 explosion)
}
pos = CExplosion::GetExplosionPosition(i);
m_sQueueSample.m_vecPos = *pos;
- distSquared = GetDistanceSquared(&m_sQueueSample.m_vecPos);
+ distSquared = GetDistanceSquared(m_sQueueSample.m_vecPos);
if (distSquared < SQR(m_sQueueSample.m_fSoundIntensity)) {
m_sQueueSample.m_fDistance = Sqrt(distSquared);
m_sQueueSample.m_nVolume = ComputeVolume(maxVolume, m_sQueueSample.m_fSoundIntensity, m_sQueueSample.m_fDistance);
@@ -4541,7 +4541,7 @@ cAudioManager::ProcessFireHydrant()
static const int intensity = 35;
m_sQueueSample.m_vecPos = ((CEntity *)m_asAudioEntities[m_sQueueSample.m_nEntityIndex].m_pEntity)->GetPosition();
- distSquared = GetDistanceSquared(&m_sQueueSample.m_vecPos);
+ distSquared = GetDistanceSquared(m_sQueueSample.m_vecPos);
if (distSquared < SQR(intensity)) {
CalculateDistance(distCalculated, distSquared);
m_sQueueSample.m_nVolume = ComputeVolume(40, 35.f, m_sQueueSample.m_fDistance);
@@ -4611,7 +4611,7 @@ void cAudioManager::ProcessFires(int32)
m_sQueueSample.m_nReleasingVolumeModificator = 8;
}
m_sQueueSample.m_vecPos = gFireManager.m_aFires[i].m_vecPos;
- distSquared = GetDistanceSquared(&m_sQueueSample.m_vecPos);
+ distSquared = GetDistanceSquared(m_sQueueSample.m_vecPos);
if (distSquared < SQR(m_sQueueSample.m_fSoundIntensity)) {
m_sQueueSample.m_fDistance = Sqrt(distSquared);
m_sQueueSample.m_nVolume = ComputeVolume(emittingVol, m_sQueueSample.m_fSoundIntensity, m_sQueueSample.m_fDistance);
@@ -4875,7 +4875,7 @@ cAudioManager::ProcessGarages()
continue;
m_sQueueSample.m_vecPos = entity->GetPosition();
distCalculated = false;
- distSquared = GetDistanceSquared(&m_sQueueSample.m_vecPos);
+ distSquared = GetDistanceSquared(m_sQueueSample.m_vecPos);
if (distSquared < 6400.f) {
state = CGarages::aGarages[i].m_eGarageState;
if (state == GS_OPENING || state == GS_CLOSING || state == GS_AFTERDROPOFF) {
@@ -5021,7 +5021,7 @@ cAudioManager::ProcessHomeScriptObject(uint8 sound)
default:
return;
}
- dist = GetDistanceSquared(&m_sQueueSample.m_vecPos);
+ dist = GetDistanceSquared(m_sQueueSample.m_vecPos);
if (dist < SQR(m_sQueueSample.m_fSoundIntensity)) {
m_sQueueSample.m_fDistance = Sqrt(dist);
rand = m_anRandomTable[0] % 30 + 40;
@@ -5173,7 +5173,7 @@ cAudioManager::ProcessLaunderetteScriptObject(uint8 sound)
default:
return;
}
- float distSquared = GetDistanceSquared(&m_sQueueSample.m_vecPos);
+ float distSquared = GetDistanceSquared(m_sQueueSample.m_vecPos);
if (distSquared < SQR(m_sQueueSample.m_fSoundIntensity)) {
m_sQueueSample.m_fDistance = Sqrt(distSquared);
m_sQueueSample.m_nVolume = ComputeVolume(45, m_sQueueSample.m_fSoundIntensity, m_sQueueSample.m_fDistance);
@@ -5804,7 +5804,7 @@ cAudioManager::ProcessLoopingScriptObject(uint8 sound)
return;
}
- distSquared = GetDistanceSquared(&m_sQueueSample.m_vecPos);
+ distSquared = GetDistanceSquared(m_sQueueSample.m_vecPos);
if (distSquared < SQR(m_sQueueSample.m_fSoundIntensity)) {
m_sQueueSample.m_fDistance = Sqrt(distSquared);
m_sQueueSample.m_nVolume = ComputeVolume(emittingVolume, m_sQueueSample.m_fSoundIntensity, m_sQueueSample.m_fDistance);
@@ -5914,7 +5914,7 @@ cAudioManager::ProcessMissionAudio()
if (m_sMissionAudio.m_bPredefinedProperties) {
SampleManager.SetStreamedVolumeAndPan(80, 63, 1, 1);
} else {
- distSquared = GetDistanceSquared(&m_sMissionAudio.m_vecPos);
+ distSquared = GetDistanceSquared(m_sMissionAudio.m_vecPos);
if (distSquared >= 2500.f) {
emittingVol = 0;
pan = 63;
@@ -6017,14 +6017,14 @@ cAudioManager::ProcessOneShotScriptObject(uint8 sound)
case SCRIPT_SOUND_INJURED_PED_MALE_OUCH_L:
male.m_pPed = nil;
male.m_bDistanceCalculated = false;
- male.m_fDistance = GetDistanceSquared(&m_sQueueSample.m_vecPos);
+ male.m_fDistance = GetDistanceSquared(m_sQueueSample.m_vecPos);
SetupPedComments(&male, SOUND_INJURED_PED_MALE_OUCH);
return;
case SCRIPT_SOUND_INJURED_PED_FEMALE_OUCH_S:
case SCRIPT_SOUND_INJURED_PED_FEMALE_OUCH_L:
female.m_pPed = nil;
female.m_bDistanceCalculated = false;
- female.m_fDistance = GetDistanceSquared(&m_sQueueSample.m_vecPos);
+ female.m_fDistance = GetDistanceSquared(m_sQueueSample.m_vecPos);
SetupPedComments(&female, SOUND_INJURED_PED_FEMALE);
return;
case SCRIPT_SOUND_GATE_START_CLUNK:
@@ -6186,7 +6186,7 @@ cAudioManager::ProcessOneShotScriptObject(uint8 sound)
m_sQueueSample.m_fSpeedMultiplier = 0.0f;
m_sQueueSample.m_bIs2D = false;
emittingVolume = m_anRandomTable[2] % 20 + 30;
- distSquared = GetDistanceSquared(&m_sQueueSample.m_vecPos);
+ distSquared = GetDistanceSquared(m_sQueueSample.m_vecPos);
if (distSquared < SQR(m_sQueueSample.m_fSoundIntensity)) {
m_sQueueSample.m_fDistance = Sqrt(distSquared);
m_sQueueSample.m_nVolume = ComputeVolume(emittingVolume, m_sQueueSample.m_fSoundIntensity, m_sQueueSample.m_fDistance);
@@ -6231,7 +6231,7 @@ cAudioManager::ProcessOneShotScriptObject(uint8 sound)
return;
}
- distSquared = GetDistanceSquared(&m_sQueueSample.m_vecPos);
+ distSquared = GetDistanceSquared(m_sQueueSample.m_vecPos);
if (distSquared < SQR(m_sQueueSample.m_fSoundIntensity)) {
m_sQueueSample.m_fDistance = Sqrt(distSquared);
m_sQueueSample.m_nVolume = ComputeVolume(emittingVolume, m_sQueueSample.m_fSoundIntensity, m_sQueueSample.m_fDistance);
@@ -6261,7 +6261,7 @@ cAudioManager::ProcessPed(CPhysical *ped)
// params.m_bDistanceCalculated = false;
params.m_pPed = (CPed *)ped;
- params.m_fDistance = GetDistanceSquared(&m_sQueueSample.m_vecPos);
+ params.m_fDistance = GetDistanceSquared(m_sQueueSample.m_vecPos);
if (ped->GetModelIndex() == MI_FATMALE02)
ProcessPedHeadphones(&params);
ProcessPedOneShots(&params);
@@ -7458,7 +7458,7 @@ cAudioManager::ProcessPoliceCellBeatingScriptObject(uint8 sound)
default:
return;
}
- distSquared = GetDistanceSquared(&m_sQueueSample.m_vecPos);
+ distSquared = GetDistanceSquared(m_sQueueSample.m_vecPos);
if (distSquared < SQR(m_sQueueSample.m_fSoundIntensity)) {
m_sQueueSample.m_fDistance = Sqrt(distSquared);
if (m_FrameCounter & 1)
@@ -7545,7 +7545,7 @@ cAudioManager::ProcessPornCinema(uint8 sound)
default:
return;
}
- distSquared = GetDistanceSquared(&m_sQueueSample.m_vecPos);
+ distSquared = GetDistanceSquared(m_sQueueSample.m_vecPos);
if (distSquared < SQR(m_sQueueSample.m_fSoundIntensity)) {
m_sQueueSample.m_fDistance = Sqrt(distSquared);
if (sound != SCRIPT_SOUND_MISTY_SEX_S && sound != SCRIPT_SOUND_MISTY_SEX_L) {
@@ -7622,7 +7622,7 @@ cAudioManager::ProcessProjectiles()
m_sQueueSample.m_fSpeedMultiplier = 4.0f;
m_sQueueSample.m_nReleasingVolumeDivider = 3;
m_sQueueSample.m_vecPos = CProjectileInfo::ms_apProjectile[i]->GetPosition();
- float distSquared = GetDistanceSquared(&m_sQueueSample.m_vecPos);
+ float distSquared = GetDistanceSquared(m_sQueueSample.m_vecPos);
if (distSquared < SQR(m_sQueueSample.m_fSoundIntensity)) {
m_sQueueSample.m_fDistance = Sqrt(distSquared);
m_sQueueSample.m_nVolume = ComputeVolume(emittingVol, m_sQueueSample.m_fSoundIntensity, m_sQueueSample.m_fDistance);
@@ -7762,7 +7762,7 @@ cAudioManager::ProcessSawMillScriptObject(uint8 sound)
default:
return;
}
- distSquared = GetDistanceSquared(&m_sQueueSample.m_vecPos);
+ distSquared = GetDistanceSquared(m_sQueueSample.m_vecPos);
if (distSquared < SQR(m_sQueueSample.m_fSoundIntensity)) {
m_sQueueSample.m_fDistance = Sqrt(distSquared);
m_sQueueSample.m_nVolume = ComputeVolume(30, m_sQueueSample.m_fSoundIntensity, m_sQueueSample.m_fDistance);
@@ -7835,7 +7835,7 @@ cAudioManager::ProcessShopScriptObject(uint8 sound)
default:
return;
}
- distSquared = GetDistanceSquared(&m_sQueueSample.m_vecPos);
+ distSquared = GetDistanceSquared(m_sQueueSample.m_vecPos);
if (distSquared < SQR(m_sQueueSample.m_fSoundIntensity)) {
m_sQueueSample.m_fDistance = Sqrt(distSquared);
m_sQueueSample.m_nVolume = ComputeVolume(30, m_sQueueSample.m_fSoundIntensity, m_sQueueSample.m_fDistance);
@@ -7980,7 +7980,7 @@ cAudioManager::ProcessVehicle(CVehicle *veh)
m_sQueueSample.m_vecPos = veh->GetPosition();
params.m_bDistanceCalculated = false;
- params.m_fDistance = GetDistanceSquared(&m_sQueueSample.m_vecPos);
+ params.m_fDistance = GetDistanceSquared(m_sQueueSample.m_vecPos);
params.m_pVehicle = veh;
params.m_pTransmission = nil;
params.m_nIndex = 0;
@@ -8990,7 +8990,7 @@ void cAudioManager::ProcessWaterCannon(int32)
for (int32 i = 0; i < NUM_WATERCANNONS; i++) {
if (CWaterCannons::aCannons[i].m_nId) {
m_sQueueSample.m_vecPos = CWaterCannons::aCannons[0].m_avecPos[CWaterCannons::aCannons[i].m_nCur];
- float distSquared = GetDistanceSquared(&m_sQueueSample.m_vecPos);
+ float distSquared = GetDistanceSquared(m_sQueueSample.m_vecPos);
if (distSquared < SOUND_INTENSITY) {
m_sQueueSample.m_fDistance = Sqrt(distSquared);
m_sQueueSample.m_nVolume = ComputeVolume(50, m_sQueueSample.m_fSoundIntensity, m_sQueueSample.m_fDistance);
@@ -9136,7 +9136,7 @@ cAudioManager::ProcessWorkShopScriptObject(uint8 sound)
default:
return;
}
- distSquared = GetDistanceSquared(&m_sQueueSample.m_vecPos);
+ distSquared = GetDistanceSquared(m_sQueueSample.m_vecPos);
if (distSquared < SQR(m_sQueueSample.m_fSoundIntensity)) {
m_sQueueSample.m_fDistance = Sqrt(distSquared);
m_sQueueSample.m_nVolume = ComputeVolume(30, m_sQueueSample.m_fSoundIntensity, m_sQueueSample.m_fDistance);
diff --git a/src/audio/AudioManager.h b/src/audio/AudioManager.h
index 426ff613..0d0c5d91 100644
--- a/src/audio/AudioManager.h
+++ b/src/audio/AudioManager.h
@@ -317,7 +317,7 @@ public:
float GetCollisionLoopingRatio(uint32 a, uint32 b, float c) const; // not used
float GetCollisionOneShotRatio(int32 a, float b) const;
float GetCollisionRatio(float a, float b, float c, float d) const;
- float GetDistanceSquared(CVector *v) const;
+ float GetDistanceSquared(const CVector &v) const;
int32 GetJumboTaxiFreq() const;
bool GetMissionAudioLoadingStatus() const;
int8 GetMissionScriptPoliceAudioPlayingStatus() const;
@@ -468,6 +468,8 @@ public:
// only used in pc
void AdjustSamplesVolume();
uint8 ComputeEmittingVolume(uint8 emittingVolume, float intensity, float dist);
+
+ void DebugShit();
};
//dstatic_assert(sizeof(cAudioManager) == 19220, "cAudioManager: error");