diff options
author | Diva Canto | 2009-10-05 09:02:52 -0700 |
---|---|---|
committer | Diva Canto | 2009-10-05 09:02:52 -0700 |
commit | ad81b453b38b538d5b4c40a326decee2577e024e (patch) | |
tree | 91c2a737700aef0ec8175508d5fb744a3d4fd5a9 /OpenSim/Region | |
parent | Eliminate pinned Mesh data on managed heap by using IntPtrs to memory allocat... (diff) | |
download | opensim-SC-ad81b453b38b538d5b4c40a326decee2577e024e.zip opensim-SC-ad81b453b38b538d5b4c40a326decee2577e024e.tar.gz opensim-SC-ad81b453b38b538d5b4c40a326decee2577e024e.tar.bz2 opensim-SC-ad81b453b38b538d5b4c40a326decee2577e024e.tar.xz |
GetRegionByPosition: use the cache, Luke.
Diffstat (limited to 'OpenSim/Region')
-rw-r--r-- | OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/LocalGridServiceConnector.cs | 14 | ||||
-rw-r--r-- | OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/RegionCache.cs | 14 |
2 files changed, 28 insertions, 0 deletions
diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/LocalGridServiceConnector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/LocalGridServiceConnector.cs index 3ca4882..1c72488 100644 --- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/LocalGridServiceConnector.cs +++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/LocalGridServiceConnector.cs | |||
@@ -206,6 +206,20 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid | |||
206 | 206 | ||
207 | public GridRegion GetRegionByPosition(UUID scopeID, int x, int y) | 207 | public GridRegion GetRegionByPosition(UUID scopeID, int x, int y) |
208 | { | 208 | { |
209 | GridRegion region = null; | ||
210 | |||
211 | // First see if it's a neighbour, even if it isn't on this sim. | ||
212 | // Neighbour data is cached in memory, so this is fast | ||
213 | foreach (RegionCache rcache in m_LocalCache.Values) | ||
214 | { | ||
215 | region = rcache.GetRegionByPosition(x, y); | ||
216 | if (region != null) | ||
217 | { | ||
218 | return region; | ||
219 | } | ||
220 | } | ||
221 | |||
222 | // Then try on this sim (may be a lookup in DB if this is using MySql). | ||
209 | return m_GridService.GetRegionByPosition(scopeID, x, y); | 223 | return m_GridService.GetRegionByPosition(scopeID, x, y); |
210 | } | 224 | } |
211 | 225 | ||
diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/RegionCache.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/RegionCache.cs index 2b336bb..44e850b 100644 --- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/RegionCache.cs +++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/RegionCache.cs | |||
@@ -29,10 +29,12 @@ using System; | |||
29 | using System.Collections.Generic; | 29 | using System.Collections.Generic; |
30 | using System.Reflection; | 30 | using System.Reflection; |
31 | 31 | ||
32 | using OpenSim.Framework; | ||
32 | using OpenSim.Region.Framework.Scenes; | 33 | using OpenSim.Region.Framework.Scenes; |
33 | using OpenSim.Services.Interfaces; | 34 | using OpenSim.Services.Interfaces; |
34 | using GridRegion = OpenSim.Services.Interfaces.GridRegion; | 35 | using GridRegion = OpenSim.Services.Interfaces.GridRegion; |
35 | 36 | ||
37 | using OpenMetaverse; | ||
36 | using log4net; | 38 | using log4net; |
37 | 39 | ||
38 | namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid | 40 | namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid |
@@ -75,5 +77,17 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid | |||
75 | { | 77 | { |
76 | return new List<GridRegion>(m_neighbours.Values); | 78 | return new List<GridRegion>(m_neighbours.Values); |
77 | } | 79 | } |
80 | |||
81 | public GridRegion GetRegionByPosition(int x, int y) | ||
82 | { | ||
83 | uint xsnap = (uint)(x / Constants.RegionSize) * Constants.RegionSize; | ||
84 | uint ysnap = (uint)(y / Constants.RegionSize) * Constants.RegionSize; | ||
85 | ulong handle = Utils.UIntsToLong(xsnap, ysnap); | ||
86 | |||
87 | if (m_neighbours.ContainsKey(handle)) | ||
88 | return m_neighbours[handle]; | ||
89 | |||
90 | return null; | ||
91 | } | ||
78 | } | 92 | } |
79 | } | 93 | } |