mirror of
https://github.com/TES3MP/openmw-tes3mp.git
synced 2025-03-29 16:06:44 +00:00
Use GMSTs for sound fading distance
This commit is contained in:
parent
9f90a1e44b
commit
fbed429b25
1 changed files with 27 additions and 9 deletions
|
@ -103,24 +103,31 @@ 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;
|
||||||
min = std::max(min, 1.0f);
|
|
||||||
max = std::max(min, max);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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);
|
||||||
|
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)
|
||||||
|
|
Loading…
Reference in a new issue