Added check for user movement specification before discarding an incoming

AgentUpdate packet. This fixes the problem with vehicles not moving forward
after the first up-arrow.
Code to fix a potential exception when using different IClientAPIs.
TeleportWork
Robert Adams 2013-07-22 15:41:14 -07:00
parent 44543ebe63
commit e6b6af62dd
2 changed files with 42 additions and 42 deletions

View File

@ -359,12 +359,6 @@ namespace OpenSim.Region.ClientStack.LindenUDP
/// cannot retain a reference to it outside of that method. /// cannot retain a reference to it outside of that method.
/// </remarks> /// </remarks>
private AgentUpdateArgs m_thisAgentUpdateArgs = new AgentUpdateArgs(); private AgentUpdateArgs m_thisAgentUpdateArgs = new AgentUpdateArgs();
private float qdelta1;
private float qdelta2;
private float vdelta1;
private float vdelta2;
private float vdelta3;
private float vdelta4;
protected Dictionary<PacketType, PacketProcessor> m_packetHandlers = new Dictionary<PacketType, PacketProcessor>(); protected Dictionary<PacketType, PacketProcessor> m_packetHandlers = new Dictionary<PacketType, PacketProcessor>();
protected Dictionary<string, GenericMessage> m_genericPacketHandlers = new Dictionary<string, GenericMessage>(); //PauPaw:Local Generic Message handlers protected Dictionary<string, GenericMessage> m_genericPacketHandlers = new Dictionary<string, GenericMessage>(); //PauPaw:Local Generic Message handlers
@ -5576,7 +5570,9 @@ namespace OpenSim.Region.ClientStack.LindenUDP
#region Scene/Avatar #region Scene/Avatar
// Threshold for body rotation to be a significant agent update
private const float QDELTA = 0.000001f; private const float QDELTA = 0.000001f;
// Threshold for camera rotation to be a significant agent update
private const float VDELTA = 0.01f; private const float VDELTA = 0.01f;
/// <summary> /// <summary>
@ -5587,31 +5583,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
/// <param name='x'></param> /// <param name='x'></param>
public bool CheckAgentUpdateSignificance(AgentUpdatePacket.AgentDataBlock x) public bool CheckAgentUpdateSignificance(AgentUpdatePacket.AgentDataBlock x)
{ {
// Compute these only once, when this function is called from down below return CheckAgentMovementUpdateSignificance(x) || CheckAgentCameraUpdateSignificance(x);
qdelta1 = 1 - (float)Math.Pow(Quaternion.Dot(x.BodyRotation, m_thisAgentUpdateArgs.BodyRotation), 2);
//qdelta2 = 1 - (float)Math.Pow(Quaternion.Dot(x.HeadRotation, m_thisAgentUpdateArgs.HeadRotation), 2);
vdelta1 = Vector3.Distance(x.CameraAtAxis, m_thisAgentUpdateArgs.CameraAtAxis);
vdelta2 = Vector3.Distance(x.CameraCenter, m_thisAgentUpdateArgs.CameraCenter);
vdelta3 = Vector3.Distance(x.CameraLeftAxis, m_thisAgentUpdateArgs.CameraLeftAxis);
vdelta4 = Vector3.Distance(x.CameraUpAxis, m_thisAgentUpdateArgs.CameraUpAxis);
bool significant = CheckAgentMovementUpdateSignificance(x) || CheckAgentCameraUpdateSignificance(x);
// Emergency debugging
//if (significant)
//{
//m_log.DebugFormat("[LLCLIENTVIEW]: Cam1 {0} {1}",
// x.CameraAtAxis, x.CameraCenter);
//m_log.DebugFormat("[LLCLIENTVIEW]: Cam2 {0} {1}",
// x.CameraLeftAxis, x.CameraUpAxis);
//m_log.DebugFormat("[LLCLIENTVIEW]: Bod {0} {1}",
// qdelta1, qdelta2);
//m_log.DebugFormat("[LLCLIENTVIEW]: St {0} {1} {2} {3}",
// x.ControlFlags, x.Flags, x.Far, x.State);
//}
return significant;
} }
/// <summary> /// <summary>
@ -5622,15 +5594,27 @@ namespace OpenSim.Region.ClientStack.LindenUDP
/// <param name='x'></param> /// <param name='x'></param>
private bool CheckAgentMovementUpdateSignificance(AgentUpdatePacket.AgentDataBlock x) private bool CheckAgentMovementUpdateSignificance(AgentUpdatePacket.AgentDataBlock x)
{ {
return ( float qdelta1 = 1 - (float)Math.Pow(Quaternion.Dot(x.BodyRotation, m_thisAgentUpdateArgs.BodyRotation), 2);
(qdelta1 > QDELTA) || //qdelta2 = 1 - (float)Math.Pow(Quaternion.Dot(x.HeadRotation, m_thisAgentUpdateArgs.HeadRotation), 2);
bool movementSignificant =
(qdelta1 > QDELTA) // significant if body rotation above threshold
// Ignoring head rotation altogether, because it's not being used for anything interesting up the stack // Ignoring head rotation altogether, because it's not being used for anything interesting up the stack
//(qdelta2 > QDELTA * 10) || // || (qdelta2 > QDELTA * 10) // significant if head rotation above threshold
(x.ControlFlags != m_thisAgentUpdateArgs.ControlFlags) || || (x.ControlFlags != m_thisAgentUpdateArgs.ControlFlags) // significant if control flags changed
(x.Far != m_thisAgentUpdateArgs.Far) || || (x.ControlFlags != (byte)AgentManager.ControlFlags.NONE) // significant if user supplying any movement update commands
(x.Flags != m_thisAgentUpdateArgs.Flags) || || (x.Far != m_thisAgentUpdateArgs.Far) // significant if far distance changed
(x.State != m_thisAgentUpdateArgs.State) || (x.Flags != m_thisAgentUpdateArgs.Flags) // significant if Flags changed
); || (x.State != m_thisAgentUpdateArgs.State) // significant if Stats changed
;
//if (movementSignificant)
//{
//m_log.DebugFormat("[LLCLIENTVIEW]: Bod {0} {1}",
// qdelta1, qdelta2);
//m_log.DebugFormat("[LLCLIENTVIEW]: St {0} {1} {2} {3}",
// x.ControlFlags, x.Flags, x.Far, x.State);
//}
return movementSignificant;
} }
/// <summary> /// <summary>
@ -5641,12 +5625,27 @@ namespace OpenSim.Region.ClientStack.LindenUDP
/// <param name='x'></param> /// <param name='x'></param>
private bool CheckAgentCameraUpdateSignificance(AgentUpdatePacket.AgentDataBlock x) private bool CheckAgentCameraUpdateSignificance(AgentUpdatePacket.AgentDataBlock x)
{ {
return ( float vdelta1 = Vector3.Distance(x.CameraAtAxis, m_thisAgentUpdateArgs.CameraAtAxis);
float vdelta2 = Vector3.Distance(x.CameraCenter, m_thisAgentUpdateArgs.CameraCenter);
float vdelta3 = Vector3.Distance(x.CameraLeftAxis, m_thisAgentUpdateArgs.CameraLeftAxis);
float vdelta4 = Vector3.Distance(x.CameraUpAxis, m_thisAgentUpdateArgs.CameraUpAxis);
bool cameraSignificant =
(vdelta1 > VDELTA) || (vdelta1 > VDELTA) ||
(vdelta2 > VDELTA) || (vdelta2 > VDELTA) ||
(vdelta3 > VDELTA) || (vdelta3 > VDELTA) ||
(vdelta4 > VDELTA) (vdelta4 > VDELTA)
); ;
//if (cameraSignificant)
//{
//m_log.DebugFormat("[LLCLIENTVIEW]: Cam1 {0} {1}",
// x.CameraAtAxis, x.CameraCenter);
//m_log.DebugFormat("[LLCLIENTVIEW]: Cam2 {0} {1}",
// x.CameraLeftAxis, x.CameraUpAxis);
//}
return cameraSignificant;
} }
private bool HandleAgentUpdate(IClientAPI sener, Packet packet) private bool HandleAgentUpdate(IClientAPI sener, Packet packet)

View File

@ -1316,9 +1316,10 @@ namespace OpenSim.Region.ClientStack.LindenUDP
AgentUpdatePacket agentUpdate = (AgentUpdatePacket)packet; AgentUpdatePacket agentUpdate = (AgentUpdatePacket)packet;
LLClientView llClient = client as LLClientView;
if (agentUpdate.AgentData.SessionID != client.SessionId if (agentUpdate.AgentData.SessionID != client.SessionId
|| agentUpdate.AgentData.AgentID != client.AgentId || agentUpdate.AgentData.AgentID != client.AgentId
|| !((LLClientView)client).CheckAgentUpdateSignificance(agentUpdate.AgentData)) || !(llClient == null || llClient.CheckAgentUpdateSignificance(agentUpdate.AgentData)) )
{ {
PacketPool.Instance.ReturnPacket(packet); PacketPool.Instance.ReturnPacket(packet);
return; return;