From 412dd7dfc56a10f590a42d0e6d014da9f4551bbf Mon Sep 17 00:00:00 2001
From: Justin Clark-Casey (justincc)
Date: Thu, 26 Feb 2015 00:48:51 +0000
Subject: When an avatar is walking across a region border, force the first
AgentUpdate received on the new root agent to update movement parameters.
This prevents the avatar from drifting in its last direction of travel if a movement key was released at certain moments in the cross.
Relates to http://opensimulator.org/mantis/view.php?id=7435
---
OpenSim/Region/Framework/Scenes/ScenePresence.cs | 23 ++++++++++++++++++-----
1 file changed, 18 insertions(+), 5 deletions(-)
diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs
index 0414f89..973f2cf 100644
--- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs
+++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs
@@ -379,6 +379,11 @@ namespace OpenSim.Region.Framework.Scenes
public uint MovementFlag { get; private set; }
///
+ /// Set this if we need to force a movement update on the next received AgentUpdate from the viewer.
+ ///
+ private const uint ForceUpdateMovementFlagValue = uint.MaxValue;
+
+ ///
/// Is the agent stop control flag currently active?
///
public bool AgentControlStopActive { get; private set; }
@@ -1267,7 +1272,7 @@ namespace OpenSim.Region.Framework.Scenes
// If we don't reset the movement flag here, an avatar that crosses to a neighbouring sim and returns will
// stall on the border crossing since the existing child agent will still have the last movement
// recorded, which stops the input from being processed.
- MovementFlag = 0;
+ MovementFlag = ForceUpdateMovementFlagValue;
m_scene.EventManager.TriggerOnMakeRootAgent(this);
@@ -1925,13 +1930,13 @@ namespace OpenSim.Region.Framework.Scenes
///
public void HandleAgentUpdate(IClientAPI remoteClient, AgentUpdateArgs agentData)
{
- //m_log.DebugFormat(
- // "[SCENE PRESENCE]: In {0} received agent update from {1}, flags {2}",
- // Scene.RegionInfo.RegionName, remoteClient.Name, (AgentManager.ControlFlags)agentData.ControlFlags);
+// m_log.DebugFormat(
+// "[SCENE PRESENCE]: In {0} received agent update from {1}, flags {2}",
+// Scene.Name, remoteClient.Name, (AgentManager.ControlFlags)agentData.ControlFlags);
if (IsChildAgent)
{
- // // m_log.Debug("DEBUG: HandleAgentUpdate: child agent");
+// m_log.DebugFormat("DEBUG: HandleAgentUpdate: child agent in {0}", Scene.Name);
return;
}
@@ -2066,6 +2071,14 @@ namespace OpenSim.Region.Framework.Scenes
bool update_movementflag = false;
+ // If we were just made root agent then we must perform movement updates for the first AgentUpdate that
+ // we get
+ if (MovementFlag == ForceUpdateMovementFlagValue)
+ {
+ MovementFlag = 0;
+ update_movementflag = true;
+ }
+
if (agentData.UseClientAgentPosition)
{
MovingToTarget = (agentData.ClientAgentPosition - AbsolutePosition).Length() > 0.2f;
--
cgit v1.1