aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Framework/Scenes/ScenePresence.cs
diff options
context:
space:
mode:
authorMelanie2011-10-12 00:10:15 +0200
committerMelanie2011-10-12 00:10:15 +0200
commit1c2b5d99c9601a3d301f4bc0f53389cca831ee04 (patch)
tree97fa9c758f429d5dee64234e442f2c83cd1b9994 /OpenSim/Region/Framework/Scenes/ScenePresence.cs
parentMerge branch 'careminster-presence-refactor' into bigmerge (diff)
parentMerge commit '92c88121c72386f85472c6cf4891eca8b62b9867' into bigmerge (diff)
downloadopensim-SC-1c2b5d99c9601a3d301f4bc0f53389cca831ee04.zip
opensim-SC-1c2b5d99c9601a3d301f4bc0f53389cca831ee04.tar.gz
opensim-SC-1c2b5d99c9601a3d301f4bc0f53389cca831ee04.tar.bz2
opensim-SC-1c2b5d99c9601a3d301f4bc0f53389cca831ee04.tar.xz
Merge branch 'bigmerge' of ssh://3dhosting.de/var/git/careminster into bigmerge
Diffstat (limited to 'OpenSim/Region/Framework/Scenes/ScenePresence.cs')
-rw-r--r--OpenSim/Region/Framework/Scenes/ScenePresence.cs94
1 files changed, 71 insertions, 23 deletions
diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs
index fa6945c..dee9bc3 100644
--- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs
+++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs
@@ -71,7 +71,7 @@ namespace OpenSim.Region.Framework.Scenes
71 { 71 {
72// ~ScenePresence() 72// ~ScenePresence()
73// { 73// {
74// m_log.Debug("[ScenePresence] Destructor called"); 74// m_log.Debug("[SCENE PRESENCE] Destructor called");
75// } 75// }
76 76
77 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); 77 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
@@ -191,8 +191,6 @@ namespace OpenSim.Region.Framework.Scenes
191 191
192 private Quaternion m_bodyRot = Quaternion.Identity; 192 private Quaternion m_bodyRot = Quaternion.Identity;
193 193
194 private Quaternion m_bodyRotPrevious = Quaternion.Identity;
195
196 private const int LAND_VELOCITYMAG_MAX = 12; 194 private const int LAND_VELOCITYMAG_MAX = 12;
197 195
198 public bool IsRestrictedToRegion; 196 public bool IsRestrictedToRegion;
@@ -238,6 +236,11 @@ namespace OpenSim.Region.Framework.Scenes
238 public Vector3 MoveToPositionTarget { get; private set; } 236 public Vector3 MoveToPositionTarget { get; private set; }
239 private Quaternion m_offsetRotation = new Quaternion(0.0f, 0.0f, 0.0f, 1.0f); 237 private Quaternion m_offsetRotation = new Quaternion(0.0f, 0.0f, 0.0f, 1.0f);
240 238
239 /// <summary>
240 /// Controls whether an avatar automatically moving to a target will land when it gets there (if flying).
241 /// </summary>
242 public bool LandAtTarget { get; private set; }
243
241 private bool m_followCamAuto; 244 private bool m_followCamAuto;
242 245
243 private int m_movementUpdateCount; 246 private int m_movementUpdateCount;
@@ -492,7 +495,13 @@ namespace OpenSim.Region.Framework.Scenes
492 PhysicsActor actor = m_physicsActor; 495 PhysicsActor actor = m_physicsActor;
493// if (actor != null) 496// if (actor != null)
494 if ((actor != null) && (m_parentID == 0)) // KF Do NOT update m_pos here if Av is sitting! 497 if ((actor != null) && (m_parentID == 0)) // KF Do NOT update m_pos here if Av is sitting!
498 {
495 m_pos = actor.Position; 499 m_pos = actor.Position;
500
501// m_log.DebugFormat(
502// "[SCENE PRESENCE]: Set position {0} for {1} in {2} via getting AbsolutePosition!",
503// m_pos, Name, Scene.RegionInfo.RegionName);
504 }
496 else 505 else
497 { 506 {
498 // Obtain the correct position of a seated avatar. 507 // Obtain the correct position of a seated avatar.
@@ -536,20 +545,28 @@ namespace OpenSim.Region.Framework.Scenes
536 } 545 }
537 catch (Exception e) 546 catch (Exception e)
538 { 547 {
539 m_log.Error("[SCENEPRESENCE]: ABSOLUTE POSITION " + e.Message); 548 m_log.Error("[SCENE PRESENCE]: ABSOLUTE POSITION " + e.Message);
540 } 549 }
541 } 550 }
542 551
543 if (m_parentID == 0) // KF Do NOT update m_pos here if Av is sitting! 552// Changed this to update unconditionally to make npose work
553// if (m_parentID == 0) // KF Do NOT update m_pos here if Av is sitting!
544 m_pos = value; 554 m_pos = value;
545 m_parentPosition = Vector3.Zero; 555 m_parentPosition = Vector3.Zero;
556
557// m_log.DebugFormat(
558// "[ENTITY BASE]: In {0} set AbsolutePosition of {1} to {2}",
559// Scene.RegionInfo.RegionName, Name, m_pos);
546 } 560 }
547 } 561 }
548 562
563 /// <summary>
564 /// If sitting, returns the offset position from the prim the avatar is sitting on.
565 /// Otherwise, returns absolute position in the scene.
566 /// </summary>
549 public Vector3 OffsetPosition 567 public Vector3 OffsetPosition
550 { 568 {
551 get { return m_pos; } 569 get { return m_pos; }
552 set { m_pos = value; }
553 } 570 }
554 571
555 /// <summary> 572 /// <summary>
@@ -561,8 +578,14 @@ namespace OpenSim.Region.Framework.Scenes
561 { 578 {
562 PhysicsActor actor = m_physicsActor; 579 PhysicsActor actor = m_physicsActor;
563 if (actor != null) 580 if (actor != null)
581 {
564 m_velocity = actor.Velocity; 582 m_velocity = actor.Velocity;
565 583
584// m_log.DebugFormat(
585// "[SCENE PRESENCE]: Set velocity {0} for {1} in {2} via getting Velocity!",
586// m_velocity, Name, Scene.RegionInfo.RegionName);
587 }
588
566 return m_velocity; 589 return m_velocity;
567 } 590 }
568 set 591 set
@@ -577,11 +600,15 @@ namespace OpenSim.Region.Framework.Scenes
577 } 600 }
578 catch (Exception e) 601 catch (Exception e)
579 { 602 {
580 m_log.Error("[SCENEPRESENCE]: VELOCITY " + e.Message); 603 m_log.Error("[SCENE PRESENCE]: VELOCITY " + e.Message);
581 } 604 }
582 } 605 }
583 606
584 m_velocity = value; 607 m_velocity = value;
608
609// m_log.DebugFormat(
610// "[SCENE PRESENCE]: In {0} set velocity of {1} to {2}",
611// Scene.RegionInfo.RegionName, Name, m_velocity);
585 } 612 }
586 } 613 }
587 614
@@ -620,12 +647,6 @@ namespace OpenSim.Region.Framework.Scenes
620 } 647 }
621 } 648 }
622 649
623 public Quaternion PreviousRotation
624 {
625 get { return m_bodyRotPrevious; }
626 set { m_bodyRotPrevious = value; }
627 }
628
629 /// <summary> 650 /// <summary>
630 /// If this is true, agent doesn't have a representation in this scene. 651 /// If this is true, agent doesn't have a representation in this scene.
631 /// this is an agent 'looking into' this scene from a nearby scene(region) 652 /// this is an agent 'looking into' this scene from a nearby scene(region)
@@ -1126,7 +1147,7 @@ namespace OpenSim.Region.Framework.Scenes
1126 Animator.ResetAnimations(); 1147 Animator.ResetAnimations();
1127 1148
1128// m_log.DebugFormat( 1149// m_log.DebugFormat(
1129// "[SCENEPRESENCE]: Downgrading root agent {0}, {1} to a child agent in {2}", 1150// "[SCENE PRESENCE]: Downgrading root agent {0}, {1} to a child agent in {2}",
1130// Name, UUID, m_scene.RegionInfo.RegionName); 1151// Name, UUID, m_scene.RegionInfo.RegionName);
1131 1152
1132 // Don't zero out the velocity since this can cause problems when an avatar is making a region crossing, 1153 // Don't zero out the velocity since this can cause problems when an avatar is making a region crossing,
@@ -1302,7 +1323,7 @@ namespace OpenSim.Region.Framework.Scenes
1302 m_callbackURI = null; 1323 m_callbackURI = null;
1303 } 1324 }
1304 1325
1305 //m_log.DebugFormat("Completed movement"); 1326 //m_log.DebugFormat("[SCENE PRESENCE] Completed movement");
1306 1327
1307 m_controllingClient.MoveAgentIntoRegion(m_scene.RegionInfo, AbsolutePosition, look); 1328 m_controllingClient.MoveAgentIntoRegion(m_scene.RegionInfo, AbsolutePosition, look);
1308 SendInitialData(); 1329 SendInitialData();
@@ -1813,7 +1834,10 @@ namespace OpenSim.Region.Framework.Scenes
1813 /// This is to allow movement to targets that are known to be on an elevated platform with a continuous path 1834 /// This is to allow movement to targets that are known to be on an elevated platform with a continuous path
1814 /// from start to finish. 1835 /// from start to finish.
1815 /// </param> 1836 /// </param>
1816 public void MoveToTarget(Vector3 pos, bool noFly) 1837 /// <param name="landAtTarget">
1838 /// If true and the avatar starts flying during the move then land at the target.
1839 /// </param>
1840 public void MoveToTarget(Vector3 pos, bool noFly, bool landAtTarget)
1817 { 1841 {
1818 m_log.DebugFormat( 1842 m_log.DebugFormat(
1819 "[SCENE PRESENCE]: Avatar {0} received request to move to position {1} in {2}", 1843 "[SCENE PRESENCE]: Avatar {0} received request to move to position {1} in {2}",
@@ -1839,7 +1863,7 @@ namespace OpenSim.Region.Framework.Scenes
1839 1863
1840 // Fudge factor. It appears that if one clicks "go here" on a piece of ground, the go here request is 1864 // Fudge factor. It appears that if one clicks "go here" on a piece of ground, the go here request is
1841 // always slightly higher than the actual terrain height. 1865 // always slightly higher than the actual terrain height.
1842 // FIXME: This constrains NOC movements as well, so should be somewhere else. 1866 // FIXME: This constrains NPC movements as well, so should be somewhere else.
1843 if (pos.Z - terrainHeight < 0.2) 1867 if (pos.Z - terrainHeight < 0.2)
1844 pos.Z = terrainHeight; 1868 pos.Z = terrainHeight;
1845 1869
@@ -1852,9 +1876,25 @@ namespace OpenSim.Region.Framework.Scenes
1852 else if (pos.Z > terrainHeight) 1876 else if (pos.Z > terrainHeight)
1853 PhysicsActor.Flying = true; 1877 PhysicsActor.Flying = true;
1854 1878
1879 LandAtTarget = landAtTarget;
1855 MovingToTarget = true; 1880 MovingToTarget = true;
1856 MoveToPositionTarget = pos; 1881 MoveToPositionTarget = pos;
1857 1882
1883 // Rotate presence around the z-axis to point in same direction as movement.
1884 // Ignore z component of vector
1885 Vector3 localVectorToTarget3D = pos - AbsolutePosition;
1886 Vector3 localVectorToTarget2D = new Vector3((float)(localVectorToTarget3D.X), (float)(localVectorToTarget3D.Y), 0f);
1887
1888// m_log.DebugFormat("[SCENE PRESENCE]: Local vector to target is {0}", localVectorToTarget2D);
1889
1890 // Calculate the yaw.
1891 Vector3 angle = new Vector3(0, 0, (float)(Math.Atan2(localVectorToTarget2D.Y, localVectorToTarget2D.X)));
1892
1893// m_log.DebugFormat("[SCENE PRESENCE]: Angle is {0}", angle);
1894
1895 Rotation = Quaternion.CreateFromEulers(angle);
1896// m_log.DebugFormat("[SCENE PRESENCE]: Body rot for {0} set to {1}", Name, Rotation);
1897
1858 Vector3 agent_control_v3 = new Vector3(); 1898 Vector3 agent_control_v3 = new Vector3();
1859 HandleMoveToTargetUpdate(ref agent_control_v3); 1899 HandleMoveToTargetUpdate(ref agent_control_v3);
1860 AddNewMovement(agent_control_v3); 1900 AddNewMovement(agent_control_v3);
@@ -2744,7 +2784,7 @@ namespace OpenSim.Region.Framework.Scenes
2744 Vector3 pos = m_pos; 2784 Vector3 pos = m_pos;
2745 pos.Z += m_appearance.HipOffset; 2785 pos.Z += m_appearance.HipOffset;
2746 2786
2747 //m_log.DebugFormat("[SCENEPRESENCE]: TerseUpdate: Pos={0} Rot={1} Vel={2}", m_pos, m_bodyRot, m_velocity); 2787 //m_log.DebugFormat("[SCENE PRESENCE]: " + Name + " sending TerseUpdate to " + remoteClient.Name + " : Pos={0} Rot={1} Vel={2}", m_pos, m_bodyRot, m_velocity);
2748 2788
2749 remoteClient.SendPrimUpdate( 2789 remoteClient.SendPrimUpdate(
2750 this, 2790 this,
@@ -2831,6 +2871,7 @@ namespace OpenSim.Region.Framework.Scenes
2831 /// </summary> 2871 /// </summary>
2832 private void SendInitialData() 2872 private void SendInitialData()
2833 { 2873 {
2874 //m_log.DebugFormat("[SCENE PRESENCE] SendInitialData: {0} ({1})", Name, UUID);
2834 // Moved this into CompleteMovement to ensure that m_appearance is initialized before 2875 // Moved this into CompleteMovement to ensure that m_appearance is initialized before
2835 // the inventory arrives 2876 // the inventory arrives
2836 // m_scene.GetAvatarAppearance(m_controllingClient, out m_appearance); 2877 // m_scene.GetAvatarAppearance(m_controllingClient, out m_appearance);
@@ -2875,10 +2916,11 @@ namespace OpenSim.Region.Framework.Scenes
2875 /// </summary> 2916 /// </summary>
2876 public void SendAvatarDataToAllAgents() 2917 public void SendAvatarDataToAllAgents()
2877 { 2918 {
2919 //m_log.DebugFormat("[SCENE PRESENCE] SendAvatarDataToAllAgents: {0} ({1})", Name, UUID);
2878 // only send update from root agents to other clients; children are only "listening posts" 2920 // only send update from root agents to other clients; children are only "listening posts"
2879 if (IsChildAgent) 2921 if (IsChildAgent)
2880 { 2922 {
2881 m_log.Warn("[SCENEPRESENCE] attempt to send avatar data from a child agent"); 2923 m_log.Warn("[SCENE PRESENCE] attempt to send avatar data from a child agent");
2882 return; 2924 return;
2883 } 2925 }
2884 2926
@@ -2928,7 +2970,7 @@ namespace OpenSim.Region.Framework.Scenes
2928 /// <param name="avatar"></param> 2970 /// <param name="avatar"></param>
2929 public void SendAvatarDataToAgent(ScenePresence avatar) 2971 public void SendAvatarDataToAgent(ScenePresence avatar)
2930 { 2972 {
2931// m_log.WarnFormat("[SP] Send avatar data from {0} to {1}",m_uuid,avatar.ControllingClient.AgentId); 2973 //m_log.DebugFormat("[SCENE PRESENCE] SendAvatarDataToAgent from {0} ({1}) to {2} ({3})", Name, UUID, avatar.Name, avatar.UUID);
2932 2974
2933 avatar.ControllingClient.SendAvatarDataImmediate(this); 2975 avatar.ControllingClient.SendAvatarDataImmediate(this);
2934 if (Animator != null) 2976 if (Animator != null)
@@ -2941,10 +2983,11 @@ namespace OpenSim.Region.Framework.Scenes
2941 /// </summary> 2983 /// </summary>
2942 public void SendAppearanceToAllOtherAgents() 2984 public void SendAppearanceToAllOtherAgents()
2943 { 2985 {
2986 m_log.DebugFormat("[SCENE PRESENCE] SendAppearanceToAllOtherAgents: {0} ({1})", Name, UUID);
2944 // only send update from root agents to other clients; children are only "listening posts" 2987 // only send update from root agents to other clients; children are only "listening posts"
2945 if (IsChildAgent) 2988 if (IsChildAgent)
2946 { 2989 {
2947 m_log.Warn("[SCENEPRESENCE] attempt to send avatar data from a child agent"); 2990 m_log.Warn("[SCENE PRESENCE] attempt to send avatar data from a child agent");
2948 return; 2991 return;
2949 } 2992 }
2950 2993
@@ -2970,6 +3013,7 @@ namespace OpenSim.Region.Framework.Scenes
2970 /// </summary> 3013 /// </summary>
2971 public void SendOtherAgentsAppearanceToMe() 3014 public void SendOtherAgentsAppearanceToMe()
2972 { 3015 {
3016 //m_log.DebugFormat("[SCENE PRESENCE] SendOtherAgentsAppearanceToMe: {0} ({1})", Name, UUID);
2973 m_perfMonMS = Util.EnvironmentTickCount(); 3017 m_perfMonMS = Util.EnvironmentTickCount();
2974 3018
2975 int count = 0; 3019 int count = 0;
@@ -3618,7 +3662,7 @@ namespace OpenSim.Region.Framework.Scenes
3618 /// <summary> 3662 /// <summary>
3619 /// Handles part of the PID controller function for moving an avatar. 3663 /// Handles part of the PID controller function for moving an avatar.
3620 /// </summary> 3664 /// </summary>
3621 public override void UpdateMovement() 3665 public void UpdateMovement()
3622 { 3666 {
3623 if (m_forceToApply.HasValue) 3667 if (m_forceToApply.HasValue)
3624 { 3668 {
@@ -3637,6 +3681,10 @@ namespace OpenSim.Region.Framework.Scenes
3637 /// </summary> 3681 /// </summary>
3638 public void AddToPhysicalScene(bool isFlying) 3682 public void AddToPhysicalScene(bool isFlying)
3639 { 3683 {
3684// m_log.DebugFormat(
3685// "[SCENE PRESENCE]: Adding physics actor for {0}, ifFlying = {1} in {2}",
3686// Name, isFlying, Scene.RegionInfo.RegionName);
3687
3640 if (m_appearance.AvatarHeight == 0) 3688 if (m_appearance.AvatarHeight == 0)
3641 m_appearance.SetHeight(); 3689 m_appearance.SetHeight();
3642 3690
@@ -4340,4 +4388,4 @@ namespace OpenSim.Region.Framework.Scenes
4340 } 4388 }
4341 } 4389 }
4342 } 4390 }
4343} \ No newline at end of file 4391}