diff options
4 files changed, 372 insertions, 144 deletions
diff --git a/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs b/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs index 6b3e8c4..b4ac968 100644 --- a/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs +++ b/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs | |||
@@ -1932,12 +1932,7 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer | |||
1932 | 1932 | ||
1933 | if (seeds.ContainsKey(regionhandler)) | 1933 | if (seeds.ContainsKey(regionhandler)) |
1934 | seeds.Remove(regionhandler); | 1934 | seeds.Remove(regionhandler); |
1935 | /* | ||
1936 | List<ulong> oldregions = new List<ulong>(seeds.Keys); | ||
1937 | 1935 | ||
1938 | if (oldregions.Contains(currentRegionHandler)) | ||
1939 | oldregions.Remove(currentRegionHandler); | ||
1940 | */ | ||
1941 | if (!seeds.ContainsKey(currentRegionHandler)) | 1936 | if (!seeds.ContainsKey(currentRegionHandler)) |
1942 | seeds.Add(currentRegionHandler, sp.ControllingClient.RequestClientInfo().CapsPath); | 1937 | seeds.Add(currentRegionHandler, sp.ControllingClient.RequestClientInfo().CapsPath); |
1943 | 1938 | ||
@@ -1975,24 +1970,7 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer | |||
1975 | agent.Mac = currentAgentCircuit.Mac; | 1970 | agent.Mac = currentAgentCircuit.Mac; |
1976 | agent.Id0 = currentAgentCircuit.Id0; | 1971 | agent.Id0 = currentAgentCircuit.Id0; |
1977 | } | 1972 | } |
1978 | /* | ||
1979 | AgentPosition agentpos = null; | ||
1980 | 1973 | ||
1981 | if (oldregions.Count > 0) | ||
1982 | { | ||
1983 | agentpos = new AgentPosition(); | ||
1984 | agentpos.AgentID = new UUID(sp.UUID.Guid); | ||
1985 | agentpos.SessionID = sp.ControllingClient.SessionId; | ||
1986 | agentpos.Size = sp.Appearance.AvatarSize; | ||
1987 | agentpos.Center = sp.CameraPosition; | ||
1988 | agentpos.Far = sp.DrawDistance; | ||
1989 | agentpos.Position = sp.AbsolutePosition; | ||
1990 | agentpos.Velocity = sp.Velocity; | ||
1991 | agentpos.RegionHandle = currentRegionHandler; | ||
1992 | agentpos.Throttles = sp.ControllingClient.GetThrottlesPacked(1); | ||
1993 | agentpos.ChildrenCapSeeds = seeds; | ||
1994 | } | ||
1995 | */ | ||
1996 | IPEndPoint external = region.ExternalEndPoint; | 1974 | IPEndPoint external = region.ExternalEndPoint; |
1997 | if (external != null) | 1975 | if (external != null) |
1998 | { | 1976 | { |
@@ -2001,20 +1979,6 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer | |||
2001 | InformClientOfNeighbourCompleted, | 1979 | InformClientOfNeighbourCompleted, |
2002 | d); | 1980 | d); |
2003 | } | 1981 | } |
2004 | /* | ||
2005 | if(oldregions.Count >0) | ||
2006 | { | ||
2007 | uint neighbourx; | ||
2008 | uint neighboury; | ||
2009 | UUID scope = sp.Scene.RegionInfo.ScopeID; | ||
2010 | foreach (ulong handler in oldregions) | ||
2011 | { | ||
2012 | Utils.LongToUInts(handler, out neighbourx, out neighboury); | ||
2013 | GridRegion neighbour = sp.Scene.GridService.GetRegionByPosition(scope, (int)neighbourx, (int)neighboury); | ||
2014 | sp.Scene.SimulationService.UpdateAgent(neighbour, agentpos); | ||
2015 | } | ||
2016 | } | ||
2017 | */ | ||
2018 | } | 1982 | } |
2019 | 1983 | ||
2020 | #endregion | 1984 | #endregion |
@@ -2024,6 +1988,44 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer | |||
2024 | private delegate void InformClientOfNeighbourDelegate( | 1988 | private delegate void InformClientOfNeighbourDelegate( |
2025 | ScenePresence avatar, AgentCircuitData a, GridRegion reg, IPEndPoint endPoint, bool newAgent); | 1989 | ScenePresence avatar, AgentCircuitData a, GridRegion reg, IPEndPoint endPoint, bool newAgent); |
2026 | 1990 | ||
1991 | List<GridRegion> RegionsInView(Vector3 pos, RegionInfo curregion, List<GridRegion> fullneighbours, float viewrange) | ||
1992 | { | ||
1993 | List<GridRegion> ret = new List<GridRegion>(); | ||
1994 | if(fullneighbours.Count == 0) | ||
1995 | return ret; | ||
1996 | |||
1997 | int curX = (int)Util.RegionToWorldLoc(curregion.RegionLocX) + (int)pos.X; | ||
1998 | int minX = curX - (int)viewrange; | ||
1999 | int maxX = curX + (int)viewrange; | ||
2000 | int curY = (int)Util.RegionToWorldLoc(curregion.RegionLocY) + (int)pos.Y; | ||
2001 | int minY = curY - (int)viewrange; | ||
2002 | int maxY = curY + (int)viewrange; | ||
2003 | int rtmp; | ||
2004 | |||
2005 | foreach (GridRegion r in fullneighbours) | ||
2006 | { | ||
2007 | OpenSim.Framework.RegionFlags? regionFlags = r.RegionFlags; | ||
2008 | if (regionFlags != null) | ||
2009 | { | ||
2010 | if ((regionFlags & OpenSim.Framework.RegionFlags.RegionOnline) == 0) | ||
2011 | continue; | ||
2012 | } | ||
2013 | |||
2014 | rtmp = r.RegionLocX; | ||
2015 | if (maxX < rtmp) | ||
2016 | continue; | ||
2017 | if (minX > rtmp + r.RegionSizeX) | ||
2018 | continue; | ||
2019 | rtmp = r.RegionLocY; | ||
2020 | if (maxY < rtmp) | ||
2021 | continue; | ||
2022 | if (minY > rtmp + r.RegionSizeY) | ||
2023 | continue; | ||
2024 | ret.Add(r); | ||
2025 | } | ||
2026 | return ret; | ||
2027 | } | ||
2028 | |||
2027 | /// <summary> | 2029 | /// <summary> |
2028 | /// This informs all neighbouring regions about agent "avatar". | 2030 | /// This informs all neighbouring regions about agent "avatar". |
2029 | /// and as important informs the avatar about then | 2031 | /// and as important informs the avatar about then |
@@ -2033,20 +2035,16 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer | |||
2033 | { | 2035 | { |
2034 | // assumes that out of view range regions are disconnected by the previus region | 2036 | // assumes that out of view range regions are disconnected by the previus region |
2035 | 2037 | ||
2036 | List<GridRegion> neighbours = new List<GridRegion>(); | ||
2037 | Scene spScene = sp.Scene; | 2038 | Scene spScene = sp.Scene; |
2038 | RegionInfo m_regionInfo = spScene.RegionInfo; | 2039 | RegionInfo regionInfo = spScene.RegionInfo; |
2039 | 2040 | ||
2040 | if (m_regionInfo != null) | 2041 | if (regionInfo == null) |
2041 | { | 2042 | return; |
2042 | neighbours = GetNeighbors(sp, m_regionInfo.RegionLocX, m_regionInfo.RegionLocY); | 2043 | |
2043 | } | 2044 | ulong currentRegionHandler = regionInfo.RegionHandle; |
2044 | else | ||
2045 | { | ||
2046 | m_log.Debug("[ENTITY TRANSFER MODULE]: m_regionInfo was null in EnableChildAgents, is this a NPC?"); | ||
2047 | } | ||
2048 | 2045 | ||
2049 | ulong currentRegionHandler = m_regionInfo.RegionHandle; | 2046 | List<GridRegion> fullneighbours = GetNeighbors(sp); |
2047 | List<GridRegion> neighbours = RegionsInView(sp.AbsolutePosition, regionInfo, fullneighbours, sp.RegionViewDistance); | ||
2050 | 2048 | ||
2051 | LinkedList<ulong> previousRegionNeighbourHandles; | 2049 | LinkedList<ulong> previousRegionNeighbourHandles; |
2052 | Dictionary<ulong, string> seeds; | 2050 | Dictionary<ulong, string> seeds; |
@@ -2082,13 +2080,11 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer | |||
2082 | List<AgentCircuitData> cagents = new List<AgentCircuitData>(); | 2080 | List<AgentCircuitData> cagents = new List<AgentCircuitData>(); |
2083 | List<ulong> newneighbours = new List<ulong>(); | 2081 | List<ulong> newneighbours = new List<ulong>(); |
2084 | 2082 | ||
2085 | bool notHG = (sp.TeleportFlags & Constants.TeleportFlags.ViaHGLogin) == 0; | ||
2086 | |||
2087 | foreach (GridRegion neighbour in neighbours) | 2083 | foreach (GridRegion neighbour in neighbours) |
2088 | { | 2084 | { |
2089 | ulong handler = neighbour.RegionHandle; | 2085 | ulong handler = neighbour.RegionHandle; |
2090 | 2086 | ||
2091 | if (notHG && previousRegionNeighbourHandles.Contains(handler)) | 2087 | if (previousRegionNeighbourHandles.Contains(handler)) |
2092 | { | 2088 | { |
2093 | // agent already knows this region | 2089 | // agent already knows this region |
2094 | previousRegionNeighbourHandles.Remove(handler); | 2090 | previousRegionNeighbourHandles.Remove(handler); |
@@ -2135,13 +2131,7 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer | |||
2135 | foreach (ulong handler in previousRegionNeighbourHandles) | 2131 | foreach (ulong handler in previousRegionNeighbourHandles) |
2136 | seeds.Remove(handler); | 2132 | seeds.Remove(handler); |
2137 | 2133 | ||
2138 | if(notHG) // does not work on HG | 2134 | toclose = new List<ulong>(previousRegionNeighbourHandles); |
2139 | { | ||
2140 | toclose = new List<ulong>(previousRegionNeighbourHandles); | ||
2141 | // sp.CloseChildAgents(toclose); | ||
2142 | } | ||
2143 | else | ||
2144 | toclose = new List<ulong>(); | ||
2145 | } | 2135 | } |
2146 | else | 2136 | else |
2147 | toclose = new List<ulong>(); | 2137 | toclose = new List<ulong>(); |
@@ -2173,7 +2163,6 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer | |||
2173 | 2163 | ||
2174 | Util.FireAndForget(delegate | 2164 | Util.FireAndForget(delegate |
2175 | { | 2165 | { |
2176 | Thread.Sleep(500); // the original delay that was at InformClientOfNeighbourAsync start | ||
2177 | int count = 0; | 2166 | int count = 0; |
2178 | IPEndPoint ipe; | 2167 | IPEndPoint ipe; |
2179 | 2168 | ||
@@ -2196,10 +2185,12 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer | |||
2196 | } | 2185 | } |
2197 | count++; | 2186 | count++; |
2198 | } | 2187 | } |
2199 | else if (notHG && !previousRegionNeighbourHandles.Contains(handler)) | 2188 | else if (!previousRegionNeighbourHandles.Contains(handler)) |
2200 | { | 2189 | { |
2201 | spScene.SimulationService.UpdateAgent(neighbour, agentpos); | 2190 | spScene.SimulationService.UpdateAgent(neighbour, agentpos); |
2202 | } | 2191 | } |
2192 | if (sp.IsDeleted) | ||
2193 | return; | ||
2203 | } | 2194 | } |
2204 | catch (Exception e) | 2195 | catch (Exception e) |
2205 | { | 2196 | { |
@@ -2216,6 +2207,202 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer | |||
2216 | } | 2207 | } |
2217 | } | 2208 | } |
2218 | 2209 | ||
2210 | public void CheckChildAgents(ScenePresence sp) | ||
2211 | { | ||
2212 | // assumes that out of view range regions are disconnected by the previus region | ||
2213 | |||
2214 | Scene spScene = sp.Scene; | ||
2215 | RegionInfo regionInfo = spScene.RegionInfo; | ||
2216 | |||
2217 | if (regionInfo == null) | ||
2218 | return; | ||
2219 | |||
2220 | ulong currentRegionHandler = regionInfo.RegionHandle; | ||
2221 | |||
2222 | List<GridRegion> fullneighbours = GetNeighbors(sp); | ||
2223 | List<GridRegion> neighbours = RegionsInView(sp.AbsolutePosition, regionInfo, fullneighbours, sp.RegionViewDistance); | ||
2224 | |||
2225 | LinkedList<ulong> previousRegionNeighbourHandles = new LinkedList<ulong>(sp.KnownRegions.Keys); | ||
2226 | |||
2227 | IClientAPI spClient = sp.ControllingClient; | ||
2228 | |||
2229 | AgentCircuitData currentAgentCircuit = | ||
2230 | spScene.AuthenticateHandler.GetAgentCircuitData(sp.ControllingClient.CircuitCode); | ||
2231 | |||
2232 | List<AgentCircuitData> cagents = new List<AgentCircuitData>(); | ||
2233 | List<GridRegion> newneighbours = new List<GridRegion>(); | ||
2234 | |||
2235 | foreach (GridRegion neighbour in neighbours) | ||
2236 | { | ||
2237 | ulong handler = neighbour.RegionHandle; | ||
2238 | |||
2239 | if (previousRegionNeighbourHandles.Contains(handler)) | ||
2240 | { | ||
2241 | // agent already knows this region | ||
2242 | previousRegionNeighbourHandles.Remove(handler); | ||
2243 | continue; | ||
2244 | } | ||
2245 | |||
2246 | if (handler == currentRegionHandler) | ||
2247 | continue; | ||
2248 | |||
2249 | // a new region to add | ||
2250 | AgentCircuitData agent = spClient.RequestClientInfo(); | ||
2251 | agent.BaseFolder = UUID.Zero; | ||
2252 | agent.InventoryFolder = UUID.Zero; | ||
2253 | agent.startpos = sp.AbsolutePosition + CalculateOffset(sp, neighbour); | ||
2254 | agent.child = true; | ||
2255 | agent.Appearance = new AvatarAppearance(); | ||
2256 | agent.Appearance.AvatarHeight = sp.Appearance.AvatarHeight; | ||
2257 | agent.startfar = sp.DrawDistance; | ||
2258 | if (currentAgentCircuit != null) | ||
2259 | { | ||
2260 | agent.ServiceURLs = currentAgentCircuit.ServiceURLs; | ||
2261 | agent.IPAddress = currentAgentCircuit.IPAddress; | ||
2262 | agent.Viewer = currentAgentCircuit.Viewer; | ||
2263 | agent.Channel = currentAgentCircuit.Channel; | ||
2264 | agent.Mac = currentAgentCircuit.Mac; | ||
2265 | agent.Id0 = currentAgentCircuit.Id0; | ||
2266 | } | ||
2267 | |||
2268 | newneighbours.Add(neighbour); | ||
2269 | agent.CapsPath = CapsUtil.GetRandomCapsObjectPath(); | ||
2270 | sp.AddNeighbourRegion(neighbour, agent.CapsPath); | ||
2271 | |||
2272 | agent.ChildrenCapSeeds = null; | ||
2273 | cagents.Add(agent); | ||
2274 | } | ||
2275 | |||
2276 | List<ulong> toclose; | ||
2277 | // previousRegionNeighbourHandles now contains regions to forget | ||
2278 | if (previousRegionNeighbourHandles.Count > 0) | ||
2279 | { | ||
2280 | if (previousRegionNeighbourHandles.Contains(currentRegionHandler)) | ||
2281 | previousRegionNeighbourHandles.Remove(currentRegionHandler); | ||
2282 | |||
2283 | foreach (ulong handler in previousRegionNeighbourHandles) | ||
2284 | sp.KnownRegions.Remove(handler); | ||
2285 | |||
2286 | toclose = new List<ulong>(previousRegionNeighbourHandles); | ||
2287 | } | ||
2288 | else | ||
2289 | toclose = new List<ulong>(); | ||
2290 | |||
2291 | ICapabilitiesModule capsModule = spScene.CapsModule; | ||
2292 | if (capsModule != null) | ||
2293 | capsModule.SetChildrenSeed(sp.UUID, sp.KnownRegions); | ||
2294 | |||
2295 | if (toclose.Count > 0) | ||
2296 | sp.CloseChildAgents(toclose); | ||
2297 | |||
2298 | if (newneighbours.Count > 0) | ||
2299 | { | ||
2300 | int count = 0; | ||
2301 | IPEndPoint ipe; | ||
2302 | |||
2303 | foreach (GridRegion neighbour in newneighbours) | ||
2304 | { | ||
2305 | try | ||
2306 | { | ||
2307 | ipe = neighbour.ExternalEndPoint; | ||
2308 | if (ipe != null) | ||
2309 | InformClientOfNeighbourAsync(sp, cagents[count], neighbour, ipe, true); | ||
2310 | else | ||
2311 | { | ||
2312 | m_log.DebugFormat("[ENTITY TRANSFER MODULE]: lost DNS resolution for neighbour {0}", neighbour.ExternalHostName); | ||
2313 | } | ||
2314 | count++; | ||
2315 | if (sp.IsDeleted) | ||
2316 | return; | ||
2317 | } | ||
2318 | catch (Exception e) | ||
2319 | { | ||
2320 | m_log.ErrorFormat( | ||
2321 | "[ENTITY TRANSFER MODULE]: Error creating child agent at {0} ({1} ({2}, {3}). {4}", | ||
2322 | neighbour.ExternalHostName, | ||
2323 | neighbour.RegionHandle, | ||
2324 | neighbour.RegionLocX, | ||
2325 | neighbour.RegionLocY, | ||
2326 | e); | ||
2327 | } | ||
2328 | } | ||
2329 | } | ||
2330 | } | ||
2331 | |||
2332 | public void CloseOldChildAgents(ScenePresence sp) | ||
2333 | { | ||
2334 | Scene spScene = sp.Scene; | ||
2335 | RegionInfo regionInfo = spScene.RegionInfo; | ||
2336 | |||
2337 | if (regionInfo == null) | ||
2338 | return; | ||
2339 | |||
2340 | ulong currentRegionHandler = regionInfo.RegionHandle; | ||
2341 | |||
2342 | List<GridRegion> fullneighbours = GetNeighbors(sp); | ||
2343 | List<GridRegion> neighbours = RegionsInView(sp.AbsolutePosition, regionInfo, fullneighbours, sp.RegionViewDistance); | ||
2344 | |||
2345 | LinkedList<ulong> previousRegionNeighbourHandles; | ||
2346 | Dictionary<ulong, string> seeds; | ||
2347 | ICapabilitiesModule capsModule = spScene.CapsModule; | ||
2348 | |||
2349 | if (capsModule != null) | ||
2350 | { | ||
2351 | seeds = new Dictionary<ulong, string>(capsModule.GetChildrenSeeds(sp.UUID)); | ||
2352 | previousRegionNeighbourHandles = new LinkedList<ulong>(seeds.Keys); | ||
2353 | } | ||
2354 | else | ||
2355 | { | ||
2356 | seeds = new Dictionary<ulong, string>(); | ||
2357 | previousRegionNeighbourHandles = new LinkedList<ulong>(); | ||
2358 | } | ||
2359 | |||
2360 | IClientAPI spClient = sp.ControllingClient; | ||
2361 | |||
2362 | // This will fail if the user aborts login | ||
2363 | try | ||
2364 | { | ||
2365 | if (!seeds.ContainsKey(currentRegionHandler)) | ||
2366 | seeds.Add(currentRegionHandler, spClient.RequestClientInfo().CapsPath); | ||
2367 | } | ||
2368 | catch | ||
2369 | { | ||
2370 | return; | ||
2371 | } | ||
2372 | |||
2373 | foreach (GridRegion neighbour in neighbours) | ||
2374 | { | ||
2375 | ulong handler = neighbour.RegionHandle; | ||
2376 | |||
2377 | if (previousRegionNeighbourHandles.Contains(handler)) | ||
2378 | previousRegionNeighbourHandles.Remove(handler); | ||
2379 | } | ||
2380 | |||
2381 | List<ulong> toclose; | ||
2382 | // previousRegionNeighbourHandles now contains regions to forget | ||
2383 | if (previousRegionNeighbourHandles.Count == 0) | ||
2384 | return; | ||
2385 | |||
2386 | if (previousRegionNeighbourHandles.Contains(currentRegionHandler)) | ||
2387 | previousRegionNeighbourHandles.Remove(currentRegionHandler); | ||
2388 | |||
2389 | foreach (ulong handler in previousRegionNeighbourHandles) | ||
2390 | seeds.Remove(handler); | ||
2391 | |||
2392 | toclose = new List<ulong>(previousRegionNeighbourHandles); | ||
2393 | |||
2394 | if (capsModule != null) | ||
2395 | capsModule.SetChildrenSeed(sp.UUID, seeds); | ||
2396 | |||
2397 | sp.KnownRegions = seeds; | ||
2398 | sp.SetNeighbourRegionSizeInfo(neighbours); | ||
2399 | |||
2400 | Util.FireAndForget(delegate | ||
2401 | { | ||
2402 | sp.CloseChildAgents(toclose); | ||
2403 | }); | ||
2404 | } | ||
2405 | |||
2219 | // Computes the difference between two region bases. | 2406 | // Computes the difference between two region bases. |
2220 | // Returns a vector of world coordinates (meters) from base of first region to the second. | 2407 | // Returns a vector of world coordinates (meters) from base of first region to the second. |
2221 | // The first region is the home region of the passed scene presence. | 2408 | // The first region is the home region of the passed scene presence. |
@@ -2416,6 +2603,11 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer | |||
2416 | 2603 | ||
2417 | } | 2604 | } |
2418 | 2605 | ||
2606 | // all this code should be moved to scene replacing the now bad one there | ||
2607 | // cache Neighbors | ||
2608 | List<GridRegion> Neighbors = null; | ||
2609 | DateTime LastNeighborsTime = DateTime.MinValue; | ||
2610 | |||
2419 | /// <summary> | 2611 | /// <summary> |
2420 | /// Return the list of online regions that are considered to be neighbours to the given scene. | 2612 | /// Return the list of online regions that are considered to be neighbours to the given scene. |
2421 | /// </summary> | 2613 | /// </summary> |
@@ -2423,39 +2615,41 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer | |||
2423 | /// <param name="pRegionLocX"></param> | 2615 | /// <param name="pRegionLocX"></param> |
2424 | /// <param name="pRegionLocY"></param> | 2616 | /// <param name="pRegionLocY"></param> |
2425 | /// <returns></returns> | 2617 | /// <returns></returns> |
2426 | protected List<GridRegion> GetNeighbors(ScenePresence avatar, uint pRegionLocX, uint pRegionLocY) | 2618 | protected List<GridRegion> GetNeighbors(ScenePresence avatar) |
2427 | { | 2619 | { |
2428 | Scene pScene = avatar.Scene; | 2620 | Scene pScene = avatar.Scene; |
2429 | RegionInfo m_regionInfo = pScene.RegionInfo; | ||
2430 | List<GridRegion> neighbours; | ||
2431 | 2621 | ||
2432 | uint dd = (uint)avatar.RegionViewDistance; | 2622 | uint dd = (uint)pScene.MaxRegionViewDistance; |
2623 | if(dd <= 1) | ||
2624 | return new List<GridRegion>(); | ||
2625 | |||
2626 | if (Neighbors != null && (DateTime.UtcNow - LastNeighborsTime).TotalSeconds < 30) | ||
2627 | { | ||
2628 | return Neighbors; | ||
2629 | } | ||
2433 | 2630 | ||
2434 | // until avatar movement updates client connections, we need to send at least this current region immediate neighbors | 2631 | RegionInfo regionInfo = pScene.RegionInfo; |
2435 | uint ddX = Math.Max(dd, Constants.RegionSize); | 2632 | List<GridRegion> neighbours; |
2436 | uint ddY = Math.Max(dd, Constants.RegionSize); | ||
2437 | 2633 | ||
2438 | ddX--; | 2634 | dd--; |
2439 | ddY--; | ||
2440 | 2635 | ||
2441 | // reference to region edges. Should be avatar position | 2636 | uint startX = Util.RegionToWorldLoc(regionInfo.RegionLocX); |
2442 | uint startX = Util.RegionToWorldLoc(pRegionLocX); | 2637 | uint endX = startX + regionInfo.RegionSizeX; |
2443 | uint endX = startX + m_regionInfo.RegionSizeX; | 2638 | uint startY = Util.RegionToWorldLoc(regionInfo.RegionLocY); |
2444 | uint startY = Util.RegionToWorldLoc(pRegionLocY); | 2639 | uint endY = startY + regionInfo.RegionSizeY; |
2445 | uint endY = startY + m_regionInfo.RegionSizeY; | ||
2446 | 2640 | ||
2447 | startX -= ddX; | 2641 | startX -= dd; |
2448 | startY -= ddY; | 2642 | startY -= dd; |
2449 | endX += ddX; | 2643 | endX += dd; |
2450 | endY += ddY; | 2644 | endY += dd; |
2451 | 2645 | ||
2452 | neighbours | 2646 | neighbours = avatar.Scene.GridService.GetRegionRange( |
2453 | = avatar.Scene.GridService.GetRegionRange( | 2647 | regionInfo.ScopeID, (int)startX, (int)endX, (int)startY, (int)endY); |
2454 | m_regionInfo.ScopeID, (int)startX, (int)endX, (int)startY, (int)endY); | ||
2455 | 2648 | ||
2456 | // The r.RegionFlags == null check only needs to be made for simulators before 2015-01-14 (pre 0.8.1). | 2649 | // The r.RegionFlags == null check only needs to be made for simulators before 2015-01-14 (pre 0.8.1). |
2457 | neighbours.RemoveAll( r => r.RegionID == m_regionInfo.RegionID ); | 2650 | neighbours.RemoveAll( r => r.RegionID == regionInfo.RegionID ); |
2458 | 2651 | Neighbors = neighbours; | |
2652 | LastNeighborsTime = DateTime.UtcNow; | ||
2459 | return neighbours; | 2653 | return neighbours; |
2460 | } | 2654 | } |
2461 | #endregion | 2655 | #endregion |
diff --git a/OpenSim/Region/Framework/Interfaces/IEntityTransferModule.cs b/OpenSim/Region/Framework/Interfaces/IEntityTransferModule.cs index 1b690ba..9377564 100644 --- a/OpenSim/Region/Framework/Interfaces/IEntityTransferModule.cs +++ b/OpenSim/Region/Framework/Interfaces/IEntityTransferModule.cs | |||
@@ -90,6 +90,8 @@ namespace OpenSim.Region.Framework.Interfaces | |||
90 | void AgentArrivedAtDestination(UUID agent); | 90 | void AgentArrivedAtDestination(UUID agent); |
91 | 91 | ||
92 | void EnableChildAgents(ScenePresence agent); | 92 | void EnableChildAgents(ScenePresence agent); |
93 | void CheckChildAgents(ScenePresence agent); | ||
94 | void CloseOldChildAgents(ScenePresence agent); | ||
93 | 95 | ||
94 | void EnableChildAgent(ScenePresence agent, GridRegion region); | 96 | void EnableChildAgent(ScenePresence agent, GridRegion region); |
95 | 97 | ||
diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs index 7d312e9..e130bd7 100755 --- a/OpenSim/Region/Framework/Scenes/Scene.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.cs | |||
@@ -1286,7 +1286,6 @@ namespace OpenSim.Region.Framework.Scenes | |||
1286 | { | 1286 | { |
1287 | if (RegionInfo.RegionHandle != otherRegion.RegionHandle) | 1287 | if (RegionInfo.RegionHandle != otherRegion.RegionHandle) |
1288 | { | 1288 | { |
1289 | |||
1290 | if (isNeighborRegion(otherRegion)) | 1289 | if (isNeighborRegion(otherRegion)) |
1291 | { | 1290 | { |
1292 | // Let the grid service module know, so this can be cached | 1291 | // Let the grid service module know, so this can be cached |
@@ -1296,9 +1295,6 @@ namespace OpenSim.Region.Framework.Scenes | |||
1296 | { | 1295 | { |
1297 | ForEachRootScenePresence(delegate(ScenePresence agent) | 1296 | ForEachRootScenePresence(delegate(ScenePresence agent) |
1298 | { | 1297 | { |
1299 | //agent.ControllingClient.new | ||
1300 | //this.CommsManager.InterRegion.InformRegionOfChildAgent(otherRegion.RegionHandle, agent.ControllingClient.RequestClientInfo()); | ||
1301 | |||
1302 | List<ulong> old = new List<ulong>(); | 1298 | List<ulong> old = new List<ulong>(); |
1303 | old.Add(otherRegion.RegionHandle); | 1299 | old.Add(otherRegion.RegionHandle); |
1304 | agent.DropOldNeighbours(old); | 1300 | agent.DropOldNeighbours(old); |
@@ -1324,7 +1320,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
1324 | 1320 | ||
1325 | public bool isNeighborRegion(GridRegion otherRegion) | 1321 | public bool isNeighborRegion(GridRegion otherRegion) |
1326 | { | 1322 | { |
1327 | int tmp = otherRegion.RegionLocX - (int)RegionInfo.WorldLocX; ; | 1323 | int tmp = otherRegion.RegionLocX - (int)RegionInfo.WorldLocX; |
1328 | 1324 | ||
1329 | if (tmp < -otherRegion.RegionSizeX && tmp > RegionInfo.RegionSizeX) | 1325 | if (tmp < -otherRegion.RegionSizeX && tmp > RegionInfo.RegionSizeX) |
1330 | return false; | 1326 | return false; |
diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index be593ad..fbf9b4a 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs | |||
@@ -165,6 +165,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
165 | public static readonly float MOVEMENT = .25f; | 165 | public static readonly float MOVEMENT = .25f; |
166 | public static readonly float SIGNIFICANT_MOVEMENT = 16.0f; | 166 | public static readonly float SIGNIFICANT_MOVEMENT = 16.0f; |
167 | public static readonly float CHILDUPDATES_MOVEMENT = 100.0f; | 167 | public static readonly float CHILDUPDATES_MOVEMENT = 100.0f; |
168 | public static readonly float CHILDAGENTSCHECK_MOVEMENT = 1024f; // 32m | ||
168 | public static readonly float CHILDUPDATES_TIME = 2000f; // min time between child updates (ms) | 169 | public static readonly float CHILDUPDATES_TIME = 2000f; // min time between child updates (ms) |
169 | 170 | ||
170 | private UUID m_previusParcelUUID = UUID.Zero; | 171 | private UUID m_previusParcelUUID = UUID.Zero; |
@@ -342,7 +343,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
342 | private int m_lastChildAgentUpdateGodLevel; | 343 | private int m_lastChildAgentUpdateGodLevel; |
343 | private float m_lastChildAgentUpdateDrawDistance; | 344 | private float m_lastChildAgentUpdateDrawDistance; |
344 | private Vector3 m_lastChildAgentUpdatePosition; | 345 | private Vector3 m_lastChildAgentUpdatePosition; |
345 | // private Vector3 m_lastChildAgentUpdateCamPosition; | 346 | private Vector3 m_lastChildAgentCheckPosition; |
347 | // private Vector3 m_lastChildAgentUpdateCamPosition; | ||
346 | 348 | ||
347 | private Vector3 m_lastCameraRayCastCam; | 349 | private Vector3 m_lastCameraRayCastCam; |
348 | private Vector3 m_lastCameraRayCastPos; | 350 | private Vector3 m_lastCameraRayCastPos; |
@@ -627,7 +629,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
627 | { | 629 | { |
628 | get | 630 | get |
629 | { | 631 | { |
630 | return Util.Clamp(m_drawDistance, 32f, m_scene.MaxRegionViewDistance); | 632 | return Util.Clamp(m_drawDistance + 64f, 64f, m_scene.MaxRegionViewDistance); |
631 | } | 633 | } |
632 | } | 634 | } |
633 | 635 | ||
@@ -2321,6 +2323,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
2321 | 2323 | ||
2322 | m_lastChildUpdatesTime = Util.EnvironmentTickCount() + 10000; | 2324 | m_lastChildUpdatesTime = Util.EnvironmentTickCount() + 10000; |
2323 | m_lastChildAgentUpdatePosition = AbsolutePosition; | 2325 | m_lastChildAgentUpdatePosition = AbsolutePosition; |
2326 | m_lastChildAgentCheckPosition = m_lastChildAgentUpdatePosition; | ||
2324 | m_lastChildAgentUpdateDrawDistance = DrawDistance; | 2327 | m_lastChildAgentUpdateDrawDistance = DrawDistance; |
2325 | 2328 | ||
2326 | m_lastChildAgentUpdateGodLevel = GodController.ViwerUIGodLevel; | 2329 | m_lastChildAgentUpdateGodLevel = GodController.ViwerUIGodLevel; |
@@ -4049,20 +4052,11 @@ namespace OpenSim.Region.Framework.Scenes | |||
4049 | //NeedInitialData = 4; | 4052 | //NeedInitialData = 4; |
4050 | //return; | 4053 | //return; |
4051 | } | 4054 | } |
4052 | |||
4053 | // Create child agents in neighbouring regions | ||
4054 | IEntityTransferModule m_agentTransfer = m_scene.RequestModuleInterface<IEntityTransferModule>(); | 4055 | IEntityTransferModule m_agentTransfer = m_scene.RequestModuleInterface<IEntityTransferModule>(); |
4055 | if (m_agentTransfer != null) | 4056 | if (m_agentTransfer != null) |
4056 | { | 4057 | { |
4057 | m_agentTransfer.EnableChildAgents(this); | 4058 | m_agentTransfer.CloseOldChildAgents(this); |
4058 | } | 4059 | } |
4059 | |||
4060 | m_lastChildUpdatesTime = Util.EnvironmentTickCount() + 10000; | ||
4061 | m_lastChildAgentUpdatePosition = AbsolutePosition; | ||
4062 | m_lastChildAgentUpdateDrawDistance = DrawDistance; | ||
4063 | |||
4064 | m_lastChildAgentUpdateGodLevel = GodController.ViwerUIGodLevel; | ||
4065 | m_childUpdatesBusy = false; // allow them | ||
4066 | } | 4060 | } |
4067 | 4061 | ||
4068 | m_log.DebugFormat("[SCENE PRESENCE({0})]: SendInitialData for {1}", Scene.RegionInfo.RegionName, UUID); | 4062 | m_log.DebugFormat("[SCENE PRESENCE({0})]: SendInitialData for {1}", Scene.RegionInfo.RegionName, UUID); |
@@ -4126,6 +4120,24 @@ namespace OpenSim.Region.Framework.Scenes | |||
4126 | 4120 | ||
4127 | m_reprioritizationBusy = false; | 4121 | m_reprioritizationBusy = false; |
4128 | } | 4122 | } |
4123 | |||
4124 | if (!IsChildAgent) | ||
4125 | { | ||
4126 | // Create child agents in neighbouring regions | ||
4127 | IEntityTransferModule m_agentTransfer = m_scene.RequestModuleInterface<IEntityTransferModule>(); | ||
4128 | if (m_agentTransfer != null) | ||
4129 | { | ||
4130 | m_agentTransfer.EnableChildAgents(this); | ||
4131 | } | ||
4132 | |||
4133 | m_lastChildUpdatesTime = Util.EnvironmentTickCount() + 10000; | ||
4134 | m_lastChildAgentUpdatePosition = AbsolutePosition; | ||
4135 | m_lastChildAgentCheckPosition = m_lastChildAgentUpdatePosition; | ||
4136 | m_lastChildAgentUpdateDrawDistance = DrawDistance; | ||
4137 | |||
4138 | m_lastChildAgentUpdateGodLevel = GodController.ViwerUIGodLevel; | ||
4139 | m_childUpdatesBusy = false; // allow them | ||
4140 | } | ||
4129 | }); | 4141 | }); |
4130 | 4142 | ||
4131 | } | 4143 | } |
@@ -4399,56 +4411,80 @@ namespace OpenSim.Region.Framework.Scenes | |||
4399 | if(m_childUpdatesBusy) | 4411 | if(m_childUpdatesBusy) |
4400 | return; | 4412 | return; |
4401 | 4413 | ||
4402 | //possible KnownRegionHandles always contains current region and this check is not needed | 4414 | int tdiff = Util.EnvironmentTickCountSubtract(m_lastChildUpdatesTime); |
4403 | int minhandles = KnownRegionHandles.Contains(RegionHandle) ? 1 : 0; | 4415 | if (tdiff < CHILDUPDATES_TIME) |
4404 | if(KnownRegionHandles.Count > minhandles) | 4416 | return; |
4405 | { | ||
4406 | int tdiff = Util.EnvironmentTickCountSubtract(m_lastChildUpdatesTime); | ||
4407 | if(tdiff < CHILDUPDATES_TIME) | ||
4408 | return; | ||
4409 | 4417 | ||
4410 | bool doUpdate = false; | 4418 | IEntityTransferModule m_agentTransfer = m_scene.RequestModuleInterface<IEntityTransferModule>(); |
4411 | if(m_lastChildAgentUpdateGodLevel != GodController.ViwerUIGodLevel) | 4419 | float dx = pos.X - m_lastChildAgentCheckPosition.Y; |
4412 | doUpdate = true; | 4420 | float dy = pos.Y - m_lastChildAgentCheckPosition.Y; |
4413 | 4421 | if ((m_agentTransfer != null) && ((dx * dx + dy *dy) > CHILDAGENTSCHECK_MOVEMENT)) | |
4414 | if(!doUpdate && Math.Abs(DrawDistance - m_lastChildAgentUpdateDrawDistance) > 32.0f) | 4422 | { |
4415 | doUpdate = true; | 4423 | m_childUpdatesBusy = true; |
4424 | m_lastChildAgentCheckPosition = pos; | ||
4425 | m_lastChildAgentUpdatePosition = pos; | ||
4426 | m_lastChildAgentUpdateGodLevel = GodController.ViwerUIGodLevel; | ||
4427 | m_lastChildAgentUpdateDrawDistance = DrawDistance; | ||
4428 | // m_lastChildAgentUpdateCamPosition = CameraPosition; | ||
4416 | 4429 | ||
4417 | if(!doUpdate) | 4430 | Util.FireAndForget( |
4431 | o => | ||
4432 | { | ||
4433 | m_agentTransfer.EnableChildAgents(this); | ||
4434 | m_lastChildUpdatesTime = Util.EnvironmentTickCount(); | ||
4435 | m_childUpdatesBusy = false; | ||
4436 | }, null, "ScenePresence.CheckChildAgents"); | ||
4437 | } | ||
4438 | else | ||
4439 | { | ||
4440 | //possible KnownRegionHandles always contains current region and this check is not needed | ||
4441 | int minhandles = KnownRegionHandles.Contains(RegionHandle) ? 1 : 0; | ||
4442 | if(KnownRegionHandles.Count > minhandles) | ||
4418 | { | 4443 | { |
4419 | diff = pos - m_lastChildAgentUpdatePosition; | 4444 | bool doUpdate = false; |
4420 | if (diff.LengthSquared() > CHILDUPDATES_MOVEMENT) | 4445 | if (m_lastChildAgentUpdateGodLevel != GodController.ViwerUIGodLevel) |
4421 | doUpdate = true; | 4446 | doUpdate = true; |
4422 | } | ||
4423 | 4447 | ||
4424 | if(doUpdate) | 4448 | bool viewchanged = Math.Abs(DrawDistance - m_lastChildAgentUpdateDrawDistance) > 32.0f; |
4425 | { | 4449 | if (!viewchanged) |
4426 | m_childUpdatesBusy = true; | 4450 | doUpdate = true; |
4427 | m_lastChildAgentUpdatePosition = pos; | 4451 | |
4428 | m_lastChildAgentUpdateGodLevel = GodController.ViwerUIGodLevel; | 4452 | if(!doUpdate) |
4429 | m_lastChildAgentUpdateDrawDistance = DrawDistance; | 4453 | { |
4430 | // m_lastChildAgentUpdateCamPosition = CameraPosition; | 4454 | diff = pos - m_lastChildAgentUpdatePosition; |
4431 | 4455 | if (diff.LengthSquared() > CHILDUPDATES_MOVEMENT) | |
4432 | AgentPosition agentpos = new AgentPosition(); | 4456 | doUpdate = true; |
4433 | agentpos.AgentID = new UUID(UUID.Guid); | 4457 | } |
4434 | agentpos.SessionID = ControllingClient.SessionId; | 4458 | |
4435 | agentpos.Size = Appearance.AvatarSize; | 4459 | if (doUpdate) |
4436 | agentpos.Center = CameraPosition; | 4460 | { |
4437 | agentpos.Far = DrawDistance; | 4461 | m_childUpdatesBusy = true; |
4438 | agentpos.Position = AbsolutePosition; | 4462 | m_lastChildAgentUpdatePosition = pos; |
4439 | agentpos.Velocity = Velocity; | 4463 | m_lastChildAgentUpdateGodLevel = GodController.ViwerUIGodLevel; |
4440 | agentpos.RegionHandle = RegionHandle; | 4464 | m_lastChildAgentUpdateDrawDistance = DrawDistance; |
4441 | agentpos.GodData = GodController.State(); | 4465 | // m_lastChildAgentUpdateCamPosition = CameraPosition; |
4442 | agentpos.Throttles = ControllingClient.GetThrottlesPacked(1); | 4466 | |
4443 | 4467 | AgentPosition agentpos = new AgentPosition(); | |
4444 | // Let's get this out of the update loop | 4468 | agentpos.AgentID = new UUID(UUID.Guid); |
4445 | Util.FireAndForget( | 4469 | agentpos.SessionID = ControllingClient.SessionId; |
4446 | o => | 4470 | agentpos.Size = Appearance.AvatarSize; |
4447 | { | 4471 | agentpos.Center = CameraPosition; |
4448 | m_scene.SendOutChildAgentUpdates(agentpos, this); | 4472 | agentpos.Far = DrawDistance; |
4449 | m_lastChildUpdatesTime = Util.EnvironmentTickCount(); | 4473 | agentpos.Position = AbsolutePosition; |
4450 | m_childUpdatesBusy = false; | 4474 | agentpos.Velocity = Velocity; |
4451 | }, null, "ScenePresence.SendOutChildAgentUpdates"); | 4475 | agentpos.RegionHandle = RegionHandle; |
4476 | agentpos.GodData = GodController.State(); | ||
4477 | agentpos.Throttles = ControllingClient.GetThrottlesPacked(1); | ||
4478 | |||
4479 | // Let's get this out of the update loop | ||
4480 | Util.FireAndForget( | ||
4481 | o => | ||
4482 | { | ||
4483 | m_scene.SendOutChildAgentUpdates(agentpos, this); | ||
4484 | m_lastChildUpdatesTime = Util.EnvironmentTickCount(); | ||
4485 | m_childUpdatesBusy = false; | ||
4486 | }, null, "ScenePresence.SendOutChildAgentUpdates"); | ||
4487 | } | ||
4452 | } | 4488 | } |
4453 | } | 4489 | } |
4454 | } | 4490 | } |