summaryrefslogtreecommitdiff
path: root/indra/newview
diff options
context:
space:
mode:
authorLeyla Farazha <leyla@lindenlab.com>2010-04-30 13:26:25 -0700
committerLeyla Farazha <leyla@lindenlab.com>2010-04-30 13:26:25 -0700
commite2e31b1b6b049adbdf16d6078827239c135be49f (patch)
tree4c1b50c3a547138afbeac07da4b6a43074996e1b /indra/newview
parent8c3feea2a2f3bcb648f712f63ea9c4dab8aaa0c3 (diff)
Added min and max for media sound attenuation
reviewed by Richard
Diffstat (limited to 'indra/newview')
-rw-r--r--indra/newview/llviewermedia.cpp28
-rw-r--r--indra/newview/llviewermedia.h1
2 files changed, 24 insertions, 5 deletions
diff --git a/indra/newview/llviewermedia.cpp b/indra/newview/llviewermedia.cpp
index fd2bb0fdf9..c8f3374f38 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"
@@ -1914,15 +1915,29 @@ 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)
+ // attenuate if this is not parcel media
+ if (!mIsParcelMedia)
{
- // 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("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
+ 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()
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)
diff --git a/indra/newview/llviewermedia.h b/indra/newview/llviewermedia.h
index e829d7a5b4..8626f4469e 100644
--- a/indra/newview/llviewermedia.h
+++ b/indra/newview/llviewermedia.h
@@ -431,6 +431,7 @@ private:
bool mIsParcelMedia;
S32 mProximity;
F64 mProximityDistance;
+ F64 mProximityCamera;
LLMimeDiscoveryResponder *mMimeTypeProbe;
bool mMediaAutoPlay;
std::string mMediaEntryURL;