From 7160d20db33f4b9e3d136dc613aa64a4c780412d Mon Sep 17 00:00:00 2001 From: Chris Robinson Date: Sat, 17 Mar 2012 10:36:34 -0700 Subject: [PATCH] Be more consistent with the vector orientations given the sound handler --- apps/openmw/mwsound/openal_output.cpp | 13 ++++++++----- apps/openmw/mwsound/openal_output.hpp | 4 ++-- apps/openmw/mwsound/sound_output.hpp | 5 ++--- apps/openmw/mwsound/soundmanager.cpp | 8 ++++++-- 4 files changed, 18 insertions(+), 12 deletions(-) diff --git a/apps/openmw/mwsound/openal_output.cpp b/apps/openmw/mwsound/openal_output.cpp index c8ed2ad8b1..0cff2303fd 100644 --- a/apps/openmw/mwsound/openal_output.cpp +++ b/apps/openmw/mwsound/openal_output.cpp @@ -368,7 +368,7 @@ Sound* OpenAL_Output::PlaySound(const std::string &fname, std::auto_ptr decoder, - MWWorld::Ptr ptr, float volume, float pitch, + const float *pos, float volume, float pitch, float min, float max, bool loop) { throwALerror(); @@ -393,7 +393,6 @@ Sound* OpenAL_Output::PlaySound3D(const std::string &fname, std::auto_ptr sound(new OpenAL_Sound(src, buf)); - const float *pos = ptr.getCellRef().pos.pos; alSource3f(src, AL_POSITION, pos[0], pos[2], -pos[1]); alSource3f(src, AL_DIRECTION, 0.0f, 0.0f, 0.0f); alSource3f(src, AL_VELOCITY, 0.0f, 0.0f, 0.0f); @@ -430,10 +429,14 @@ Sound* OpenAL_Output::StreamSound(const std::string &fname, std::auto_ptr decoder, float volume, float pitch, bool loop); virtual Sound *PlaySound3D(const std::string &fname, std::auto_ptr decoder, - MWWorld::Ptr ptr, float volume, float pitch, + const float *pos, float volume, float pitch, float min, float max, bool loop); virtual Sound *StreamSound(const std::string &fname, std::auto_ptr decoder, float volume, float pitch); - virtual void UpdateListener(float pos[3], float atdir[3], float updir[3]); + virtual void UpdateListener(const float *pos, const float *atdir, const float *updir); OpenAL_Output(SoundManager &mgr); virtual ~OpenAL_Output(); diff --git a/apps/openmw/mwsound/sound_output.hpp b/apps/openmw/mwsound/sound_output.hpp index 9c8d0303b3..c69247cc9d 100644 --- a/apps/openmw/mwsound/sound_output.hpp +++ b/apps/openmw/mwsound/sound_output.hpp @@ -22,13 +22,12 @@ namespace MWSound virtual Sound *PlaySound(const std::string &fname, std::auto_ptr decoder, float volume, float pitch, bool loop) = 0; virtual Sound *PlaySound3D(const std::string &fname, std::auto_ptr decoder, - MWWorld::Ptr ptr, float volume, float pitch, + const float *pos, float volume, float pitch, float min, float max, bool loop) = 0; virtual Sound *StreamSound(const std::string &fname, std::auto_ptr decoder, float volume, float pitch) = 0; - // FIXME: This should take an MWWorld::Ptr that represents the in-world camera - virtual void UpdateListener(float pos[3], float atdir[3], float updir[3]) = 0; + virtual void UpdateListener(const float *pos, const float *atdir, const float *updir) = 0; Sound_Output(SoundManager &mgr) : mgr(mgr) { } public: diff --git a/apps/openmw/mwsound/soundmanager.cpp b/apps/openmw/mwsound/soundmanager.cpp index 9f80a8e20f..af1cdf76df 100644 --- a/apps/openmw/mwsound/soundmanager.cpp +++ b/apps/openmw/mwsound/soundmanager.cpp @@ -125,8 +125,9 @@ namespace MWSound try { Sound *sound; + const float *pos = ptr.getCellRef().pos.pos; std::auto_ptr decoder(new DEFAULT_DECODER); - sound = Output->PlaySound3D(file, decoder, ptr, volume, pitch, min, max, loop); + sound = Output->PlaySound3D(file, decoder, pos, volume, pitch, min, max, loop); if(untracked) LooseSounds[id] = SoundPtr(sound); else @@ -444,7 +445,10 @@ namespace MWSound nDir = cam->getRealDirection(); nUp = cam->getRealUp(); - Output->UpdateListener(&nPos[0], &nDir[0], &nUp[0]); + float pos[3] = { nPos[0], -nPos[2], nPos[1] }; + float at[3] = { nDir[0], -nDir[2], nDir[1] }; + float up[3] = { nUp[0], -nUp[2], nUp[1] }; + Output->UpdateListener(pos, at, up); IDMap::iterator snditer = LooseSounds.begin();