diff options
author | UbitUmarov | 2012-05-19 02:04:10 +0100 |
---|---|---|
committer | UbitUmarov | 2012-05-19 02:04:10 +0100 |
commit | 9ecdef2686de9045f1fddd8b64bcf73c04e1e0ab (patch) | |
tree | 26b18810c8eb8304d74562e1f33ef1caecf94cc2 /OpenSim/Region/Framework/Scenes/SceneObjectPart.cs | |
parent | modulate collision sounds intensity with relative collision speed (diff) | |
download | opensim-SC_OLD-9ecdef2686de9045f1fddd8b64bcf73c04e1e0ab.zip opensim-SC_OLD-9ecdef2686de9045f1fddd8b64bcf73c04e1e0ab.tar.gz opensim-SC_OLD-9ecdef2686de9045f1fddd8b64bcf73c04e1e0ab.tar.bz2 opensim-SC_OLD-9ecdef2686de9045f1fddd8b64bcf73c04e1e0ab.tar.xz |
modulate collision sound intensity with collision relative velocity for parts also
Diffstat (limited to '')
-rw-r--r-- | OpenSim/Region/Framework/Scenes/SceneObjectPart.cs | 45 |
1 files changed, 29 insertions, 16 deletions
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs index b5705b7..467b625 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs | |||
@@ -333,7 +333,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
333 | private UUID m_collisionSound; | 333 | private UUID m_collisionSound; |
334 | private float m_collisionSoundVolume; | 334 | private float m_collisionSoundVolume; |
335 | 335 | ||
336 | private DateTime LastColSoundSentTime; | 336 | private int LastColSoundSentTime; |
337 | 337 | ||
338 | 338 | ||
339 | private SOPVehicle m_vehicle = null; | 339 | private SOPVehicle m_vehicle = null; |
@@ -374,7 +374,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
374 | // this appears to have the same UUID (!) as the prim. If this isn't the case, one can't drag items from | 374 | // this appears to have the same UUID (!) as the prim. If this isn't the case, one can't drag items from |
375 | // the prim into an agent inventory (Linden client reports that the "Object not found for drop" in its log | 375 | // the prim into an agent inventory (Linden client reports that the "Object not found for drop" in its log |
376 | m_inventory = new SceneObjectPartInventory(this); | 376 | m_inventory = new SceneObjectPartInventory(this); |
377 | LastColSoundSentTime = DateTime.UtcNow; | 377 | LastColSoundSentTime = Util.EnvironmentTickCount(); |
378 | } | 378 | } |
379 | 379 | ||
380 | /// <summary> | 380 | /// <summary> |
@@ -2632,13 +2632,29 @@ namespace OpenSim.Region.Framework.Scenes | |||
2632 | 2632 | ||
2633 | else | 2633 | else |
2634 | { | 2634 | { |
2635 | List<CollisionForSoundInfo> soundinfolist = new List<CollisionForSoundInfo>(); | ||
2636 | CollisionForSoundInfo soundinfo; | ||
2637 | ContactPoint curcontact; | ||
2638 | |||
2635 | // calculate things that started colliding this time | 2639 | // calculate things that started colliding this time |
2636 | // and build up list of colliders this time | 2640 | // and build up list of colliders this time |
2637 | foreach (uint localid in collissionswith.Keys) | 2641 | foreach (uint id in collissionswith.Keys) |
2638 | { | 2642 | { |
2639 | thisHitColliders.Add(localid); | 2643 | thisHitColliders.Add(id); |
2640 | if (!m_lastColliders.Contains(localid)) | 2644 | if (!m_lastColliders.Contains(id)) |
2641 | startedColliders.Add(localid); | 2645 | { |
2646 | startedColliders.Add(id); | ||
2647 | |||
2648 | curcontact = collissionswith[id]; | ||
2649 | if (Math.Abs(curcontact.RelativeSpeed) > 0.2) | ||
2650 | { | ||
2651 | soundinfo = new CollisionForSoundInfo(); | ||
2652 | soundinfo.colliderID = id; | ||
2653 | soundinfo.position = curcontact.Position; | ||
2654 | soundinfo.relativeVel = curcontact.RelativeSpeed; | ||
2655 | soundinfolist.Add(soundinfo); | ||
2656 | } | ||
2657 | } | ||
2642 | } | 2658 | } |
2643 | 2659 | ||
2644 | // calculate things that ended colliding | 2660 | // calculate things that ended colliding |
@@ -2655,17 +2671,14 @@ namespace OpenSim.Region.Framework.Scenes | |||
2655 | // remove things that ended colliding from the last colliders list | 2671 | // remove things that ended colliding from the last colliders list |
2656 | foreach (uint localID in endedColliders) | 2672 | foreach (uint localID in endedColliders) |
2657 | m_lastColliders.Remove(localID); | 2673 | m_lastColliders.Remove(localID); |
2658 | } | ||
2659 | |||
2660 | // play the sound. | ||
2661 | 2674 | ||
2662 | bool IsNotVolumeDtc = !VolumeDetectActive; | 2675 | // play sounds. |
2663 | 2676 | if (soundinfolist.Count > 0 && !VolumeDetectActive && CollisionSound != invalidCollisionSoundUUID) | |
2664 | if (IsNotVolumeDtc && startedColliders.Count > 0 && CollisionSound != invalidCollisionSoundUUID) | 2677 | CollisionSounds.PartCollisionSound(this, soundinfolist); |
2665 | CollisionSounds.PartCollisionSound(this, startedColliders); | 2678 | } |
2666 | 2679 | ||
2667 | SendCollisionEvent(scriptEvents.collision_start, startedColliders, ParentGroup.Scene.EventManager.TriggerScriptCollidingStart); | 2680 | SendCollisionEvent(scriptEvents.collision_start, startedColliders, ParentGroup.Scene.EventManager.TriggerScriptCollidingStart); |
2668 | if (IsNotVolumeDtc) | 2681 | if (!VolumeDetectActive) |
2669 | SendCollisionEvent(scriptEvents.collision , m_lastColliders , ParentGroup.Scene.EventManager.TriggerScriptColliding); | 2682 | SendCollisionEvent(scriptEvents.collision , m_lastColliders , ParentGroup.Scene.EventManager.TriggerScriptColliding); |
2670 | SendCollisionEvent(scriptEvents.collision_end , endedColliders , ParentGroup.Scene.EventManager.TriggerScriptCollidingEnd); | 2683 | SendCollisionEvent(scriptEvents.collision_end , endedColliders , ParentGroup.Scene.EventManager.TriggerScriptCollidingEnd); |
2671 | 2684 | ||
@@ -3210,8 +3223,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
3210 | if (volume < 0) | 3223 | if (volume < 0) |
3211 | volume = 0; | 3224 | volume = 0; |
3212 | 3225 | ||
3213 | DateTime now = DateTime.UtcNow; | 3226 | int now = Util.EnvironmentTickCount(); |
3214 | if((now - LastColSoundSentTime).Milliseconds < 200) // reduce rate to 5 per sec per part ?? | 3227 | if(Util.EnvironmentTickCountSubtract(now,LastColSoundSentTime) <200) |
3215 | return; | 3228 | return; |
3216 | 3229 | ||
3217 | LastColSoundSentTime = now; | 3230 | LastColSoundSentTime = now; |