diff --git a/OpenSim/Region/CoreModules/World/Sound/SoundModule.cs b/OpenSim/Region/CoreModules/World/Sound/SoundModule.cs
index 3143a2e22a..0997984b4c 100644
--- a/OpenSim/Region/CoreModules/World/Sound/SoundModule.cs
+++ b/OpenSim/Region/CoreModules/World/Sound/SoundModule.cs
@@ -215,6 +215,58 @@ namespace OpenSim.Region.CoreModules.World.Sound
});
}
+ public virtual void TriggerCollisionSound(
+ UUID soundId, UUID ownerID, UUID objectID, UUID parentID, double gain, Vector3 position, UInt64 handle)
+ {
+ float radius;
+ SceneObjectPart part;
+ ScenePresence ssp = null;
+ if (!m_scene.TryGetSceneObjectPart(objectID, out part))
+ {
+ if (!m_scene.TryGetScenePresence(ownerID, out ssp))
+ return;
+ if (!ssp.ParcelAllowThisAvatarSounds)
+ return;
+
+ radius = MaxDistance;
+ }
+ else
+ {
+ SceneObjectGroup grp = part.ParentGroup;
+
+ if (grp.IsAttachment)
+ {
+ if (!m_scene.TryGetScenePresence(grp.AttachedAvatar, out ssp))
+ return;
+
+ if (!ssp.ParcelAllowThisAvatarSounds)
+ return;
+
+ }
+
+ radius = (float)part.SoundRadius;
+ if (radius == 0)
+ {
+ radius = MaxDistance;
+ part.SoundRadius = MaxDistance;
+ }
+ }
+
+ radius *= radius;
+ m_scene.ForEachRootScenePresence(delegate (ScenePresence sp)
+ {
+ if(sp.MuteCollisions)
+ return;
+
+ if (Vector3.DistanceSquared(sp.AbsolutePosition, position) > radius) // Max audio distance
+ return;
+
+ sp.ControllingClient.SendTriggeredSound(soundId, ownerID,
+ objectID, parentID, handle, position,
+ (float)gain);
+ });
+ }
+
public virtual void StopSound(UUID objectID)
{
SceneObjectPart m_host;
diff --git a/OpenSim/Region/Framework/Interfaces/ISoundModule.cs b/OpenSim/Region/Framework/Interfaces/ISoundModule.cs
index aaa99315f3..60409901a9 100644
--- a/OpenSim/Region/Framework/Interfaces/ISoundModule.cs
+++ b/OpenSim/Region/Framework/Interfaces/ISoundModule.cs
@@ -67,6 +67,9 @@ namespace OpenSim.Region.Framework.Interfaces
UUID soundId, UUID ownerID, UUID objectID, UUID parentID,
double gain, Vector3 position, UInt64 handle);
+ void TriggerCollisionSound(
+ UUID soundId, UUID ownerID, UUID objectID, UUID parentID,
+ double gain, Vector3 position, UInt64 handle);
///
/// Stop sounds eminating from an object.
///
diff --git a/OpenSim/Region/Framework/Scenes/CollisionSounds.cs b/OpenSim/Region/Framework/Scenes/CollisionSounds.cs
index 63aafcd066..365113f3f5 100644
--- a/OpenSim/Region/Framework/Scenes/CollisionSounds.cs
+++ b/OpenSim/Region/Framework/Scenes/CollisionSounds.cs
@@ -265,7 +265,7 @@ namespace OpenSim.Region.Framework.Scenes
int thisMatScaled = thisMaterial * MaxMaterials;
- // bool doneownsound = false;
+ // bool doneownsound = false;
CollisionForSoundInfo colInfo;
uint id;
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs
index b88cb93acf..3ee077feca 100644
--- a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs
+++ b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs
@@ -2916,19 +2916,19 @@ namespace OpenSim.Region.Framework.Scenes
if (soundID.IsZero())
return;
+ int now = Util.EnvironmentTickCount();
+ if (Util.EnvironmentTickCountSubtract(now, LastColSoundSentTime) < 200)
+ return;
+
ISoundModule soundModule = ParentGroup.Scene.RequestModuleInterface();
if (soundModule == null)
return;
if (volume > 1)
volume = 1;
- if (volume < 0)
+ else if (volume < 0)
volume = 0;
- int now = Util.EnvironmentTickCount();
- if(Util.EnvironmentTickCountSubtract(now, LastColSoundSentTime) < 200)
- return;
-
LastColSoundSentTime = now;
UUID ownerID = OwnerID;
@@ -2936,7 +2936,7 @@ namespace OpenSim.Region.Framework.Scenes
UUID parentID = ParentGroup.UUID;
ulong regionHandle = ParentGroup.Scene.RegionInfo.RegionHandle;
- soundModule.TriggerSound(soundID, ownerID, objectID, parentID, volume, position, regionHandle);
+ soundModule.TriggerCollisionSound(soundID, ownerID, objectID, parentID, volume, position, regionHandle);
}
public void PhysicsOutOfBounds(Vector3 pos)
diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs
index 23194aea20..e90296fb2f 100644
--- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs
+++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs
@@ -72,9 +72,10 @@ namespace OpenSim.Region.Framework.Scenes
enum AgentUpdateFlags: byte
{
- None = 0,
- HideTitle = 1,
- CliAutoPilot = 2
+ None = 0,
+ HideTitle = 0x01,
+ CliAutoPilot = 0x02,
+ MuteCollisions = 0x80
}
public delegate void SendCoarseLocationsMethod(UUID scene, ScenePresence presence, List coarseLocations, List avatarUUIDs);
@@ -142,7 +143,8 @@ namespace OpenSim.Region.Framework.Scenes
}
}
- public bool HideTitle = false;
+ public bool HideTitle;
+ public bool MuteCollisions;
private ScenePresenceStateMachine m_stateMachine;
@@ -2652,6 +2654,8 @@ namespace OpenSim.Region.Framework.Scenes
SendAvatarDataToAllAgents();
}
+ MuteCollisions = (agentData.Flags & (byte)AgentUpdateFlags.MuteCollisions) != 0;
+
// FIXME: This does not work as intended because the viewer only sends the lbutton down when the button
// is first pressed, not whilst it is held down. If this is required in the future then need to look
// for an AGENT_CONTROL_LBUTTON_UP event and make sure to handle cases where an initial DOWN is not