From 2e1a629cb4ff793e6cdfe2eaa214374406f9507a Mon Sep 17 00:00:00 2001 From: Vsevolod Kremianskii Date: Wed, 13 Jan 2021 00:49:02 +0700 Subject: [PATCH] fix: Use party leader, not camera, position when toggling sounds --- src/game/object/area.cpp | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/src/game/object/area.cpp b/src/game/object/area.cpp index 4dea5c2f..2e67314d 100644 --- a/src/game/object/area.cpp +++ b/src/game/object/area.cpp @@ -805,11 +805,21 @@ void Area::updateVisibility() { } void Area::updateSounds() { - Camera *camera = _game->getActiveCamera(); - if (!camera) return; + glm::vec3 refPosition; + + shared_ptr partyLeader(_game->party().leader()); + if (partyLeader) { + refPosition = partyLeader->position(); + } else { + Camera *camera = _game->getActiveCamera(); + if (camera) { + refPosition = camera->sceneNode()->absoluteTransform()[3]; + } else { + return; + } + } vector> soundDistances; - glm::vec3 cameraPosition(camera->sceneNode()->absoluteTransform()[3]); for (auto &sound : _objectsByType[ObjectType::Sound]) { Sound *soundPtr = static_cast(sound.get()); @@ -819,7 +829,7 @@ void Area::updateSounds() { float maxDist = soundPtr->maxDistance(); - float dist = soundPtr->distanceTo(cameraPosition); + float dist = soundPtr->distanceTo(refPosition); if (dist > maxDist) continue; soundDistances.push_back(make_pair(soundPtr, dist));