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.cs68
1 files changed, 47 insertions, 21 deletions
diff --git a/OpenSim/Region/Framework/Scenes/CollisionSounds.cs b/OpenSim/Region/Framework/Scenes/CollisionSounds.cs
index 075724e..84817a0 100644
--- a/OpenSim/Region/Framework/Scenes/CollisionSounds.cs
+++ b/OpenSim/Region/Framework/Scenes/CollisionSounds.cs
@@ -128,20 +128,29 @@ namespace OpenSim.Region.Framework.Scenes
128 if (part.CollisionSoundType < 0) 128 if (part.CollisionSoundType < 0)
129 return; 129 return;
130 130
131 float volume = 0.0f; 131 float volume = part.CollisionSoundVolume;
132 bool HaveSound = false;
133 132
134 UUID soundID = part.CollisionSound; 133 UUID soundID = part.CollisionSound;
135 134
136 if (part.CollisionSoundType > 0) 135 bool HaveSound = false;
136 switch (part.CollisionSoundType)
137 { 137 {
138 // soundID = part.CollisionSound; 138 case 0: // default sounds
139 volume = part.CollisionSoundVolume; 139 volume = 1.0f;
140 if (volume == 0.0f) 140 break;
141 return; 141 case 1: // selected sound
142 HaveSound = true; 142 if(soundID == part.invalidCollisionSoundUUID)
143 return;
144 HaveSound = true;
145 break;
146 case 2: // default sounds with volume set by script
147 default:
148 break;
143 } 149 }
144 150
151 if (volume == 0.0f)
152 return;
153
145 bool doneownsound = false; 154 bool doneownsound = false;
146 155
147 int thisMaterial = (int)part.Material; 156 int thisMaterial = (int)part.Material;
@@ -152,7 +161,7 @@ namespace OpenSim.Region.Framework.Scenes
152 CollisionForSoundInfo colInfo; 161 CollisionForSoundInfo colInfo;
153 uint id; 162 uint id;
154 163
155 for(int i = 0; i< collidersinfolist.Count; i++) 164 for(int i = 0; i < collidersinfolist.Count; i++)
156 { 165 {
157 colInfo = collidersinfolist[i]; 166 colInfo = collidersinfolist[i];
158 167
@@ -163,15 +172,16 @@ namespace OpenSim.Region.Framework.Scenes
163 { 172 {
164 if (!HaveSound) 173 if (!HaveSound)
165 { 174 {
166 volume = Math.Abs(colInfo.relativeVel); 175 float vol = Math.Abs(colInfo.relativeVel);
167 if (volume < 0.2f) 176 if (vol < 0.2f)
168 continue; 177 continue;
169 178
170 volume *= volume * .0625f; // 4m/s == full volume 179 vol *= vol * .0625f; // 4m/s == full volume
171 if (volume > 1.0f) 180 if (vol > 1.0f)
172 volume = 1.0f; 181 vol = 1.0f;
173 182
174 soundID = m_TerrainPart[thisMaterial]; 183 soundID = m_TerrainPart[thisMaterial];
184 volume *= vol;
175 } 185 }
176 part.SendCollisionSound(soundID, volume, colInfo.position); 186 part.SendCollisionSound(soundID, volume, colInfo.position);
177 doneownsound = true; 187 doneownsound = true;
@@ -187,7 +197,7 @@ namespace OpenSim.Region.Framework.Scenes
187 197
188 if (!HaveSound) 198 if (!HaveSound)
189 { 199 {
190 if (otherPart.CollisionSoundType > 0) 200 if (otherPart.CollisionSoundType == 1)
191 { 201 {
192 soundID = otherPart.CollisionSound; 202 soundID = otherPart.CollisionSound;
193 volume = otherPart.CollisionSoundVolume; 203 volume = otherPart.CollisionSoundVolume;
@@ -196,19 +206,27 @@ namespace OpenSim.Region.Framework.Scenes
196 } 206 }
197 else 207 else
198 { 208 {
199 volume = Math.Abs(colInfo.relativeVel); 209 if (otherPart.CollisionSoundType == 2)
200 if (volume < 0.2f) 210 {
211 volume = otherPart.CollisionSoundVolume;
212 if (volume == 0.0f)
213 continue;
214 }
215
216 float vol = Math.Abs(colInfo.relativeVel);
217 if (vol < 0.2f)
201 continue; 218 continue;
202 219
203 volume *= volume * .0625f; // 4m/s == full volume 220 vol *= vol * .0625f; // 4m/s == full volume
204 if (volume > 1.0f) 221 if (vol > 1.0f)
205 volume = 1.0f; 222 vol = 1.0f;
206 223
207 int otherMaterial = (int)otherPart.Material; 224 int otherMaterial = (int)otherPart.Material;
208 if (otherMaterial >= MaxMaterials) 225 if (otherMaterial >= MaxMaterials)
209 otherMaterial = 3; 226 otherMaterial = 3;
210 227
211 soundID = m_PartPart[thisMatScaled + otherMaterial]; 228 soundID = m_PartPart[thisMatScaled + otherMaterial];
229 volume *= vol;
212 } 230 }
213 } 231 }
214 232
@@ -261,10 +279,17 @@ namespace OpenSim.Region.Framework.Scenes
261 { 279 {
262 if (otherPart.CollisionSoundType < 0) 280 if (otherPart.CollisionSoundType < 0)
263 continue; 281 continue;
264 if (otherPart.CollisionSoundType > 0 && otherPart.CollisionSoundVolume > 0f) 282 if (otherPart.CollisionSoundType == 1 && otherPart.CollisionSoundVolume > 0f)
265 otherPart.SendCollisionSound(otherPart.CollisionSound, otherPart.CollisionSoundVolume, colInfo.position); 283 otherPart.SendCollisionSound(otherPart.CollisionSound, otherPart.CollisionSoundVolume, colInfo.position);
266 else 284 else
267 { 285 {
286 float volmod = 1.0f;
287 if (otherPart.CollisionSoundType == 2)
288 {
289 volmod = otherPart.CollisionSoundVolume;
290 if(volmod == 0.0)
291 continue;
292 }
268 volume = Math.Abs(colInfo.relativeVel); 293 volume = Math.Abs(colInfo.relativeVel);
269 // Most noral collisions (running into walls, stairs) 294 // Most noral collisions (running into walls, stairs)
270 // should never be heard. 295 // should never be heard.
@@ -281,6 +306,7 @@ namespace OpenSim.Region.Framework.Scenes
281 if (otherMaterial >= MaxMaterials) 306 if (otherMaterial >= MaxMaterials)
282 otherMaterial = 3; 307 otherMaterial = 3;
283 308
309 volume *= volmod;
284 soundID = m_PartPart[thisMatScaled + otherMaterial]; 310 soundID = m_PartPart[thisMatScaled + otherMaterial];
285 otherPart.SendCollisionSound(soundID, volume, colInfo.position); 311 otherPart.SendCollisionSound(soundID, volume, colInfo.position);
286 } 312 }