diff options
author | UbitUmarov | 2014-10-19 15:51:12 +0100 |
---|---|---|
committer | UbitUmarov | 2014-10-19 15:51:12 +0100 |
commit | f44c29effbd0d14427f288470aee028e9e09d6e3 (patch) | |
tree | e36ceb596388272eace994827f210ff56749d554 /OpenSim/Region/CoreModules/Framework/EntityTransfer | |
parent | change position in new region estimation. Reduce border jitter margin (diff) | |
download | opensim-SC-f44c29effbd0d14427f288470aee028e9e09d6e3.zip opensim-SC-f44c29effbd0d14427f288470aee028e9e09d6e3.tar.gz opensim-SC-f44c29effbd0d14427f288470aee028e9e09d6e3.tar.bz2 opensim-SC-f44c29effbd0d14427f288470aee028e9e09d6e3.tar.xz |
try to fix propagation of seeds to all relevante regions
Diffstat (limited to 'OpenSim/Region/CoreModules/Framework/EntityTransfer')
-rw-r--r-- | OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs | 104 |
1 files changed, 82 insertions, 22 deletions
diff --git a/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs b/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs index ae571c0..87a0ff6 100644 --- a/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs +++ b/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs | |||
@@ -1838,33 +1838,43 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer | |||
1838 | { | 1838 | { |
1839 | m_log.DebugFormat("[ENTITY TRANSFER]: Enabling child agent in new neighbour {0}", region.RegionName); | 1839 | m_log.DebugFormat("[ENTITY TRANSFER]: Enabling child agent in new neighbour {0}", region.RegionName); |
1840 | 1840 | ||
1841 | ulong currentRegionHandler = sp.Scene.RegionInfo.RegionHandle; | ||
1842 | ulong regionhandler = region.RegionHandle; | ||
1843 | |||
1844 | Dictionary<ulong, string> seeds = new Dictionary<ulong, string>(sp.Scene.CapsModule.GetChildrenSeeds(sp.UUID)); | ||
1845 | |||
1846 | if (seeds.ContainsKey(regionhandler)) | ||
1847 | seeds.Remove(regionhandler); | ||
1848 | |||
1849 | List<ulong> oldregions = new List<ulong>(seeds.Keys); | ||
1850 | |||
1851 | if (oldregions.Contains(currentRegionHandler)) | ||
1852 | oldregions.Remove(currentRegionHandler); | ||
1853 | |||
1854 | if (!seeds.ContainsKey(currentRegionHandler)) | ||
1855 | seeds.Add(currentRegionHandler, sp.ControllingClient.RequestClientInfo().CapsPath); | ||
1856 | |||
1841 | AgentCircuitData currentAgentCircuit = sp.Scene.AuthenticateHandler.GetAgentCircuitData(sp.ControllingClient.CircuitCode); | 1857 | AgentCircuitData currentAgentCircuit = sp.Scene.AuthenticateHandler.GetAgentCircuitData(sp.ControllingClient.CircuitCode); |
1842 | AgentCircuitData agent = sp.ControllingClient.RequestClientInfo(); | 1858 | AgentCircuitData agent = sp.ControllingClient.RequestClientInfo(); |
1843 | agent.BaseFolder = UUID.Zero; | 1859 | agent.BaseFolder = UUID.Zero; |
1844 | agent.InventoryFolder = UUID.Zero; | 1860 | agent.InventoryFolder = UUID.Zero; |
1845 | agent.startpos = sp.AbsolutePosition + CalculateOffset(sp, region); | 1861 | agent.startpos = sp.AbsolutePosition + CalculateOffset(sp, region); |
1846 | agent.child = true; | 1862 | agent.child = true; |
1847 | |||
1848 | agent.Appearance = new AvatarAppearance(); | 1863 | agent.Appearance = new AvatarAppearance(); |
1849 | agent.Appearance.AvatarHeight = sp.Appearance.AvatarHeight; | 1864 | agent.Appearance.AvatarHeight = sp.Appearance.AvatarHeight; |
1850 | 1865 | ||
1851 | agent.CapsPath = CapsUtil.GetRandomCapsObjectPath(); | 1866 | agent.CapsPath = CapsUtil.GetRandomCapsObjectPath(); |
1867 | seeds.Add(regionhandler, agent.CapsPath); | ||
1852 | 1868 | ||
1853 | agent.ChildrenCapSeeds = new Dictionary<ulong, string>(sp.Scene.CapsModule.GetChildrenSeeds(sp.UUID)); | 1869 | agent.ChildrenCapSeeds = new Dictionary<ulong, string>(seeds); |
1854 | //m_log.DebugFormat("[XXX] Seeds 1 {0}", agent.ChildrenCapSeeds.Count); | 1870 | |
1855 | |||
1856 | if (!agent.ChildrenCapSeeds.ContainsKey(sp.Scene.RegionInfo.RegionHandle)) | ||
1857 | agent.ChildrenCapSeeds.Add(sp.Scene.RegionInfo.RegionHandle, sp.ControllingClient.RequestClientInfo().CapsPath); | ||
1858 | //m_log.DebugFormat("[XXX] Seeds 2 {0}", agent.ChildrenCapSeeds.Count); | ||
1859 | |||
1860 | sp.AddNeighbourRegion(region.RegionHandle, agent.CapsPath); | ||
1861 | agent.ChildrenCapSeeds.Add(region.RegionHandle, agent.CapsPath); | ||
1862 | |||
1863 | if (sp.Scene.CapsModule != null) | 1871 | if (sp.Scene.CapsModule != null) |
1864 | { | 1872 | { |
1865 | sp.Scene.CapsModule.SetChildrenSeed(sp.UUID, agent.ChildrenCapSeeds); | 1873 | sp.Scene.CapsModule.SetChildrenSeed(sp.UUID, seeds); |
1866 | } | 1874 | } |
1867 | 1875 | ||
1876 | sp.KnownRegions = seeds; | ||
1877 | |||
1868 | if (currentAgentCircuit != null) | 1878 | if (currentAgentCircuit != null) |
1869 | { | 1879 | { |
1870 | agent.ServiceURLs = currentAgentCircuit.ServiceURLs; | 1880 | agent.ServiceURLs = currentAgentCircuit.ServiceURLs; |
@@ -1875,7 +1885,22 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer | |||
1875 | agent.Id0 = currentAgentCircuit.Id0; | 1885 | agent.Id0 = currentAgentCircuit.Id0; |
1876 | } | 1886 | } |
1877 | 1887 | ||
1878 | Thread.Sleep(200); // the original delay that was at InformClientOfNeighbourAsync start | 1888 | AgentPosition agentpos = null; |
1889 | |||
1890 | if (oldregions.Count > 0) | ||
1891 | { | ||
1892 | agentpos = new AgentPosition(); | ||
1893 | agentpos.AgentID = new UUID(sp.UUID.Guid); | ||
1894 | agentpos.SessionID = sp.ControllingClient.SessionId; | ||
1895 | agentpos.Size = sp.Appearance.AvatarSize; | ||
1896 | agentpos.Center = sp.CameraPosition; | ||
1897 | agentpos.Far = sp.DrawDistance; | ||
1898 | agentpos.Position = sp.AbsolutePosition; | ||
1899 | agentpos.Velocity = sp.Velocity; | ||
1900 | agentpos.RegionHandle = currentRegionHandler; | ||
1901 | agentpos.Throttles = sp.ControllingClient.GetThrottlesPacked(1); | ||
1902 | agentpos.ChildrenCapSeeds = seeds; | ||
1903 | } | ||
1879 | 1904 | ||
1880 | IPEndPoint external = region.ExternalEndPoint; | 1905 | IPEndPoint external = region.ExternalEndPoint; |
1881 | if (external != null) | 1906 | if (external != null) |
@@ -1885,7 +1910,22 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer | |||
1885 | InformClientOfNeighbourCompleted, | 1910 | InformClientOfNeighbourCompleted, |
1886 | d); | 1911 | d); |
1887 | } | 1912 | } |
1913 | |||
1914 | if(oldregions.Count >0) | ||
1915 | { | ||
1916 | uint neighbourx; | ||
1917 | uint neighboury; | ||
1918 | UUID scope = sp.Scene.RegionInfo.ScopeID; | ||
1919 | foreach (ulong handler in oldregions) | ||
1920 | { | ||
1921 | // crap code | ||
1922 | Utils.LongToUInts(handler, out neighbourx, out neighboury); | ||
1923 | GridRegion neighbour = sp.Scene.GridService.GetRegionByPosition(scope, (int)neighbourx, (int)neighboury); | ||
1924 | sp.Scene.SimulationService.UpdateAgent(neighbour, agentpos); | ||
1925 | } | ||
1926 | } | ||
1888 | } | 1927 | } |
1928 | |||
1889 | #endregion | 1929 | #endregion |
1890 | 1930 | ||
1891 | #region Enable Child Agents | 1931 | #region Enable Child Agents |
@@ -1935,7 +1975,7 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer | |||
1935 | AgentCircuitData currentAgentCircuit = sp.Scene.AuthenticateHandler.GetAgentCircuitData(sp.ControllingClient.CircuitCode); | 1975 | AgentCircuitData currentAgentCircuit = sp.Scene.AuthenticateHandler.GetAgentCircuitData(sp.ControllingClient.CircuitCode); |
1936 | 1976 | ||
1937 | List<AgentCircuitData> cagents = new List<AgentCircuitData>(); | 1977 | List<AgentCircuitData> cagents = new List<AgentCircuitData>(); |
1938 | List<GridRegion> newneighbours = new List<GridRegion>(); | 1978 | List<ulong> newneighbours = new List<ulong>(); |
1939 | 1979 | ||
1940 | ulong currentRegionHandler = sp.Scene.RegionInfo.RegionHandle; | 1980 | ulong currentRegionHandler = sp.Scene.RegionInfo.RegionHandle; |
1941 | 1981 | ||
@@ -1972,7 +2012,7 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer | |||
1972 | agent.Id0 = currentAgentCircuit.Id0; | 2012 | agent.Id0 = currentAgentCircuit.Id0; |
1973 | } | 2013 | } |
1974 | 2014 | ||
1975 | newneighbours.Add(neighbour); | 2015 | newneighbours.Add(handler); |
1976 | agent.CapsPath = CapsUtil.GetRandomCapsObjectPath(); | 2016 | agent.CapsPath = CapsUtil.GetRandomCapsObjectPath(); |
1977 | seeds.Add(handler, agent.CapsPath); | 2017 | seeds.Add(handler, agent.CapsPath); |
1978 | cagents.Add(agent); | 2018 | cagents.Add(agent); |
@@ -1993,21 +2033,41 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer | |||
1993 | sp.Scene.CapsModule.SetChildrenSeed(sp.UUID, seeds); | 2033 | sp.Scene.CapsModule.SetChildrenSeed(sp.UUID, seeds); |
1994 | 2034 | ||
1995 | sp.KnownRegions = seeds; | 2035 | sp.KnownRegions = seeds; |
1996 | 2036 | ||
1997 | if (newneighbours.Count > 0) | 2037 | AgentPosition agentpos = new AgentPosition(); |
2038 | agentpos.AgentID = new UUID(sp.UUID.Guid); | ||
2039 | agentpos.SessionID = sp.ControllingClient.SessionId; | ||
2040 | agentpos.Size = sp.Appearance.AvatarSize; | ||
2041 | agentpos.Center = sp.CameraPosition; | ||
2042 | agentpos.Far = sp.DrawDistance; | ||
2043 | agentpos.Position = sp.AbsolutePosition; | ||
2044 | agentpos.Velocity = sp.Velocity; | ||
2045 | agentpos.RegionHandle = currentRegionHandler; | ||
2046 | agentpos.Throttles = sp.ControllingClient.GetThrottlesPacked(1); | ||
2047 | agentpos.ChildrenCapSeeds = seeds; | ||
2048 | |||
2049 | if (neighbours.Count - previousRegionNeighbourHandles.Count > 0) | ||
1998 | { | 2050 | { |
1999 | Util.FireAndForget(delegate | 2051 | Util.FireAndForget(delegate |
2000 | { | 2052 | { |
2001 | Thread.Sleep(200); // the original delay that was at InformClientOfNeighbourAsync start | 2053 | Thread.Sleep(200); // the original delay that was at InformClientOfNeighbourAsync start |
2002 | int count = 0; | 2054 | int count = 0; |
2003 | 2055 | ||
2004 | foreach (GridRegion neighbour in newneighbours) | 2056 | foreach (GridRegion neighbour in neighbours) |
2005 | { | 2057 | { |
2058 | ulong handler = neighbour.RegionHandle; | ||
2006 | try | 2059 | try |
2007 | { | 2060 | { |
2008 | InformClientOfNeighbourAsync(sp, cagents[count], neighbour, | 2061 | if (newneighbours.Contains(handler)) |
2009 | neighbour.ExternalEndPoint, true); | 2062 | { |
2010 | count++; | 2063 | InformClientOfNeighbourAsync(sp, cagents[count], neighbour, |
2064 | neighbour.ExternalEndPoint, true); | ||
2065 | count++; | ||
2066 | } | ||
2067 | else if(!previousRegionNeighbourHandles.Contains(handler)) | ||
2068 | { | ||
2069 | sp.Scene.SimulationService.UpdateAgent(neighbour, agentpos); | ||
2070 | } | ||
2011 | } | 2071 | } |
2012 | catch (ArgumentOutOfRangeException) | 2072 | catch (ArgumentOutOfRangeException) |
2013 | { | 2073 | { |
@@ -2483,7 +2543,7 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer | |||
2483 | // no one or failed lets go back and tell physics to go on | 2543 | // no one or failed lets go back and tell physics to go on |
2484 | oldGroupPosition.X = Util.Clamp<float>(oldGroupPosition.X, 0.5f, (float)Constants.RegionSize - 0.5f); | 2544 | oldGroupPosition.X = Util.Clamp<float>(oldGroupPosition.X, 0.5f, (float)Constants.RegionSize - 0.5f); |
2485 | oldGroupPosition.Y = Util.Clamp<float>(oldGroupPosition.Y, 0.5f, (float)Constants.RegionSize - 0.5f); | 2545 | oldGroupPosition.Y = Util.Clamp<float>(oldGroupPosition.Y, 0.5f, (float)Constants.RegionSize - 0.5f); |
2486 | oldGroupPosition.Z = Util.Clamp<float>(oldGroupPosition.Z, 0.5f, 4096.0f); | 2546 | // oldGroupPosition.Z = Util.Clamp<float>(oldGroupPosition.Z, 0.5f, 4096.0f); |
2487 | 2547 | ||
2488 | grp.AbsolutePosition = oldGroupPosition; | 2548 | grp.AbsolutePosition = oldGroupPosition; |
2489 | grp.Velocity = Vector3.Zero; | 2549 | grp.Velocity = Vector3.Zero; |