GetRegionByPosition: use the cache, Luke.
parent
6d52974c5f
commit
ad81b453b3
|
@ -206,6 +206,20 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid
|
||||||
|
|
||||||
public GridRegion GetRegionByPosition(UUID scopeID, int x, int y)
|
public GridRegion GetRegionByPosition(UUID scopeID, int x, int y)
|
||||||
{
|
{
|
||||||
|
GridRegion region = null;
|
||||||
|
|
||||||
|
// First see if it's a neighbour, even if it isn't on this sim.
|
||||||
|
// Neighbour data is cached in memory, so this is fast
|
||||||
|
foreach (RegionCache rcache in m_LocalCache.Values)
|
||||||
|
{
|
||||||
|
region = rcache.GetRegionByPosition(x, y);
|
||||||
|
if (region != null)
|
||||||
|
{
|
||||||
|
return region;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Then try on this sim (may be a lookup in DB if this is using MySql).
|
||||||
return m_GridService.GetRegionByPosition(scopeID, x, y);
|
return m_GridService.GetRegionByPosition(scopeID, x, y);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -29,10 +29,12 @@ using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
|
|
||||||
|
using OpenSim.Framework;
|
||||||
using OpenSim.Region.Framework.Scenes;
|
using OpenSim.Region.Framework.Scenes;
|
||||||
using OpenSim.Services.Interfaces;
|
using OpenSim.Services.Interfaces;
|
||||||
using GridRegion = OpenSim.Services.Interfaces.GridRegion;
|
using GridRegion = OpenSim.Services.Interfaces.GridRegion;
|
||||||
|
|
||||||
|
using OpenMetaverse;
|
||||||
using log4net;
|
using log4net;
|
||||||
|
|
||||||
namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid
|
namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid
|
||||||
|
@ -75,5 +77,17 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid
|
||||||
{
|
{
|
||||||
return new List<GridRegion>(m_neighbours.Values);
|
return new List<GridRegion>(m_neighbours.Values);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public GridRegion GetRegionByPosition(int x, int y)
|
||||||
|
{
|
||||||
|
uint xsnap = (uint)(x / Constants.RegionSize) * Constants.RegionSize;
|
||||||
|
uint ysnap = (uint)(y / Constants.RegionSize) * Constants.RegionSize;
|
||||||
|
ulong handle = Utils.UIntsToLong(xsnap, ysnap);
|
||||||
|
|
||||||
|
if (m_neighbours.ContainsKey(handle))
|
||||||
|
return m_neighbours[handle];
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue