1
0
Fork 1
mirror of https://github.com/TES3MP/openmw-tes3mp.git synced 2025-03-03 12:49:40 +00:00

Replace Play_NoTrack with playManualSound3D, and rename the latter

This commit is contained in:
Chris Robinson 2015-11-24 23:24:42 -08:00
parent caae305ddd
commit 73448c72f6
7 changed files with 39 additions and 37 deletions

View file

@ -29,13 +29,10 @@ namespace MWBase
public: public:
/* These must all fit together */ /* These must all fit together */
enum PlayMode { enum PlayMode {
Play_Normal = 0, /* tracked, non-looping, multi-instance, environment */ Play_Normal = 0, /* non-looping, affected by environment */
Play_Loop = 1<<0, /* Sound will continually loop until explicitly stopped */ Play_Loop = 1<<0, /* Sound will continually loop until explicitly stopped */
Play_NoEnv = 1<<1, /* Do not apply environment effects (eg, underwater filters) */ Play_NoEnv = 1<<1, /* Do not apply environment effects (eg, underwater filters) */
Play_NoTrack = 1<<2, /* (3D only) Play the sound at the given object's position Play_RemoveAtDistance = 1<<2, /* (3D only) If the listener gets further than 2000 units away
* but do not keep it updated (the sound will not move with
* the object and will not stop when the object is deleted. */
Play_RemoveAtDistance = 1<<3, /* (3D only) If the listener gets further than 2000 units away
from the sound source, the sound is removed. from the sound source, the sound is removed.
This is weird stuff but apparently how vanilla works for sounds This is weird stuff but apparently how vanilla works for sounds
played by the PlayLoopSound family of script functions. Perhaps we played by the PlayLoopSound family of script functions. Perhaps we
@ -45,11 +42,11 @@ namespace MWBase
Play_LoopRemoveAtDistance = Play_Loop | Play_RemoveAtDistance Play_LoopRemoveAtDistance = Play_Loop | Play_RemoveAtDistance
}; };
enum PlayType { enum PlayType {
Play_TypeSfx = 1<<4, /* Normal SFX sound */ Play_TypeSfx = 1<<3, /* Normal SFX sound */
Play_TypeVoice = 1<<5, /* Voice sound */ Play_TypeVoice = 1<<4, /* Voice sound */
Play_TypeFoot = 1<<6, /* Footstep sound */ Play_TypeFoot = 1<<5, /* Footstep sound */
Play_TypeMusic = 1<<7, /* Music track */ Play_TypeMusic = 1<<6, /* Music track */
Play_TypeMovie = 1<<8, /* Movie audio track */ Play_TypeMovie = 1<<7, /* Movie audio track */
Play_TypeMask = Play_TypeSfx|Play_TypeVoice|Play_TypeFoot|Play_TypeMusic|Play_TypeMovie Play_TypeMask = Play_TypeSfx|Play_TypeVoice|Play_TypeFoot|Play_TypeMusic|Play_TypeMovie
}; };
@ -120,9 +117,9 @@ namespace MWBase
///< Play a 3D sound attached to an MWWorld::Ptr. Will be updated automatically with the Ptr's position, unless Play_NoTrack is specified. ///< Play a 3D sound attached to an MWWorld::Ptr. Will be updated automatically with the Ptr's position, unless Play_NoTrack is specified.
///< @param offset Value from [0,1] meaning from which fraction the sound the playback starts. ///< @param offset Value from [0,1] meaning from which fraction the sound the playback starts.
virtual MWBase::SoundPtr playManualSound3D(const osg::Vec3f& initialPos, const std::string& soundId, virtual MWBase::SoundPtr playSound3D(const osg::Vec3f& initialPos, const std::string& soundId,
float volume, float pitch, PlayType type, PlayMode mode, float offset=0) = 0; float volume, float pitch, PlayType type=Play_TypeSfx, PlayMode mode=Play_Normal, float offset=0) = 0;
///< Play a 3D sound at \a initialPos. If the sound should be moving, it must be updated manually using Sound::setPosition. ///< Play a 3D sound at \a initialPos. If the sound should be moving, it must be updated using Sound::setPosition.
virtual void stopSound3D(const MWWorld::Ptr &reference, const std::string& soundId) = 0; virtual void stopSound3D(const MWWorld::Ptr &reference, const std::string& soundId) = 0;
///< Stop the given object from playing the given sound, ///< Stop the given object from playing the given sound,

View file

@ -212,8 +212,9 @@ namespace MWMechanics
MWBase::Environment::get().getWorld()->spawnEffect("meshes\\" + fx->mModel, MWBase::Environment::get().getWorld()->spawnEffect("meshes\\" + fx->mModel,
"", mCreature.getRefData().getPosition().asVec3()); "", mCreature.getRefData().getPosition().asVec3());
MWBase::Environment::get().getSoundManager()->playSound3D(mCreature, "conjuration hit", 1.f, 1.f, MWBase::Environment::get().getSoundManager()->playSound3D(
MWBase::SoundManager::Play_TypeSfx, MWBase::SoundManager::Play_NoTrack); mCreature.getRefData().getPosition().asVec3(), "conjuration hit", 1.f, 1.f
);
} }
}; };

View file

@ -560,10 +560,7 @@ namespace MWSound
if(iter != mUnusedBuffers.end()) if(iter != mUnusedBuffers.end())
mUnusedBuffers.erase(iter); mUnusedBuffers.erase(iter);
} }
if((mode&Play_NoTrack)) mActiveSounds[ptr].push_back(std::make_pair(sound, sfxid));
mActiveSounds[MWWorld::Ptr()].push_back(std::make_pair(sound, sfxid));
else
mActiveSounds[ptr].push_back(std::make_pair(sound, sfxid));
} }
catch(std::exception&) catch(std::exception&)
{ {
@ -572,8 +569,8 @@ namespace MWSound
return sound; return sound;
} }
MWBase::SoundPtr SoundManager::playManualSound3D(const osg::Vec3f& initialPos, const std::string& soundId, MWBase::SoundPtr SoundManager::playSound3D(const osg::Vec3f& initialPos, const std::string& soundId,
float volume, float pitch, PlayType type, PlayMode mode, float offset) float volume, float pitch, PlayType type, PlayMode mode, float offset)
{ {
MWBase::SoundPtr sound; MWBase::SoundPtr sound;
if(!mOutput->isInitialized()) if(!mOutput->isInitialized())

View file

@ -168,9 +168,9 @@ namespace MWSound
///< Play a 3D sound attached to an MWWorld::Ptr. Will be updated automatically with the Ptr's position, unless Play_NoTrack is specified. ///< Play a 3D sound attached to an MWWorld::Ptr. Will be updated automatically with the Ptr's position, unless Play_NoTrack is specified.
///< @param offset Value from [0,1] meaning from which fraction the sound the playback starts. ///< @param offset Value from [0,1] meaning from which fraction the sound the playback starts.
virtual MWBase::SoundPtr playManualSound3D(const osg::Vec3f& initialPos, const std::string& soundId, virtual MWBase::SoundPtr playSound3D(const osg::Vec3f& initialPos, const std::string& soundId,
float volume, float pitch, PlayType type, PlayMode mode, float offset=0); float volume, float pitch, PlayType type, PlayMode mode, float offset=0);
///< Play a 3D sound at \a initialPos. If the sound should be moving, it must be updated manually using Sound::setPosition. ///< Play a 3D sound at \a initialPos. If the sound should be moving, it must be updated using Sound::setPosition.
///< Play a sound from an object ///< Play a sound from an object
///< @param offset value from [0,1], when to start playback. 0 is beginning, 1 is end. ///< @param offset value from [0,1], when to start playback. 0 is beginning, 1 is end.

View file

@ -19,19 +19,26 @@ MWWorld::Action::~Action() {}
void MWWorld::Action::execute (const Ptr& actor) void MWWorld::Action::execute (const Ptr& actor)
{ {
if (!mSoundId.empty()) if(!mSoundId.empty())
{ {
if (mKeepSound && actor == MWMechanics::getPlayer()) if(mKeepSound && actor == MWMechanics::getPlayer())
MWBase::Environment::get().getSoundManager()->playSound(mSoundId, 1.0, 1.0, MWBase::Environment::get().getSoundManager()->playSound(mSoundId, 1.0, 1.0,
MWBase::SoundManager::Play_TypeSfx, MWBase::SoundManager::Play_Normal,mSoundOffset); MWBase::SoundManager::Play_TypeSfx, MWBase::SoundManager::Play_Normal, mSoundOffset
);
else else
{ {
bool local = mTarget.isEmpty() || !mTarget.isInCell(); // no usable target bool local = mTarget.isEmpty() || !mTarget.isInCell(); // no usable target
if(mKeepSound)
MWBase::Environment::get().getSoundManager()->playSound3D(local ? actor : mTarget, MWBase::Environment::get().getSoundManager()->playSound3D(
mSoundId, 1.0, 1.0, MWBase::SoundManager::Play_TypeSfx, (local ? actor : mTarget).getRefData().getPosition().asVec3(),
mKeepSound ? MWBase::SoundManager::Play_NoTrack : MWBase::SoundManager::Play_Normal, mSoundId, 1.0, 1.0, MWBase::SoundManager::Play_TypeSfx,
mSoundOffset); MWBase::SoundManager::Play_Normal, mSoundOffset
);
else
MWBase::Environment::get().getSoundManager()->playSound3D(local ? actor : mTarget,
mSoundId, 1.0, 1.0, MWBase::SoundManager::Play_TypeSfx,
MWBase::SoundManager::Play_Normal, mSoundOffset
);
} }
} }

View file

@ -107,7 +107,7 @@ namespace MWWorld
createModel(state, ptr.getClass().getModel(ptr), pos, orient); createModel(state, ptr.getClass().getModel(ptr), pos, orient);
MWBase::SoundManager *sndMgr = MWBase::Environment::get().getSoundManager(); MWBase::SoundManager *sndMgr = MWBase::Environment::get().getSoundManager();
state.mSound = sndMgr->playManualSound3D(pos, sound, 1.0f, 1.0f, MWBase::SoundManager::Play_TypeSfx, MWBase::SoundManager::Play_Loop); state.mSound = sndMgr->playSound3D(pos, sound, 1.0f, 1.0f, MWBase::SoundManager::Play_TypeSfx, MWBase::SoundManager::Play_Loop);
mMagicBolts.push_back(state); mMagicBolts.push_back(state);
} }
@ -374,8 +374,8 @@ namespace MWWorld
createModel(state, model, osg::Vec3f(esm.mPosition), osg::Quat(esm.mOrientation)); createModel(state, model, osg::Vec3f(esm.mPosition), osg::Quat(esm.mOrientation));
MWBase::SoundManager *sndMgr = MWBase::Environment::get().getSoundManager(); MWBase::SoundManager *sndMgr = MWBase::Environment::get().getSoundManager();
state.mSound = sndMgr->playManualSound3D(esm.mPosition, esm.mSound, 1.0f, 1.0f, state.mSound = sndMgr->playSound3D(esm.mPosition, esm.mSound, 1.0f, 1.0f,
MWBase::SoundManager::Play_TypeSfx, MWBase::SoundManager::Play_Loop); MWBase::SoundManager::Play_TypeSfx, MWBase::SoundManager::Play_Loop);
state.mSoundId = esm.mSound; state.mSoundId = esm.mSound;
mMagicBolts.push_back(state); mMagicBolts.push_back(state);

View file

@ -3153,9 +3153,9 @@ namespace MWWorld
{ {
MWBase::SoundManager *sndMgr = MWBase::Environment::get().getSoundManager(); MWBase::SoundManager *sndMgr = MWBase::Environment::get().getSoundManager();
if(!effect->mAreaSound.empty()) if(!effect->mAreaSound.empty())
sndMgr->playManualSound3D(origin, effect->mAreaSound, 1.0f, 1.0f, MWBase::SoundManager::Play_TypeSfx, MWBase::SoundManager::Play_NoTrack); sndMgr->playSound3D(origin, effect->mAreaSound, 1.0f, 1.0f);
else else
sndMgr->playManualSound3D(origin, schools[effect->mData.mSchool]+" area", 1.0f, 1.0f, MWBase::SoundManager::Play_TypeSfx, MWBase::SoundManager::Play_NoTrack); sndMgr->playSound3D(origin, schools[effect->mData.mSchool]+" area", 1.0f, 1.0f);
} }
// Get the actors in range of the effect // Get the actors in range of the effect
std::vector<MWWorld::Ptr> objects; std::vector<MWWorld::Ptr> objects;