diff --git a/apps/openmw/mwsound/soundmanager.cpp b/apps/openmw/mwsound/soundmanager.cpp index 2440eda23..57bb0f56e 100644 --- a/apps/openmw/mwsound/soundmanager.cpp +++ b/apps/openmw/mwsound/soundmanager.cpp @@ -397,6 +397,7 @@ namespace MWSound snd->setVolume(volume); snd->setRange(min,max); snd->setPitch(pitch); + snd->setRelative(true); snd->play(); if (loop) diff --git a/libs/mangle/sound/clients/ogre_listener_mover.hpp b/libs/mangle/sound/clients/ogre_listener_mover.hpp index 739c08a13..74c21db32 100644 --- a/libs/mangle/sound/clients/ogre_listener_mover.hpp +++ b/libs/mangle/sound/clients/ogre_listener_mover.hpp @@ -52,9 +52,9 @@ namespace Sound { Ogre::Vector3 nPos, nDir, nUp; - nPos = camera->getPosition(); - nDir = camera->getDirection(); - nUp = camera->getUp(); + nPos = camera->getRealPosition(); + nDir = camera->getRealDirection(); + nUp = camera->getRealUp(); // Don't bother the sound system needlessly if(nDir != dir || nPos != pos || nUp != up) diff --git a/libs/mangle/sound/filters/pure_filter.hpp b/libs/mangle/sound/filters/pure_filter.hpp index 1e8b9f92c..fc5e62574 100644 --- a/libs/mangle/sound/filters/pure_filter.hpp +++ b/libs/mangle/sound/filters/pure_filter.hpp @@ -28,6 +28,7 @@ namespace Mangle void setRange(float a, float b=0, float c=0) { client->setRange(a,b,c); } void setStreaming(bool b) { client->setStreaming(b); } + void setRelative(bool b) { client->setRelative(b); } // The clone() function is not implemented here, as you will // almost certainly want to override it yourself diff --git a/libs/mangle/sound/output.hpp b/libs/mangle/sound/output.hpp index 9bbdebb2c..e30bf21e2 100644 --- a/libs/mangle/sound/output.hpp +++ b/libs/mangle/sound/output.hpp @@ -62,6 +62,9 @@ class Sound /// Set loop mode virtual void setRepeat(bool) = 0; + /// If set to true the sound will not be affected by player movement + virtual void setRelative(bool) = 0; + /// Set streaming mode. /** This may be used by implementations to optimize for very large files. If streaming mode is off (default), most implementations diff --git a/libs/mangle/sound/outputs/openal_out.cpp b/libs/mangle/sound/outputs/openal_out.cpp index f1cf39838..fb37e484e 100644 --- a/libs/mangle/sound/outputs/openal_out.cpp +++ b/libs/mangle/sound/outputs/openal_out.cpp @@ -197,6 +197,7 @@ class Mangle::Sound::OpenAL_Sound : public Sound void setPos(float x, float y, float z); void setPitch(float); void setRepeat(bool); + void setRelative(bool); void notifyOwnerDeath() { ownerAlive = false; } @@ -363,6 +364,12 @@ void OpenAL_Sound::setRepeat(bool rep) alSourcei(inst, AL_LOOPING, rep?AL_TRUE:AL_FALSE); } +void OpenAL_Sound::setRelative(bool rel) +{ + alSourcei(inst, AL_SOURCE_RELATIVE, rel?AL_TRUE:AL_FALSE); + checkALError("setting relative"); +} + SoundPtr OpenAL_Sound::clone() { setupBuffer();