1
0
Fork 1
mirror of https://github.com/TES3MP/openmw-tes3mp.git synced 2025-02-03 20:45:31 +00:00

Merge pull request #2956 from elsid/sound_reoder_conditions

Check distance to object before load sound
This commit is contained in:
Andrei Kortunov 2020-07-08 08:53:20 +04:00 committed by GitHub
commit 700f70595f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -620,14 +620,14 @@ namespace MWSound
if(!mOutput->isInitialized())
return nullptr;
const osg::Vec3f objpos(ptr.getRefData().getPosition().asVec3());
if ((mode & PlayMode::RemoveAtDistance) && (mListenerPos - objpos).length2() > 2000 * 2000)
return nullptr;
// Look up the sound in the ESM data
Sound_Buffer *sfx = loadSound(Misc::StringUtils::lowerCase(soundId));
if(!sfx) return nullptr;
const osg::Vec3f objpos(ptr.getRefData().getPosition().asVec3());
if((mode&PlayMode::RemoveAtDistance) && (mListenerPos-objpos).length2() > 2000*2000)
return nullptr;
// Only one copy of given sound can be played at time on ptr, so stop previous copy
stopSound(sfx, ptr);