diff options
author | UbitUmarov | 2016-07-31 23:12:09 +0100 |
---|---|---|
committer | UbitUmarov | 2016-07-31 23:12:09 +0100 |
commit | 159d7229661cd1b0bc300dd8b6a6772bd0b5a8d5 (patch) | |
tree | 3b409df1219654f1ee511bc7413dd611a4d271c8 /OpenSim/Region/CoreModules/Framework/EntityTransfer | |
parent | simply NotFoundLocationCache, comment out some debug messages (diff) | |
download | opensim-SC_OLD-159d7229661cd1b0bc300dd8b6a6772bd0b5a8d5.zip opensim-SC_OLD-159d7229661cd1b0bc300dd8b6a6772bd0b5a8d5.tar.gz opensim-SC_OLD-159d7229661cd1b0bc300dd8b6a6772bd0b5a8d5.tar.bz2 opensim-SC_OLD-159d7229661cd1b0bc300dd8b6a6772bd0b5a8d5.tar.xz |
on 0.8 grids compatibility code just do a BIG range request. It whould be done in most cases (open borders) plus 4 more. In future this code should not be used if the grid is >=0.9
Diffstat (limited to 'OpenSim/Region/CoreModules/Framework/EntityTransfer')
-rw-r--r-- | OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs | 74 |
1 files changed, 25 insertions, 49 deletions
diff --git a/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs b/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs index c6cabf1..980d3cc 100644 --- a/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs +++ b/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs | |||
@@ -2183,10 +2183,6 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer | |||
2183 | 2183 | ||
2184 | // Given a world position, get the GridRegion info for | 2184 | // Given a world position, get the GridRegion info for |
2185 | // the region containing that point. | 2185 | // the region containing that point. |
2186 | // Not needed on 0.9 grids | ||
2187 | // 'pSizeHint' is the size of the source region but since the destination point can be anywhere | ||
2188 | // the size of the target region is unknown thus the search area might have to be very large. | ||
2189 | // Return 'null' if no such region exists. | ||
2190 | protected GridRegion GetRegionContainingWorldLocation(IGridService pGridService, UUID pScopeID, | 2186 | protected GridRegion GetRegionContainingWorldLocation(IGridService pGridService, UUID pScopeID, |
2191 | double px, double py, uint pSizeHint) | 2187 | double px, double py, uint pSizeHint) |
2192 | { | 2188 | { |
@@ -2194,11 +2190,6 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer | |||
2194 | GridRegion ret = null; | 2190 | GridRegion ret = null; |
2195 | const double fudge = 2.0; | 2191 | const double fudge = 2.0; |
2196 | 2192 | ||
2197 | // One problem with this routine is negative results. That is, this can be called lots of times | ||
2198 | // for regions that don't exist. m_notFoundLocationCache remembers 'not found' results so they | ||
2199 | // will be quick 'not found's next time. | ||
2200 | // NotFoundLocationCache is an expiring cache so it will eventually forget about 'not found' and | ||
2201 | // thus re-ask the GridService about the location. | ||
2202 | if (m_notFoundLocationCache.Contains(px, py)) | 2193 | if (m_notFoundLocationCache.Contains(px, py)) |
2203 | { | 2194 | { |
2204 | // m_log.DebugFormat("{0} GetRegionContainingWorldLocation: Not found via cache. loc=<{1},{2}>", LogHeader, px, py); | 2195 | // m_log.DebugFormat("{0} GetRegionContainingWorldLocation: Not found via cache. loc=<{1},{2}>", LogHeader, px, py); |
@@ -2207,60 +2198,45 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer | |||
2207 | 2198 | ||
2208 | // As an optimization, since most regions will be legacy sized regions (256x256), first try to get | 2199 | // As an optimization, since most regions will be legacy sized regions (256x256), first try to get |
2209 | // the region at the appropriate legacy region location. | 2200 | // the region at the appropriate legacy region location. |
2210 | uint possibleX = (uint)Math.Floor(px); | 2201 | // this is all that is needed on 0.9 grids |
2211 | possibleX -= possibleX % Constants.RegionSize; | 2202 | uint possibleX = (uint)px & 0xffffff00u; |
2212 | uint possibleY = (uint)Math.Floor(py); | 2203 | uint possibleY = (uint)py & 0xffffff00u; |
2213 | possibleY -= possibleY % Constants.RegionSize; | ||
2214 | ret = pGridService.GetRegionByPosition(pScopeID, (int)possibleX, (int)possibleY); | 2204 | ret = pGridService.GetRegionByPosition(pScopeID, (int)possibleX, (int)possibleY); |
2215 | if (ret != null) | 2205 | if (ret != null) |
2216 | { | 2206 | { |
2217 | // m_log.DebugFormat("{0} GetRegionContainingWorldLocation: Found region using legacy size. rloc=<{1},{2}>. Rname={3}", | 2207 | // m_log.DebugFormat("{0} GetRegionContainingWorldLocation: Found region using legacy size. rloc=<{1},{2}>. Rname={3}", |
2218 | // LogHeader, possibleX, possibleY, ret.RegionName); | 2208 | // LogHeader, possibleX, possibleY, ret.RegionName); |
2209 | return ret; | ||
2219 | } | 2210 | } |
2220 | 2211 | ||
2221 | if (ret == null) | 2212 | // for 0.8 regions just make a BIG area request. old code whould do it plus 4 more smaller on region open edges |
2213 | // this is what 0.9 grids now do internally | ||
2214 | List<GridRegion> possibleRegions = pGridService.GetRegionRange(pScopeID, | ||
2215 | (int)(px - Constants.MaximumRegionSize), (int)(px + 1), // +1 bc left mb not part of range | ||
2216 | (int)(py - Constants.MaximumRegionSize), (int)(py + 1)); | ||
2217 | // m_log.DebugFormat("{0} GetRegionContainingWorldLocation: possibleRegions cnt={1}, range={2}", | ||
2218 | // LogHeader, possibleRegions.Count, range); | ||
2219 | if (possibleRegions != null && possibleRegions.Count > 0) | ||
2222 | { | 2220 | { |
2223 | // If the simple lookup failed, search the larger area for a region that contains this point | 2221 | // If we found some regions, check to see if the point is within |
2224 | double range = (double)pSizeHint + fudge; | 2222 | foreach (GridRegion gr in possibleRegions) |
2225 | while (ret == null && range <= (Constants.MaximumRegionSize + Constants.RegionSize)) | ||
2226 | { | 2223 | { |
2227 | // Get from the grid service a list of regions that might contain this point. | 2224 | // m_log.DebugFormat("{0} GetRegionContainingWorldLocation: possibleRegion nm={1}, regionLoc=<{2},{3}>, regionSize=<{4},{5}>", |
2228 | // The region origin will be in the zero direction so only subtract the range. | 2225 | // LogHeader, gr.RegionName, gr.RegionLocX, gr.RegionLocY, gr.RegionSizeX, gr.RegionSizeY); |
2229 | List<GridRegion> possibleRegions = pGridService.GetRegionRange(pScopeID, | 2226 | if (px >= (double)gr.RegionLocX && px < (double)(gr.RegionLocX + gr.RegionSizeX) |
2230 | (int)(px - range), (int)(px), | ||
2231 | (int)(py - range), (int)(py)); | ||
2232 | // m_log.DebugFormat("{0} GetRegionContainingWorldLocation: possibleRegions cnt={1}, range={2}", | ||
2233 | // LogHeader, possibleRegions.Count, range); | ||
2234 | if (possibleRegions != null && possibleRegions.Count > 0) | ||
2235 | { | ||
2236 | // If we found some regions, check to see if the point is within | ||
2237 | foreach (GridRegion gr in possibleRegions) | ||
2238 | { | ||
2239 | // m_log.DebugFormat("{0} GetRegionContainingWorldLocation: possibleRegion nm={1}, regionLoc=<{2},{3}>, regionSize=<{4},{5}>", | ||
2240 | // LogHeader, gr.RegionName, gr.RegionLocX, gr.RegionLocY, gr.RegionSizeX, gr.RegionSizeY); | ||
2241 | if (px >= (double)gr.RegionLocX && px < (double)(gr.RegionLocX + gr.RegionSizeX) | ||
2242 | && py >= (double)gr.RegionLocY && py < (double)(gr.RegionLocY + gr.RegionSizeY)) | 2227 | && py >= (double)gr.RegionLocY && py < (double)(gr.RegionLocY + gr.RegionSizeY)) |
2243 | { | 2228 | { |
2244 | // Found a region that contains the point | 2229 | // Found a region that contains the point |
2245 | ret = gr; | 2230 | return gr; |
2246 | // m_log.DebugFormat("{0} GetRegionContainingWorldLocation: found. RegionName={1}", LogHeader, ret.RegionName); | 2231 | // m_log.DebugFormat("{0} GetRegionContainingWorldLocation: found. RegionName={1}", LogHeader, ret.RegionName); |
2247 | break; | ||
2248 | } | ||
2249 | } | ||
2250 | } | 2232 | } |
2251 | // Larger search area for next time around if not found | ||
2252 | range *= 2; | ||
2253 | } | 2233 | } |
2254 | } | 2234 | } |
2255 | 2235 | ||
2256 | if (ret == null) | 2236 | // remember this location was not found so we can quickly not find it next time |
2257 | { | 2237 | m_notFoundLocationCache.Add(px, py); |
2258 | // remember this location was not found so we can quickly not find it next time | 2238 | // m_log.DebugFormat("{0} GetRegionContainingWorldLocation: Not found. Remembering loc=<{1},{2}>", LogHeader, px, py); |
2259 | m_notFoundLocationCache.Add(px, py); | 2239 | return null; |
2260 | // m_log.DebugFormat("{0} GetRegionContainingWorldLocation: Not found. Remembering loc=<{1},{2}>", LogHeader, px, py); | ||
2261 | } | ||
2262 | |||
2263 | return ret; | ||
2264 | } | 2240 | } |
2265 | 2241 | ||
2266 | private void InformClientOfNeighbourCompleted(IAsyncResult iar) | 2242 | private void InformClientOfNeighbourCompleted(IAsyncResult iar) |