diff options
author | UbitUmarov | 2012-05-19 13:53:49 +0100 |
---|---|---|
committer | UbitUmarov | 2012-05-19 13:53:49 +0100 |
commit | 2c498baf58005be487b4e457455a9896a96b90d3 (patch) | |
tree | 05976958d4499c7394000a44efa25f965535b0e8 /OpenSim/Region/Framework/Scenes/CollisionSounds.cs | |
parent | temp work: sounds simetric acording to materials, still 'window close' test ... (diff) | |
download | opensim-SC-2c498baf58005be487b4e457455a9896a96b90d3.zip opensim-SC-2c498baf58005be487b4e457455a9896a96b90d3.tar.gz opensim-SC-2c498baf58005be487b4e457455a9896a96b90d3.tar.bz2 opensim-SC-2c498baf58005be487b4e457455a9896a96b90d3.tar.xz |
a bit faster collision sound type verification plus a few fixes/changes
Diffstat (limited to 'OpenSim/Region/Framework/Scenes/CollisionSounds.cs')
-rw-r--r-- | OpenSim/Region/Framework/Scenes/CollisionSounds.cs | 73 |
1 files changed, 40 insertions, 33 deletions
diff --git a/OpenSim/Region/Framework/Scenes/CollisionSounds.cs b/OpenSim/Region/Framework/Scenes/CollisionSounds.cs index c593b63..476eccd 100644 --- a/OpenSim/Region/Framework/Scenes/CollisionSounds.cs +++ b/OpenSim/Region/Framework/Scenes/CollisionSounds.cs | |||
@@ -197,30 +197,29 @@ namespace OpenSim.Region.Framework.Scenes | |||
197 | if (part.ParentGroup == null) | 197 | if (part.ParentGroup == null) |
198 | return; | 198 | return; |
199 | 199 | ||
200 | UUID soundID = part.CollisionSound; | 200 | if (part.CollisionSoundType < 0) |
201 | if (soundID == part.invalidCollisionSoundUUID) | ||
202 | return; | 201 | return; |
203 | 202 | ||
204 | float volume = 0.0f; | 203 | float volume = 0.0f; |
205 | int otherMaterial; | ||
206 | bool HaveSound = false; | 204 | bool HaveSound = false; |
207 | 205 | ||
208 | if (soundID != UUID.Zero) | 206 | UUID soundID = part.CollisionSound; |
207 | |||
208 | if (part.CollisionSoundType > 0) | ||
209 | { | 209 | { |
210 | // soundID = part.CollisionSound; | ||
210 | volume = part.CollisionSoundVolume; | 211 | volume = part.CollisionSoundVolume; |
211 | if (volume == 0.0f) | 212 | if (volume == 0.0f) |
212 | return; | 213 | return; |
213 | HaveSound = true; | 214 | HaveSound = true; |
214 | } | 215 | } |
215 | 216 | ||
216 | int thisMaterial = (int) part.Material; | 217 | bool doneownsound = false; |
218 | |||
219 | int thisMaterial = (int)part.Material; | ||
217 | if (thisMaterial >= MaxMaterials) | 220 | if (thisMaterial >= MaxMaterials) |
218 | thisMaterial = 3; | 221 | thisMaterial = 3; |
219 | |||
220 | int thisMatScaled = thisMaterial * MaxMaterials; | 222 | int thisMatScaled = thisMaterial * MaxMaterials; |
221 | int index; | ||
222 | |||
223 | bool doneownsound = false; | ||
224 | 223 | ||
225 | CollisionForSoundInfo colInfo; | 224 | CollisionForSoundInfo colInfo; |
226 | uint id; | 225 | uint id; |
@@ -229,23 +228,21 @@ namespace OpenSim.Region.Framework.Scenes | |||
229 | { | 228 | { |
230 | colInfo = collidersinfolist[i]; | 229 | colInfo = collidersinfolist[i]; |
231 | 230 | ||
232 | if (!HaveSound) | ||
233 | { | ||
234 | volume = Math.Abs(colInfo.relativeVel); | ||
235 | if (volume < 0.2f) | ||
236 | continue; | ||
237 | } | ||
238 | |||
239 | id = colInfo.colliderID; | 231 | id = colInfo.colliderID; |
240 | if (id == 0) | 232 | if (id == 0) // terrain collision |
241 | { | 233 | { |
242 | if (!doneownsound) | 234 | if (!doneownsound) |
243 | { | 235 | { |
244 | if (!HaveSound) | 236 | if (!HaveSound) |
245 | { | 237 | { |
238 | volume = Math.Abs(colInfo.relativeVel); | ||
239 | if (volume < 0.2f) | ||
240 | continue; | ||
241 | |||
246 | volume *= volume * .0625f; // 4m/s == full volume | 242 | volume *= volume * .0625f; // 4m/s == full volume |
247 | if (volume > 1.0f) | 243 | if (volume > 1.0f) |
248 | volume = 1.0f; | 244 | volume = 1.0f; |
245 | |||
249 | soundID = m_TerrainPart[thisMaterial]; | 246 | soundID = m_TerrainPart[thisMaterial]; |
250 | } | 247 | } |
251 | part.SendCollisionSound(soundID, volume, colInfo.position); | 248 | part.SendCollisionSound(soundID, volume, colInfo.position); |
@@ -257,12 +254,12 @@ namespace OpenSim.Region.Framework.Scenes | |||
257 | SceneObjectPart otherPart = part.ParentGroup.Scene.GetSceneObjectPart(id); | 254 | SceneObjectPart otherPart = part.ParentGroup.Scene.GetSceneObjectPart(id); |
258 | if (otherPart != null) | 255 | if (otherPart != null) |
259 | { | 256 | { |
260 | if (otherPart.CollisionSound == part.invalidCollisionSoundUUID || otherPart.VolumeDetectActive) | 257 | if (otherPart.CollisionSoundType < 0 || otherPart.VolumeDetectActive) |
261 | continue; | 258 | continue; |
262 | 259 | ||
263 | if (!HaveSound) | 260 | if (!HaveSound) |
264 | { | 261 | { |
265 | if (otherPart.CollisionSound != UUID.Zero) | 262 | if (otherPart.CollisionSoundType > 0) |
266 | { | 263 | { |
267 | soundID = otherPart.CollisionSound; | 264 | soundID = otherPart.CollisionSound; |
268 | volume = otherPart.CollisionSoundVolume; | 265 | volume = otherPart.CollisionSoundVolume; |
@@ -271,14 +268,19 @@ namespace OpenSim.Region.Framework.Scenes | |||
271 | } | 268 | } |
272 | else | 269 | else |
273 | { | 270 | { |
271 | volume = Math.Abs(colInfo.relativeVel); | ||
272 | if (volume < 0.2f) | ||
273 | continue; | ||
274 | |||
274 | volume *= volume * .0625f; // 4m/s == full volume | 275 | volume *= volume * .0625f; // 4m/s == full volume |
275 | if (volume > 1.0f) | 276 | if (volume > 1.0f) |
276 | volume = 1.0f; | 277 | volume = 1.0f; |
277 | otherMaterial = (int)otherPart.Material; | 278 | |
279 | int otherMaterial = (int)otherPart.Material; | ||
278 | if (otherMaterial >= MaxMaterials) | 280 | if (otherMaterial >= MaxMaterials) |
279 | otherMaterial = 3; | 281 | otherMaterial = 3; |
280 | index = thisMatScaled + otherMaterial; | 282 | |
281 | soundID = m_PartPart[index]; | 283 | soundID = m_PartPart[thisMatScaled + otherMaterial]; |
282 | } | 284 | } |
283 | } | 285 | } |
284 | 286 | ||
@@ -301,11 +303,11 @@ namespace OpenSim.Region.Framework.Scenes | |||
301 | UUID soundID; | 303 | UUID soundID; |
302 | int otherMaterial; | 304 | int otherMaterial; |
303 | 305 | ||
304 | int thisMaterial = 3; | 306 | int thisMaterial = 4; // flesh |
305 | 307 | ||
306 | int thisMatScaled = thisMaterial * MaxMaterials; | 308 | int thisMatScaled = thisMaterial * MaxMaterials; |
307 | int index; | 309 | |
308 | // bool doneownsound = false; | 310 | // bool doneownsound = false; |
309 | 311 | ||
310 | CollisionForSoundInfo colInfo; | 312 | CollisionForSoundInfo colInfo; |
311 | uint id; | 313 | uint id; |
@@ -315,36 +317,41 @@ namespace OpenSim.Region.Framework.Scenes | |||
315 | { | 317 | { |
316 | colInfo = collidersinfolist[i]; | 318 | colInfo = collidersinfolist[i]; |
317 | 319 | ||
318 | volume = Math.Abs(colInfo.relativeVel); | ||
319 | if(volume < 0.2f) | ||
320 | continue; | ||
321 | |||
322 | id = colInfo.colliderID; | 320 | id = colInfo.colliderID; |
323 | 321 | ||
324 | if (id == 0) // no terrain collision sounds for now | 322 | if (id == 0) // no terrain collision sounds for now |
325 | { | 323 | { |
326 | continue; | 324 | continue; |
325 | // volume = Math.Abs(colInfo.relativeVel); | ||
326 | // if (volume < 0.2f) | ||
327 | // continue; | ||
328 | |||
327 | } | 329 | } |
328 | 330 | ||
329 | SceneObjectPart otherPart = av.Scene.GetSceneObjectPart(id); | 331 | SceneObjectPart otherPart = av.Scene.GetSceneObjectPart(id); |
330 | if (otherPart != null) | 332 | if (otherPart != null) |
331 | { | 333 | { |
332 | if (otherPart.CollisionSound == otherPart.invalidCollisionSoundUUID) | 334 | if (otherPart.CollisionSoundType < 0) |
333 | continue; | 335 | continue; |
334 | if (otherPart.CollisionSound != UUID.Zero) | 336 | if (otherPart.CollisionSoundType > 0 && otherPart.CollisionSoundVolume > 0f) |
335 | otherPart.SendCollisionSound(otherPart.CollisionSound, otherPart.CollisionSoundVolume, colInfo.position); | 337 | otherPart.SendCollisionSound(otherPart.CollisionSound, otherPart.CollisionSoundVolume, colInfo.position); |
336 | else | 338 | else |
337 | { | 339 | { |
340 | volume = Math.Abs(colInfo.relativeVel); | ||
341 | if (volume < 0.2f) | ||
342 | continue; | ||
343 | |||
338 | volume *= volume * .0625f; // 4m/s == full volume | 344 | volume *= volume * .0625f; // 4m/s == full volume |
339 | if (volume > 1.0f) | 345 | if (volume > 1.0f) |
340 | volume = 1.0f; | 346 | volume = 1.0f; |
341 | otherMaterial = (int)otherPart.Material; | 347 | otherMaterial = (int)otherPart.Material; |
342 | if (otherMaterial >= MaxMaterials) | 348 | if (otherMaterial >= MaxMaterials) |
343 | otherMaterial = 3; | 349 | otherMaterial = 3; |
344 | index = thisMatScaled + otherMaterial; | 350 | |
345 | soundID = m_PartPart[index]; | 351 | soundID = m_PartPart[thisMatScaled + otherMaterial]; |
346 | otherPart.SendCollisionSound(soundID, volume, colInfo.position); | 352 | otherPart.SendCollisionSound(soundID, volume, colInfo.position); |
347 | } | 353 | } |
354 | continue; | ||
348 | } | 355 | } |
349 | /* | 356 | /* |
350 | else if (!doneownsound) | 357 | else if (!doneownsound) |