forked from mirror/openmw-tes3mp
Store the current sound position with the Sound object
This commit is contained in:
parent
de102cd274
commit
71d9d7e943
2 changed files with 10 additions and 1 deletions
|
@ -1,6 +1,8 @@
|
|||
#ifndef GAME_SOUND_SOUND_H
|
||||
#define GAME_SOUND_SOUND_H
|
||||
|
||||
#include <OgreVector3.h>
|
||||
|
||||
namespace MWSound
|
||||
{
|
||||
class Sound
|
||||
|
@ -11,6 +13,7 @@ namespace MWSound
|
|||
Sound(const Sound &rhs);
|
||||
|
||||
protected:
|
||||
Ogre::Vector3 mPos;
|
||||
float mVolume; /* NOTE: Real volume = mVolume*mBaseVolume */
|
||||
float mBaseVolume;
|
||||
float mMinDistance;
|
||||
|
@ -21,7 +24,8 @@ namespace MWSound
|
|||
virtual bool isPlaying() = 0;
|
||||
virtual void setVolume(float volume) = 0;
|
||||
|
||||
Sound() : mVolume(1.0f)
|
||||
Sound() : mPos(0.0f, 0.0f, 0.0f)
|
||||
, mVolume(1.0f)
|
||||
, mBaseVolume(1.0f)
|
||||
, mMinDistance(20.0f) /* 1 * min_range_scale */
|
||||
, mMaxDistance(12750.0f) /* 255 * max_range_scale */
|
||||
|
|
|
@ -187,6 +187,7 @@ namespace MWSound
|
|||
|
||||
SoundPtr sound = mOutput->playSound3D(filePath, pos.pos, basevol, 1.0f,
|
||||
20.0f, 12750.0f, false);
|
||||
sound->mPos = Ogre::Vector3(pos.pos[0], pos.pos[1], pos.pos[2]);
|
||||
sound->mBaseVolume = basevol;
|
||||
|
||||
mActiveSounds[sound] = std::make_pair(ptr, std::string("_say_sound"));
|
||||
|
@ -241,6 +242,7 @@ namespace MWSound
|
|||
const ESM::Position &pos = ptr.getCellRef().pos;
|
||||
|
||||
sound = mOutput->playSound3D(file, pos.pos, volume*basevol, pitch, min, max, loop);
|
||||
sound->mPos = Ogre::Vector3(pos.pos[0], pos.pos[1], pos.pos[2]);
|
||||
sound->mVolume = volume;
|
||||
sound->mBaseVolume = basevol;
|
||||
sound->mMinDistance = min;
|
||||
|
@ -330,7 +332,10 @@ namespace MWSound
|
|||
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++;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue