From dbbfaf3ac375a8d8f95327c334183e74b9fa70be Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Tue, 12 Aug 2014 22:17:15 +0100 Subject: force AgentUpdate after CompleteAgentMovement to pass by significance test --- OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) (limited to 'OpenSim') diff --git a/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs b/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs index 8a28faf..89deafd 100644 --- a/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs +++ b/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs @@ -5764,14 +5764,14 @@ namespace OpenSim.Region.ClientStack.LindenUDP //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 - // || (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 > 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.Far != m_thisAgentUpdateArgs.Far) // significant if far distance changed ; //if (movementSignificant) //{ @@ -6751,6 +6751,10 @@ namespace OpenSim.Region.ClientStack.LindenUDP private bool HandleCompleteAgentMovement(IClientAPI sender, Packet Pack) { + + m_thisAgentUpdateArgs.CameraAtAxis.X = float.MinValue; + m_thisAgentUpdateArgs.ControlFlags = uint.MaxValue; + Action handlerCompleteMovementToRegion = OnCompleteMovementToRegion; if (handlerCompleteMovementToRegion != null) { -- cgit v1.1 From b9224a70c488ac53726dcf53e18c718bbb9948d6 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Tue, 12 Aug 2014 22:27:50 +0100 Subject: no need to go from cos into squared sin when just abs of cos is as good --- OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) (limited to 'OpenSim') diff --git a/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs b/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs index 89deafd..0b82ce9 100644 --- a/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs +++ b/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs @@ -5737,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; @@ -5760,17 +5762,17 @@ namespace OpenSim.Region.ClientStack.LindenUDP /// 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 = (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.Flags != m_thisAgentUpdateArgs.Flags) // significant if Flags changed || (x.State != m_thisAgentUpdateArgs.State) // significant if Stats changed - || (qdelta1 > QDELTA) // significant if body rotation above threshold + || (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 > QDELTA * 10) // significant if head rotation above threshold + // || (qdelta2 < QDELTAHead) // significant if head rotation above(below cos) threshold || (x.Far != m_thisAgentUpdateArgs.Far) // significant if far distance changed ; //if (movementSignificant) -- cgit v1.1 From f811efde852e921d6deb82b45b31629bdd04ab11 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Tue, 12 Aug 2014 22:36:17 +0100 Subject: do the significance test invalidation at MoveAgentToRegion --- OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) (limited to 'OpenSim') diff --git a/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs b/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs index 0b82ce9..f5bb70b 100644 --- a/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs +++ b/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs @@ -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; @@ -6753,10 +6756,6 @@ namespace OpenSim.Region.ClientStack.LindenUDP private bool HandleCompleteAgentMovement(IClientAPI sender, Packet Pack) { - - m_thisAgentUpdateArgs.CameraAtAxis.X = float.MinValue; - m_thisAgentUpdateArgs.ControlFlags = uint.MaxValue; - Action handlerCompleteMovementToRegion = OnCompleteMovementToRegion; if (handlerCompleteMovementToRegion != null) { -- cgit v1.1 From 20b3cab5d1cb1bbbe951a90ae6de7ffb495e6375 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Tue, 12 Aug 2014 23:57:41 +0100 Subject: take agentUpdate checks out of llUDPserver (disabling useless debug) and do it only where its supposed to be done.. --- .../Region/ClientStack/Linden/UDP/LLClientView.cs | 56 ++++++++++++---------- .../Region/ClientStack/Linden/UDP/LLUDPServer.cs | 22 ++------- 2 files changed, 35 insertions(+), 43 deletions(-) (limited to 'OpenSim') diff --git a/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs b/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs index f5bb70b..9462bdc 100644 --- a/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs +++ b/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs @@ -5819,55 +5819,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); diff --git a/OpenSim/Region/ClientStack/Linden/UDP/LLUDPServer.cs b/OpenSim/Region/ClientStack/Linden/UDP/LLUDPServer.cs index 0bb53c4..15d0316 100644 --- a/OpenSim/Region/ClientStack/Linden/UDP/LLUDPServer.cs +++ b/OpenSim/Region/ClientStack/Linden/UDP/LLUDPServer.cs @@ -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) @@ -1553,24 +1554,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 -- cgit v1.1 From 0760fa3106955147d9a4dc96e5ef81635275c164 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Wed, 13 Aug 2014 00:17:03 +0100 Subject: process AgentUpdates in order with rest of packets. Only give higher priority to chat --- OpenSim/Region/ClientStack/Linden/UDP/LLUDPServer.cs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'OpenSim') diff --git a/OpenSim/Region/ClientStack/Linden/UDP/LLUDPServer.cs b/OpenSim/Region/ClientStack/Linden/UDP/LLUDPServer.cs index 15d0316..2e9ac4c 100644 --- a/OpenSim/Region/ClientStack/Linden/UDP/LLUDPServer.cs +++ b/OpenSim/Region/ClientStack/Linden/UDP/LLUDPServer.cs @@ -1595,11 +1595,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 -- cgit v1.1 From cf48b814ebbc28761571c1b219376da445f844c9 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Wed, 13 Aug 2014 01:42:16 +0100 Subject: remove HandleCompleteMovementIntoRegion delay hack from llUDPserver. If we need a delay, we need to do it at end of HandleUseCircuitCode before feeding pending packets (including that one) into processing queue. --- .../Region/ClientStack/Linden/UDP/LLClientView.cs | 6 ++++-- .../Region/ClientStack/Linden/UDP/LLUDPServer.cs | 22 +++++++++++++--------- 2 files changed, 17 insertions(+), 11 deletions(-) (limited to 'OpenSim') diff --git a/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs b/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs index 9462bdc..73d7a6c 100644 --- a/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs +++ b/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs @@ -5845,7 +5845,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP m_thisAgentUpdateArgs.Far = x.Far; m_thisAgentUpdateArgs.Flags = x.Flags; m_thisAgentUpdateArgs.HeadRotation = x.HeadRotation; - m_thisAgentUpdateArgs.SessionID = x.SessionID; +// m_thisAgentUpdateArgs.SessionID = x.SessionID; m_thisAgentUpdateArgs.State = x.State; UpdateAgent handlerAgentUpdate = OnAgentUpdate; @@ -6762,8 +6762,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 handlerCompleteMovementToRegion = OnCompleteMovementToRegion; if (handlerCompleteMovementToRegion != null) { diff --git a/OpenSim/Region/ClientStack/Linden/UDP/LLUDPServer.cs b/OpenSim/Region/ClientStack/Linden/UDP/LLUDPServer.cs index 2e9ac4c..fe79f87 100644 --- a/OpenSim/Region/ClientStack/Linden/UDP/LLUDPServer.cs +++ b/OpenSim/Region/ClientStack/Linden/UDP/LLUDPServer.cs @@ -1422,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. @@ -1435,6 +1436,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP return; } + */ } // Determine which agent this packet came from @@ -1718,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]; @@ -1738,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 queue = null; @@ -1751,6 +1753,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP { m_log.DebugFormat("[LLUDPSERVER]: Client created but no pending queue present"); return; + } m_pendingCache.Remove(endPoint); } @@ -1758,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. @@ -1788,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); @@ -1806,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; @@ -1916,6 +1919,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP e.StackTrace); } } +*/ /// /// Send an ack immediately to the given endpoint. @@ -2053,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); } -- cgit v1.1