From a46f8ced05c519a6d6b921ae3eb1ca12385c6583 Mon Sep 17 00:00:00 2001 From: Chris Robinson Date: Sat, 17 Mar 2012 06:18:59 -0700 Subject: [PATCH] Keep the sound output's listener updated with the camera position --- apps/openmw/mwsound/openal_output.cpp | 7 ++----- apps/openmw/mwsound/soundmanager.cpp | 23 ++++++++++++++++++++++- apps/openmw/mwsound/soundmanager.hpp | 1 + 3 files changed, 25 insertions(+), 6 deletions(-) diff --git a/apps/openmw/mwsound/openal_output.cpp b/apps/openmw/mwsound/openal_output.cpp index 1a02dc258f..2dbe4baad1 100644 --- a/apps/openmw/mwsound/openal_output.cpp +++ b/apps/openmw/mwsound/openal_output.cpp @@ -245,11 +245,8 @@ Sound* OpenAL_Output::StreamSound(const std::string &fname, std::auto_ptrgetPlayer().getPlayer().getCell(); static int total = 0; @@ -363,4 +363,25 @@ namespace MWSound pos += chance; } } + + void SoundManager::update(float duration) + { + static float timePassed = 0.0; + + timePassed += duration; + if(timePassed > (1.0f/30.0f)) + { + timePassed = 0.0f; + Ogre::Camera *cam = mEnvironment.mWorld->getPlayer().getRenderer()->getCamera(); + + Ogre::Vector3 nPos, nDir, nUp; + nPos = cam->getRealPosition(); + nDir = cam->getRealDirection(); + nUp = cam->getRealUp(); + + Output->UpdateListener(&nPos[0], &nDir[0], &nUp[0]); + } + + updateRegionSound(duration); + } } diff --git a/apps/openmw/mwsound/soundmanager.hpp b/apps/openmw/mwsound/soundmanager.hpp index 709ab2817d..b31e1db7f1 100644 --- a/apps/openmw/mwsound/soundmanager.hpp +++ b/apps/openmw/mwsound/soundmanager.hpp @@ -62,6 +62,7 @@ namespace MWSound bool isPlaying(MWWorld::Ptr ptr, const std::string &id) const; void removeCell(const MWWorld::Ptr::CellStore *cell); void updatePositions(MWWorld::Ptr ptr); + void updateRegionSound(float duration); public: SoundManager(Ogre::Root*, Ogre::Camera*,