Update the actual sound position after the listener

actorid
Chris Robinson 13 years ago
parent 71d9d7e943
commit 479df78ea1

@ -90,7 +90,7 @@ public:
virtual void stop();
virtual bool isPlaying();
virtual void setVolume(float volume);
virtual void update(const float *pos);
virtual void update();
void play();
bool process();
@ -262,9 +262,9 @@ void OpenAL_SoundStream::setVolume(float volume)
mVolume = volume;
}
void OpenAL_SoundStream::update(const float *pos)
void OpenAL_SoundStream::update()
{
alSource3f(mSource, AL_POSITION, pos[0], pos[2], -pos[1]);
alSource3f(mSource, AL_POSITION, mPos[0], mPos[2], -mPos[1]);
alSource3f(mSource, AL_DIRECTION, 0.0f, 0.0f, 0.0f);
alSource3f(mSource, AL_VELOCITY, 0.0f, 0.0f, 0.0f);
throwALerror();
@ -340,7 +340,7 @@ public:
virtual void stop();
virtual bool isPlaying();
virtual void setVolume(float volume);
virtual void update(const float *pos);
virtual void update();
};
OpenAL_Sound::OpenAL_Sound(OpenAL_Output &output, ALuint src, ALuint buf)
@ -379,9 +379,9 @@ void OpenAL_Sound::setVolume(float volume)
mVolume = volume;
}
void OpenAL_Sound::update(const float *pos)
void OpenAL_Sound::update()
{
alSource3f(mSource, AL_POSITION, pos[0], pos[2], -pos[1]);
alSource3f(mSource, AL_POSITION, mPos[0], mPos[2], -mPos[1]);
alSource3f(mSource, AL_DIRECTION, 0.0f, 0.0f, 0.0f);
alSource3f(mSource, AL_VELOCITY, 0.0f, 0.0f, 0.0f);
throwALerror();

@ -7,7 +7,7 @@ namespace MWSound
{
class Sound
{
virtual void update(const float *pos) = 0;
virtual void update() = 0;
Sound& operator=(const Sound &rhs);
Sound(const Sound &rhs);

@ -328,14 +328,12 @@ namespace MWSound
void SoundManager::updateObject(MWWorld::Ptr ptr)
{
const ESM::Position &pos = ptr.getCellRef().pos;
const Ogre::Vector3 objpos(pos.pos[0], pos.pos[1], pos.pos[2]);
SoundMap::iterator snditer = mActiveSounds.begin();
while(snditer != mActiveSounds.end())
{
if(snditer->second.first == ptr)
{
snditer->first->update(pos.pos);
snditer->first->mPos = Ogre::Vector3(pos.pos[0], pos.pos[1], pos.pos[2]);
}
snditer->first->mPos = objpos;
snditer++;
}
}
@ -428,7 +426,10 @@ namespace MWSound
if(!snditer->first->isPlaying())
mActiveSounds.erase(snditer++);
else
{
snditer->first->update();
snditer++;
}
}
}

Loading…
Cancel
Save