From 412dd7dfc56a10f590a42d0e6d014da9f4551bbf Mon Sep 17 00:00:00 2001 From: "Justin Clark-Casey (justincc)" Date: Thu, 26 Feb 2015 00:48:51 +0000 Subject: [PATCH] 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 --- .../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 0414f893c3..973f2cf1ce 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -378,6 +378,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? /// @@ -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;