Skip to content
Snippets Groups Projects
Commit e2e31b1b authored by Leyla Farazha's avatar Leyla Farazha
Browse files

Added min and max for media sound attenuation

reviewed by Richard
parent 8c3feea2
Branches
Tags
No related merge requests found
...@@ -33,6 +33,7 @@ ...@@ -33,6 +33,7 @@
#include "llviewerprecompiledheaders.h" #include "llviewerprecompiledheaders.h"
#include "llagent.h" #include "llagent.h"
#include "llagentcamera.h"
#include "llviewermedia.h" #include "llviewermedia.h"
#include "llviewermediafocus.h" #include "llviewermediafocus.h"
#include "llmimetypes.h" #include "llmimetypes.h"
...@@ -1914,15 +1915,29 @@ void LLViewerMediaImpl::updateVolume() ...@@ -1914,15 +1915,29 @@ void LLViewerMediaImpl::updateVolume()
{ {
if(mMediaSource) if(mMediaSource)
{ {
F32 attenuation_multiplier = 1.0; // always scale the volume by the global media volume
F32 volume = mRequestedVolume * LLViewerMedia::getVolume();
if (mProximityDistance > 0) // attenuate if this is not parcel media
if (!mIsParcelMedia)
{ {
if (mProximityCamera > gSavedSettings.getF32("MediaRollOffMaxDistance"))
{
volume = 0;
}
else
{
// attenuated volume = volume * roll_off rate / distance^2
// adjust distance by saved setting so we can tune the distance at which attenuation begins
// the actual start distance is sqrt(MediaRollOffMaxDistance)+MediaRollOffStartAdjustment
F64 adjusted_distance = mProximityCamera - gSavedSettings.getF32("MediaRollOffStart");
// the attenuation multiplier should never be more than one since that would increase volume // the attenuation multiplier should never be more than one since that would increase volume
attenuation_multiplier = llmin(1.0, gSavedSettings.getF32("MediaRollOffFactor")/mProximityDistance); volume = volume * llmin(1.0, gSavedSettings.getF32("MediaRollOffRate")/adjusted_distance*adjusted_distance);
}
} }
mMediaSource->setVolume(mRequestedVolume * LLViewerMedia::getVolume() * attenuation_multiplier); mMediaSource->setVolume(volume);
} }
} }
...@@ -3009,6 +3024,9 @@ void LLViewerMediaImpl::calculateInterest() ...@@ -3009,6 +3024,9 @@ void LLViewerMediaImpl::calculateInterest()
LLVector3d agent_global = gAgent.getPositionGlobal() ; LLVector3d agent_global = gAgent.getPositionGlobal() ;
LLVector3d global_delta = agent_global - obj_global ; LLVector3d global_delta = agent_global - obj_global ;
mProximityDistance = global_delta.magVecSquared(); // use distance-squared because it's cheaper and sorts the same. 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) if(mNeedsMuteCheck)
......
...@@ -431,6 +431,7 @@ class LLViewerMediaImpl ...@@ -431,6 +431,7 @@ class LLViewerMediaImpl
bool mIsParcelMedia; bool mIsParcelMedia;
S32 mProximity; S32 mProximity;
F64 mProximityDistance; F64 mProximityDistance;
F64 mProximityCamera;
LLMimeDiscoveryResponder *mMimeTypeProbe; LLMimeDiscoveryResponder *mMimeTypeProbe;
bool mMediaAutoPlay; bool mMediaAutoPlay;
std::string mMediaEntryURL; std::string mMediaEntryURL;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment