mirror of
https://github.com/TES3MP/openmw-tes3mp.git
synced 2025-01-31 18:45:33 +00:00
Set the appropriate meter/unit scale for sound
This commit is contained in:
parent
c790fedd3f
commit
0b720cd90c
1 changed files with 15 additions and 0 deletions
|
@ -33,6 +33,10 @@
|
|||
namespace
|
||||
{
|
||||
|
||||
// The game uses 64 units per yard, or approximately 69.99125109 units per meter.
|
||||
// Should this be defined publically somewhere?
|
||||
const float UnitsPerMeter = 69.99125109f;
|
||||
|
||||
const int sLoudnessFPS = 20; // loudness values per second of audio
|
||||
|
||||
// Helper to get an OpenAL extension function
|
||||
|
@ -719,7 +723,13 @@ void OpenAL_Output::init(const std::string &devname)
|
|||
}
|
||||
LoadEffect(mWaterEffect, EFX_REVERB_PRESET_UNDERWATER);
|
||||
}
|
||||
|
||||
alListenerf(AL_METERS_PER_UNIT, 1.0f / UnitsPerMeter);
|
||||
}
|
||||
// Speed of sound is in units per second. Given the default speed of sound is 343.3 (assumed
|
||||
// meters per second), multiply by the units per meter to get the speed in u/s.
|
||||
alSpeedOfSound(343.3f * UnitsPerMeter);
|
||||
alGetError();
|
||||
|
||||
mInitialized = true;
|
||||
}
|
||||
|
@ -1246,6 +1256,11 @@ void OpenAL_Output::updateListener(const osg::Vec3f &pos, const osg::Vec3f &atdi
|
|||
};
|
||||
alListenerfv(AL_POSITION, pos.ptr());
|
||||
alListenerfv(AL_ORIENTATION, orient);
|
||||
if(env != mListenerEnv)
|
||||
{
|
||||
// Speed of sound in water is 1484m/s, and in air is 343.3m/s (roughly)
|
||||
alSpeedOfSound(((env == Env_Underwater) ? 1484.0f : 343.3f) * UnitsPerMeter);
|
||||
}
|
||||
throwALerror();
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue