mirror of
https://github.com/TES3MP/openmw-tes3mp.git
synced 2025-01-19 21:23:52 +00:00
Update the actual sound position after the listener
This commit is contained in:
parent
71d9d7e943
commit
479df78ea1
3 changed files with 12 additions and 11 deletions
|
@ -90,7 +90,7 @@ public:
|
||||||
virtual void stop();
|
virtual void stop();
|
||||||
virtual bool isPlaying();
|
virtual bool isPlaying();
|
||||||
virtual void setVolume(float volume);
|
virtual void setVolume(float volume);
|
||||||
virtual void update(const float *pos);
|
virtual void update();
|
||||||
|
|
||||||
void play();
|
void play();
|
||||||
bool process();
|
bool process();
|
||||||
|
@ -262,9 +262,9 @@ void OpenAL_SoundStream::setVolume(float volume)
|
||||||
mVolume = 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_DIRECTION, 0.0f, 0.0f, 0.0f);
|
||||||
alSource3f(mSource, AL_VELOCITY, 0.0f, 0.0f, 0.0f);
|
alSource3f(mSource, AL_VELOCITY, 0.0f, 0.0f, 0.0f);
|
||||||
throwALerror();
|
throwALerror();
|
||||||
|
@ -340,7 +340,7 @@ public:
|
||||||
virtual void stop();
|
virtual void stop();
|
||||||
virtual bool isPlaying();
|
virtual bool isPlaying();
|
||||||
virtual void setVolume(float volume);
|
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)
|
OpenAL_Sound::OpenAL_Sound(OpenAL_Output &output, ALuint src, ALuint buf)
|
||||||
|
@ -379,9 +379,9 @@ void OpenAL_Sound::setVolume(float volume)
|
||||||
mVolume = 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_DIRECTION, 0.0f, 0.0f, 0.0f);
|
||||||
alSource3f(mSource, AL_VELOCITY, 0.0f, 0.0f, 0.0f);
|
alSource3f(mSource, AL_VELOCITY, 0.0f, 0.0f, 0.0f);
|
||||||
throwALerror();
|
throwALerror();
|
||||||
|
|
|
@ -7,7 +7,7 @@ namespace MWSound
|
||||||
{
|
{
|
||||||
class Sound
|
class Sound
|
||||||
{
|
{
|
||||||
virtual void update(const float *pos) = 0;
|
virtual void update() = 0;
|
||||||
|
|
||||||
Sound& operator=(const Sound &rhs);
|
Sound& operator=(const Sound &rhs);
|
||||||
Sound(const Sound &rhs);
|
Sound(const Sound &rhs);
|
||||||
|
|
|
@ -328,14 +328,12 @@ namespace MWSound
|
||||||
void SoundManager::updateObject(MWWorld::Ptr ptr)
|
void SoundManager::updateObject(MWWorld::Ptr ptr)
|
||||||
{
|
{
|
||||||
const ESM::Position &pos = ptr.getCellRef().pos;
|
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();
|
SoundMap::iterator snditer = mActiveSounds.begin();
|
||||||
while(snditer != mActiveSounds.end())
|
while(snditer != mActiveSounds.end())
|
||||||
{
|
{
|
||||||
if(snditer->second.first == ptr)
|
if(snditer->second.first == ptr)
|
||||||
{
|
snditer->first->mPos = objpos;
|
||||||
snditer->first->update(pos.pos);
|
|
||||||
snditer->first->mPos = Ogre::Vector3(pos.pos[0], pos.pos[1], pos.pos[2]);
|
|
||||||
}
|
|
||||||
snditer++;
|
snditer++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -428,7 +426,10 @@ namespace MWSound
|
||||||
if(!snditer->first->isPlaying())
|
if(!snditer->first->isPlaying())
|
||||||
mActiveSounds.erase(snditer++);
|
mActiveSounds.erase(snditer++);
|
||||||
else
|
else
|
||||||
|
{
|
||||||
|
snditer->first->update();
|
||||||
snditer++;
|
snditer++;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue