diff options
author | Justin Clarke Casey | 2008-12-23 17:54:13 +0000 |
---|---|---|
committer | Justin Clarke Casey | 2008-12-23 17:54:13 +0000 |
commit | cce1b096dbd8aba46c405b7654d67d3ba96de33a (patch) | |
tree | ae8208af8343d8d82df1343038855e1d3c91eba0 /OpenSim/Region/Environment | |
parent | * Add a method to allow friendship offers to a logged in client from an offli... (diff) | |
download | opensim-SC-cce1b096dbd8aba46c405b7654d67d3ba96de33a.zip opensim-SC-cce1b096dbd8aba46c405b7654d67d3ba96de33a.tar.gz opensim-SC-cce1b096dbd8aba46c405b7654d67d3ba96de33a.tar.bz2 opensim-SC-cce1b096dbd8aba46c405b7654d67d3ba96de33a.tar.xz |
* refactor: Replace part of SceneObjectPart with the identical sound playing code in the SoundModule
Diffstat (limited to '')
3 files changed, 28 insertions, 19 deletions
diff --git a/OpenSim/Region/Environment/Interfaces/ISoundModule.cs b/OpenSim/Region/Environment/Interfaces/ISoundModule.cs index 0ec5652..3bb4c57 100644 --- a/OpenSim/Region/Environment/Interfaces/ISoundModule.cs +++ b/OpenSim/Region/Environment/Interfaces/ISoundModule.cs | |||
@@ -33,7 +33,9 @@ namespace OpenSim.Region.Environment | |||
33 | { | 33 | { |
34 | public interface ISoundModule | 34 | public interface ISoundModule |
35 | { | 35 | { |
36 | void PlayAttachedSound(UUID soundID, UUID ownerID, UUID objectID, double gain, Vector3 position, byte flags); | ||
37 | |||
36 | void TriggerSound( | 38 | void TriggerSound( |
37 | UUID soundId, UUID ownerID, UUID objectID, UUID parentID, float gain, Vector3 position, UInt64 handle); | 39 | UUID soundId, UUID ownerID, UUID objectID, UUID parentID, double gain, Vector3 position, UInt64 handle); |
38 | } | 40 | } |
39 | } \ No newline at end of file | 41 | } \ No newline at end of file |
diff --git a/OpenSim/Region/Environment/Modules/World/Sound/SoundModule.cs b/OpenSim/Region/Environment/Modules/World/Sound/SoundModule.cs index 7c89466..4547480 100644 --- a/OpenSim/Region/Environment/Modules/World/Sound/SoundModule.cs +++ b/OpenSim/Region/Environment/Modules/World/Sound/SoundModule.cs | |||
@@ -61,20 +61,37 @@ namespace OpenSim.Region.Environment.World.Sound | |||
61 | client.OnSoundTrigger += TriggerSound; | 61 | client.OnSoundTrigger += TriggerSound; |
62 | } | 62 | } |
63 | 63 | ||
64 | public virtual void PlayAttachedSound( | ||
65 | UUID soundID, UUID ownerID, UUID objectID, double gain, Vector3 position, byte flags) | ||
66 | { | ||
67 | foreach (ScenePresence p in m_scene.GetAvatars()) | ||
68 | { | ||
69 | double dis = Util.GetDistanceTo(p.AbsolutePosition, position); | ||
70 | if (dis > 100.0) // Max audio distance | ||
71 | continue; | ||
72 | |||
73 | // Scale by distance | ||
74 | gain = (float)((double)gain*((100.0 - dis) / 100.0)); | ||
75 | |||
76 | p.ControllingClient.SendPlayAttachedSound(soundID, objectID, ownerID, (float)gain, flags); | ||
77 | } | ||
78 | } | ||
79 | |||
64 | public virtual void TriggerSound( | 80 | public virtual void TriggerSound( |
65 | UUID soundId, UUID ownerID, UUID objectID, UUID parentID, float gain, Vector3 position, UInt64 handle) | 81 | UUID soundId, UUID ownerID, UUID objectID, UUID parentID, double gain, Vector3 position, UInt64 handle) |
66 | { | 82 | { |
67 | foreach (ScenePresence p in m_scene.GetAvatars()) | 83 | foreach (ScenePresence p in m_scene.GetAvatars()) |
68 | { | 84 | { |
69 | double dis = Util.GetDistanceTo(p.AbsolutePosition, position); | 85 | double dis = Util.GetDistanceTo(p.AbsolutePosition, position); |
70 | if (dis > 100.0) // Max audio distance | 86 | if (dis > 100.0) // Max audio distance |
71 | continue; | 87 | continue; |
72 | 88 | ||
73 | // Scale by distance | 89 | // Scale by distance |
74 | gain = (float)((double)gain*((100.0 - dis) / 100.0)); | 90 | gain = (float)((double)gain*((100.0 - dis) / 100.0)); |
91 | |||
75 | p.ControllingClient.SendTriggeredSound( | 92 | p.ControllingClient.SendTriggeredSound( |
76 | soundId, ownerID, objectID, parentID, handle, position, (float)gain); | 93 | soundId, ownerID, objectID, parentID, handle, position, (float)gain); |
77 | } | 94 | } |
78 | } | 95 | } |
79 | } | 96 | } |
80 | } | 97 | } |
diff --git a/OpenSim/Region/Environment/Scenes/SceneObjectPart.cs b/OpenSim/Region/Environment/Scenes/SceneObjectPart.cs index ddfb413..6795c0a 100644 --- a/OpenSim/Region/Environment/Scenes/SceneObjectPart.cs +++ b/OpenSim/Region/Environment/Scenes/SceneObjectPart.cs | |||
@@ -37,6 +37,7 @@ using log4net; | |||
37 | using OpenMetaverse; | 37 | using OpenMetaverse; |
38 | using OpenMetaverse.Packets; | 38 | using OpenMetaverse.Packets; |
39 | using OpenSim.Framework; | 39 | using OpenSim.Framework; |
40 | using OpenSim.Region.Environment.Interfaces; | ||
40 | using OpenSim.Region.Environment.Scenes.Scripting; | 41 | using OpenSim.Region.Environment.Scenes.Scripting; |
41 | using OpenSim.Region.Physics.Manager; | 42 | using OpenSim.Region.Physics.Manager; |
42 | 43 | ||
@@ -2362,24 +2363,13 @@ if (m_shape != null) { | |||
2362 | if (soundID == UUID.Zero) | 2363 | if (soundID == UUID.Zero) |
2363 | return; | 2364 | return; |
2364 | 2365 | ||
2365 | List<ScenePresence> avatarts = m_parentGroup.Scene.GetAvatars(); | 2366 | ISoundModule soundModule = m_parentGroup.Scene.RequestModuleInterface<ISoundModule>(); |
2366 | foreach (ScenePresence p in avatarts) | 2367 | if (soundModule != null) |
2367 | { | 2368 | { |
2368 | double dis=Util.GetDistanceTo(p.AbsolutePosition, position); | ||
2369 | if (dis > 100.0) // Max audio distance | ||
2370 | continue; | ||
2371 | |||
2372 | // Scale by distance | ||
2373 | volume*=((100.0-dis)/100.0); | ||
2374 | |||
2375 | if (triggered) | 2369 | if (triggered) |
2376 | { | 2370 | soundModule.TriggerSound(soundID, ownerID, objectID, parentID, volume, position, regionHandle); |
2377 | p.ControllingClient.SendTriggeredSound(soundID, ownerID, objectID, parentID, regionHandle, position, (float)volume); | ||
2378 | } | ||
2379 | else | 2371 | else |
2380 | { | 2372 | soundModule.PlayAttachedSound(soundID, ownerID, objectID, volume, position, flags); |
2381 | p.ControllingClient.SendPlayAttachedSound(soundID, objectID, ownerID, (float)volume, flags); | ||
2382 | } | ||
2383 | } | 2373 | } |
2384 | } | 2374 | } |
2385 | 2375 | ||