diff options
Diffstat (limited to 'OpenSim/Region/Framework/Scenes/SceneObjectPart.cs')
-rw-r--r-- | OpenSim/Region/Framework/Scenes/SceneObjectPart.cs | 108 |
1 files changed, 86 insertions, 22 deletions
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs index b5705b7..2852c4b 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs | |||
@@ -329,11 +329,13 @@ namespace OpenSim.Region.Framework.Scenes | |||
329 | private Vector3 m_cameraAtOffset; | 329 | private Vector3 m_cameraAtOffset; |
330 | private bool m_forceMouselook; | 330 | private bool m_forceMouselook; |
331 | 331 | ||
332 | // TODO: Collision sound should have default. | 332 | |
333 | // 0 for default collision sounds, -1 for script disabled sound 1 for script defined sound | ||
334 | private sbyte m_collisionSoundType; | ||
333 | private UUID m_collisionSound; | 335 | private UUID m_collisionSound; |
334 | private float m_collisionSoundVolume; | 336 | private float m_collisionSoundVolume; |
335 | 337 | ||
336 | private DateTime LastColSoundSentTime; | 338 | private int LastColSoundSentTime; |
337 | 339 | ||
338 | 340 | ||
339 | private SOPVehicle m_vehicle = null; | 341 | private SOPVehicle m_vehicle = null; |
@@ -374,7 +376,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 | 376 | // 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 | 377 | // 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); | 378 | m_inventory = new SceneObjectPartInventory(this); |
377 | LastColSoundSentTime = DateTime.UtcNow; | 379 | LastColSoundSentTime = Util.EnvironmentTickCount(); |
378 | } | 380 | } |
379 | 381 | ||
380 | /// <summary> | 382 | /// <summary> |
@@ -1342,12 +1344,39 @@ namespace OpenSim.Region.Framework.Scenes | |||
1342 | 1344 | ||
1343 | public UUID invalidCollisionSoundUUID = new UUID("ffffffff-ffff-ffff-ffff-ffffffffffff"); | 1345 | public UUID invalidCollisionSoundUUID = new UUID("ffffffff-ffff-ffff-ffff-ffffffffffff"); |
1344 | 1346 | ||
1347 | // 0 for default collision sounds, -1 for script disabled sound 1 for script defined sound | ||
1348 | // runtime thing.. do not persist | ||
1349 | [XmlIgnore] | ||
1350 | public sbyte CollisionSoundType | ||
1351 | { | ||
1352 | get | ||
1353 | { | ||
1354 | return m_collisionSoundType; | ||
1355 | } | ||
1356 | set | ||
1357 | { | ||
1358 | m_collisionSoundType = value; | ||
1359 | if (value == -1) | ||
1360 | m_collisionSound = invalidCollisionSoundUUID; | ||
1361 | else if (value == 0) | ||
1362 | m_collisionSound = UUID.Zero; | ||
1363 | } | ||
1364 | } | ||
1365 | |||
1345 | public UUID CollisionSound | 1366 | public UUID CollisionSound |
1346 | { | 1367 | { |
1347 | get { return m_collisionSound; } | 1368 | get { return m_collisionSound; } |
1348 | set | 1369 | set |
1349 | { | 1370 | { |
1350 | m_collisionSound = value; | 1371 | m_collisionSound = value; |
1372 | |||
1373 | if (value == invalidCollisionSoundUUID) | ||
1374 | m_collisionSoundType = -1; | ||
1375 | else if (value == UUID.Zero) | ||
1376 | m_collisionSoundType = 0; | ||
1377 | else | ||
1378 | m_collisionSoundType = 1; | ||
1379 | |||
1351 | aggregateScriptEvents(); | 1380 | aggregateScriptEvents(); |
1352 | } | 1381 | } |
1353 | } | 1382 | } |
@@ -1575,7 +1604,10 @@ namespace OpenSim.Region.Framework.Scenes | |||
1575 | } | 1604 | } |
1576 | } | 1605 | } |
1577 | else if (PhysActor == null) | 1606 | else if (PhysActor == null) |
1607 | { | ||
1578 | ApplyPhysics((uint)Flags, VolumeDetectActive, false); | 1608 | ApplyPhysics((uint)Flags, VolumeDetectActive, false); |
1609 | UpdatePhysicsSubscribedEvents(); | ||
1610 | } | ||
1579 | else | 1611 | else |
1580 | { | 1612 | { |
1581 | PhysActor.PhysicsShapeType = m_physicsShapeType; | 1613 | PhysActor.PhysicsShapeType = m_physicsShapeType; |
@@ -2632,13 +2664,42 @@ namespace OpenSim.Region.Framework.Scenes | |||
2632 | 2664 | ||
2633 | else | 2665 | else |
2634 | { | 2666 | { |
2667 | List<CollisionForSoundInfo> soundinfolist = new List<CollisionForSoundInfo>(); | ||
2668 | |||
2635 | // calculate things that started colliding this time | 2669 | // calculate things that started colliding this time |
2636 | // and build up list of colliders this time | 2670 | // and build up list of colliders this time |
2637 | foreach (uint localid in collissionswith.Keys) | 2671 | if (!VolumeDetectActive && CollisionSoundType >= 0) |
2672 | { | ||
2673 | CollisionForSoundInfo soundinfo; | ||
2674 | ContactPoint curcontact; | ||
2675 | |||
2676 | foreach (uint id in collissionswith.Keys) | ||
2677 | { | ||
2678 | thisHitColliders.Add(id); | ||
2679 | if (!m_lastColliders.Contains(id)) | ||
2680 | { | ||
2681 | startedColliders.Add(id); | ||
2682 | |||
2683 | curcontact = collissionswith[id]; | ||
2684 | if (Math.Abs(curcontact.RelativeSpeed) > 0.2) | ||
2685 | { | ||
2686 | soundinfo = new CollisionForSoundInfo(); | ||
2687 | soundinfo.colliderID = id; | ||
2688 | soundinfo.position = curcontact.Position; | ||
2689 | soundinfo.relativeVel = curcontact.RelativeSpeed; | ||
2690 | soundinfolist.Add(soundinfo); | ||
2691 | } | ||
2692 | } | ||
2693 | } | ||
2694 | } | ||
2695 | else | ||
2638 | { | 2696 | { |
2639 | thisHitColliders.Add(localid); | 2697 | foreach (uint id in collissionswith.Keys) |
2640 | if (!m_lastColliders.Contains(localid)) | 2698 | { |
2641 | startedColliders.Add(localid); | 2699 | thisHitColliders.Add(id); |
2700 | if (!m_lastColliders.Contains(id)) | ||
2701 | startedColliders.Add(id); | ||
2702 | } | ||
2642 | } | 2703 | } |
2643 | 2704 | ||
2644 | // calculate things that ended colliding | 2705 | // calculate things that ended colliding |
@@ -2655,17 +2716,14 @@ namespace OpenSim.Region.Framework.Scenes | |||
2655 | // remove things that ended colliding from the last colliders list | 2716 | // remove things that ended colliding from the last colliders list |
2656 | foreach (uint localID in endedColliders) | 2717 | foreach (uint localID in endedColliders) |
2657 | m_lastColliders.Remove(localID); | 2718 | m_lastColliders.Remove(localID); |
2658 | } | ||
2659 | |||
2660 | // play the sound. | ||
2661 | 2719 | ||
2662 | bool IsNotVolumeDtc = !VolumeDetectActive; | 2720 | // play sounds. |
2663 | 2721 | if (soundinfolist.Count > 0) | |
2664 | if (IsNotVolumeDtc && startedColliders.Count > 0 && CollisionSound != invalidCollisionSoundUUID) | 2722 | CollisionSounds.PartCollisionSound(this, soundinfolist); |
2665 | CollisionSounds.PartCollisionSound(this, startedColliders); | 2723 | } |
2666 | 2724 | ||
2667 | SendCollisionEvent(scriptEvents.collision_start, startedColliders, ParentGroup.Scene.EventManager.TriggerScriptCollidingStart); | 2725 | SendCollisionEvent(scriptEvents.collision_start, startedColliders, ParentGroup.Scene.EventManager.TriggerScriptCollidingStart); |
2668 | if (IsNotVolumeDtc) | 2726 | if (!VolumeDetectActive) |
2669 | SendCollisionEvent(scriptEvents.collision , m_lastColliders , ParentGroup.Scene.EventManager.TriggerScriptColliding); | 2727 | SendCollisionEvent(scriptEvents.collision , m_lastColliders , ParentGroup.Scene.EventManager.TriggerScriptColliding); |
2670 | SendCollisionEvent(scriptEvents.collision_end , endedColliders , ParentGroup.Scene.EventManager.TriggerScriptCollidingEnd); | 2728 | SendCollisionEvent(scriptEvents.collision_end , endedColliders , ParentGroup.Scene.EventManager.TriggerScriptCollidingEnd); |
2671 | 2729 | ||
@@ -3210,8 +3268,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
3210 | if (volume < 0) | 3268 | if (volume < 0) |
3211 | volume = 0; | 3269 | volume = 0; |
3212 | 3270 | ||
3213 | DateTime now = DateTime.UtcNow; | 3271 | int now = Util.EnvironmentTickCount(); |
3214 | if((now - LastColSoundSentTime).Milliseconds < 200) // reduce rate to 5 per sec per part ?? | 3272 | if(Util.EnvironmentTickCountSubtract(now,LastColSoundSentTime) <200) |
3215 | return; | 3273 | return; |
3216 | 3274 | ||
3217 | LastColSoundSentTime = now; | 3275 | LastColSoundSentTime = now; |
@@ -4609,7 +4667,15 @@ namespace OpenSim.Region.Framework.Scenes | |||
4609 | /// </remarks> | 4667 | /// </remarks> |
4610 | public void RemoveFromPhysics() | 4668 | public void RemoveFromPhysics() |
4611 | { | 4669 | { |
4612 | ParentGroup.Scene.PhysicsScene.RemovePrim(PhysActor); | 4670 | PhysicsActor pa = PhysActor; |
4671 | if (pa != null) | ||
4672 | { | ||
4673 | pa.OnCollisionUpdate -= PhysicsCollision; | ||
4674 | pa.OnRequestTerseUpdate -= PhysicsRequestingTerseUpdate; | ||
4675 | pa.OnOutOfBounds -= PhysicsOutOfBounds; | ||
4676 | |||
4677 | ParentGroup.Scene.PhysicsScene.RemovePrim(pa); | ||
4678 | } | ||
4613 | PhysActor = null; | 4679 | PhysActor = null; |
4614 | } | 4680 | } |
4615 | 4681 | ||
@@ -4778,7 +4844,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
4778 | 4844 | ||
4779 | pa.OnCollisionUpdate -= PhysicsCollision; | 4845 | pa.OnCollisionUpdate -= PhysicsCollision; |
4780 | 4846 | ||
4781 | bool hassound = ( CollisionSound != invalidCollisionSoundUUID); | 4847 | bool hassound = (CollisionSoundType >= 0 && !VolumeDetectActive); |
4848 | |||
4782 | scriptEvents CombinedEvents = AggregateScriptEvents; | 4849 | scriptEvents CombinedEvents = AggregateScriptEvents; |
4783 | 4850 | ||
4784 | // merge with root part | 4851 | // merge with root part |
@@ -4787,10 +4854,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
4787 | 4854 | ||
4788 | // submit to this part case | 4855 | // submit to this part case |
4789 | if (VolumeDetectActive) | 4856 | if (VolumeDetectActive) |
4790 | { | ||
4791 | CombinedEvents &= PhyscicsVolumeDtcSubsEvents; | 4857 | CombinedEvents &= PhyscicsVolumeDtcSubsEvents; |
4792 | hassound = false; | ||
4793 | } | ||
4794 | else if ((Flags & PrimFlags.Phantom) != 0) | 4858 | else if ((Flags & PrimFlags.Phantom) != 0) |
4795 | CombinedEvents &= PhyscicsPhantonSubsEvents; | 4859 | CombinedEvents &= PhyscicsPhantonSubsEvents; |
4796 | else | 4860 | else |