diff options
Diffstat (limited to 'OpenSim/Region/CoreModules/World/Sound')
-rw-r--r-- | OpenSim/Region/CoreModules/World/Sound/SoundModule.cs | 34 |
1 files changed, 20 insertions, 14 deletions
diff --git a/OpenSim/Region/CoreModules/World/Sound/SoundModule.cs b/OpenSim/Region/CoreModules/World/Sound/SoundModule.cs index 1f5a4ff..a52fea4 100644 --- a/OpenSim/Region/CoreModules/World/Sound/SoundModule.cs +++ b/OpenSim/Region/CoreModules/World/Sound/SoundModule.cs | |||
@@ -62,40 +62,46 @@ namespace OpenSim.Region.CoreModules.World.Sound | |||
62 | public virtual void PlayAttachedSound( | 62 | public virtual void PlayAttachedSound( |
63 | UUID soundID, UUID ownerID, UUID objectID, double gain, Vector3 position, byte flags, float radius) | 63 | UUID soundID, UUID ownerID, UUID objectID, double gain, Vector3 position, byte flags, float radius) |
64 | { | 64 | { |
65 | foreach (ScenePresence p in m_scene.GetAvatars()) | 65 | m_scene.ForEachScenePresence(delegate(ScenePresence sp) |
66 | { | 66 | { |
67 | double dis = Util.GetDistanceTo(p.AbsolutePosition, position); | 67 | if (sp.IsChildAgent) |
68 | return; | ||
69 | |||
70 | double dis = Util.GetDistanceTo(sp.AbsolutePosition, position); | ||
68 | if (dis > 100.0) // Max audio distance | 71 | if (dis > 100.0) // Max audio distance |
69 | continue; | 72 | return; |
70 | 73 | ||
71 | // Scale by distance | 74 | // Scale by distance |
72 | if (radius == 0) | 75 | if (radius == 0) |
73 | gain = (float)((double)gain * ((100.0 - dis) / 100.0)); | 76 | gain = (float)((double)gain * ((100.0 - dis) / 100.0)); |
74 | else | 77 | else |
75 | gain = (float)((double)gain * ((radius - dis) / radius)); | 78 | gain = (float)((double)gain * ((radius - dis) / radius)); |
76 | 79 | ||
77 | p.ControllingClient.SendPlayAttachedSound(soundID, objectID, ownerID, (float)gain, flags); | 80 | sp.ControllingClient.SendPlayAttachedSound(soundID, objectID, ownerID, (float)gain, flags); |
78 | } | 81 | }); |
79 | } | 82 | } |
80 | 83 | ||
81 | public virtual void TriggerSound( | 84 | public virtual void TriggerSound( |
82 | UUID soundId, UUID ownerID, UUID objectID, UUID parentID, double gain, Vector3 position, UInt64 handle, float radius) | 85 | UUID soundId, UUID ownerID, UUID objectID, UUID parentID, double gain, Vector3 position, UInt64 handle, float radius) |
83 | { | 86 | { |
84 | foreach (ScenePresence p in m_scene.GetAvatars()) | 87 | m_scene.ForEachScenePresence(delegate(ScenePresence sp) |
85 | { | 88 | { |
86 | double dis = Util.GetDistanceTo(p.AbsolutePosition, position); | 89 | if (sp.IsChildAgent) |
90 | return; | ||
91 | |||
92 | double dis = Util.GetDistanceTo(sp.AbsolutePosition, position); | ||
87 | if (dis > 100.0) // Max audio distance | 93 | if (dis > 100.0) // Max audio distance |
88 | continue; | 94 | return; |
89 | 95 | ||
90 | // Scale by distance | 96 | // Scale by distance |
91 | if (radius == 0) | 97 | if (radius == 0) |
92 | gain = (float)((double)gain * ((100.0 - dis) / 100.0)); | 98 | gain = (float)((double)gain * ((100.0 - dis) / 100.0)); |
93 | else | 99 | else |
94 | gain = (float)((double)gain * ((radius - dis) / radius)); | 100 | gain = (float)((double)gain * ((radius - dis) / radius)); |
95 | 101 | ||
96 | p.ControllingClient.SendTriggeredSound( | 102 | sp.ControllingClient.SendTriggeredSound( |
97 | soundId, ownerID, objectID, parentID, handle, position, (float)gain); | 103 | soundId, ownerID, objectID, parentID, handle, position, (float)gain); |
98 | } | 104 | }); |
99 | } | 105 | } |
100 | } | 106 | } |
101 | } | 107 | } |