mirror of
https://github.com/TES3MP/openmw-tes3mp.git
synced 2025-07-21 06:14:05 +00:00
Fix both relative and 3D sounds
This commit is contained in:
parent
97030c5dba
commit
836732096e
5 changed files with 15 additions and 3 deletions
|
@ -397,6 +397,7 @@ namespace MWSound
|
||||||
snd->setVolume(volume);
|
snd->setVolume(volume);
|
||||||
snd->setRange(min,max);
|
snd->setRange(min,max);
|
||||||
snd->setPitch(pitch);
|
snd->setPitch(pitch);
|
||||||
|
snd->setRelative(true);
|
||||||
snd->play();
|
snd->play();
|
||||||
|
|
||||||
if (loop)
|
if (loop)
|
||||||
|
|
|
@ -52,9 +52,9 @@ namespace Sound {
|
||||||
|
|
||||||
Ogre::Vector3 nPos, nDir, nUp;
|
Ogre::Vector3 nPos, nDir, nUp;
|
||||||
|
|
||||||
nPos = camera->getPosition();
|
nPos = camera->getRealPosition();
|
||||||
nDir = camera->getDirection();
|
nDir = camera->getRealDirection();
|
||||||
nUp = camera->getUp();
|
nUp = camera->getRealUp();
|
||||||
|
|
||||||
// Don't bother the sound system needlessly
|
// Don't bother the sound system needlessly
|
||||||
if(nDir != dir || nPos != pos || nUp != up)
|
if(nDir != dir || nPos != pos || nUp != up)
|
||||||
|
|
|
@ -28,6 +28,7 @@ namespace Mangle
|
||||||
void setRange(float a, float b=0, float c=0)
|
void setRange(float a, float b=0, float c=0)
|
||||||
{ client->setRange(a,b,c); }
|
{ client->setRange(a,b,c); }
|
||||||
void setStreaming(bool b) { client->setStreaming(b); }
|
void setStreaming(bool b) { client->setStreaming(b); }
|
||||||
|
void setRelative(bool b) { client->setRelative(b); }
|
||||||
|
|
||||||
// The clone() function is not implemented here, as you will
|
// The clone() function is not implemented here, as you will
|
||||||
// almost certainly want to override it yourself
|
// almost certainly want to override it yourself
|
||||||
|
|
|
@ -62,6 +62,9 @@ class Sound
|
||||||
/// Set loop mode
|
/// Set loop mode
|
||||||
virtual void setRepeat(bool) = 0;
|
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.
|
/// Set streaming mode.
|
||||||
/** This may be used by implementations to optimize for very large
|
/** This may be used by implementations to optimize for very large
|
||||||
files. If streaming mode is off (default), most implementations
|
files. If streaming mode is off (default), most implementations
|
||||||
|
|
|
@ -197,6 +197,7 @@ class Mangle::Sound::OpenAL_Sound : public Sound
|
||||||
void setPos(float x, float y, float z);
|
void setPos(float x, float y, float z);
|
||||||
void setPitch(float);
|
void setPitch(float);
|
||||||
void setRepeat(bool);
|
void setRepeat(bool);
|
||||||
|
void setRelative(bool);
|
||||||
|
|
||||||
void notifyOwnerDeath()
|
void notifyOwnerDeath()
|
||||||
{ ownerAlive = false; }
|
{ ownerAlive = false; }
|
||||||
|
@ -363,6 +364,12 @@ void OpenAL_Sound::setRepeat(bool rep)
|
||||||
alSourcei(inst, AL_LOOPING, rep?AL_TRUE:AL_FALSE);
|
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()
|
SoundPtr OpenAL_Sound::clone()
|
||||||
{
|
{
|
||||||
setupBuffer();
|
setupBuffer();
|
||||||
|
|
Loading…
Reference in a new issue