aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs
diff options
context:
space:
mode:
authorMelanie2012-05-27 19:35:36 +0100
committerMelanie2012-05-27 19:35:36 +0100
commit78e657fd8d911deb0dc1a0eb20a7f2bb2fea1a63 (patch)
treef89d40cb907cd6d8a0df0432c089633c1eb50b8b /OpenSim/Region/Framework/Scenes/SceneObjectPart.cs
parentMerge branch 'master' into careminster (diff)
parentMerge branch 'ubitwork' into avination (diff)
downloadopensim-SC-78e657fd8d911deb0dc1a0eb20a7f2bb2fea1a63.zip
opensim-SC-78e657fd8d911deb0dc1a0eb20a7f2bb2fea1a63.tar.gz
opensim-SC-78e657fd8d911deb0dc1a0eb20a7f2bb2fea1a63.tar.bz2
opensim-SC-78e657fd8d911deb0dc1a0eb20a7f2bb2fea1a63.tar.xz
Merge branch 'avination' into careminster
Diffstat (limited to 'OpenSim/Region/Framework/Scenes/SceneObjectPart.cs')
-rw-r--r--OpenSim/Region/Framework/Scenes/SceneObjectPart.cs108
1 files changed, 86 insertions, 22 deletions
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs
index 221a32b..749b281 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>
@@ -1353,12 +1355,39 @@ namespace OpenSim.Region.Framework.Scenes
1353 1355
1354 public UUID invalidCollisionSoundUUID = new UUID("ffffffff-ffff-ffff-ffff-ffffffffffff"); 1356 public UUID invalidCollisionSoundUUID = new UUID("ffffffff-ffff-ffff-ffff-ffffffffffff");
1355 1357
1358 // 0 for default collision sounds, -1 for script disabled sound 1 for script defined sound
1359 // runtime thing.. do not persist
1360 [XmlIgnore]
1361 public sbyte CollisionSoundType
1362 {
1363 get
1364 {
1365 return m_collisionSoundType;
1366 }
1367 set
1368 {
1369 m_collisionSoundType = value;
1370 if (value == -1)
1371 m_collisionSound = invalidCollisionSoundUUID;
1372 else if (value == 0)
1373 m_collisionSound = UUID.Zero;
1374 }
1375 }
1376
1356 public UUID CollisionSound 1377 public UUID CollisionSound
1357 { 1378 {
1358 get { return m_collisionSound; } 1379 get { return m_collisionSound; }
1359 set 1380 set
1360 { 1381 {
1361 m_collisionSound = value; 1382 m_collisionSound = value;
1383
1384 if (value == invalidCollisionSoundUUID)
1385 m_collisionSoundType = -1;
1386 else if (value == UUID.Zero)
1387 m_collisionSoundType = 0;
1388 else
1389 m_collisionSoundType = 1;
1390
1362 aggregateScriptEvents(); 1391 aggregateScriptEvents();
1363 } 1392 }
1364 } 1393 }
@@ -1586,7 +1615,10 @@ namespace OpenSim.Region.Framework.Scenes
1586 } 1615 }
1587 } 1616 }
1588 else if (PhysActor == null) 1617 else if (PhysActor == null)
1618 {
1589 ApplyPhysics((uint)Flags, VolumeDetectActive, false); 1619 ApplyPhysics((uint)Flags, VolumeDetectActive, false);
1620 UpdatePhysicsSubscribedEvents();
1621 }
1590 else 1622 else
1591 { 1623 {
1592 PhysActor.PhysicsShapeType = m_physicsShapeType; 1624 PhysActor.PhysicsShapeType = m_physicsShapeType;
@@ -2646,13 +2678,42 @@ namespace OpenSim.Region.Framework.Scenes
2646 2678
2647 else 2679 else
2648 { 2680 {
2681 List<CollisionForSoundInfo> soundinfolist = new List<CollisionForSoundInfo>();
2682
2649 // calculate things that started colliding this time 2683 // calculate things that started colliding this time
2650 // and build up list of colliders this time 2684 // and build up list of colliders this time
2651 foreach (uint localid in collissionswith.Keys) 2685 if (!VolumeDetectActive && CollisionSoundType >= 0)
2686 {
2687 CollisionForSoundInfo soundinfo;
2688 ContactPoint curcontact;
2689
2690 foreach (uint id in collissionswith.Keys)
2691 {
2692 thisHitColliders.Add(id);
2693 if (!m_lastColliders.Contains(id))
2694 {
2695 startedColliders.Add(id);
2696
2697 curcontact = collissionswith[id];
2698 if (Math.Abs(curcontact.RelativeSpeed) > 0.2)
2699 {
2700 soundinfo = new CollisionForSoundInfo();
2701 soundinfo.colliderID = id;
2702 soundinfo.position = curcontact.Position;
2703 soundinfo.relativeVel = curcontact.RelativeSpeed;
2704 soundinfolist.Add(soundinfo);
2705 }
2706 }
2707 }
2708 }
2709 else
2652 { 2710 {
2653 thisHitColliders.Add(localid); 2711 foreach (uint id in collissionswith.Keys)
2654 if (!m_lastColliders.Contains(localid)) 2712 {
2655 startedColliders.Add(localid); 2713 thisHitColliders.Add(id);
2714 if (!m_lastColliders.Contains(id))
2715 startedColliders.Add(id);
2716 }
2656 } 2717 }
2657 2718
2658 // calculate things that ended colliding 2719 // calculate things that ended colliding
@@ -2669,17 +2730,14 @@ namespace OpenSim.Region.Framework.Scenes
2669 // remove things that ended colliding from the last colliders list 2730 // remove things that ended colliding from the last colliders list
2670 foreach (uint localID in endedColliders) 2731 foreach (uint localID in endedColliders)
2671 m_lastColliders.Remove(localID); 2732 m_lastColliders.Remove(localID);
2672 }
2673
2674 // play the sound.
2675 2733
2676 bool IsNotVolumeDtc = !VolumeDetectActive; 2734 // play sounds.
2677 2735 if (soundinfolist.Count > 0)
2678 if (IsNotVolumeDtc && startedColliders.Count > 0 && CollisionSound != invalidCollisionSoundUUID) 2736 CollisionSounds.PartCollisionSound(this, soundinfolist);
2679 CollisionSounds.PartCollisionSound(this, startedColliders); 2737 }
2680 2738
2681 SendCollisionEvent(scriptEvents.collision_start, startedColliders, ParentGroup.Scene.EventManager.TriggerScriptCollidingStart); 2739 SendCollisionEvent(scriptEvents.collision_start, startedColliders, ParentGroup.Scene.EventManager.TriggerScriptCollidingStart);
2682 if (IsNotVolumeDtc) 2740 if (!VolumeDetectActive)
2683 SendCollisionEvent(scriptEvents.collision , m_lastColliders , ParentGroup.Scene.EventManager.TriggerScriptColliding); 2741 SendCollisionEvent(scriptEvents.collision , m_lastColliders , ParentGroup.Scene.EventManager.TriggerScriptColliding);
2684 SendCollisionEvent(scriptEvents.collision_end , endedColliders , ParentGroup.Scene.EventManager.TriggerScriptCollidingEnd); 2742 SendCollisionEvent(scriptEvents.collision_end , endedColliders , ParentGroup.Scene.EventManager.TriggerScriptCollidingEnd);
2685 2743
@@ -3224,8 +3282,8 @@ namespace OpenSim.Region.Framework.Scenes
3224 if (volume < 0) 3282 if (volume < 0)
3225 volume = 0; 3283 volume = 0;
3226 3284
3227 DateTime now = DateTime.UtcNow; 3285 int now = Util.EnvironmentTickCount();
3228 if((now - LastColSoundSentTime).Milliseconds < 200) // reduce rate to 5 per sec per part ?? 3286 if(Util.EnvironmentTickCountSubtract(now,LastColSoundSentTime) <200)
3229 return; 3287 return;
3230 3288
3231 LastColSoundSentTime = now; 3289 LastColSoundSentTime = now;
@@ -4623,7 +4681,15 @@ namespace OpenSim.Region.Framework.Scenes
4623 /// </remarks> 4681 /// </remarks>
4624 public void RemoveFromPhysics() 4682 public void RemoveFromPhysics()
4625 { 4683 {
4626 ParentGroup.Scene.PhysicsScene.RemovePrim(PhysActor); 4684 PhysicsActor pa = PhysActor;
4685 if (pa != null)
4686 {
4687 pa.OnCollisionUpdate -= PhysicsCollision;
4688 pa.OnRequestTerseUpdate -= PhysicsRequestingTerseUpdate;
4689 pa.OnOutOfBounds -= PhysicsOutOfBounds;
4690
4691 ParentGroup.Scene.PhysicsScene.RemovePrim(pa);
4692 }
4627 PhysActor = null; 4693 PhysActor = null;
4628 } 4694 }
4629 4695
@@ -4792,7 +4858,8 @@ namespace OpenSim.Region.Framework.Scenes
4792 4858
4793 pa.OnCollisionUpdate -= PhysicsCollision; 4859 pa.OnCollisionUpdate -= PhysicsCollision;
4794 4860
4795 bool hassound = ( CollisionSound != invalidCollisionSoundUUID); 4861 bool hassound = (CollisionSoundType >= 0 && !VolumeDetectActive);
4862
4796 scriptEvents CombinedEvents = AggregateScriptEvents; 4863 scriptEvents CombinedEvents = AggregateScriptEvents;
4797 4864
4798 // merge with root part 4865 // merge with root part
@@ -4801,10 +4868,7 @@ namespace OpenSim.Region.Framework.Scenes
4801 4868
4802 // submit to this part case 4869 // submit to this part case
4803 if (VolumeDetectActive) 4870 if (VolumeDetectActive)
4804 {
4805 CombinedEvents &= PhyscicsVolumeDtcSubsEvents; 4871 CombinedEvents &= PhyscicsVolumeDtcSubsEvents;
4806 hassound = false;
4807 }
4808 else if ((Flags & PrimFlags.Phantom) != 0) 4872 else if ((Flags & PrimFlags.Phantom) != 0)
4809 CombinedEvents &= PhyscicsPhantonSubsEvents; 4873 CombinedEvents &= PhyscicsPhantonSubsEvents;
4810 else 4874 else