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
inv-download
Justin Clark-Casey (justincc) 2015-02-26 00:48:51 +00:00
parent 5fa651c529
commit 412dd7dfc5
1 changed files with 18 additions and 5 deletions

View File

@ -378,6 +378,11 @@ namespace OpenSim.Region.Framework.Scenes
/// </summary>
public uint MovementFlag { get; private set; }
/// <summary>
/// Set this if we need to force a movement update on the next received AgentUpdate from the viewer.
/// </summary>
private const uint ForceUpdateMovementFlagValue = uint.MaxValue;
/// <summary>
/// Is the agent stop control flag currently active?
/// </summary>
@ -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
/// </summary>
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;