aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Framework/Scenes/ScenePresence.cs
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Region/Framework/Scenes/ScenePresence.cs')
-rw-r--r--OpenSim/Region/Framework/Scenes/ScenePresence.cs99
1 files changed, 73 insertions, 26 deletions
diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs
index a8aa551..bacc9c9 100644
--- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs
+++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs
@@ -1,4 +1,4 @@
1/* 1/*
2 * Copyright (c) Contributors, http://opensimulator.org/ 2 * Copyright (c) Contributors, http://opensimulator.org/
3 * See CONTRIBUTORS.TXT for a full list of copyright holders. 3 * See CONTRIBUTORS.TXT for a full list of copyright holders.
4 * 4 *
@@ -69,14 +69,15 @@ namespace OpenSim.Region.Framework.Scenes
69 public ScriptControlled eventControls; 69 public ScriptControlled eventControls;
70 } 70 }
71 71
72 public delegate void SendCourseLocationsMethod(UUID scene, ScenePresence presence, List<Vector3> coarseLocations, List<UUID> avatarUUIDs); 72 public delegate void SendCoarseLocationsMethod(UUID scene, ScenePresence presence, List<Vector3> coarseLocations, List<UUID> avatarUUIDs);
73 73
74 public class ScenePresence : EntityBase, IScenePresence 74 public class ScenePresence : EntityBase, IScenePresence
75 { 75 {
76// ~ScenePresence() 76// ~ScenePresence()
77// { 77// {
78// m_log.Debug("[SCENE PRESENCE] Destructor called"); 78// m_log.DebugFormat("[SCENE PRESENCE]: Destructor called on {0}", Name);
79// } 79// }
80
80 private void TriggerScenePresenceUpdated() 81 private void TriggerScenePresenceUpdated()
81 { 82 {
82 if (m_scene != null) 83 if (m_scene != null)
@@ -188,7 +189,7 @@ namespace OpenSim.Region.Framework.Scenes
188 /// </summary> 189 /// </summary>
189 public bool SitGround { get; private set; } 190 public bool SitGround { get; private set; }
190 191
191 private SendCourseLocationsMethod m_sendCourseLocationsMethod; 192 private SendCoarseLocationsMethod m_sendCoarseLocationsMethod;
192 193
193 //private Vector3 m_requestedSitOffset = new Vector3(); 194 //private Vector3 m_requestedSitOffset = new Vector3();
194 195
@@ -546,7 +547,7 @@ namespace OpenSim.Region.Framework.Scenes
546 { 547 {
547 try 548 try
548 { 549 {
549 PhysicsActor.Velocity = value; 550 PhysicsActor.TargetVelocity = value;
550 } 551 }
551 catch (Exception e) 552 catch (Exception e)
552 { 553 {
@@ -570,7 +571,18 @@ namespace OpenSim.Region.Framework.Scenes
570 set 571 set
571 { 572 {
572 m_bodyRot = value; 573 m_bodyRot = value;
573// m_log.DebugFormat("[SCENE PRESENCE]: Body rot for {0} set to {1}", Name, m_bodyRot); 574 // m_log.DebugFormat("[SCENE PRESENCE]: Body rot for {0} set to {1}", Name, m_bodyRot);
575 if (PhysicsActor != null)
576 {
577 try
578 {
579 PhysicsActor.Orientation = value;
580 }
581 catch (Exception e)
582 {
583 m_log.Error("[SCENE PRESENCE]: Orientation " + e.Message);
584 }
585 }
574 } 586 }
575 } 587 }
576 588
@@ -711,7 +723,7 @@ namespace OpenSim.Region.Framework.Scenes
711 AttachmentsSyncLock = new Object(); 723 AttachmentsSyncLock = new Object();
712 AllowMovement = true; 724 AllowMovement = true;
713 IsChildAgent = true; 725 IsChildAgent = true;
714 m_sendCourseLocationsMethod = SendCoarseLocationsDefault; 726 m_sendCoarseLocationsMethod = SendCoarseLocationsDefault;
715 Animator = new ScenePresenceAnimator(this); 727 Animator = new ScenePresenceAnimator(this);
716 PresenceType = type; 728 PresenceType = type;
717 DrawDistance = world.DefaultDrawDistance; 729 DrawDistance = world.DefaultDrawDistance;
@@ -793,6 +805,7 @@ namespace OpenSim.Region.Framework.Scenes
793 ControllingClient.OnChangeAnim += avnHandleChangeAnim; 805 ControllingClient.OnChangeAnim += avnHandleChangeAnim;
794 ControllingClient.OnForceReleaseControls += HandleForceReleaseControls; 806 ControllingClient.OnForceReleaseControls += HandleForceReleaseControls;
795 ControllingClient.OnAutoPilotGo += MoveToTarget; 807 ControllingClient.OnAutoPilotGo += MoveToTarget;
808 ControllingClient.OnUpdateThrottles += RaiseUpdateThrottles;
796 809
797 // ControllingClient.OnChildAgentStatus += new StatusChange(this.ChildStatusChange); 810 // ControllingClient.OnChildAgentStatus += new StatusChange(this.ChildStatusChange);
798 // ControllingClient.OnStopMovement += new GenericCall2(this.StopMovement); 811 // ControllingClient.OnStopMovement += new GenericCall2(this.StopMovement);
@@ -974,7 +987,9 @@ namespace OpenSim.Region.Framework.Scenes
974 { 987 {
975 if (wasChild && HasAttachments()) 988 if (wasChild && HasAttachments())
976 { 989 {
977 m_log.DebugFormat("[SCENE PRESENCE]: Restarting scripts in attachments..."); 990 m_log.DebugFormat(
991 "[SCENE PRESENCE]: Restarting scripts in attachments for {0} in {1}", Name, Scene.Name);
992
978 // Resume scripts 993 // Resume scripts
979 Util.FireAndForget(delegate(object x) { 994 Util.FireAndForget(delegate(object x) {
980 foreach (SceneObjectGroup sog in m_attachments) 995 foreach (SceneObjectGroup sog in m_attachments)
@@ -1530,17 +1545,22 @@ namespace OpenSim.Region.Framework.Scenes
1530 bool DCFlagKeyPressed = false; 1545 bool DCFlagKeyPressed = false;
1531 Vector3 agent_control_v3 = Vector3.Zero; 1546 Vector3 agent_control_v3 = Vector3.Zero;
1532 1547
1533 bool oldflying = Flying; 1548 bool newFlying = actor.Flying;
1534 1549
1535 if (ForceFly) 1550 if (ForceFly)
1536 actor.Flying = true; 1551 newFlying = true;
1537 else if (FlyDisabled) 1552 else if (FlyDisabled)
1538 actor.Flying = false; 1553 newFlying = false;
1539 else 1554 else
1540 actor.Flying = ((flags & AgentManager.ControlFlags.AGENT_CONTROL_FLY) != 0); 1555 newFlying = ((flags & AgentManager.ControlFlags.AGENT_CONTROL_FLY) != 0);
1541 1556
1542 if (actor.Flying != oldflying) 1557 if (actor.Flying != newFlying)
1558 {
1559 // Note: ScenePresence.Flying is actually fetched from the physical actor
1560 // so setting PhysActor.Flying here also sets the ScenePresence's value.
1561 actor.Flying = newFlying;
1543 update_movementflag = true; 1562 update_movementflag = true;
1563 }
1544 1564
1545 if (ParentID == 0) 1565 if (ParentID == 0)
1546 { 1566 {
@@ -1835,8 +1855,16 @@ namespace OpenSim.Region.Framework.Scenes
1835// "[SCENE PRESENCE]: Avatar {0} received request to move to position {1} in {2}", 1855// "[SCENE PRESENCE]: Avatar {0} received request to move to position {1} in {2}",
1836// Name, pos, m_scene.RegionInfo.RegionName); 1856// Name, pos, m_scene.RegionInfo.RegionName);
1837 1857
1838 if (pos.X < 0 || pos.X >= Constants.RegionSize 1858 // Allow move to another sub-region within a megaregion
1839 || pos.Y < 0 || pos.Y >= Constants.RegionSize 1859 Vector2 regionSize;
1860 IRegionCombinerModule regionCombinerModule = m_scene.RequestModuleInterface<IRegionCombinerModule>();
1861 if (regionCombinerModule != null)
1862 regionSize = regionCombinerModule.GetSizeOfMegaregion(m_scene.RegionInfo.RegionID);
1863 else
1864 regionSize = new Vector2(Constants.RegionSize);
1865
1866 if (pos.X < 0 || pos.X >= regionSize.X
1867 || pos.Y < 0 || pos.Y >= regionSize.Y
1840 || pos.Z < 0) 1868 || pos.Z < 0)
1841 return; 1869 return;
1842 1870
@@ -1850,7 +1878,16 @@ namespace OpenSim.Region.Framework.Scenes
1850// pos.Z = AbsolutePosition.Z; 1878// pos.Z = AbsolutePosition.Z;
1851// } 1879// }
1852 1880
1853 float terrainHeight = (float)m_scene.Heightmap[(int)pos.X, (int)pos.Y]; 1881 // Get terrain height for sub-region in a megaregion if necessary
1882 int X = (int)((m_scene.RegionInfo.RegionLocX * Constants.RegionSize) + pos.X);
1883 int Y = (int)((m_scene.RegionInfo.RegionLocY * Constants.RegionSize) + pos.Y);
1884 UUID target_regionID = m_scene.GridService.GetRegionByPosition(m_scene.RegionInfo.ScopeID, X, Y).RegionID;
1885 Scene targetScene = m_scene;
1886
1887 if (!SceneManager.Instance.TryGetScene(target_regionID, out targetScene))
1888 targetScene = m_scene;
1889
1890 float terrainHeight = (float)targetScene.Heightmap[(int)(pos.X % Constants.RegionSize), (int)(pos.Y % Constants.RegionSize)];
1854 pos.Z = Math.Max(terrainHeight, pos.Z); 1891 pos.Z = Math.Max(terrainHeight, pos.Z);
1855 1892
1856 // Fudge factor. It appears that if one clicks "go here" on a piece of ground, the go here request is 1893 // Fudge factor. It appears that if one clicks "go here" on a piece of ground, the go here request is
@@ -2622,17 +2659,17 @@ namespace OpenSim.Region.Framework.Scenes
2622 2659
2623 public void SendCoarseLocations(List<Vector3> coarseLocations, List<UUID> avatarUUIDs) 2660 public void SendCoarseLocations(List<Vector3> coarseLocations, List<UUID> avatarUUIDs)
2624 { 2661 {
2625 SendCourseLocationsMethod d = m_sendCourseLocationsMethod; 2662 SendCoarseLocationsMethod d = m_sendCoarseLocationsMethod;
2626 if (d != null) 2663 if (d != null)
2627 { 2664 {
2628 d.Invoke(m_scene.RegionInfo.originRegionID, this, coarseLocations, avatarUUIDs); 2665 d.Invoke(m_scene.RegionInfo.originRegionID, this, coarseLocations, avatarUUIDs);
2629 } 2666 }
2630 } 2667 }
2631 2668
2632 public void SetSendCourseLocationMethod(SendCourseLocationsMethod d) 2669 public void SetSendCoarseLocationMethod(SendCoarseLocationsMethod d)
2633 { 2670 {
2634 if (d != null) 2671 if (d != null)
2635 m_sendCourseLocationsMethod = d; 2672 m_sendCoarseLocationsMethod = d;
2636 } 2673 }
2637 2674
2638 public void SendCoarseLocationsDefault(UUID sceneId, ScenePresence p, List<Vector3> coarseLocations, List<UUID> avatarUUIDs) 2675 public void SendCoarseLocationsDefault(UUID sceneId, ScenePresence p, List<Vector3> coarseLocations, List<UUID> avatarUUIDs)
@@ -2836,7 +2873,7 @@ namespace OpenSim.Region.Framework.Scenes
2836 #region Significant Movement Method 2873 #region Significant Movement Method
2837 2874
2838 /// <summary> 2875 /// <summary>
2839 /// This checks for a significant movement and sends a courselocationchange update 2876 /// This checks for a significant movement and sends a coarselocationchange update
2840 /// </summary> 2877 /// </summary>
2841 protected void CheckForSignificantMovement() 2878 protected void CheckForSignificantMovement()
2842 { 2879 {
@@ -3166,6 +3203,10 @@ namespace OpenSim.Region.Framework.Scenes
3166 } 3203 }
3167 3204
3168 private static Vector3 marker = new Vector3(-1f, -1f, -1f); 3205 private static Vector3 marker = new Vector3(-1f, -1f, -1f);
3206 private void RaiseUpdateThrottles()
3207 {
3208 m_scene.EventManager.TriggerThrottleUpdate(this);
3209 }
3169 /// <summary> 3210 /// <summary>
3170 /// This updates important decision making data about a child agent 3211 /// This updates important decision making data about a child agent
3171 /// The main purpose is to figure out what objects to send to a child agent that's in a neighboring region 3212 /// The main purpose is to figure out what objects to send to a child agent that's in a neighboring region
@@ -3269,6 +3310,7 @@ namespace OpenSim.Region.Framework.Scenes
3269 } 3310 }
3270 catch { } 3311 catch { }
3271 cAgent.DefaultAnim = Animator.Animations.DefaultAnimation; 3312 cAgent.DefaultAnim = Animator.Animations.DefaultAnimation;
3313 cAgent.AnimState = Animator.Animations.ImplicitDefaultAnimation;
3272 3314
3273 if (Scene.AttachmentsModule != null) 3315 if (Scene.AttachmentsModule != null)
3274 Scene.AttachmentsModule.CopyAttachments(this, cAgent); 3316 Scene.AttachmentsModule.CopyAttachments(this, cAgent);
@@ -3345,6 +3387,8 @@ namespace OpenSim.Region.Framework.Scenes
3345 Animator.Animations.FromArray(cAgent.Anims); 3387 Animator.Animations.FromArray(cAgent.Anims);
3346 if (cAgent.DefaultAnim != null) 3388 if (cAgent.DefaultAnim != null)
3347 Animator.Animations.SetDefaultAnimation(cAgent.DefaultAnim.AnimID, cAgent.DefaultAnim.SequenceNum, UUID.Zero); 3389 Animator.Animations.SetDefaultAnimation(cAgent.DefaultAnim.AnimID, cAgent.DefaultAnim.SequenceNum, UUID.Zero);
3390 if (cAgent.AnimState != null)
3391 Animator.Animations.SetImplicitDefaultAnimation(cAgent.AnimState.AnimID, cAgent.AnimState.SequenceNum, UUID.Zero);
3348 3392
3349 if (Scene.AttachmentsModule != null) 3393 if (Scene.AttachmentsModule != null)
3350 Scene.AttachmentsModule.CopyAttachments(cAgent, this); 3394 Scene.AttachmentsModule.CopyAttachments(cAgent, this);
@@ -3402,7 +3446,7 @@ namespace OpenSim.Region.Framework.Scenes
3402 3446
3403 PhysicsActor = scene.AddAvatar( 3447 PhysicsActor = scene.AddAvatar(
3404 LocalId, Firstname + "." + Lastname, pVec, 3448 LocalId, Firstname + "." + Lastname, pVec,
3405 new Vector3(0f, 0f, Appearance.AvatarHeight), isFlying); 3449 new Vector3(0.45f, 0.6f, Appearance.AvatarHeight), isFlying);
3406 3450
3407 //PhysicsActor.OnRequestTerseUpdate += SendTerseUpdateToAllClients; 3451 //PhysicsActor.OnRequestTerseUpdate += SendTerseUpdateToAllClients;
3408 PhysicsActor.OnCollisionUpdate += PhysicsCollisionUpdate; 3452 PhysicsActor.OnCollisionUpdate += PhysicsCollisionUpdate;
@@ -3627,13 +3671,16 @@ namespace OpenSim.Region.Framework.Scenes
3627 public List<SceneObjectGroup> GetAttachments(uint attachmentPoint) 3671 public List<SceneObjectGroup> GetAttachments(uint attachmentPoint)
3628 { 3672 {
3629 List<SceneObjectGroup> attachments = new List<SceneObjectGroup>(); 3673 List<SceneObjectGroup> attachments = new List<SceneObjectGroup>();
3630 3674
3631 lock (m_attachments) 3675 if (attachmentPoint >= 0)
3632 { 3676 {
3633 foreach (SceneObjectGroup so in m_attachments) 3677 lock (m_attachments)
3634 { 3678 {
3635 if (attachmentPoint == so.AttachmentPoint) 3679 foreach (SceneObjectGroup so in m_attachments)
3636 attachments.Add(so); 3680 {
3681 if (attachmentPoint == so.AttachmentPoint)
3682 attachments.Add(so);
3683 }
3637 } 3684 }
3638 } 3685 }
3639 3686