aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Framework/Scenes/CollisionSounds.cs
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Region/Framework/Scenes/CollisionSounds.cs')
-rw-r--r--OpenSim/Region/Framework/Scenes/CollisionSounds.cs74
1 files changed, 42 insertions, 32 deletions
diff --git a/OpenSim/Region/Framework/Scenes/CollisionSounds.cs b/OpenSim/Region/Framework/Scenes/CollisionSounds.cs
index 4522f9e..724ecb6 100644
--- a/OpenSim/Region/Framework/Scenes/CollisionSounds.cs
+++ b/OpenSim/Region/Framework/Scenes/CollisionSounds.cs
@@ -33,14 +33,24 @@ using OpenSim.Framework;
33 33
34namespace OpenSim.Region.Framework.Scenes 34namespace OpenSim.Region.Framework.Scenes
35{ 35{
36 public struct CollisionForSoundInfo
37 {
38 public uint colliderID;
39 public Vector3 position;
40 public float relativeVel;
41 }
42
36 public static class CollisionSounds 43 public static class CollisionSounds
37 { 44 {
45
46
47
38 // defines for cases 48 // defines for cases
39 // only know one UUID for now (woodflesh) 49 // only know one UUID for now (woodflesh)
40 50
41 private const int MaxMaterials = 7; 51 private const int MaxMaterials = 7;
42 // part part 52 // part part
43 private static UUID snd_StoneStone = new UUID("c80260ba-41fd-8a46-768a-6bf236360e3a"); 53 private static UUID snd_StoneStone = new UUID("c80260ba-41fd-8a46-768a-6bf236360e3a");
44 private static UUID snd_StoneMetal = new UUID("c80260ba-41fd-8a46-768a-6bf236360e3a"); 54 private static UUID snd_StoneMetal = new UUID("c80260ba-41fd-8a46-768a-6bf236360e3a");
45 private static UUID snd_StoneGlass = new UUID("c80260ba-41fd-8a46-768a-6bf236360e3a"); 55 private static UUID snd_StoneGlass = new UUID("c80260ba-41fd-8a46-768a-6bf236360e3a");
46 private static UUID snd_StoneWood = new UUID("c80260ba-41fd-8a46-768a-6bf236360e3a"); 56 private static UUID snd_StoneWood = new UUID("c80260ba-41fd-8a46-768a-6bf236360e3a");
@@ -48,29 +58,29 @@ namespace OpenSim.Region.Framework.Scenes
48 private static UUID snd_StonePlastic = new UUID("c80260ba-41fd-8a46-768a-6bf236360e3a"); 58 private static UUID snd_StonePlastic = new UUID("c80260ba-41fd-8a46-768a-6bf236360e3a");
49 private static UUID snd_StoneRubber = new UUID("c80260ba-41fd-8a46-768a-6bf236360e3a"); 59 private static UUID snd_StoneRubber = new UUID("c80260ba-41fd-8a46-768a-6bf236360e3a");
50 60
51 private static UUID snd_MetalMetal = new UUID("c80260ba-41fd-8a46-768a-6bf236360e3a"); 61 private static UUID snd_MetalMetal = new UUID("c80260ba-41fd-8a46-768a-6bf236360e3a");
52 private static UUID snd_MetalGlass = new UUID("c80260ba-41fd-8a46-768a-6bf236360e3a"); 62 private static UUID snd_MetalGlass = new UUID("c80260ba-41fd-8a46-768a-6bf236360e3a");
53 private static UUID snd_MetalWood = new UUID("c80260ba-41fd-8a46-768a-6bf236360e3a"); 63 private static UUID snd_MetalWood = new UUID("c80260ba-41fd-8a46-768a-6bf236360e3a");
54 private static UUID snd_MetalFlesh = new UUID("c80260ba-41fd-8a46-768a-6bf236360e3a"); 64 private static UUID snd_MetalFlesh = new UUID("c80260ba-41fd-8a46-768a-6bf236360e3a");
55 private static UUID snd_MetalPlastic = new UUID("c80260ba-41fd-8a46-768a-6bf236360e3a"); 65 private static UUID snd_MetalPlastic = new UUID("c80260ba-41fd-8a46-768a-6bf236360e3a");
56 private static UUID snd_MetalRubber = new UUID("c80260ba-41fd-8a46-768a-6bf236360e3a"); 66 private static UUID snd_MetalRubber = new UUID("c80260ba-41fd-8a46-768a-6bf236360e3a");
57 67
58 private static UUID snd_GlassGlass = new UUID("c80260ba-41fd-8a46-768a-6bf236360e3a"); 68 private static UUID snd_GlassGlass = new UUID("c80260ba-41fd-8a46-768a-6bf236360e3a");
59 private static UUID snd_GlassWood = new UUID("c80260ba-41fd-8a46-768a-6bf236360e3a"); 69 private static UUID snd_GlassWood = new UUID("c80260ba-41fd-8a46-768a-6bf236360e3a");
60 private static UUID snd_GlassFlesh = new UUID("c80260ba-41fd-8a46-768a-6bf236360e3a"); 70 private static UUID snd_GlassFlesh = new UUID("c80260ba-41fd-8a46-768a-6bf236360e3a");
61 private static UUID snd_GlassPlastic = new UUID("c80260ba-41fd-8a46-768a-6bf236360e3a"); 71 private static UUID snd_GlassPlastic = new UUID("c80260ba-41fd-8a46-768a-6bf236360e3a");
62 private static UUID snd_GlassRubber = new UUID("c80260ba-41fd-8a46-768a-6bf236360e3a"); 72 private static UUID snd_GlassRubber = new UUID("c80260ba-41fd-8a46-768a-6bf236360e3a");
63 73
64 private static UUID snd_WoodWood = new UUID("c80260ba-41fd-8a46-768a-6bf236360e3a"); 74 private static UUID snd_WoodWood = new UUID("c80260ba-41fd-8a46-768a-6bf236360e3a");
65 private static UUID snd_WoodFlesh = new UUID("c80260ba-41fd-8a46-768a-6bf236360e3a"); 75 private static UUID snd_WoodFlesh = new UUID("c80260ba-41fd-8a46-768a-6bf236360e3a");
66 private static UUID snd_WoodPlastic = new UUID("c80260ba-41fd-8a46-768a-6bf236360e3a"); 76 private static UUID snd_WoodPlastic = new UUID("c80260ba-41fd-8a46-768a-6bf236360e3a");
67 private static UUID snd_WoodRubber = new UUID("c80260ba-41fd-8a46-768a-6bf236360e3a"); 77 private static UUID snd_WoodRubber = new UUID("c80260ba-41fd-8a46-768a-6bf236360e3a");
68 78
69 private static UUID snd_FleshFlesh = new UUID("c80260ba-41fd-8a46-768a-6bf236360e3a"); 79 private static UUID snd_FleshFlesh = new UUID("c80260ba-41fd-8a46-768a-6bf236360e3a");
70 private static UUID snd_FleshPlastic = new UUID("c80260ba-41fd-8a46-768a-6bf236360e3a"); 80 private static UUID snd_FleshPlastic = new UUID("c80260ba-41fd-8a46-768a-6bf236360e3a");
71 private static UUID snd_FleshRubber = new UUID("c80260ba-41fd-8a46-768a-6bf236360e3a"); 81 private static UUID snd_FleshRubber = new UUID("c80260ba-41fd-8a46-768a-6bf236360e3a");
72 82
73 private static UUID snd_PlasticPlastic = new UUID("c80260ba-41fd-8a46-768a-6bf236360e3a"); 83 private static UUID snd_PlasticPlastic = new UUID("c80260ba-41fd-8a46-768a-6bf236360e3a");
74 private static UUID snd_PlasticRubber = new UUID("c80260ba-41fd-8a46-768a-6bf236360e3a"); 84 private static UUID snd_PlasticRubber = new UUID("c80260ba-41fd-8a46-768a-6bf236360e3a");
75 85
76 private static UUID snd_RubberRubber = new UUID("c80260ba-41fd-8a46-768a-6bf236360e3a"); 86 private static UUID snd_RubberRubber = new UUID("c80260ba-41fd-8a46-768a-6bf236360e3a");
@@ -107,7 +117,7 @@ namespace OpenSim.Region.Framework.Scenes
107 public static void PartCollisionSound(SceneObjectPart part,List<uint> Colliders) 117 public static void PartCollisionSound(SceneObjectPart part,List<uint> Colliders)
108 { 118 {
109 // temporary mute sounds 119 // temporary mute sounds
110 return; 120// return;
111 121
112 if(Colliders.Count == 0 || part == null) 122 if(Colliders.Count == 0 || part == null)
113 return; 123 return;
@@ -178,28 +188,15 @@ namespace OpenSim.Region.Framework.Scenes
178 } 188 }
179 } 189 }
180 } 190 }
181/* avatars get notification let them trigger the sound
182 else if (!doneownsound)
183 {
184 ScenePresence av = part.ParentGroup.Scene.GetScenePresence(Id);
185 if (av != null && (!av.IsChildAgent))
186 {
187 index = thisMatScaled + 4; // flesh
188 soundID = m_PartPart[index];
189 part.SendCollisionSound(soundID, 1.0);
190 doneownsound = true;
191 }
192 }
193 */
194 } 191 }
195 } 192 }
196 193
197 public static void AvatarCollisionSound(ScenePresence av, List<uint> Colliders) 194 public static void AvatarCollisionSound(ScenePresence av, List<CollisionForSoundInfo> collidersinfolist)
198 { 195 {
199 // temporary mute sounds 196 // temporary mute sounds
200 return; 197// return;
201 198
202 if (Colliders.Count == 0 || av == null) 199 if (collidersinfolist.Count == 0 || av == null)
203 return; 200 return;
204 201
205 UUID soundID; 202 UUID soundID;
@@ -211,30 +208,43 @@ namespace OpenSim.Region.Framework.Scenes
211 int index; 208 int index;
212// bool doneownsound = false; 209// bool doneownsound = false;
213 210
214 Vector3 position = av.AbsolutePosition; 211 CollisionForSoundInfo colInfo;
212 uint id;
213 float volume;
215 214
216 foreach (uint Id in Colliders) 215 for(int i = 0; i< collidersinfolist.Count; i++)
217 { 216 {
218 if (Id == 0) 217 colInfo = collidersinfolist[i];
218
219 volume = Math.Abs(colInfo.relativeVel);
220 if(volume < 0.2f)
221 continue;
222
223 id = colInfo.colliderID;
224
225 if (id == 0) // no terrain collision sounds for now
219 { 226 {
220 continue; 227 continue;
221 } 228 }
222 229
223 SceneObjectPart otherPart = av.Scene.GetSceneObjectPart(Id); 230 SceneObjectPart otherPart = av.Scene.GetSceneObjectPart(id);
224 if (otherPart != null) 231 if (otherPart != null)
225 { 232 {
226 if (otherPart.CollisionSound == otherPart.invalidCollisionSoundUUID) 233 if (otherPart.CollisionSound == otherPart.invalidCollisionSoundUUID)
227 continue; 234 continue;
228 if (otherPart.CollisionSound != UUID.Zero) 235 if (otherPart.CollisionSound != UUID.Zero)
229 otherPart.SendCollisionSound(otherPart.CollisionSound, otherPart.CollisionSoundVolume, position); 236 otherPart.SendCollisionSound(otherPart.CollisionSound, otherPart.CollisionSoundVolume, colInfo.position);
230 else 237 else
231 { 238 {
239 volume *= volume * .0625f; // 4m/s == full volume
240 if (volume > 1.0f)
241 volume = 1.0f;
232 otherMaterial = (int)otherPart.Material; 242 otherMaterial = (int)otherPart.Material;
233 if (otherMaterial >= MaxMaterials) 243 if (otherMaterial >= MaxMaterials)
234 otherMaterial = 3; 244 otherMaterial = 3;
235 index = thisMatScaled + otherMaterial; 245 index = thisMatScaled + otherMaterial;
236 soundID = m_PartPart[index]; 246 soundID = m_PartPart[index];
237 otherPart.SendCollisionSound(soundID, 1.0, position); 247 otherPart.SendCollisionSound(soundID, volume, colInfo.position);
238 } 248 }
239 } 249 }
240/* 250/*