diff options
Diffstat (limited to 'OpenSim/Region/Framework/Scenes/SceneObjectPart.cs')
-rw-r--r-- | OpenSim/Region/Framework/Scenes/SceneObjectPart.cs | 52 |
1 files changed, 48 insertions, 4 deletions
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs index 8716e20..af9b7eb 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs | |||
@@ -188,6 +188,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
188 | 188 | ||
189 | public double SoundRadius; | 189 | public double SoundRadius; |
190 | 190 | ||
191 | |||
191 | public uint TimeStampFull; | 192 | public uint TimeStampFull; |
192 | 193 | ||
193 | public uint TimeStampLastActivity; // Will be used for AutoReturn | 194 | public uint TimeStampLastActivity; // Will be used for AutoReturn |
@@ -332,6 +333,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
332 | private UUID m_collisionSound; | 333 | private UUID m_collisionSound; |
333 | private float m_collisionSoundVolume; | 334 | private float m_collisionSoundVolume; |
334 | 335 | ||
336 | private DateTime LastColSoundSentTime; | ||
337 | |||
335 | 338 | ||
336 | private SOPVehicle m_vehicle = null; | 339 | private SOPVehicle m_vehicle = null; |
337 | 340 | ||
@@ -371,6 +374,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
371 | // 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 |
372 | // 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 |
373 | m_inventory = new SceneObjectPartInventory(this); | 376 | m_inventory = new SceneObjectPartInventory(this); |
377 | LastColSoundSentTime = DateTime.UtcNow; | ||
374 | } | 378 | } |
375 | 379 | ||
376 | /// <summary> | 380 | /// <summary> |
@@ -1336,11 +1340,13 @@ namespace OpenSim.Region.Framework.Scenes | |||
1336 | set { m_sitAnimation = value; } | 1340 | set { m_sitAnimation = value; } |
1337 | } | 1341 | } |
1338 | 1342 | ||
1343 | public UUID invalidCollisionSoundUUID = new UUID("ffffffff-ffff-ffff-ffff-ffffffffffff"); | ||
1344 | |||
1339 | public UUID CollisionSound | 1345 | public UUID CollisionSound |
1340 | { | 1346 | { |
1341 | get { return m_collisionSound; } | 1347 | get { return m_collisionSound; } |
1342 | set | 1348 | set |
1343 | { | 1349 | { |
1344 | m_collisionSound = value; | 1350 | m_collisionSound = value; |
1345 | aggregateScriptEvents(); | 1351 | aggregateScriptEvents(); |
1346 | } | 1352 | } |
@@ -2655,8 +2661,15 @@ namespace OpenSim.Region.Framework.Scenes | |||
2655 | 2661 | ||
2656 | bool IsNotVolumeDtc = !VolumeDetectActive; | 2662 | bool IsNotVolumeDtc = !VolumeDetectActive; |
2657 | 2663 | ||
2658 | if (startedColliders.Count > 0 && CollisionSound != UUID.Zero && CollisionSoundVolume > 0.0f && IsNotVolumeDtc) | 2664 | if (IsNotVolumeDtc && startedColliders.Count > 0 && CollisionSoundVolume > 0.0f && CollisionSound != invalidCollisionSoundUUID) |
2659 | SendSound(CollisionSound.ToString(), CollisionSoundVolume, true, (byte)0, 0, false, false); | 2665 | { |
2666 | if(CollisionSound != UUID.Zero) | ||
2667 | SendCollisionSound(CollisionSound, CollisionSoundVolume); | ||
2668 | else | ||
2669 | { | ||
2670 | CollisionSounds.PartCollisionSound(this, startedColliders); | ||
2671 | } | ||
2672 | } | ||
2660 | 2673 | ||
2661 | SendCollisionEvent(scriptEvents.collision_start, startedColliders, ParentGroup.Scene.EventManager.TriggerScriptCollidingStart); | 2674 | SendCollisionEvent(scriptEvents.collision_start, startedColliders, ParentGroup.Scene.EventManager.TriggerScriptCollidingStart); |
2662 | if (IsNotVolumeDtc) | 2675 | if (IsNotVolumeDtc) |
@@ -3190,6 +3203,37 @@ namespace OpenSim.Region.Framework.Scenes | |||
3190 | } | 3203 | } |
3191 | } | 3204 | } |
3192 | 3205 | ||
3206 | public void SendCollisionSound(UUID soundID, double volume) | ||
3207 | { | ||
3208 | if (soundID == UUID.Zero) | ||
3209 | return; | ||
3210 | |||
3211 | |||
3212 | ISoundModule soundModule = ParentGroup.Scene.RequestModuleInterface<ISoundModule>(); | ||
3213 | if (soundModule == null) | ||
3214 | return; | ||
3215 | |||
3216 | if (volume > 1) | ||
3217 | volume = 1; | ||
3218 | if (volume < 0) | ||
3219 | volume = 0; | ||
3220 | |||
3221 | DateTime now = DateTime.UtcNow; | ||
3222 | if((now - LastColSoundSentTime).Milliseconds < 200) // reduce rate to 5 per sec per part ?? | ||
3223 | return; | ||
3224 | |||
3225 | LastColSoundSentTime = now; | ||
3226 | |||
3227 | UUID ownerID = OwnerID; | ||
3228 | UUID objectID = ParentGroup.RootPart.UUID; | ||
3229 | UUID parentID = ParentGroup.UUID; | ||
3230 | Vector3 position = AbsolutePosition; // region local | ||
3231 | ulong regionHandle = ParentGroup.Scene.RegionInfo.RegionHandle; | ||
3232 | |||
3233 | soundModule.TriggerSound(soundID, ownerID, objectID, parentID, volume, position, regionHandle, 0); | ||
3234 | } | ||
3235 | |||
3236 | |||
3193 | /// <summary> | 3237 | /// <summary> |
3194 | /// Send a terse update to all clients | 3238 | /// Send a terse update to all clients |
3195 | /// </summary> | 3239 | /// </summary> |
@@ -4743,7 +4787,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
4743 | 4787 | ||
4744 | pa.OnCollisionUpdate -= PhysicsCollision; | 4788 | pa.OnCollisionUpdate -= PhysicsCollision; |
4745 | 4789 | ||
4746 | bool hassound = ( CollisionSound != UUID.Zero && CollisionSoundVolume > 0.0f); | 4790 | bool hassound = ( CollisionSound != invalidCollisionSoundUUID); |
4747 | scriptEvents CombinedEvents = AggregateScriptEvents; | 4791 | scriptEvents CombinedEvents = AggregateScriptEvents; |
4748 | 4792 | ||
4749 | // merge with root part | 4793 | // merge with root part |