aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim')
-rw-r--r--OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs81
-rw-r--r--OpenSim/Region/ClientStack/Linden/UDP/LLUDPServer.cs50
2 files changed, 68 insertions, 63 deletions
diff --git a/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs b/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs
index aa742ef..59d1c69 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
856 856
857 public void MoveAgentIntoRegion(RegionInfo regInfo, Vector3 pos, Vector3 look) 857 public void MoveAgentIntoRegion(RegionInfo regInfo, Vector3 pos, Vector3 look)
858 { 858 {
859 m_thisAgentUpdateArgs.CameraAtAxis.X = float.MinValue;
860 m_thisAgentUpdateArgs.ControlFlags = uint.MaxValue;
861
859 AgentMovementCompletePacket mov = (AgentMovementCompletePacket)PacketPool.Instance.GetPacket(PacketType.AgentMovementComplete); 862 AgentMovementCompletePacket mov = (AgentMovementCompletePacket)PacketPool.Instance.GetPacket(PacketType.AgentMovementComplete);
860 mov.SimData.ChannelVersion = m_channelVersion; 863 mov.SimData.ChannelVersion = m_channelVersion;
861 mov.AgentData.SessionID = m_sessionId; 864 mov.AgentData.SessionID = m_sessionId;
@@ -5734,7 +5737,9 @@ namespace OpenSim.Region.ClientStack.LindenUDP
5734 #region Scene/Avatar 5737 #region Scene/Avatar
5735 5738
5736 // Threshold for body rotation to be a significant agent update 5739 // Threshold for body rotation to be a significant agent update
5737 private const float QDELTA = 0.000001f; 5740 // use the abs of cos
5741 private const float QDELTABody = 1.0f - 0.0001f;
5742 private const float QDELTAHead = 1.0f - 0.0001f;
5738 // Threshold for camera rotation to be a significant agent update 5743 // Threshold for camera rotation to be a significant agent update
5739 private const float VDELTA = 0.01f; 5744 private const float VDELTA = 0.01f;
5740 5745
@@ -5757,18 +5762,18 @@ namespace OpenSim.Region.ClientStack.LindenUDP
5757 /// <param name='x'></param> 5762 /// <param name='x'></param>
5758 private bool CheckAgentMovementUpdateSignificance(AgentUpdatePacket.AgentDataBlock x) 5763 private bool CheckAgentMovementUpdateSignificance(AgentUpdatePacket.AgentDataBlock x)
5759 { 5764 {
5760 float qdelta1 = 1 - (float)Math.Pow(Quaternion.Dot(x.BodyRotation, m_thisAgentUpdateArgs.BodyRotation), 2); 5765 float qdelta1 = Math.Abs(Quaternion.Dot(x.BodyRotation, m_thisAgentUpdateArgs.BodyRotation));
5761 //qdelta2 = 1 - (float)Math.Pow(Quaternion.Dot(x.HeadRotation, m_thisAgentUpdateArgs.HeadRotation), 2); 5766 //qdelta2 = Math.Abs(Quaternion.Dot(x.HeadRotation, m_thisAgentUpdateArgs.HeadRotation));
5762 5767
5763 bool movementSignificant = 5768 bool movementSignificant =
5764 (qdelta1 > QDELTA) // significant if body rotation above threshold 5769 (x.ControlFlags != m_thisAgentUpdateArgs.ControlFlags) // significant if control flags changed
5765 // Ignoring head rotation altogether, because it's not being used for anything interesting up the stack
5766 // || (qdelta2 > QDELTA * 10) // significant if head rotation above threshold
5767 || (x.ControlFlags != m_thisAgentUpdateArgs.ControlFlags) // significant if control flags changed
5768 || (x.ControlFlags != (byte)AgentManager.ControlFlags.NONE) // significant if user supplying any movement update commands 5770 || (x.ControlFlags != (byte)AgentManager.ControlFlags.NONE) // significant if user supplying any movement update commands
5769 || (x.Far != m_thisAgentUpdateArgs.Far) // significant if far distance changed
5770 || (x.Flags != m_thisAgentUpdateArgs.Flags) // significant if Flags changed 5771 || (x.Flags != m_thisAgentUpdateArgs.Flags) // significant if Flags changed
5771 || (x.State != m_thisAgentUpdateArgs.State) // significant if Stats changed 5772 || (x.State != m_thisAgentUpdateArgs.State) // significant if Stats changed
5773 || (qdelta1 < QDELTABody) // significant if body rotation above(below cos) threshold
5774 // Ignoring head rotation altogether, because it's not being used for anything interesting up the stack
5775 // || (qdelta2 < QDELTAHead) // significant if head rotation above(below cos) threshold
5776 || (x.Far != m_thisAgentUpdateArgs.Far) // significant if far distance changed
5772 ; 5777 ;
5773 //if (movementSignificant) 5778 //if (movementSignificant)
5774 //{ 5779 //{
@@ -5811,55 +5816,63 @@ namespace OpenSim.Region.ClientStack.LindenUDP
5811 return cameraSignificant; 5816 return cameraSignificant;
5812 } 5817 }
5813 5818
5814 private bool HandleAgentUpdate(IClientAPI sener, Packet packet) 5819 private bool HandleAgentUpdate(IClientAPI sender, Packet packet)
5815 { 5820 {
5816 // We got here, which means that something in agent update was significant 5821 // We got here, which means that something in agent update was significant
5817 5822
5818 AgentUpdatePacket agentUpdate = (AgentUpdatePacket)packet; 5823 AgentUpdatePacket agentUpdate = (AgentUpdatePacket)packet;
5819 AgentUpdatePacket.AgentDataBlock x = agentUpdate.AgentData; 5824 AgentUpdatePacket.AgentDataBlock x = agentUpdate.AgentData;
5820 5825
5821 if (x.AgentID != AgentId || x.SessionID != SessionId) 5826 if (x.AgentID != AgentId || x.SessionID != SessionId)
5827 {
5828 PacketPool.Instance.ReturnPacket(packet);
5822 return false; 5829 return false;
5830 }
5831
5832 TotalAgentUpdates++;
5823 5833
5824 // Before we update the current m_thisAgentUpdateArgs, let's check this again
5825 // to see what exactly changed
5826 bool movement = CheckAgentMovementUpdateSignificance(x); 5834 bool movement = CheckAgentMovementUpdateSignificance(x);
5827 bool camera = CheckAgentCameraUpdateSignificance(x); 5835 bool camera = CheckAgentCameraUpdateSignificance(x);
5828 5836
5829 m_thisAgentUpdateArgs.AgentID = x.AgentID;
5830 m_thisAgentUpdateArgs.BodyRotation = x.BodyRotation;
5831 m_thisAgentUpdateArgs.CameraAtAxis = x.CameraAtAxis;
5832 m_thisAgentUpdateArgs.CameraCenter = x.CameraCenter;
5833 m_thisAgentUpdateArgs.CameraLeftAxis = x.CameraLeftAxis;
5834 m_thisAgentUpdateArgs.CameraUpAxis = x.CameraUpAxis;
5835 m_thisAgentUpdateArgs.ControlFlags = x.ControlFlags;
5836 m_thisAgentUpdateArgs.Far = x.Far;
5837 m_thisAgentUpdateArgs.Flags = x.Flags;
5838 m_thisAgentUpdateArgs.HeadRotation = x.HeadRotation;
5839 m_thisAgentUpdateArgs.SessionID = x.SessionID;
5840 m_thisAgentUpdateArgs.State = x.State;
5841
5842 UpdateAgent handlerAgentUpdate = OnAgentUpdate;
5843 UpdateAgent handlerPreAgentUpdate = OnPreAgentUpdate;
5844 UpdateAgent handlerAgentCameraUpdate = OnAgentCameraUpdate;
5845
5846 // Was there a significant movement/state change? 5837 // Was there a significant movement/state change?
5847 if (movement) 5838 if (movement)
5848 { 5839 {
5840 m_thisAgentUpdateArgs.BodyRotation = x.BodyRotation;
5841 m_thisAgentUpdateArgs.ControlFlags = x.ControlFlags;
5842 m_thisAgentUpdateArgs.Far = x.Far;
5843 m_thisAgentUpdateArgs.Flags = x.Flags;
5844 m_thisAgentUpdateArgs.HeadRotation = x.HeadRotation;
5845// m_thisAgentUpdateArgs.SessionID = x.SessionID;
5846 m_thisAgentUpdateArgs.State = x.State;
5847
5848 UpdateAgent handlerAgentUpdate = OnAgentUpdate;
5849 UpdateAgent handlerPreAgentUpdate = OnPreAgentUpdate;
5850
5849 if (handlerPreAgentUpdate != null) 5851 if (handlerPreAgentUpdate != null)
5850 OnPreAgentUpdate(this, m_thisAgentUpdateArgs); 5852 OnPreAgentUpdate(this, m_thisAgentUpdateArgs);
5851 5853
5852 if (handlerAgentUpdate != null) 5854 if (handlerAgentUpdate != null)
5853 OnAgentUpdate(this, m_thisAgentUpdateArgs); 5855 OnAgentUpdate(this, m_thisAgentUpdateArgs);
5856
5857 handlerAgentUpdate = null;
5858 handlerPreAgentUpdate = null;
5854 } 5859 }
5860
5855 // Was there a significant camera(s) change? 5861 // Was there a significant camera(s) change?
5856 if (camera) 5862 if (camera)
5863 {
5864 m_thisAgentUpdateArgs.CameraAtAxis = x.CameraAtAxis;
5865 m_thisAgentUpdateArgs.CameraCenter = x.CameraCenter;
5866 m_thisAgentUpdateArgs.CameraLeftAxis = x.CameraLeftAxis;
5867 m_thisAgentUpdateArgs.CameraUpAxis = x.CameraUpAxis;
5868
5869 UpdateAgent handlerAgentCameraUpdate = OnAgentCameraUpdate;
5870
5857 if (handlerAgentCameraUpdate != null) 5871 if (handlerAgentCameraUpdate != null)
5858 handlerAgentCameraUpdate(this, m_thisAgentUpdateArgs); 5872 handlerAgentCameraUpdate(this, m_thisAgentUpdateArgs);
5859 5873
5860 handlerAgentUpdate = null; 5874 handlerAgentCameraUpdate = null;
5861 handlerPreAgentUpdate = null; 5875 }
5862 handlerAgentCameraUpdate = null;
5863 5876
5864 PacketPool.Instance.ReturnPacket(packet); 5877 PacketPool.Instance.ReturnPacket(packet);
5865 5878
@@ -6745,8 +6758,10 @@ namespace OpenSim.Region.ClientStack.LindenUDP
6745 return true; 6758 return true;
6746 } 6759 }
6747 6760
6748 private bool HandleCompleteAgentMovement(IClientAPI sender, Packet Pack) 6761 private bool HandleCompleteAgentMovement(IClientAPI sender, Packet Pack)
6749 { 6762 {
6763 m_log.DebugFormat("[LLClientView] HandleCompleteAgentMovement");
6764
6750 Action<IClientAPI, bool> handlerCompleteMovementToRegion = OnCompleteMovementToRegion; 6765 Action<IClientAPI, bool> handlerCompleteMovementToRegion = OnCompleteMovementToRegion;
6751 if (handlerCompleteMovementToRegion != null) 6766 if (handlerCompleteMovementToRegion != null)
6752 { 6767 {
diff --git a/OpenSim/Region/ClientStack/Linden/UDP/LLUDPServer.cs b/OpenSim/Region/ClientStack/Linden/UDP/LLUDPServer.cs
index 0bb53c4..fe79f87 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
731 "debug lludp status", 731 "debug lludp status",
732 "Return status of LLUDP packet processing.", 732 "Return status of LLUDP packet processing.",
733 HandleStatusCommand); 733 HandleStatusCommand);
734 734/* disabled
735 MainConsole.Instance.Commands.AddCommand( 735 MainConsole.Instance.Commands.AddCommand(
736 "Debug", 736 "Debug",
737 false, 737 false,
@@ -739,6 +739,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
739 "debug lludp toggle agentupdate", 739 "debug lludp toggle agentupdate",
740 "Toggle whether agentupdate packets are processed or simply discarded.", 740 "Toggle whether agentupdate packets are processed or simply discarded.",
741 HandleAgentUpdateCommand); 741 HandleAgentUpdateCommand);
742 */
742 } 743 }
743 744
744 private void HandlePacketCommand(string module, string[] args) 745 private void HandlePacketCommand(string module, string[] args)
@@ -1421,6 +1422,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
1421 return; 1422 return;
1422 } 1423 }
1423 1424
1425/*
1424 else if (packet.Type == PacketType.CompleteAgentMovement) 1426 else if (packet.Type == PacketType.CompleteAgentMovement)
1425 { 1427 {
1426 // Send ack straight away to let the viewer know that we got it. 1428 // Send ack straight away to let the viewer know that we got it.
@@ -1434,6 +1436,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
1434 1436
1435 return; 1437 return;
1436 } 1438 }
1439 */
1437 } 1440 }
1438 1441
1439 // Determine which agent this packet came from 1442 // Determine which agent this packet came from
@@ -1553,24 +1556,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
1553 LogPacketHeader(true, udpClient.CircuitCode, 0, packet.Type, (ushort)packet.Length); 1556 LogPacketHeader(true, udpClient.CircuitCode, 0, packet.Type, (ushort)packet.Length);
1554 #endregion BinaryStats 1557 #endregion BinaryStats
1555 1558
1556 if (packet.Type == PacketType.AgentUpdate) 1559// AgentUpdate mess removed from here
1557 {
1558 if (m_discardAgentUpdates)
1559 return;
1560
1561 ((LLClientView)client).TotalAgentUpdates++;
1562
1563 AgentUpdatePacket agentUpdate = (AgentUpdatePacket)packet;
1564
1565 LLClientView llClient = client as LLClientView;
1566 if (agentUpdate.AgentData.SessionID != client.SessionId
1567 || agentUpdate.AgentData.AgentID != client.AgentId
1568 || !(llClient == null || llClient.CheckAgentUpdateSignificance(agentUpdate.AgentData)) )
1569 {
1570 PacketPool.Instance.ReturnPacket(packet);
1571 return;
1572 }
1573 }
1574 1560
1575 #region Ping Check Handling 1561 #region Ping Check Handling
1576 1562
@@ -1611,11 +1597,13 @@ namespace OpenSim.Region.ClientStack.LindenUDP
1611 incomingPacket = new IncomingPacket((LLClientView)client, packet); 1597 incomingPacket = new IncomingPacket((LLClientView)client, packet);
1612 } 1598 }
1613 1599
1614 if (incomingPacket.Packet.Type == PacketType.AgentUpdate || 1600// if (incomingPacket.Packet.Type == PacketType.AgentUpdate ||
1615 incomingPacket.Packet.Type == PacketType.ChatFromViewer) 1601// incomingPacket.Packet.Type == PacketType.ChatFromViewer)
1602 if (incomingPacket.Packet.Type == PacketType.ChatFromViewer)
1616 packetInbox.EnqueueHigh(incomingPacket); 1603 packetInbox.EnqueueHigh(incomingPacket);
1617 else 1604 else
1618 packetInbox.EnqueueLow(incomingPacket); 1605 packetInbox.EnqueueLow(incomingPacket);
1606
1619 } 1607 }
1620 1608
1621 #region BinaryStats 1609 #region BinaryStats
@@ -1732,7 +1720,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
1732 1720
1733 try 1721 try
1734 { 1722 {
1735 // DateTime startTime = DateTime.Now; 1723// DateTime startTime = DateTime.Now;
1736 object[] array = (object[])o; 1724 object[] array = (object[])o;
1737 endPoint = (IPEndPoint)array[0]; 1725 endPoint = (IPEndPoint)array[0];
1738 UseCircuitCodePacket uccp = (UseCircuitCodePacket)array[1]; 1726 UseCircuitCodePacket uccp = (UseCircuitCodePacket)array[1];
@@ -1752,9 +1740,9 @@ namespace OpenSim.Region.ClientStack.LindenUDP
1752 uccp.CircuitCode.SessionID, 1740 uccp.CircuitCode.SessionID,
1753 endPoint, 1741 endPoint,
1754 sessionInfo); 1742 sessionInfo);
1755 1743
1756 // Now we know we can handle more data 1744 // Now we know we can handle more data
1757// Thread.Sleep(200); 1745 Thread.Sleep(200);
1758 1746
1759 // Obtain the pending queue and remove it from the cache 1747 // Obtain the pending queue and remove it from the cache
1760 Queue<UDPPacketBuffer> queue = null; 1748 Queue<UDPPacketBuffer> queue = null;
@@ -1765,6 +1753,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
1765 { 1753 {
1766 m_log.DebugFormat("[LLUDPSERVER]: Client created but no pending queue present"); 1754 m_log.DebugFormat("[LLUDPSERVER]: Client created but no pending queue present");
1767 return; 1755 return;
1756
1768 } 1757 }
1769 m_pendingCache.Remove(endPoint); 1758 m_pendingCache.Remove(endPoint);
1770 } 1759 }
@@ -1772,11 +1761,12 @@ namespace OpenSim.Region.ClientStack.LindenUDP
1772 m_log.DebugFormat("[LLUDPSERVER]: Client created, processing pending queue, {0} entries", queue.Count); 1761 m_log.DebugFormat("[LLUDPSERVER]: Client created, processing pending queue, {0} entries", queue.Count);
1773 1762
1774 // Reinject queued packets 1763 // Reinject queued packets
1775 while(queue.Count > 0) 1764 while (queue.Count > 0)
1776 { 1765 {
1777 UDPPacketBuffer buf = queue.Dequeue(); 1766 UDPPacketBuffer buf = queue.Dequeue();
1778 PacketReceived(buf); 1767 PacketReceived(buf);
1779 } 1768 }
1769
1780 queue = null; 1770 queue = null;
1781 1771
1782 // Send ack straight away to let the viewer know that the connection is active. 1772 // Send ack straight away to let the viewer know that the connection is active.
@@ -1802,8 +1792,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
1802 uccp.CircuitCode.ID, m_scene.RegionInfo.RegionName, uccp.CircuitCode.Code, endPoint); 1792 uccp.CircuitCode.ID, m_scene.RegionInfo.RegionName, uccp.CircuitCode.Code, endPoint);
1803 lock (m_pendingCache) 1793 lock (m_pendingCache)
1804 m_pendingCache.Remove(endPoint); 1794 m_pendingCache.Remove(endPoint);
1805 } 1795 }
1806
1807 // m_log.DebugFormat( 1796 // m_log.DebugFormat(
1808 // "[LLUDPSERVER]: Handling UseCircuitCode request from {0} took {1}ms", 1797 // "[LLUDPSERVER]: Handling UseCircuitCode request from {0} took {1}ms",
1809 // buffer.RemoteEndPoint, (DateTime.Now - startTime).Milliseconds); 1798 // buffer.RemoteEndPoint, (DateTime.Now - startTime).Milliseconds);
@@ -1820,8 +1809,8 @@ namespace OpenSim.Region.ClientStack.LindenUDP
1820 e.StackTrace); 1809 e.StackTrace);
1821 } 1810 }
1822 } 1811 }
1823 1812/*
1824 private void HandleCompleteMovementIntoRegion(object o) 1813 private void HandleCompleteMovementIntoRegion(object o)
1825 { 1814 {
1826 IPEndPoint endPoint = null; 1815 IPEndPoint endPoint = null;
1827 IClientAPI client = null; 1816 IClientAPI client = null;
@@ -1930,6 +1919,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
1930 e.StackTrace); 1919 e.StackTrace);
1931 } 1920 }
1932 } 1921 }
1922*/
1933 1923
1934 /// <summary> 1924 /// <summary>
1935 /// Send an ack immediately to the given endpoint. 1925 /// Send an ack immediately to the given endpoint.
@@ -2067,7 +2057,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
2067 m_incomingPacketPool.ReturnObject(incomingPacket); 2057 m_incomingPacketPool.ReturnObject(incomingPacket);
2068 } 2058 }
2069 } 2059 }
2070 catch (Exception ex) 2060 catch(Exception ex)
2071 { 2061 {
2072 m_log.Error("[LLUDPSERVER]: Error in the incoming packet handler loop: " + ex.Message, ex); 2062 m_log.Error("[LLUDPSERVER]: Error in the incoming packet handler loop: " + ex.Message, ex);
2073 } 2063 }