Merge branch 'ubitworkmaster'

avinationmerge
Melanie Thielker 2014-08-13 03:05:54 +02:00
commit b96f951a6a
2 changed files with 68 additions and 63 deletions

View File

@ -856,6 +856,9 @@ namespace OpenSim.Region.ClientStack.LindenUDP
public void MoveAgentIntoRegion(RegionInfo regInfo, Vector3 pos, Vector3 look)
{
m_thisAgentUpdateArgs.CameraAtAxis.X = float.MinValue;
m_thisAgentUpdateArgs.ControlFlags = uint.MaxValue;
AgentMovementCompletePacket mov = (AgentMovementCompletePacket)PacketPool.Instance.GetPacket(PacketType.AgentMovementComplete);
mov.SimData.ChannelVersion = m_channelVersion;
mov.AgentData.SessionID = m_sessionId;
@ -5734,7 +5737,9 @@ namespace OpenSim.Region.ClientStack.LindenUDP
#region Scene/Avatar
// Threshold for body rotation to be a significant agent update
private const float QDELTA = 0.000001f;
// use the abs of cos
private const float QDELTABody = 1.0f - 0.0001f;
private const float QDELTAHead = 1.0f - 0.0001f;
// Threshold for camera rotation to be a significant agent update
private const float VDELTA = 0.01f;
@ -5757,18 +5762,18 @@ namespace OpenSim.Region.ClientStack.LindenUDP
/// <param name='x'></param>
private bool CheckAgentMovementUpdateSignificance(AgentUpdatePacket.AgentDataBlock x)
{
float 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);
float qdelta1 = Math.Abs(Quaternion.Dot(x.BodyRotation, m_thisAgentUpdateArgs.BodyRotation));
//qdelta2 = Math.Abs(Quaternion.Dot(x.HeadRotation, m_thisAgentUpdateArgs.HeadRotation));
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
// || (qdelta2 > QDELTA * 10) // significant if head rotation above threshold
|| (x.ControlFlags != m_thisAgentUpdateArgs.ControlFlags) // significant if control flags changed
(x.ControlFlags != m_thisAgentUpdateArgs.ControlFlags) // significant if control flags changed
|| (x.ControlFlags != (byte)AgentManager.ControlFlags.NONE) // significant if user supplying any movement update commands
|| (x.Far != m_thisAgentUpdateArgs.Far) // significant if far distance changed
|| (x.Flags != m_thisAgentUpdateArgs.Flags) // significant if Flags changed
|| (x.State != m_thisAgentUpdateArgs.State) // significant if Stats changed
|| (qdelta1 < QDELTABody) // significant if body rotation above(below cos) threshold
// Ignoring head rotation altogether, because it's not being used for anything interesting up the stack
// || (qdelta2 < QDELTAHead) // significant if head rotation above(below cos) threshold
|| (x.Far != m_thisAgentUpdateArgs.Far) // significant if far distance changed
;
//if (movementSignificant)
//{
@ -5811,55 +5816,63 @@ namespace OpenSim.Region.ClientStack.LindenUDP
return cameraSignificant;
}
private bool HandleAgentUpdate(IClientAPI sener, Packet packet)
{
private bool HandleAgentUpdate(IClientAPI sender, Packet packet)
{
// We got here, which means that something in agent update was significant
AgentUpdatePacket agentUpdate = (AgentUpdatePacket)packet;
AgentUpdatePacket.AgentDataBlock x = agentUpdate.AgentData;
if (x.AgentID != AgentId || x.SessionID != SessionId)
{
PacketPool.Instance.ReturnPacket(packet);
return false;
}
TotalAgentUpdates++;
// Before we update the current m_thisAgentUpdateArgs, let's check this again
// to see what exactly changed
bool movement = CheckAgentMovementUpdateSignificance(x);
bool camera = CheckAgentCameraUpdateSignificance(x);
m_thisAgentUpdateArgs.AgentID = x.AgentID;
m_thisAgentUpdateArgs.BodyRotation = x.BodyRotation;
m_thisAgentUpdateArgs.CameraAtAxis = x.CameraAtAxis;
m_thisAgentUpdateArgs.CameraCenter = x.CameraCenter;
m_thisAgentUpdateArgs.CameraLeftAxis = x.CameraLeftAxis;
m_thisAgentUpdateArgs.CameraUpAxis = x.CameraUpAxis;
m_thisAgentUpdateArgs.ControlFlags = x.ControlFlags;
m_thisAgentUpdateArgs.Far = x.Far;
m_thisAgentUpdateArgs.Flags = x.Flags;
m_thisAgentUpdateArgs.HeadRotation = x.HeadRotation;
m_thisAgentUpdateArgs.SessionID = x.SessionID;
m_thisAgentUpdateArgs.State = x.State;
UpdateAgent handlerAgentUpdate = OnAgentUpdate;
UpdateAgent handlerPreAgentUpdate = OnPreAgentUpdate;
UpdateAgent handlerAgentCameraUpdate = OnAgentCameraUpdate;
// Was there a significant movement/state change?
if (movement)
{
m_thisAgentUpdateArgs.BodyRotation = x.BodyRotation;
m_thisAgentUpdateArgs.ControlFlags = x.ControlFlags;
m_thisAgentUpdateArgs.Far = x.Far;
m_thisAgentUpdateArgs.Flags = x.Flags;
m_thisAgentUpdateArgs.HeadRotation = x.HeadRotation;
// m_thisAgentUpdateArgs.SessionID = x.SessionID;
m_thisAgentUpdateArgs.State = x.State;
UpdateAgent handlerAgentUpdate = OnAgentUpdate;
UpdateAgent handlerPreAgentUpdate = OnPreAgentUpdate;
if (handlerPreAgentUpdate != null)
OnPreAgentUpdate(this, m_thisAgentUpdateArgs);
if (handlerAgentUpdate != null)
OnAgentUpdate(this, m_thisAgentUpdateArgs);
handlerAgentUpdate = null;
handlerPreAgentUpdate = null;
}
// Was there a significant camera(s) change?
if (camera)
{
m_thisAgentUpdateArgs.CameraAtAxis = x.CameraAtAxis;
m_thisAgentUpdateArgs.CameraCenter = x.CameraCenter;
m_thisAgentUpdateArgs.CameraLeftAxis = x.CameraLeftAxis;
m_thisAgentUpdateArgs.CameraUpAxis = x.CameraUpAxis;
UpdateAgent handlerAgentCameraUpdate = OnAgentCameraUpdate;
if (handlerAgentCameraUpdate != null)
handlerAgentCameraUpdate(this, m_thisAgentUpdateArgs);
handlerAgentUpdate = null;
handlerPreAgentUpdate = null;
handlerAgentCameraUpdate = null;
handlerAgentCameraUpdate = null;
}
PacketPool.Instance.ReturnPacket(packet);
@ -6745,8 +6758,10 @@ namespace OpenSim.Region.ClientStack.LindenUDP
return true;
}
private bool HandleCompleteAgentMovement(IClientAPI sender, Packet Pack)
private bool HandleCompleteAgentMovement(IClientAPI sender, Packet Pack)
{
m_log.DebugFormat("[LLClientView] HandleCompleteAgentMovement");
Action<IClientAPI, bool> handlerCompleteMovementToRegion = OnCompleteMovementToRegion;
if (handlerCompleteMovementToRegion != null)
{

View File

@ -731,7 +731,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
"debug lludp status",
"Return status of LLUDP packet processing.",
HandleStatusCommand);
/* disabled
MainConsole.Instance.Commands.AddCommand(
"Debug",
false,
@ -739,6 +739,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
"debug lludp toggle agentupdate",
"Toggle whether agentupdate packets are processed or simply discarded.",
HandleAgentUpdateCommand);
*/
}
private void HandlePacketCommand(string module, string[] args)
@ -1421,6 +1422,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
return;
}
/*
else if (packet.Type == PacketType.CompleteAgentMovement)
{
// Send ack straight away to let the viewer know that we got it.
@ -1434,6 +1436,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
return;
}
*/
}
// Determine which agent this packet came from
@ -1553,24 +1556,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
LogPacketHeader(true, udpClient.CircuitCode, 0, packet.Type, (ushort)packet.Length);
#endregion BinaryStats
if (packet.Type == PacketType.AgentUpdate)
{
if (m_discardAgentUpdates)
return;
((LLClientView)client).TotalAgentUpdates++;
AgentUpdatePacket agentUpdate = (AgentUpdatePacket)packet;
LLClientView llClient = client as LLClientView;
if (agentUpdate.AgentData.SessionID != client.SessionId
|| agentUpdate.AgentData.AgentID != client.AgentId
|| !(llClient == null || llClient.CheckAgentUpdateSignificance(agentUpdate.AgentData)) )
{
PacketPool.Instance.ReturnPacket(packet);
return;
}
}
// AgentUpdate mess removed from here
#region Ping Check Handling
@ -1611,11 +1597,13 @@ namespace OpenSim.Region.ClientStack.LindenUDP
incomingPacket = new IncomingPacket((LLClientView)client, packet);
}
if (incomingPacket.Packet.Type == PacketType.AgentUpdate ||
incomingPacket.Packet.Type == PacketType.ChatFromViewer)
// if (incomingPacket.Packet.Type == PacketType.AgentUpdate ||
// incomingPacket.Packet.Type == PacketType.ChatFromViewer)
if (incomingPacket.Packet.Type == PacketType.ChatFromViewer)
packetInbox.EnqueueHigh(incomingPacket);
else
packetInbox.EnqueueLow(incomingPacket);
}
#region BinaryStats
@ -1732,7 +1720,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
try
{
// DateTime startTime = DateTime.Now;
// DateTime startTime = DateTime.Now;
object[] array = (object[])o;
endPoint = (IPEndPoint)array[0];
UseCircuitCodePacket uccp = (UseCircuitCodePacket)array[1];
@ -1752,9 +1740,9 @@ namespace OpenSim.Region.ClientStack.LindenUDP
uccp.CircuitCode.SessionID,
endPoint,
sessionInfo);
// Now we know we can handle more data
// Thread.Sleep(200);
Thread.Sleep(200);
// Obtain the pending queue and remove it from the cache
Queue<UDPPacketBuffer> queue = null;
@ -1765,6 +1753,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
{
m_log.DebugFormat("[LLUDPSERVER]: Client created but no pending queue present");
return;
}
m_pendingCache.Remove(endPoint);
}
@ -1772,11 +1761,12 @@ namespace OpenSim.Region.ClientStack.LindenUDP
m_log.DebugFormat("[LLUDPSERVER]: Client created, processing pending queue, {0} entries", queue.Count);
// Reinject queued packets
while(queue.Count > 0)
while (queue.Count > 0)
{
UDPPacketBuffer buf = queue.Dequeue();
PacketReceived(buf);
}
queue = null;
// Send ack straight away to let the viewer know that the connection is active.
@ -1802,8 +1792,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
uccp.CircuitCode.ID, m_scene.RegionInfo.RegionName, uccp.CircuitCode.Code, endPoint);
lock (m_pendingCache)
m_pendingCache.Remove(endPoint);
}
}
// m_log.DebugFormat(
// "[LLUDPSERVER]: Handling UseCircuitCode request from {0} took {1}ms",
// buffer.RemoteEndPoint, (DateTime.Now - startTime).Milliseconds);
@ -1820,8 +1809,8 @@ namespace OpenSim.Region.ClientStack.LindenUDP
e.StackTrace);
}
}
private void HandleCompleteMovementIntoRegion(object o)
/*
private void HandleCompleteMovementIntoRegion(object o)
{
IPEndPoint endPoint = null;
IClientAPI client = null;
@ -1930,6 +1919,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
e.StackTrace);
}
}
*/
/// <summary>
/// Send an ack immediately to the given endpoint.
@ -2067,7 +2057,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
m_incomingPacketPool.ReturnObject(incomingPacket);
}
}
catch (Exception ex)
catch(Exception ex)
{
m_log.Error("[LLUDPSERVER]: Error in the incoming packet handler loop: " + ex.Message, ex);
}