1
0
Fork 1
mirror of https://github.com/TES3MP/openmw-tes3mp.git synced 2025-04-01 00:36:46 +00:00

Use GMSTs for sound fading distance

This commit is contained in:
scrawl 2014-12-08 17:24:45 +01:00
parent 9f90a1e44b
commit fbed429b25

View file

@ -103,23 +103,30 @@ namespace MWSound
std::string SoundManager::lookup(const std::string &soundId, std::string SoundManager::lookup(const std::string &soundId,
float &volume, float &min, float &max) float &volume, float &min, float &max)
{ {
const ESM::Sound *snd = MWBase::World* world = MWBase::Environment::get().getWorld();
MWBase::Environment::get().getWorld()->getStore().get<ESM::Sound>().find(soundId); const ESM::Sound *snd = world->getStore().get<ESM::Sound>().find(soundId);
volume *= pow(10.0, (snd->mData.mVolume/255.0*3348.0 - 3348.0) / 2000.0); volume *= pow(10.0, (snd->mData.mVolume/255.0*3348.0 - 3348.0) / 2000.0);
if(snd->mData.mMinRange == 0 && snd->mData.mMaxRange == 0) if(snd->mData.mMinRange == 0 && snd->mData.mMaxRange == 0)
{ {
min = 100.0f; static const float fAudioDefaultMinDistance = world->getStore().get<ESM::GameSetting>().find("fAudioDefaultMinDistance")->getFloat();
max = 2000.0f; static const float fAudioDefaultMaxDistance = world->getStore().get<ESM::GameSetting>().find("fAudioDefaultMaxDistance")->getFloat();
min = fAudioDefaultMinDistance;
max = fAudioDefaultMaxDistance;
} }
else else
{ {
min = snd->mData.mMinRange * 20.0f; min = snd->mData.mMinRange;
max = snd->mData.mMaxRange * 50.0f; max = snd->mData.mMaxRange;
}
static const float fAudioMinDistanceMult = world->getStore().get<ESM::GameSetting>().find("fAudioMinDistanceMult")->getFloat();
static const float fAudioMaxDistanceMult = world->getStore().get<ESM::GameSetting>().find("fAudioMaxDistanceMult")->getFloat();
min *= fAudioMinDistanceMult;
max *= fAudioMaxDistanceMult;
min = std::max(min, 1.0f); min = std::max(min, 1.0f);
max = std::max(min, max); max = std::max(min, max);
}
return "Sound/"+snd->mSound; return "Sound/"+snd->mSound;
} }
@ -250,8 +257,19 @@ namespace MWSound
const ESM::Position &pos = ptr.getRefData().getPosition(); const ESM::Position &pos = ptr.getRefData().getPosition();
const Ogre::Vector3 objpos(pos.pos); const Ogre::Vector3 objpos(pos.pos);
MWBase::World* world = MWBase::Environment::get().getWorld();
static const float fAudioMinDistanceMult = world->getStore().get<ESM::GameSetting>().find("fAudioMinDistanceMult")->getFloat();
static const float fAudioMaxDistanceMult = world->getStore().get<ESM::GameSetting>().find("fAudioMaxDistanceMult")->getFloat();
static const float fAudioVoiceDefaultMinDistance = world->getStore().get<ESM::GameSetting>().find("fAudioVoiceDefaultMinDistance")->getFloat();
static const float fAudioVoiceDefaultMaxDistance = world->getStore().get<ESM::GameSetting>().find("fAudioVoiceDefaultMaxDistance")->getFloat();
float minDistance = fAudioVoiceDefaultMinDistance * fAudioMinDistanceMult;
float maxDistance = fAudioVoiceDefaultMaxDistance * fAudioMaxDistanceMult;
minDistance = std::max(minDistance, 1.f);
maxDistance = std::max(minDistance, maxDistance);
MWBase::SoundPtr sound = mOutput->playSound3D(filePath, objpos, 1.0f, basevol, 1.0f, MWBase::SoundPtr sound = mOutput->playSound3D(filePath, objpos, 1.0f, basevol, 1.0f,
20.0f, 1500.0f, Play_Normal|Play_TypeVoice, 0, true); minDistance, maxDistance, Play_Normal|Play_TypeVoice, 0, true);
mActiveSounds[sound] = std::make_pair(ptr, std::string("_say_sound")); mActiveSounds[sound] = std::make_pair(ptr, std::string("_say_sound"));
} }
catch(std::exception &e) catch(std::exception &e)