diff options
Diffstat (limited to 'indra/newview/llviewermedia.cpp')
-rw-r--r-- | indra/newview/llviewermedia.cpp | 30 |
1 files changed, 24 insertions, 6 deletions
diff --git a/indra/newview/llviewermedia.cpp b/indra/newview/llviewermedia.cpp index a4d8dddfe4..1f6687bd83 100644 --- a/indra/newview/llviewermedia.cpp +++ b/indra/newview/llviewermedia.cpp @@ -33,6 +33,7 @@ #include "llviewerprecompiledheaders.h" #include "llagent.h" +#include "llagentcamera.h" #include "llviewermedia.h" #include "llviewermediafocus.h" #include "llmimetypes.h" @@ -1585,6 +1586,7 @@ void LLViewerMediaImpl::destroyMediaSource() if(mMediaSource) { + mMediaSource->setDeleteOK(true) ; delete mMediaSource; mMediaSource = NULL; } @@ -1736,7 +1738,7 @@ bool LLViewerMediaImpl::initializePlugin(const std::string& media_type) } mMediaSource = media_source; - + mMediaSource->setDeleteOK(false) ; updateVolume(); return true; @@ -1921,15 +1923,28 @@ void LLViewerMediaImpl::updateVolume() { if(mMediaSource) { - F32 attenuation_multiplier = 1.0; + // always scale the volume by the global media volume + F32 volume = mRequestedVolume * LLViewerMedia::getVolume(); - if (mProximityDistance > 0) + if (mProximityCamera > 0) { - // the attenuation multiplier should never be more than one since that would increase volume - attenuation_multiplier = llmin(1.0, gSavedSettings.getF32("MediaRollOffFactor")/mProximityDistance); + if (mProximityCamera > gSavedSettings.getF32("MediaRollOffMax")) + { + volume = 0; + } + else if (mProximityCamera > gSavedSettings.getF32("MediaRollOffMin")) + { + // attenuated_volume = v / ( 1 + (roll_off_rate * (d - min))^2 + // the +1 is there so that for distance 0 the volume stays the same + F64 adjusted_distance = mProximityCamera - gSavedSettings.getF32("MediaRollOffMin"); + F64 attenuation = gSavedSettings.getF32("MediaRollOffRate") * adjusted_distance; + attenuation = attenuation * attenuation; + // the attenuation multiplier should never be more than one since that would increase volume + volume = volume * llmin(1.0, 1 /(attenuation + 1)); + } } - mMediaSource->setVolume(mRequestedVolume * LLViewerMedia::getVolume() * attenuation_multiplier); + mMediaSource->setVolume(volume); } } @@ -3016,6 +3031,9 @@ void LLViewerMediaImpl::calculateInterest() LLVector3d agent_global = gAgent.getPositionGlobal() ; LLVector3d global_delta = agent_global - obj_global ; mProximityDistance = global_delta.magVecSquared(); // use distance-squared because it's cheaper and sorts the same. + + LLVector3d camera_delta = gAgentCamera.getCameraPositionGlobal() - obj_global; + mProximityCamera = camera_delta.magVec(); } if(mNeedsMuteCheck) |