diff --git a/OpenSim/Region/Framework/Scenes/CollisionSounds.cs b/OpenSim/Region/Framework/Scenes/CollisionSounds.cs index e76fef4a79..f87043ea3b 100644 --- a/OpenSim/Region/Framework/Scenes/CollisionSounds.cs +++ b/OpenSim/Region/Framework/Scenes/CollisionSounds.cs @@ -116,16 +116,20 @@ namespace OpenSim.Region.Framework.Scenes public static void PartCollisionSound(SceneObjectPart part, List collidersinfolist) { + if (part.CollisionSoundType < 0) + return; + if (collidersinfolist.Count == 0 || part == null) return; if (part.VolumeDetectActive || (part.Flags & PrimFlags.Physics) == 0) return; - if (part.ParentGroup == null) + SceneObjectGroup sog = part.ParentGroup; + if (sog == null || sog.IsDeleted || sog.inTransit) return; - if (part.CollisionSoundType < 0) + if(sog.CollisionSoundThrootled(part.CollisionSoundType)) return; float volume = part.CollisionSoundVolume; @@ -189,15 +193,23 @@ namespace OpenSim.Region.Framework.Scenes continue; } - SceneObjectPart otherPart = part.ParentGroup.Scene.GetSceneObjectPart(id); + SceneObjectPart otherPart = sog.Scene.GetSceneObjectPart(id); if (otherPart != null) { - if (otherPart.CollisionSoundType < 0 || otherPart.VolumeDetectActive) + SceneObjectGroup othersog = otherPart.ParentGroup; + if(othersog == null || othersog.IsDeleted || othersog.inTransit) + continue; + + int otherType = otherPart.CollisionSoundType; + if (otherType < 0 || otherPart.VolumeDetectActive) continue; if (!HaveSound) { - if (otherPart.CollisionSoundType == 1) + if(othersog.CollisionSoundThrootled(otherType)) + continue; + + if (otherType == 1) { soundID = otherPart.CollisionSound; volume = otherPart.CollisionSoundVolume; @@ -206,7 +218,7 @@ namespace OpenSim.Region.Framework.Scenes } else { - if (otherPart.CollisionSoundType == 2) + if (otherType == 2) { volume = otherPart.CollisionSoundVolume; if (volume == 0.0f) diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs index fdfe8ae7ce..bf915e000d 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs @@ -1259,6 +1259,8 @@ namespace OpenSim.Region.Framework.Scenes set { m_LoopSoundSlavePrims = value; } } + private double m_lastCollisionSoundMS; + /// /// The UUID for the region this object is in. /// @@ -1336,7 +1338,7 @@ namespace OpenSim.Region.Framework.Scenes /// public SceneObjectGroup() { - + m_lastCollisionSoundMS = Util.GetTimeStampMS() + 1000.0; } /// @@ -5528,7 +5530,33 @@ namespace OpenSim.Region.Framework.Scenes } } + public bool CollisionSoundThrootled(int collisionSoundType) + { + double time = m_lastCollisionSoundMS; +// m_lastCollisionSoundMS = Util.GetTimeStampMS(); +// time = m_lastCollisionSoundMS - time; + double now = Util.GetTimeStampMS(); + time = now - time; + switch (collisionSoundType) + { + case 0: // default sounds + case 2: // default sounds with volume set by script + if(time < 300.0) + return true; + break; + case 1: // selected sound + if(time < 200.0) + return true; + break; + default: + break; + } + m_lastCollisionSoundMS = now; + return false; + } + #endregion } + }