1
0
mirror of https://gitlab.com/OpenMW/openmw.git synced 2025-01-26 09:35:28 +00:00

Check distance to object before load sound

This commit is contained in:
elsid 2020-06-28 19:59:53 +02:00
parent 49489b31f7
commit 624baa6d89
No known key found for this signature in database
GPG Key ID: B845CB9FEE18AB40

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);