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

LSLKeyTest
UbitUmarov 2016-07-31 23:12:09 +01:00
parent c0eae1f8f9
commit 159d722966
1 changed files with 25 additions and 49 deletions

View File

@ -2183,10 +2183,6 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
// Given a world position, get the GridRegion info for
// the region containing that point.
// Not needed on 0.9 grids
// 'pSizeHint' is the size of the source region but since the destination point can be anywhere
// the size of the target region is unknown thus the search area might have to be very large.
// Return 'null' if no such region exists.
protected GridRegion GetRegionContainingWorldLocation(IGridService pGridService, UUID pScopeID,
double px, double py, uint pSizeHint)
{
@ -2194,11 +2190,6 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
GridRegion ret = null;
const double fudge = 2.0;
// One problem with this routine is negative results. That is, this can be called lots of times
// for regions that don't exist. m_notFoundLocationCache remembers 'not found' results so they
// will be quick 'not found's next time.
// NotFoundLocationCache is an expiring cache so it will eventually forget about 'not found' and
// thus re-ask the GridService about the location.
if (m_notFoundLocationCache.Contains(px, py))
{
// m_log.DebugFormat("{0} GetRegionContainingWorldLocation: Not found via cache. loc=<{1},{2}>", LogHeader, px, py);
@ -2207,28 +2198,22 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
// As an optimization, since most regions will be legacy sized regions (256x256), first try to get
// the region at the appropriate legacy region location.
uint possibleX = (uint)Math.Floor(px);
possibleX -= possibleX % Constants.RegionSize;
uint possibleY = (uint)Math.Floor(py);
possibleY -= possibleY % Constants.RegionSize;
// this is all that is needed on 0.9 grids
uint possibleX = (uint)px & 0xffffff00u;
uint possibleY = (uint)py & 0xffffff00u;
ret = pGridService.GetRegionByPosition(pScopeID, (int)possibleX, (int)possibleY);
if (ret != null)
{
// m_log.DebugFormat("{0} GetRegionContainingWorldLocation: Found region using legacy size. rloc=<{1},{2}>. Rname={3}",
// LogHeader, possibleX, possibleY, ret.RegionName);
return ret;
}
if (ret == null)
{
// If the simple lookup failed, search the larger area for a region that contains this point
double range = (double)pSizeHint + fudge;
while (ret == null && range <= (Constants.MaximumRegionSize + Constants.RegionSize))
{
// Get from the grid service a list of regions that might contain this point.
// The region origin will be in the zero direction so only subtract the range.
// for 0.8 regions just make a BIG area request. old code whould do it plus 4 more smaller on region open edges
// this is what 0.9 grids now do internally
List<GridRegion> possibleRegions = pGridService.GetRegionRange(pScopeID,
(int)(px - range), (int)(px),
(int)(py - range), (int)(py));
(int)(px - Constants.MaximumRegionSize), (int)(px + 1), // +1 bc left mb not part of range
(int)(py - Constants.MaximumRegionSize), (int)(py + 1));
// m_log.DebugFormat("{0} GetRegionContainingWorldLocation: possibleRegions cnt={1}, range={2}",
// LogHeader, possibleRegions.Count, range);
if (possibleRegions != null && possibleRegions.Count > 0)
@ -2242,25 +2227,16 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
&& py >= (double)gr.RegionLocY && py < (double)(gr.RegionLocY + gr.RegionSizeY))
{
// Found a region that contains the point
ret = gr;
return gr;
// m_log.DebugFormat("{0} GetRegionContainingWorldLocation: found. RegionName={1}", LogHeader, ret.RegionName);
break;
}
}
}
// Larger search area for next time around if not found
range *= 2;
}
}
if (ret == null)
{
// remember this location was not found so we can quickly not find it next time
m_notFoundLocationCache.Add(px, py);
// m_log.DebugFormat("{0} GetRegionContainingWorldLocation: Not found. Remembering loc=<{1},{2}>", LogHeader, px, py);
}
return ret;
return null;
}
private void InformClientOfNeighbourCompleted(IAsyncResult iar)