From caddabb5c4f62767305a589e9d818ae3457a8030 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Thu, 6 Nov 2014 22:25:16 +0000 Subject: scale ChildAgentThrottles with distance (internal to child server and not root as was done before ) --- OpenSim/Framework/IClientAPI.cs | 1 + .../Region/ClientStack/Linden/UDP/LLClientView.cs | 7 ++++++- OpenSim/Region/ClientStack/Linden/UDP/LLUDPClient.cs | 20 +++++++++++++------- OpenSim/Region/Framework/Scenes/ScenePresence.cs | 19 ++++++++++++++++++- .../InternetRelayClientView/Server/IRCClientView.cs | 5 +++++ .../Region/OptionalModules/World/NPC/NPCAvatar.cs | 5 +++++ OpenSim/Tests/Common/Mock/TestClient.cs | 4 ++++ 7 files changed, 52 insertions(+), 9 deletions(-) (limited to 'OpenSim') diff --git a/OpenSim/Framework/IClientAPI.cs b/OpenSim/Framework/IClientAPI.cs index c386c95..4bb865a 100644 --- a/OpenSim/Framework/IClientAPI.cs +++ b/OpenSim/Framework/IClientAPI.cs @@ -1184,6 +1184,7 @@ namespace OpenSim.Framework void SendCoarseLocationUpdate(List users, List CoarseLocations); void SetChildAgentThrottle(byte[] throttle); + void SetChildAgentThrottle(byte[] throttle,float factor); void SetAgentThrottleSilent(int throttle, int setting); int GetAgentThrottleSilent(int throttle); diff --git a/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs b/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs index b9646c7..f2f7cf9 100644 --- a/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs +++ b/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs @@ -12344,7 +12344,12 @@ namespace OpenSim.Region.ClientStack.LindenUDP /// public void SetChildAgentThrottle(byte[] throttles) { - m_udpClient.SetThrottles(throttles); + SetChildAgentThrottle(throttles, 1.0f); + } + + public void SetChildAgentThrottle(byte[] throttles,float factor) + { + m_udpClient.SetThrottles(throttles, factor); GenericCall2 handler = OnUpdateThrottles; if (handler != null) { diff --git a/OpenSim/Region/ClientStack/Linden/UDP/LLUDPClient.cs b/OpenSim/Region/ClientStack/Linden/UDP/LLUDPClient.cs index 33375ff..0ae7617 100644 --- a/OpenSim/Region/ClientStack/Linden/UDP/LLUDPClient.cs +++ b/OpenSim/Region/ClientStack/Linden/UDP/LLUDPClient.cs @@ -340,6 +340,11 @@ namespace OpenSim.Region.ClientStack.LindenUDP public void SetThrottles(byte[] throttleData) { + SetThrottles(throttleData, 1.0f); + } + + public void SetThrottles(byte[] throttleData, float factor) + { byte[] adjData; int pos = 0; @@ -359,13 +364,14 @@ namespace OpenSim.Region.ClientStack.LindenUDP } // 0.125f converts from bits to bytes - int resend = (int)(BitConverter.ToSingle(adjData, pos) * 0.125f); pos += 4; - int land = (int)(BitConverter.ToSingle(adjData, pos) * 0.125f); pos += 4; - int wind = (int)(BitConverter.ToSingle(adjData, pos) * 0.125f); pos += 4; - int cloud = (int)(BitConverter.ToSingle(adjData, pos) * 0.125f); pos += 4; - int task = (int)(BitConverter.ToSingle(adjData, pos) * 0.125f); pos += 4; - int texture = (int)(BitConverter.ToSingle(adjData, pos) * 0.125f); pos += 4; - int asset = (int)(BitConverter.ToSingle(adjData, pos) * 0.125f); + float scale = 0.125f * factor; + int resend = (int)(BitConverter.ToSingle(adjData, pos) * scale); pos += 4; + int land = (int)(BitConverter.ToSingle(adjData, pos) * scale); pos += 4; + int wind = (int)(BitConverter.ToSingle(adjData, pos) * scale); pos += 4; + int cloud = (int)(BitConverter.ToSingle(adjData, pos) * scale); pos += 4; + int task = (int)(BitConverter.ToSingle(adjData, pos) * scale); pos += 4; + int texture = (int)(BitConverter.ToSingle(adjData, pos) * scale); pos += 4; + int asset = (int)(BitConverter.ToSingle(adjData, pos) * scale); // Make sure none of the throttles are set below our packet MTU, // otherwise a throttle could become permanently clogged diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index 6a9e0ca..3b64088 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -4104,7 +4104,24 @@ namespace OpenSim.Region.Framework.Scenes CameraPosition = cAgentData.Center + offset; if ((cAgentData.Throttles != null) && cAgentData.Throttles.Length > 0) - ControllingClient.SetChildAgentThrottle(cAgentData.Throttles); + { + // some scaling factor + float x = m_pos.X; + if (x > m_scene.RegionInfo.RegionSizeX) + x -= m_scene.RegionInfo.RegionSizeX; + float y = m_pos.Y; + if (y > m_scene.RegionInfo.RegionSizeY) + y -= m_scene.RegionInfo.RegionSizeY; + + x = x * x + y * y; + + const float distScale = 0.4f / Constants.RegionSize / Constants.RegionSize; + float factor = 1.0f - distScale * x; + if (factor < 0.2f) + factor = 0.2f; + + ControllingClient.SetChildAgentThrottle(cAgentData.Throttles,factor); + } if(cAgentData.ChildrenCapSeeds != null && cAgentData.ChildrenCapSeeds.Count >0) { diff --git a/OpenSim/Region/OptionalModules/Agent/InternetRelayClientView/Server/IRCClientView.cs b/OpenSim/Region/OptionalModules/Agent/InternetRelayClientView/Server/IRCClientView.cs index a45bea9..ed1503c 100644 --- a/OpenSim/Region/OptionalModules/Agent/InternetRelayClientView/Server/IRCClientView.cs +++ b/OpenSim/Region/OptionalModules/Agent/InternetRelayClientView/Server/IRCClientView.cs @@ -1433,6 +1433,11 @@ namespace OpenSim.Region.OptionalModules.Agent.InternetRelayClientView.Server } + public virtual void SetChildAgentThrottle(byte[] throttle,float factor) + { + + } + public void SetAgentThrottleSilent(int throttle, int setting) { diff --git a/OpenSim/Region/OptionalModules/World/NPC/NPCAvatar.cs b/OpenSim/Region/OptionalModules/World/NPC/NPCAvatar.cs index cb87536..0b33c51 100644 --- a/OpenSim/Region/OptionalModules/World/NPC/NPCAvatar.cs +++ b/OpenSim/Region/OptionalModules/World/NPC/NPCAvatar.cs @@ -621,6 +621,11 @@ namespace OpenSim.Region.OptionalModules.World.NPC { } + public virtual void SetChildAgentThrottle(byte[] throttle, float factor) + { + + } + public void SetAgentThrottleSilent(int throttle, int setting) { diff --git a/OpenSim/Tests/Common/Mock/TestClient.cs b/OpenSim/Tests/Common/Mock/TestClient.cs index 00929df..d4f29c8 100644 --- a/OpenSim/Tests/Common/Mock/TestClient.cs +++ b/OpenSim/Tests/Common/Mock/TestClient.cs @@ -544,6 +544,10 @@ namespace OpenSim.Tests.Common.Mock { } + public virtual void SetChildAgentThrottle(byte[] throttle, float factor) + { + } + public void SetAgentThrottleSilent(int throttle, int setting) { } -- cgit v1.1