aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/CoreModules/World/Sound
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Region/CoreModules/World/Sound')
-rw-r--r--OpenSim/Region/CoreModules/World/Sound/SoundModule.cs58
1 files changed, 29 insertions, 29 deletions
diff --git a/OpenSim/Region/CoreModules/World/Sound/SoundModule.cs b/OpenSim/Region/CoreModules/World/Sound/SoundModule.cs
index 662e3fe..14c230a 100644
--- a/OpenSim/Region/CoreModules/World/Sound/SoundModule.cs
+++ b/OpenSim/Region/CoreModules/World/Sound/SoundModule.cs
@@ -125,22 +125,23 @@ namespace OpenSim.Region.CoreModules.World.Sound
125 #region ISoundModule 125 #region ISoundModule
126 126
127 public virtual void PlayAttachedSound( 127 public virtual void PlayAttachedSound(
128 UUID soundID, UUID ownerID, UUID objectID, double gain, Vector3 position, byte flags, float radius) 128 UUID soundID, UUID ownerID, UUID objectID, double gain, Vector3 position, byte flags)
129 { 129 {
130 SceneObjectPart part; 130 SceneObjectPart part;
131 if (!m_scene.TryGetSceneObjectPart(objectID, out part)) 131 if (!m_scene.TryGetSceneObjectPart(objectID, out part))
132 return; 132 return;
133 133
134 if (part.SoundRadius == 0)
135 part.SoundRadius = MaxDistance;
134 part.SoundFlags = 0; 136 part.SoundFlags = 0;
135 137
136 SceneObjectGroup grp = part.ParentGroup;
137
138 if (radius == 0)
139 radius = MaxDistance;
140
141 if (part.SoundQueueing) 138 if (part.SoundQueueing)
142 flags |= (byte)SoundFlags.QUEUE; 139 flags |= (byte)SoundFlags.QUEUE;
143 140
141 SceneObjectGroup grp = part.ParentGroup;
142 if(grp == null | grp.IsDeleted)
143 return;
144
144 if (grp.IsAttachment) 145 if (grp.IsAttachment)
145 { 146 {
146 ScenePresence ssp = null; 147 ScenePresence ssp = null;
@@ -166,7 +167,7 @@ namespace OpenSim.Region.CoreModules.World.Sound
166 } 167 }
167 168
168 public virtual void TriggerSound( 169 public virtual void TriggerSound(
169 UUID soundId, UUID ownerID, UUID objectID, UUID parentID, double gain, Vector3 position, UInt64 handle, float radius) 170 UUID soundId, UUID ownerID, UUID objectID, UUID parentID, double gain, Vector3 position, UInt64 handle)
170 { 171 {
171 SceneObjectPart part; 172 SceneObjectPart part;
172 ScenePresence ssp = null; 173 ScenePresence ssp = null;
@@ -188,28 +189,21 @@ namespace OpenSim.Region.CoreModules.World.Sound
188 189
189 if (!ssp.ParcelAllowThisAvatarSounds) 190 if (!ssp.ParcelAllowThisAvatarSounds)
190 return; 191 return;
191
192/* mantis 7942: coment out to allow trigger in HUDs to send sounds to all
193 if (grp.HasPrivateAttachmentPoint)
194 {
195 ssp.ControllingClient.SendTriggeredSound(soundId, ownerID,
196 objectID, parentID, handle, position,
197 (float)gain);
198 return;
199 }
200*/
201 } 192 }
202 } 193 }
203 194
204 part.SoundFlags = 0; 195 float radius = (float)part.SoundRadius;
205
206 if (radius == 0) 196 if (radius == 0)
197 {
207 radius = MaxDistance; 198 radius = MaxDistance;
199 part.SoundRadius = MaxDistance;
200 }
201 part.SoundFlags = 0;
208 202
203 radius *= radius;
209 m_scene.ForEachRootScenePresence(delegate(ScenePresence sp) 204 m_scene.ForEachRootScenePresence(delegate(ScenePresence sp)
210 { 205 {
211 double dis = Util.GetDistanceTo(sp.AbsolutePosition, position); 206 if (Vector3.DistanceSquared(sp.AbsolutePosition, position) > radius) // Max audio distance
212 if (dis > radius) // Max audio distance
213 return; 207 return;
214 208
215 sp.ControllingClient.SendTriggeredSound(soundId, ownerID, 209 sp.ControllingClient.SendTriggeredSound(soundId, ownerID,
@@ -231,13 +225,12 @@ namespace OpenSim.Region.CoreModules.World.Sound
231 { 225 {
232 m_host.Sound = UUID.Zero; 226 m_host.Sound = UUID.Zero;
233 m_host.SoundFlags = (byte)SoundFlags.STOP; 227 m_host.SoundFlags = (byte)SoundFlags.STOP;
234 m_host.SoundRadius = 0;
235 m_host.SoundGain = 0; 228 m_host.SoundGain = 0;
236 m_host.ScheduleFullUpdate(); 229 m_host.ScheduleFullUpdate();
237 m_host.SendFullUpdateToAllClients(); 230 m_host.SendFullUpdateToAllClients();
238 } 231 }
239 232
240 public virtual void PreloadSound(UUID objectID, UUID soundID, float radius) 233 public virtual void PreloadSound(UUID objectID, UUID soundID)
241 { 234 {
242 SceneObjectPart part; 235 SceneObjectPart part;
243 if (soundID == UUID.Zero 236 if (soundID == UUID.Zero
@@ -246,12 +239,17 @@ namespace OpenSim.Region.CoreModules.World.Sound
246 return; 239 return;
247 } 240 }
248 241
242 float radius = (float)part.SoundRadius;
249 if (radius == 0) 243 if (radius == 0)
244 {
250 radius = MaxDistance; 245 radius = MaxDistance;
246 part.SoundRadius = radius;
247 }
251 248
249 radius *= 4.0f * radius; // avatars and prims do move
252 m_scene.ForEachRootScenePresence(delegate(ScenePresence sp) 250 m_scene.ForEachRootScenePresence(delegate(ScenePresence sp)
253 { 251 {
254 if (Util.GetDistanceTo(sp.AbsolutePosition, part.AbsolutePosition) < radius) 252 if (Vector3.DistanceSquared(sp.AbsolutePosition, part.AbsolutePosition) < radius)
255 sp.ControllingClient.SendPreLoadSound(objectID, objectID, soundID); 253 sp.ControllingClient.SendPreLoadSound(objectID, objectID, soundID);
256 }); 254 });
257 } 255 }
@@ -265,7 +263,7 @@ namespace OpenSim.Region.CoreModules.World.Sound
265 // 20080530 Updated to remove code duplication 263 // 20080530 Updated to remove code duplication
266 // 20080530 Stop sound if there is one, otherwise volume only changes don't work 264 // 20080530 Stop sound if there is one, otherwise volume only changes don't work
267 public void LoopSound(UUID objectID, UUID soundID, 265 public void LoopSound(UUID objectID, UUID soundID,
268 double volume, double radius, bool isMaster, bool isSlave) 266 double volume, bool isMaster, bool isSlave)
269 { 267 {
270 SceneObjectPart m_host; 268 SceneObjectPart m_host;
271 if (!m_scene.TryGetSceneObjectPart(objectID, out m_host)) 269 if (!m_scene.TryGetSceneObjectPart(objectID, out m_host))
@@ -283,14 +281,15 @@ namespace OpenSim.Region.CoreModules.World.Sound
283 m_host.Sound = soundID; 281 m_host.Sound = soundID;
284 m_host.SoundGain = volume; 282 m_host.SoundGain = volume;
285 m_host.SoundFlags = iflags; 283 m_host.SoundFlags = iflags;
286 m_host.SoundRadius = radius; 284 if (m_host.SoundRadius == 0)
285 m_host.SoundRadius = MaxDistance;
287 286
288 m_host.ScheduleFullUpdate(); 287 m_host.ScheduleFullUpdate();
289 m_host.SendFullUpdateToAllClients(); 288 m_host.SendFullUpdateToAllClients();
290 } 289 }
291 290
292 public void SendSound(UUID objectID, UUID soundID, double volume, 291 public void SendSound(UUID objectID, UUID soundID, double volume,
293 bool triggered, byte flags, float radius, bool useMaster, 292 bool triggered, byte flags, bool useMaster,
294 bool isMaster) 293 bool isMaster)
295 { 294 {
296 if (soundID == UUID.Zero) 295 if (soundID == UUID.Zero)
@@ -308,7 +307,7 @@ namespace OpenSim.Region.CoreModules.World.Sound
308 ulong regionHandle = m_scene.RegionInfo.RegionHandle; 307 ulong regionHandle = m_scene.RegionInfo.RegionHandle;
309 308
310 if(triggered) 309 if(triggered)
311 TriggerSound(soundID, part.OwnerID, part.UUID, parentID, volume, position, regionHandle, radius); 310 TriggerSound(soundID, part.OwnerID, part.UUID, parentID, volume, position, regionHandle);
312 else 311 else
313 { 312 {
314 byte bflags = 0; 313 byte bflags = 0;
@@ -318,7 +317,7 @@ namespace OpenSim.Region.CoreModules.World.Sound
318 // TODO check viewer seems to accept both 317 // TODO check viewer seems to accept both
319 if (useMaster) 318 if (useMaster)
320 bflags |= (byte)SoundFlags.SYNC_SLAVE; 319 bflags |= (byte)SoundFlags.SYNC_SLAVE;
321 PlayAttachedSound(soundID, part.OwnerID, part.UUID, volume, position, bflags, radius); 320 PlayAttachedSound(soundID, part.OwnerID, part.UUID, volume, position, bflags);
322 } 321 }
323 } 322 }
324 323
@@ -339,6 +338,7 @@ namespace OpenSim.Region.CoreModules.World.Sound
339 338
340 if (dis > MaxDistance) // Max audio distance 339 if (dis > MaxDistance) // Max audio distance
341 return; 340 return;
341
342 else if (!Util.IsInsideBox(sp.AbsolutePosition, min, max)) 342 else if (!Util.IsInsideBox(sp.AbsolutePosition, min, max))
343 return; 343 return;
344 344