From 50eaf092093a292941d5b3c816d514c217157125 Mon Sep 17 00:00:00 2001 From: milek7 Date: Thu, 5 Oct 2017 12:07:51 +0200 Subject: [PATCH] sound changes --- Gauge.cpp | 2 +- World.cpp | 19 ++++++++++--------- sound.cpp | 8 +++++--- 3 files changed, 16 insertions(+), 13 deletions(-) diff --git a/Gauge.cpp b/Gauge.cpp index 97327aa9..3339e581 100644 --- a/Gauge.cpp +++ b/Gauge.cpp @@ -339,7 +339,7 @@ void TGauge::play( sound *Sound ) auto pos = glm::vec3(glm::vec4(model_pos, 1.0f) * glm::inverse((glm::mat4)World.train()->Dynamic()->mMatrix)); pos += (glm::vec3)World.train()->Dynamic()->GetPosition(); - Sound->set_mode(sound::anchored).dist(1.5f).position(pos); + Sound->set_mode(sound::anchored).dist(3.0f).position(pos); } } diff --git a/World.cpp b/World.cpp index 015db2ae..20617628 100644 --- a/World.cpp +++ b/World.cpp @@ -1055,15 +1055,6 @@ bool TWorld::Update() Ground.Update_Hidden(); Ground.Update_Lights(); - { - glm::dmat4 cam_matrix; - Camera.SetMatrix(cam_matrix); - - glm::vec3 pos(Camera.Pos.x, Camera.Pos.y, Camera.Pos.z); - sound_man->set_listener(pos, glm::mat3(cam_matrix)); - sound_man->update(dt); - } - // render time routines follow: dt = Timer::GetDeltaRenderTime(); // nie uwzględnia pauzowania ani mnożenia czasu @@ -1094,6 +1085,16 @@ bool TWorld::Update() Update_Camera( dt ); + { + glm::dmat4 cam_matrix; + Camera.SetMatrix(cam_matrix); + + glm::vec3 pos(Camera.Pos.x, Camera.Pos.y, Camera.Pos.z); + sound_man->set_listener(pos, glm::mat3(cam_matrix)); + sound_man->update(Global::iPause ? 0.0f : dt); + } + + GfxRenderer.Update( dt ); ResourceSweep(); diff --git a/sound.cpp b/sound.cpp index 95f8c26b..652ecf3d 100644 --- a/sound.cpp +++ b/sound.cpp @@ -348,9 +348,11 @@ sound& sound::position(Math3D::vector3 const &pos) sound& sound::dist(float dist) { - alSourcef(id, AL_MAX_DISTANCE, dist); - alSourcef(id, AL_REFERENCE_DISTANCE, dist / 3.82f); - max_dist = dist * 1.5f; + max_dist = dist * 2.0f; + float half_dist = dist / 3.82f; + alSourcef(id, AL_REFERENCE_DISTANCE, half_dist / 1.32f); + alSourcef(id, AL_ROLLOFF_FACTOR, 3.0f); + alSourcef(id, AL_MAX_DISTANCE, max_dist); return *this; }