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.cs317
1 files changed, 216 insertions, 101 deletions
diff --git a/OpenSim/Region/Framework/Scenes/CollisionSounds.cs b/OpenSim/Region/Framework/Scenes/CollisionSounds.cs
index b1b0f5b..81ca9f1 100644
--- a/OpenSim/Region/Framework/Scenes/CollisionSounds.cs
+++ b/OpenSim/Region/Framework/Scenes/CollisionSounds.cs
@@ -33,45 +33,115 @@ using OpenSim.Framework;
33 33
34namespace OpenSim.Region.Framework.Scenes 34namespace OpenSim.Region.Framework.Scenes
35{ 35{
36 public static class CollisionSounds 36 public struct CollisionForSoundInfo
37 { 37 {
38 // defines for cases 38 public uint colliderID;
39 // only know one UUID for now (woodflesh) 39 public Vector3 position;
40 public float relativeVel;
41 }
40 42
43 public static class CollisionSounds
44 {
41 private const int MaxMaterials = 7; 45 private const int MaxMaterials = 7;
42 // part part 46 // part part
43 private static UUID snd_StoneStone = new UUID("c80260ba-41fd-8a46-768a-6bf236360e3a"); 47/*
44 private static UUID snd_StoneMetal = new UUID("c80260ba-41fd-8a46-768a-6bf236360e3a"); 48 private static UUID snd_StoneStone = new UUID("be7295c0-a158-11e1-b3dd-0800200c9a66");
45 private static UUID snd_StoneGlass = new UUID("c80260ba-41fd-8a46-768a-6bf236360e3a"); 49 private static UUID snd_StoneMetal = new UUID("be7295c0-a158-11e1-b3dd-0800201c9a66");
46 private static UUID snd_StoneWood = new UUID("c80260ba-41fd-8a46-768a-6bf236360e3a"); 50 private static UUID snd_StoneGlass = new UUID("be7295c0-a158-11e1-b3dd-0800202c9a66");
47 private static UUID snd_StoneFlesh = new UUID("c80260ba-41fd-8a46-768a-6bf236360e3a"); 51 private static UUID snd_StoneWood = new UUID("be7295c0-a158-11e1-b3dd-0800203c9a66");
48 private static UUID snd_StonePlastic = new UUID("c80260ba-41fd-8a46-768a-6bf236360e3a"); 52 private static UUID snd_StoneFlesh = new UUID("be7295c0-a158-11e1-b3dd-0800204c9a66");
49 private static UUID snd_StoneRubber = new UUID("c80260ba-41fd-8a46-768a-6bf236360e3a"); 53 private static UUID snd_StonePlastic = new UUID("be7295c0-a158-11e1-b3dd-0800205c9a66");
50 54 private static UUID snd_StoneRubber = new UUID("be7295c0-a158-11e1-b3dd-0800206c9a66");
51 private static UUID snd_MetalMetal = new UUID("c80260ba-41fd-8a46-768a-6bf236360e3a"); 55
52 private static UUID snd_MetalGlass = new UUID("c80260ba-41fd-8a46-768a-6bf236360e3a"); 56 private static UUID snd_MetalStone = new UUID("be7295c0-a158-11e1-b3dd-0801200c9a66");
53 private static UUID snd_MetalWood = new UUID("c80260ba-41fd-8a46-768a-6bf236360e3a"); 57 private static UUID snd_MetalMetal = new UUID("be7295c0-a158-11e1-b3dd-0801201c9a66");
54 private static UUID snd_MetalFlesh = new UUID("c80260ba-41fd-8a46-768a-6bf236360e3a"); 58 private static UUID snd_MetalGlass = new UUID("be7295c0-a158-11e1-b3dd-0801202c9a66");
55 private static UUID snd_MetalPlastic = new UUID("c80260ba-41fd-8a46-768a-6bf236360e3a"); 59 private static UUID snd_MetalWood = new UUID("be7295c0-a158-11e1-b3dd-0801203c9a66");
56 private static UUID snd_MetalRubber = new UUID("c80260ba-41fd-8a46-768a-6bf236360e3a"); 60 private static UUID snd_MetalFlesh = new UUID("be7295c0-a158-11e1-b3dd-0801204c9a66");
57 61 private static UUID snd_MetalPlastic = new UUID("be7295c0-a158-11e1-b3dd-0801205c9a66");
58 private static UUID snd_GlassGlass = new UUID("c80260ba-41fd-8a46-768a-6bf236360e3a"); 62 private static UUID snd_MetalRubber = new UUID("be7295c0-a158-11e1-b3dd-0801206c9a66");
59 private static UUID snd_GlassWood = new UUID("c80260ba-41fd-8a46-768a-6bf236360e3a"); 63
60 private static UUID snd_GlassFlesh = new UUID("c80260ba-41fd-8a46-768a-6bf236360e3a"); 64 private static UUID snd_GlassStone = new UUID("be7295c0-a158-11e1-b3dd-0802200c9a66");
61 private static UUID snd_GlassPlastic = new UUID("c80260ba-41fd-8a46-768a-6bf236360e3a"); 65 private static UUID snd_GlassMetal = new UUID("be7295c0-a158-11e1-b3dd-0802201c9a66");
62 private static UUID snd_GlassRubber = new UUID("c80260ba-41fd-8a46-768a-6bf236360e3a"); 66 private static UUID snd_GlassGlass = new UUID("be7295c0-a158-11e1-b3dd-0802202c9a66");
63 67 private static UUID snd_GlassWood = new UUID("be7295c0-a158-11e1-b3dd-0802203c9a66");
64 private static UUID snd_WoodWood = new UUID("c80260ba-41fd-8a46-768a-6bf236360e3a"); 68 private static UUID snd_GlassFlesh = new UUID("be7295c0-a158-11e1-b3dd-0802204c9a66");
65 private static UUID snd_WoodFlesh = new UUID("c80260ba-41fd-8a46-768a-6bf236360e3a"); 69 private static UUID snd_GlassPlastic = new UUID("be7295c0-a158-11e1-b3dd-0802205c9a66");
66 private static UUID snd_WoodPlastic = new UUID("c80260ba-41fd-8a46-768a-6bf236360e3a"); 70 private static UUID snd_GlassRubber = new UUID("be7295c0-a158-11e1-b3dd-0802206c9a66");
67 private static UUID snd_WoodRubber = new UUID("c80260ba-41fd-8a46-768a-6bf236360e3a"); 71
68 72 private static UUID snd_WoodStone = new UUID("be7295c0-a158-11e1-b3dd-0803200c9a66");
69 private static UUID snd_FleshFlesh = new UUID("c80260ba-41fd-8a46-768a-6bf236360e3a"); 73 private static UUID snd_WoodMetal = new UUID("be7295c0-a158-11e1-b3dd-0803201c9a66");
70 private static UUID snd_FleshPlastic = new UUID("c80260ba-41fd-8a46-768a-6bf236360e3a"); 74 private static UUID snd_WoodGlass = new UUID("be7295c0-a158-11e1-b3dd-0803202c9a66");
71 private static UUID snd_FleshRubber = new UUID("c80260ba-41fd-8a46-768a-6bf236360e3a"); 75 private static UUID snd_WoodWood = new UUID("be7295c0-a158-11e1-b3dd-0803203c9a66");
72 76 private static UUID snd_WoodFlesh = new UUID("be7295c0-a158-11e1-b3dd-0803204c9a66");
73 private static UUID snd_PlasticPlastic = new UUID("c80260ba-41fd-8a46-768a-6bf236360e3a"); 77 private static UUID snd_WoodPlastic = new UUID("be7295c0-a158-11e1-b3dd-0803205c9a66");
74 private static UUID snd_PlasticRubber = new UUID("c80260ba-41fd-8a46-768a-6bf236360e3a"); 78 private static UUID snd_WoodRubber = new UUID("be7295c0-a158-11e1-b3dd-0803206c9a66");
79
80 private static UUID snd_FleshStone = new UUID("be7295c0-a158-11e1-b3dd-0804200c9a66");
81 private static UUID snd_FleshMetal = new UUID("be7295c0-a158-11e1-b3dd-0804201c9a66");
82 private static UUID snd_FleshGlass = new UUID("be7295c0-a158-11e1-b3dd-0804202c9a66");
83 private static UUID snd_FleshWood = new UUID("be7295c0-a158-11e1-b3dd-0804203c9a66");
84 private static UUID snd_FleshFlesh = new UUID("be7295c0-a158-11e1-b3dd-0804204c9a66");
85 private static UUID snd_FleshPlastic = new UUID("be7295c0-a158-11e1-b3dd-0804205c9a66");
86 private static UUID snd_FleshRubber = new UUID("be7295c0-a158-11e1-b3dd-0804206c9a66");
87
88 private static UUID snd_PlasticStone = new UUID("be7295c0-a158-11e1-b3dd-0805200c9a66");
89 private static UUID snd_PlasticMetal = new UUID("be7295c0-a158-11e1-b3dd-0805201c9a66");
90 private static UUID snd_PlasticGlass = new UUID("be7295c0-a158-11e1-b3dd-0805202c9a66");
91 private static UUID snd_PlasticWood = new UUID("be7295c0-a158-11e1-b3dd-0805203c9a66");
92 private static UUID snd_PlasticFlesh = new UUID("be7295c0-a158-11e1-b3dd-0805204c9a66");
93 private static UUID snd_PlasticPlastic = new UUID("be7295c0-a158-11e1-b3dd-0805205c9a66");
94 private static UUID snd_PlasticRubber = new UUID("be7295c0-a158-11e1-b3dd-0805206c9a66");
95
96 private static UUID snd_RubberStone = new UUID("be7295c0-a158-11e1-b3dd-0806200c9a66");
97 private static UUID snd_RubberMetal = new UUID("be7295c0-a158-11e1-b3dd-0806201c9a66");
98 private static UUID snd_RubberGlass = new UUID("be7295c0-a158-11e1-b3dd-0806202c9a66");
99 private static UUID snd_RubberWood = new UUID("be7295c0-a158-11e1-b3dd-0806203c9a66");
100 private static UUID snd_RubberFlesh = new UUID("be7295c0-a158-11e1-b3dd-0806204c9a66");
101 private static UUID snd_RubberPlastic = new UUID("be7295c0-a158-11e1-b3dd-0806205c9a66");
102 private static UUID snd_RubberRubber = new UUID("be7295c0-a158-11e1-b3dd-0806206c9a66");
103
104 // terrain part
105 private static UUID snd_TerrainStone = new UUID("be7295c0-a158-11e1-b3dd-0807200c9a66");
106 private static UUID snd_TerrainMetal = new UUID("be7295c0-a158-11e1-b3dd-0807200c9a66");
107 private static UUID snd_TerrainGlass = new UUID("be7295c0-a158-11e1-b3dd-0807200c9a66");
108 private static UUID snd_TerrainWood = new UUID("be7295c0-a158-11e1-b3dd-0807200c9a66");
109 private static UUID snd_TerrainFlesh = new UUID("be7295c0-a158-11e1-b3dd-0807200c9a66");
110 private static UUID snd_TerrainPlastic = new UUID("be7295c0-a158-11e1-b3dd-0807200c9a66");
111 private static UUID snd_TerrainRubber = new UUID("be7295c0-a158-11e1-b3dd-0807200c9a66");
112*/
113 private static UUID snd_StoneStone = new UUID("c80260ba-41fd-8a46-768a-6bf236360e3a");
114 private static UUID snd_StoneMetal = new UUID("c80260ba-41fd-8a46-768a-6bf236360e3a");
115 private static UUID snd_StoneGlass = new UUID("c80260ba-41fd-8a46-768a-6bf236360e3a");
116 private static UUID snd_StoneWood = new UUID("c80260ba-41fd-8a46-768a-6bf236360e3a");
117 private static UUID snd_StoneFlesh = new UUID("c80260ba-41fd-8a46-768a-6bf236360e3a");
118 private static UUID snd_StonePlastic = new UUID("c80260ba-41fd-8a46-768a-6bf236360e3a");
119 private static UUID snd_StoneRubber = new UUID("c80260ba-41fd-8a46-768a-6bf236360e3a");
120
121 private static UUID snd_MetalMetal = new UUID("c80260ba-41fd-8a46-768a-6bf236360e3a");
122 private static UUID snd_MetalGlass = new UUID("c80260ba-41fd-8a46-768a-6bf236360e3a");
123 private static UUID snd_MetalWood = new UUID("c80260ba-41fd-8a46-768a-6bf236360e3a");
124 private static UUID snd_MetalFlesh = new UUID("c80260ba-41fd-8a46-768a-6bf236360e3a");
125 private static UUID snd_MetalPlastic = new UUID("c80260ba-41fd-8a46-768a-6bf236360e3a");
126 private static UUID snd_MetalRubber = new UUID("c80260ba-41fd-8a46-768a-6bf236360e3a");
127
128 private static UUID snd_GlassGlass = new UUID("c80260ba-41fd-8a46-768a-6bf236360e3a");
129 private static UUID snd_GlassWood = new UUID("c80260ba-41fd-8a46-768a-6bf236360e3a");
130 private static UUID snd_GlassFlesh = new UUID("c80260ba-41fd-8a46-768a-6bf236360e3a");
131 private static UUID snd_GlassPlastic = new UUID("c80260ba-41fd-8a46-768a-6bf236360e3a");
132 private static UUID snd_GlassRubber = new UUID("c80260ba-41fd-8a46-768a-6bf236360e3a");
133
134 private static UUID snd_WoodWood = new UUID("c80260ba-41fd-8a46-768a-6bf236360e3a");
135 private static UUID snd_WoodFlesh = new UUID("c80260ba-41fd-8a46-768a-6bf236360e3a");
136 private static UUID snd_WoodPlastic = new UUID("c80260ba-41fd-8a46-768a-6bf236360e3a");
137 private static UUID snd_WoodRubber = new UUID("c80260ba-41fd-8a46-768a-6bf236360e3a");
138
139 private static UUID snd_FleshFlesh = new UUID("c80260ba-41fd-8a46-768a-6bf236360e3a");
140 private static UUID snd_FleshPlastic = new UUID("c80260ba-41fd-8a46-768a-6bf236360e3a");
141 private static UUID snd_FleshRubber = new UUID("c80260ba-41fd-8a46-768a-6bf236360e3a");
142
143 private static UUID snd_PlasticPlastic = new UUID("c80260ba-41fd-8a46-768a-6bf236360e3a");
144 private static UUID snd_PlasticRubber = new UUID("c80260ba-41fd-8a46-768a-6bf236360e3a");
75 145
76 private static UUID snd_RubberRubber = new UUID("c80260ba-41fd-8a46-768a-6bf236360e3a"); 146 private static UUID snd_RubberRubber = new UUID("c80260ba-41fd-8a46-768a-6bf236360e3a");
77 147
@@ -93,7 +163,19 @@ namespace OpenSim.Region.Framework.Scenes
93 snd_TerrainPlastic, 163 snd_TerrainPlastic,
94 snd_TerrainRubber 164 snd_TerrainRubber
95 }; 165 };
96 166/*
167 //full assimetric sounds
168 public static UUID[] m_PartPart = {
169 snd_StoneStone, snd_StoneMetal, snd_StoneGlass, snd_StoneWood, snd_StoneFlesh, snd_StonePlastic, snd_StoneRubber,
170 snd_MetalStone, snd_MetalMetal, snd_MetalGlass, snd_MetalWood, snd_MetalFlesh, snd_MetalPlastic, snd_MetalRubber,
171 snd_GlassStone, snd_GlassMetal, snd_GlassGlass, snd_GlassWood, snd_GlassFlesh, snd_GlassPlastic, snd_GlassRubber,
172 snd_WoodStone, snd_WoodMetal, snd_WoodGlass, snd_WoodWood, snd_WoodFlesh, snd_WoodPlastic, snd_WoodRubber,
173 snd_FleshStone, snd_FleshMetal, snd_FleshGlass, snd_FleshWood, snd_FleshFlesh, snd_FleshPlastic, snd_FleshRubber,
174 snd_PlasticStone, snd_PlasticMetal, snd_PlasticGlass, snd_PlasticWood, snd_PlasticFlesh, snd_PlasticPlastic, snd_PlasticRubber,
175 snd_RubberStone, snd_RubberMetal, snd_RubberGlass, snd_RubberWood, snd_RubberFlesh, snd_RubberPlastic, snd_RubberRubber
176 };
177*/
178 // simetric sounds
97 public static UUID[] m_PartPart = { 179 public static UUID[] m_PartPart = {
98 snd_StoneStone, snd_StoneMetal, snd_StoneGlass, snd_StoneWood, snd_StoneFlesh, snd_StonePlastic, snd_StoneRubber, 180 snd_StoneStone, snd_StoneMetal, snd_StoneGlass, snd_StoneWood, snd_StoneFlesh, snd_StonePlastic, snd_StoneRubber,
99 snd_StoneMetal, snd_MetalMetal, snd_MetalGlass, snd_MetalWood, snd_MetalFlesh, snd_MetalPlastic, snd_MetalRubber, 181 snd_StoneMetal, snd_MetalMetal, snd_MetalGlass, snd_MetalWood, snd_MetalFlesh, snd_MetalPlastic, snd_MetalRubber,
@@ -103,13 +185,10 @@ namespace OpenSim.Region.Framework.Scenes
103 snd_StonePlastic, snd_MetalPlastic, snd_GlassPlastic, snd_WoodPlastic, snd_FleshPlastic, snd_PlasticPlastic, snd_PlasticRubber, 185 snd_StonePlastic, snd_MetalPlastic, snd_GlassPlastic, snd_WoodPlastic, snd_FleshPlastic, snd_PlasticPlastic, snd_PlasticRubber,
104 snd_StoneRubber, snd_MetalRubber, snd_GlassRubber, snd_WoodRubber, snd_FleshRubber, snd_PlasticRubber, snd_RubberRubber 186 snd_StoneRubber, snd_MetalRubber, snd_GlassRubber, snd_WoodRubber, snd_FleshRubber, snd_PlasticRubber, snd_RubberRubber
105 }; 187 };
106 188
107 public static void PartCollisionSound(SceneObjectPart part,List<uint> Colliders) 189 public static void PartCollisionSound(SceneObjectPart part, List<CollisionForSoundInfo> collidersinfolist)
108 { 190 {
109 // temporary mute sounds 191 if (collidersinfolist.Count == 0 || part == null)
110 return;
111
112 if(Colliders.Count == 0 || part == null)
113 return; 192 return;
114 193
115 if (part.VolumeDetectActive || (part.Flags & PrimFlags.Physics) == 0) 194 if (part.VolumeDetectActive || (part.Flags & PrimFlags.Physics) == 0)
@@ -118,124 +197,161 @@ namespace OpenSim.Region.Framework.Scenes
118 if (part.ParentGroup == null) 197 if (part.ParentGroup == null)
119 return; 198 return;
120 199
121 if (part.CollisionSound == part.invalidCollisionSoundUUID) 200 if (part.CollisionSoundType < 0)
122 return; 201 return;
123 202
124 UUID soundID; 203 float volume = 0.0f;
125 int otherMaterial; 204 bool HaveSound = false;
126 205
127 Vector3 position = part.AbsolutePosition; 206 UUID soundID = part.CollisionSound;
128 207
129 if (part.CollisionSound != UUID.Zero) 208 if (part.CollisionSoundType > 0)
130 { 209 {
131 if (part.CollisionSoundVolume > 0.0f) 210 // soundID = part.CollisionSound;
132 part.SendCollisionSound(part.CollisionSound, part.CollisionSoundVolume, position); 211 volume = part.CollisionSoundVolume;
133 return; 212 if (volume == 0.0f)
213 return;
214 HaveSound = true;
134 } 215 }
135 216
136 int thisMaterial = (int) part.Material; 217 bool doneownsound = false;
218
219 int thisMaterial = (int)part.Material;
137 if (thisMaterial >= MaxMaterials) 220 if (thisMaterial >= MaxMaterials)
138 thisMaterial = 3; 221 thisMaterial = 3;
139
140 int thisMatScaled = thisMaterial * MaxMaterials; 222 int thisMatScaled = thisMaterial * MaxMaterials;
141 int index;
142 223
143 bool doneownsound = false; 224 CollisionForSoundInfo colInfo;
225 uint id;
144 226
145 foreach (uint Id in Colliders) 227 for(int i = 0; i< collidersinfolist.Count; i++)
146 { 228 {
147 if (Id == 0) 229 colInfo = collidersinfolist[i];
230
231 id = colInfo.colliderID;
232 if (id == 0) // terrain collision
148 { 233 {
149 if (!doneownsound) 234 if (!doneownsound)
150 { 235 {
151 soundID = m_TerrainPart[thisMaterial]; 236 if (!HaveSound)
152 part.SendCollisionSound(soundID, 1.0, position); 237 {
238 volume = Math.Abs(colInfo.relativeVel);
239 if (volume < 0.2f)
240 continue;
241
242 volume *= volume * .0625f; // 4m/s == full volume
243 if (volume > 1.0f)
244 volume = 1.0f;
245
246 soundID = m_TerrainPart[thisMaterial];
247 }
248 part.SendCollisionSound(soundID, volume, colInfo.position);
153 doneownsound = true; 249 doneownsound = true;
154 } 250 }
155 continue; 251 continue;
156 } 252 }
157 253
158 SceneObjectPart otherPart = part.ParentGroup.Scene.GetSceneObjectPart(Id); 254 SceneObjectPart otherPart = part.ParentGroup.Scene.GetSceneObjectPart(id);
159 if (otherPart != null) 255 if (otherPart != null)
160 { 256 {
161 if (otherPart.CollisionSound == part.invalidCollisionSoundUUID || otherPart.VolumeDetectActive) 257 if (otherPart.CollisionSoundType < 0 || otherPart.VolumeDetectActive)
162 continue; 258 continue;
163 if (otherPart.CollisionSound != UUID.Zero) 259
164 otherPart.SendCollisionSound(otherPart.CollisionSound, otherPart.CollisionSoundVolume, position); 260 if (!HaveSound)
165 else
166 { 261 {
167 otherMaterial = (int)otherPart.Material; 262 if (otherPart.CollisionSoundType > 0)
168 if (otherMaterial >= MaxMaterials) 263 {
169 otherMaterial = 3; 264 soundID = otherPart.CollisionSound;
170 index = thisMatScaled + otherMaterial; 265 volume = otherPart.CollisionSoundVolume;
171 soundID = m_PartPart[index]; 266 if (volume == 0.0f)
172 if (doneownsound) 267 continue;
173 otherPart.SendCollisionSound(soundID, 1.0, position); 268 }
174 else 269 else
175 { 270 {
176 part.SendCollisionSound(soundID, 1.0, position); 271 volume = Math.Abs(colInfo.relativeVel);
177 doneownsound = true; 272 if (volume < 0.2f)
273 continue;
274
275 volume *= volume * .0625f; // 4m/s == full volume
276 if (volume > 1.0f)
277 volume = 1.0f;
278
279 int otherMaterial = (int)otherPart.Material;
280 if (otherMaterial >= MaxMaterials)
281 otherMaterial = 3;
282
283 soundID = m_PartPart[thisMatScaled + otherMaterial];
178 } 284 }
179 } 285 }
180 } 286
181/* avatars get notification let them trigger the sound 287 if (doneownsound)
182 else if (!doneownsound) 288 otherPart.SendCollisionSound(soundID, volume, colInfo.position);
183 { 289 else
184 ScenePresence av = part.ParentGroup.Scene.GetScenePresence(Id);
185 if (av != null && (!av.IsChildAgent))
186 { 290 {
187 index = thisMatScaled + 4; // flesh 291 part.SendCollisionSound(soundID, volume, colInfo.position);
188 soundID = m_PartPart[index];
189 part.SendCollisionSound(soundID, 1.0);
190 doneownsound = true; 292 doneownsound = true;
191 } 293 }
192 } 294 }
193 */
194 } 295 }
195 } 296 }
196 297
197 public static void AvatarCollisionSound(ScenePresence av, List<uint> Colliders) 298 public static void AvatarCollisionSound(ScenePresence av, List<CollisionForSoundInfo> collidersinfolist)
198 { 299 {
199 // temporary mute sounds 300 if (collidersinfolist.Count == 0 || av == null)
200 return;
201
202 if (Colliders.Count == 0 || av == null)
203 return; 301 return;
204 302
205 UUID soundID; 303 UUID soundID;
206 int otherMaterial; 304 int otherMaterial;
207 305
208 int thisMaterial = 3; 306 int thisMaterial = 4; // flesh
209 307
210 int thisMatScaled = thisMaterial * MaxMaterials; 308 int thisMatScaled = thisMaterial * MaxMaterials;
211 int index;
212// bool doneownsound = false;
213 309
214 Vector3 position = av.AbsolutePosition; 310 // bool doneownsound = false;
215 311
216 foreach (uint Id in Colliders) 312 CollisionForSoundInfo colInfo;
313 uint id;
314 float volume;
315
316 for(int i = 0; i< collidersinfolist.Count; i++)
217 { 317 {
218 if (Id == 0) 318 colInfo = collidersinfolist[i];
319
320 id = colInfo.colliderID;
321
322 if (id == 0) // no terrain collision sounds for now
219 { 323 {
220 continue; 324 continue;
325// volume = Math.Abs(colInfo.relativeVel);
326// if (volume < 0.2f)
327// continue;
328
221 } 329 }
222 330
223 SceneObjectPart otherPart = av.Scene.GetSceneObjectPart(Id); 331 SceneObjectPart otherPart = av.Scene.GetSceneObjectPart(id);
224 if (otherPart != null) 332 if (otherPart != null)
225 { 333 {
226 if (otherPart.CollisionSound == otherPart.invalidCollisionSoundUUID) 334 if (otherPart.CollisionSoundType < 0)
227 continue; 335 continue;
228 if (otherPart.CollisionSound != UUID.Zero) 336 if (otherPart.CollisionSoundType > 0 && otherPart.CollisionSoundVolume > 0f)
229 otherPart.SendCollisionSound(otherPart.CollisionSound, otherPart.CollisionSoundVolume, position); 337 otherPart.SendCollisionSound(otherPart.CollisionSound, otherPart.CollisionSoundVolume, colInfo.position);
230 else 338 else
231 { 339 {
340 volume = Math.Abs(colInfo.relativeVel);
341 if (volume < 0.2f)
342 continue;
343
344 volume *= volume * .0625f; // 4m/s == full volume
345 if (volume > 1.0f)
346 volume = 1.0f;
232 otherMaterial = (int)otherPart.Material; 347 otherMaterial = (int)otherPart.Material;
233 if (otherMaterial >= MaxMaterials) 348 if (otherMaterial >= MaxMaterials)
234 otherMaterial = 3; 349 otherMaterial = 3;
235 index = thisMatScaled + otherMaterial; 350
236 soundID = m_PartPart[index]; 351 soundID = m_PartPart[thisMatScaled + otherMaterial];
237 otherPart.SendCollisionSound(soundID, 1.0, position); 352 otherPart.SendCollisionSound(soundID, volume, colInfo.position);
238 } 353 }
354 continue;
239 } 355 }
240/* 356/*
241 else if (!doneownsound) 357 else if (!doneownsound)
@@ -251,6 +367,5 @@ namespace OpenSim.Region.Framework.Scenes
251 */ 367 */
252 } 368 }
253 } 369 }
254
255 } 370 }
256} 371}