From a9999a9676d46669150343e4cdbf65428326a91d Mon Sep 17 00:00:00 2001 From: SignpostMarv Date: Tue, 16 Oct 2012 13:11:17 +0100 Subject: Refactoring llTriggerSoundLimited with a new method on ISoundModule, as the LL Wiki spec for llTriggerSoundLimited states an axis-aligned bounding box, not radial constraint --- .../World/Sound/SoundModuleNonShared.cs | 30 ++++++++++++++++++++++ 1 file changed, 30 insertions(+) (limited to 'OpenSim/Region/CoreModules/World/Sound') diff --git a/OpenSim/Region/CoreModules/World/Sound/SoundModuleNonShared.cs b/OpenSim/Region/CoreModules/World/Sound/SoundModuleNonShared.cs index 417c071..ac7f7b4 100644 --- a/OpenSim/Region/CoreModules/World/Sound/SoundModuleNonShared.cs +++ b/OpenSim/Region/CoreModules/World/Sound/SoundModuleNonShared.cs @@ -334,6 +334,36 @@ namespace OpenSim.Region.CoreModules.World.Sound } } + public void TriggerSoundLimited(UUID objectID, UUID sound, + double volume, Vector3 min, Vector3 max) + { + if (sound == UUID.Zero) + return; + + SceneObjectPart part; + if (!m_scene.TryGetSceneObjectPart(objectID, out part)) + return; + + m_scene.ForEachRootScenePresence(delegate(ScenePresence sp) + { + double dis = Util.GetDistanceTo(sp.AbsolutePosition, + part.AbsolutePosition); + + if (dis > MaxDistance) // Max audio distance + return; + else if (!Util.IsInsideBox(sp.AbsolutePosition, min, max)) + return; + + // Scale by distance + double thisSpGain = volume * ((MaxDistance - dis) / MaxDistance); + + sp.ControllingClient.SendTriggeredSound(sound, part.OwnerID, + part.UUID, part.ParentGroup.UUID, + m_scene.RegionInfo.RegionHandle, + part.AbsolutePosition, (float)thisSpGain); + }); + } + #endregion } } -- cgit v1.1