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.cs74
1 files changed, 39 insertions, 35 deletions
diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs
index 0414f89..b0aa434 100644
--- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs
+++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs
@@ -379,6 +379,11 @@ namespace OpenSim.Region.Framework.Scenes
379 public uint MovementFlag { get; private set; } 379 public uint MovementFlag { get; private set; }
380 380
381 /// <summary> 381 /// <summary>
382 /// Set this if we need to force a movement update on the next received AgentUpdate from the viewer.
383 /// </summary>
384 private const uint ForceUpdateMovementFlagValue = uint.MaxValue;
385
386 /// <summary>
382 /// Is the agent stop control flag currently active? 387 /// Is the agent stop control flag currently active?
383 /// </summary> 388 /// </summary>
384 public bool AgentControlStopActive { get; private set; } 389 public bool AgentControlStopActive { get; private set; }
@@ -822,7 +827,7 @@ namespace OpenSim.Region.Framework.Scenes
822 } 827 }
823 828
824 private bool m_mouseLook; 829 private bool m_mouseLook;
825 private bool m_leftButtonDown; 830// private bool m_leftButtonDown;
826 831
827 private bool m_inTransit; 832 private bool m_inTransit;
828 833
@@ -1005,23 +1010,6 @@ namespace OpenSim.Region.Framework.Scenes
1005 Dir_Vectors[10] = new Vector3(0f, 0f, -0.5f); //DOWN_Nudge 1010 Dir_Vectors[10] = new Vector3(0f, 0f, -0.5f); //DOWN_Nudge
1006 } 1011 }
1007 1012
1008 private Vector3[] GetWalkDirectionVectors()
1009 {
1010 Vector3[] vector = new Vector3[11];
1011 vector[0] = new Vector3(CameraUpAxis.Z, 0f, -CameraAtAxis.Z); //FORWARD
1012 vector[1] = new Vector3(-CameraUpAxis.Z, 0f, CameraAtAxis.Z); //BACK
1013 vector[2] = Vector3.UnitY; //LEFT
1014 vector[3] = -Vector3.UnitY; //RIGHT
1015 vector[4] = new Vector3(CameraAtAxis.Z, 0f, CameraUpAxis.Z); //UP
1016 vector[5] = new Vector3(-CameraAtAxis.Z, 0f, -CameraUpAxis.Z); //DOWN
1017 vector[6] = new Vector3(CameraUpAxis.Z, 0f, -CameraAtAxis.Z); //FORWARD_NUDGE
1018 vector[7] = new Vector3(-CameraUpAxis.Z, 0f, CameraAtAxis.Z); //BACK_NUDGE
1019 vector[8] = Vector3.UnitY; //LEFT_NUDGE
1020 vector[9] = -Vector3.UnitY; //RIGHT_NUDGE
1021 vector[10] = new Vector3(-CameraAtAxis.Z, 0f, -CameraUpAxis.Z); //DOWN_NUDGE
1022 return vector;
1023 }
1024
1025 #endregion 1013 #endregion
1026 1014
1027 #region Status Methods 1015 #region Status Methods
@@ -1267,7 +1255,7 @@ namespace OpenSim.Region.Framework.Scenes
1267 // If we don't reset the movement flag here, an avatar that crosses to a neighbouring sim and returns will 1255 // If we don't reset the movement flag here, an avatar that crosses to a neighbouring sim and returns will
1268 // stall on the border crossing since the existing child agent will still have the last movement 1256 // stall on the border crossing since the existing child agent will still have the last movement
1269 // recorded, which stops the input from being processed. 1257 // recorded, which stops the input from being processed.
1270 MovementFlag = 0; 1258 MovementFlag = ForceUpdateMovementFlagValue;
1271 1259
1272 m_scene.EventManager.TriggerOnMakeRootAgent(this); 1260 m_scene.EventManager.TriggerOnMakeRootAgent(this);
1273 1261
@@ -1925,13 +1913,13 @@ namespace OpenSim.Region.Framework.Scenes
1925 /// </summary> 1913 /// </summary>
1926 public void HandleAgentUpdate(IClientAPI remoteClient, AgentUpdateArgs agentData) 1914 public void HandleAgentUpdate(IClientAPI remoteClient, AgentUpdateArgs agentData)
1927 { 1915 {
1928 //m_log.DebugFormat( 1916// m_log.DebugFormat(
1929 // "[SCENE PRESENCE]: In {0} received agent update from {1}, flags {2}", 1917// "[SCENE PRESENCE]: In {0} received agent update from {1}, flags {2}",
1930 // Scene.RegionInfo.RegionName, remoteClient.Name, (AgentManager.ControlFlags)agentData.ControlFlags); 1918// Scene.Name, remoteClient.Name, (AgentManager.ControlFlags)agentData.ControlFlags);
1931 1919
1932 if (IsChildAgent) 1920 if (IsChildAgent)
1933 { 1921 {
1934 // // m_log.Debug("DEBUG: HandleAgentUpdate: child agent"); 1922// m_log.DebugFormat("DEBUG: HandleAgentUpdate: child agent in {0}", Scene.Name);
1935 return; 1923 return;
1936 } 1924 }
1937 1925
@@ -1973,7 +1961,12 @@ namespace OpenSim.Region.Framework.Scenes
1973 // DrawDistance = Scene.DefaultDrawDistance; 1961 // DrawDistance = Scene.DefaultDrawDistance;
1974 1962
1975 m_mouseLook = (flags & AgentManager.ControlFlags.AGENT_CONTROL_MOUSELOOK) != 0; 1963 m_mouseLook = (flags & AgentManager.ControlFlags.AGENT_CONTROL_MOUSELOOK) != 0;
1976 m_leftButtonDown = (flags & AgentManager.ControlFlags.AGENT_CONTROL_LBUTTON_DOWN) != 0; 1964
1965 // FIXME: This does not work as intended because the viewer only sends the lbutton down when the button
1966 // is first pressed, not whilst it is held down. If this is required in the future then need to look
1967 // for an AGENT_CONTROL_LBUTTON_UP event and make sure to handle cases where an initial DOWN is not
1968 // received (e.g. on holding LMB down on the avatar in a viewer).
1969// m_leftButtonDown = (flags & AgentManager.ControlFlags.AGENT_CONTROL_LBUTTON_DOWN) != 0;
1977 1970
1978 #endregion Inputs 1971 #endregion Inputs
1979 1972
@@ -2066,6 +2059,14 @@ namespace OpenSim.Region.Framework.Scenes
2066 2059
2067 bool update_movementflag = false; 2060 bool update_movementflag = false;
2068 2061
2062 // If we were just made root agent then we must perform movement updates for the first AgentUpdate that
2063 // we get
2064 if (MovementFlag == ForceUpdateMovementFlagValue)
2065 {
2066 MovementFlag = 0;
2067 update_movementflag = true;
2068 }
2069
2069 if (agentData.UseClientAgentPosition) 2070 if (agentData.UseClientAgentPosition)
2070 { 2071 {
2071 MovingToTarget = (agentData.ClientAgentPosition - AbsolutePosition).Length() > 0.2f; 2072 MovingToTarget = (agentData.ClientAgentPosition - AbsolutePosition).Length() > 0.2f;
@@ -2097,15 +2098,6 @@ namespace OpenSim.Region.Framework.Scenes
2097 { 2098 {
2098 bool bAllowUpdateMoveToPosition = false; 2099 bool bAllowUpdateMoveToPosition = false;
2099 2100
2100 Vector3[] dirVectors;
2101
2102 // use camera up angle when in mouselook and not flying or when holding the left mouse button down and not flying
2103 // this prevents 'jumping' in inappropriate situations.
2104 if (!Flying && (m_mouseLook || m_leftButtonDown))
2105 dirVectors = GetWalkDirectionVectors();
2106 else
2107 dirVectors = Dir_Vectors;
2108
2109 // A DIR_CONTROL_FLAG occurs when the user is trying to move in a particular direction. 2101 // A DIR_CONTROL_FLAG occurs when the user is trying to move in a particular direction.
2110 foreach (Dir_ControlFlags DCF in DIR_CONTROL_FLAGS) 2102 foreach (Dir_ControlFlags DCF in DIR_CONTROL_FLAGS)
2111 { 2103 {
@@ -2115,7 +2107,9 @@ namespace OpenSim.Region.Framework.Scenes
2115 2107
2116 try 2108 try
2117 { 2109 {
2118 agent_control_v3 += dirVectors[i]; 2110 // Don't slide against ground when crouching if camera is panned around avatar
2111 if (Flying || DCF != Dir_ControlFlags.DIR_CONTROL_FLAG_DOWN)
2112 agent_control_v3 += Dir_Vectors[i];
2119 //m_log.DebugFormat("[Motion]: {0}, {1}",i, dirVectors[i]); 2113 //m_log.DebugFormat("[Motion]: {0}, {1}",i, dirVectors[i]);
2120 } 2114 }
2121 catch (IndexOutOfRangeException) 2115 catch (IndexOutOfRangeException)
@@ -3149,7 +3143,17 @@ namespace OpenSim.Region.Framework.Scenes
3149// "[SCENE PRESENCE]: Adding new movement {0} with rotation {1}, thisAddSpeedModifier {2} for {3}", 3143// "[SCENE PRESENCE]: Adding new movement {0} with rotation {1}, thisAddSpeedModifier {2} for {3}",
3150// vec, Rotation, thisAddSpeedModifier, Name); 3144// vec, Rotation, thisAddSpeedModifier, Name);
3151 3145
3152 Vector3 direc = vec * Rotation; 3146 Quaternion rot = Rotation;
3147 if (!(Flying && m_mouseLook) && (PresenceType != PresenceType.Npc))
3148 {
3149 // The only situation in which we care about X and Y is in mouselook flying. The rest of the time
3150 // these parameters are not relevant for determining avatar movement direction and cause issues such
3151 // as wrong walk speed if the camera is rotated.
3152 rot.X = 0;
3153 rot.Y = 0;
3154 }
3155
3156 Vector3 direc = vec * rot;
3153 direc.Normalize(); 3157 direc.Normalize();
3154 3158
3155 if (Flying != FlyingOld) // add for fly velocity control 3159 if (Flying != FlyingOld) // add for fly velocity control