1
0
Fork 1
mirror of https://github.com/TES3MP/openmw-tes3mp.git synced 2025-01-20 03:53:52 +00:00

Track whether a sound is 3D

This commit is contained in:
Chris Robinson 2015-11-26 09:33:16 -08:00
parent fc912b135f
commit 8b7587f9a6
3 changed files with 12 additions and 4 deletions

View file

@ -43,6 +43,7 @@ namespace MWSound
MWBase::SoundManager::PlayType getPlayType() const MWBase::SoundManager::PlayType getPlayType() const
{ return (MWBase::SoundManager::PlayType)(mFlags&MWBase::SoundManager::Play_TypeMask); } { return (MWBase::SoundManager::PlayType)(mFlags&MWBase::SoundManager::Play_TypeMask); }
bool getDistanceCull() const { return mFlags&MWBase::SoundManager::Play_RemoveAtDistance; } bool getDistanceCull() const { return mFlags&MWBase::SoundManager::Play_RemoveAtDistance; }
bool getIs3D() const { return mFlags&Play_3D; }
Sound(const osg::Vec3f& pos, float vol, float basevol, float pitch, float mindist, float maxdist, int flags) Sound(const osg::Vec3f& pos, float vol, float basevol, float pitch, float mindist, float maxdist, int flags)
: mPos(pos) : mPos(pos)

View file

@ -483,7 +483,7 @@ namespace MWSound
float basevol = volumeFromType(type); float basevol = volumeFromType(type);
sound = mOutput->playSound(sfx->mHandle, sound = mOutput->playSound(sfx->mHandle,
volume * sfx->mVolume, basevol, pitch, mode|type, offset volume * sfx->mVolume, basevol, pitch, mode|type|Play_2D, offset
); );
if(sfx->mUses++ == 0) if(sfx->mUses++ == 0)
{ {
@ -518,7 +518,8 @@ namespace MWSound
return MWBase::SoundPtr(); return MWBase::SoundPtr();
sound = mOutput->playSound3D(sfx->mHandle, sound = mOutput->playSound3D(sfx->mHandle,
objpos, volume * sfx->mVolume, basevol, pitch, sfx->mMinDist, sfx->mMaxDist, mode|type, offset objpos, volume * sfx->mVolume, basevol, pitch, sfx->mMinDist, sfx->mMaxDist,
mode|type|Play_3D, offset
); );
if(sfx->mUses++ == 0) if(sfx->mUses++ == 0)
{ {
@ -548,7 +549,8 @@ namespace MWSound
float basevol = volumeFromType(type); float basevol = volumeFromType(type);
sound = mOutput->playSound3D(sfx->mHandle, sound = mOutput->playSound3D(sfx->mHandle,
initialPos, volume * sfx->mVolume, basevol, pitch, sfx->mMinDist, sfx->mMaxDist, mode|type, offset initialPos, volume * sfx->mVolume, basevol, pitch, sfx->mMinDist, sfx->mMaxDist,
mode|type|Play_3D, offset
); );
if(sfx->mUses++ == 0) if(sfx->mUses++ == 0)
{ {
@ -822,7 +824,7 @@ namespace MWSound
bool SoundManager::updateSound(MWBase::SoundPtr sound, const MWWorld::Ptr& ptr, float duration) bool SoundManager::updateSound(MWBase::SoundPtr sound, const MWWorld::Ptr& ptr, float duration)
{ {
if(!ptr.isEmpty()) if(!ptr.isEmpty() && sound->getIs3D())
{ {
const ESM::Position &pos = ptr.getRefData().getPosition(); const ESM::Position &pos = ptr.getRefData().getPosition();
const osg::Vec3f objpos(pos.asVec3()); const osg::Vec3f objpos(pos.asVec3());

View file

@ -34,6 +34,11 @@ namespace MWSound
Env_Normal, Env_Normal,
Env_Underwater Env_Underwater
}; };
// Extra play flags, not intended for caller use
enum PlayModeEx {
Play_2D = 0,
Play_3D = 1<<31
};
class SoundManager : public MWBase::SoundManager class SoundManager : public MWBase::SoundManager
{ {