diff options
Diffstat (limited to 'OpenSim/Region/CoreModules/World/Land/RegionCombinerModule.cs')
-rw-r--r-- | OpenSim/Region/CoreModules/World/Land/RegionCombinerModule.cs | 640 |
1 files changed, 640 insertions, 0 deletions
diff --git a/OpenSim/Region/CoreModules/World/Land/RegionCombinerModule.cs b/OpenSim/Region/CoreModules/World/Land/RegionCombinerModule.cs new file mode 100644 index 0000000..5ba6f39 --- /dev/null +++ b/OpenSim/Region/CoreModules/World/Land/RegionCombinerModule.cs | |||
@@ -0,0 +1,640 @@ | |||
1 | using System; | ||
2 | using System.Collections.Generic; | ||
3 | using System.Reflection; | ||
4 | using log4net; | ||
5 | using Nini.Config; | ||
6 | using OpenMetaverse; | ||
7 | using OpenSim.Framework; | ||
8 | using OpenSim.Region.Framework.Interfaces; | ||
9 | using OpenSim.Region.Framework.Scenes; | ||
10 | |||
11 | namespace OpenSim.Region.CoreModules.World.Land | ||
12 | { | ||
13 | public class RegionCombinerModule : ISharedRegionModule | ||
14 | { | ||
15 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | ||
16 | |||
17 | public string Name { get { return "RegionCombinerModule"; } } | ||
18 | public Type ReplaceableInterface | ||
19 | { | ||
20 | get { return null; } | ||
21 | } | ||
22 | |||
23 | public Type ReplacableInterface { get { return null; } } | ||
24 | |||
25 | private Dictionary<UUID, RegionConnections> m_regions = new Dictionary<UUID, RegionConnections>(); | ||
26 | private bool enabledYN = false; | ||
27 | public void Initialise(IConfigSource source) | ||
28 | { | ||
29 | IConfig myConfig = source.Configs["Startup"]; | ||
30 | enabledYN = myConfig.GetBoolean("CombineContiguiousRegions", false); | ||
31 | } | ||
32 | |||
33 | public void Close() | ||
34 | { | ||
35 | |||
36 | } | ||
37 | |||
38 | public void AddRegion(Scene scene) | ||
39 | { | ||
40 | if (!enabledYN) | ||
41 | return; | ||
42 | |||
43 | RegionConnections regionConnections = new RegionConnections(); | ||
44 | regionConnections.ConnectedRegions = new List<RegionData>(); | ||
45 | regionConnections.RegionScene = scene; | ||
46 | regionConnections.RegionLandChannel = scene.LandChannel; | ||
47 | regionConnections.RegionId = scene.RegionInfo.originRegionID; | ||
48 | regionConnections.X = scene.RegionInfo.RegionLocX; | ||
49 | regionConnections.Y = scene.RegionInfo.RegionLocY; | ||
50 | regionConnections.XEnd = (int)Constants.RegionSize; | ||
51 | regionConnections.YEnd = (int)Constants.RegionSize; | ||
52 | lock (m_regions) | ||
53 | { | ||
54 | bool connectedYN = false; | ||
55 | |||
56 | foreach (RegionConnections conn in m_regions.Values) | ||
57 | { | ||
58 | #region commented | ||
59 | /* | ||
60 | // If we're one region over +x +y | ||
61 | //xxy | ||
62 | //xxx | ||
63 | //xxx | ||
64 | if ((((int)conn.X * (int)Constants.RegionSize) + conn.XEnd | ||
65 | == (regionConnections.X * (int)Constants.RegionSize)) | ||
66 | && (((int)conn.Y * (int)Constants.RegionSize) - conn.YEnd | ||
67 | == (regionConnections.Y * (int)Constants.RegionSize))) | ||
68 | { | ||
69 | Vector3 offset = Vector3.Zero; | ||
70 | offset.X = (((regionConnections.X * (int) Constants.RegionSize)) - | ||
71 | ((conn.X * (int) Constants.RegionSize))); | ||
72 | offset.Y = (((regionConnections.Y * (int) Constants.RegionSize)) - | ||
73 | ((conn.Y * (int) Constants.RegionSize))); | ||
74 | |||
75 | Vector3 extents = Vector3.Zero; | ||
76 | extents.Y = regionConnections.YEnd + conn.YEnd; | ||
77 | extents.X = conn.XEnd + conn.XEnd; | ||
78 | |||
79 | m_log.DebugFormat("Scene: {0} to the northwest of Scene{1}. Offset: {2}. Extents:{3}", | ||
80 | conn.RegionScene.RegionInfo.RegionName, | ||
81 | regionConnections.RegionScene.RegionInfo.RegionName, | ||
82 | offset, extents); | ||
83 | |||
84 | scene.PhysicsScene.Combine(conn.RegionScene.PhysicsScene, offset, extents); | ||
85 | |||
86 | connectedYN = true; | ||
87 | break; | ||
88 | } | ||
89 | */ | ||
90 | |||
91 | /* | ||
92 | //If we're one region over x +y | ||
93 | //xxx | ||
94 | //xxx | ||
95 | //xyx | ||
96 | if ((((int)conn.X * (int)Constants.RegionSize) | ||
97 | == (regionConnections.X * (int)Constants.RegionSize)) | ||
98 | && (((int)conn.Y * (int)Constants.RegionSize) - conn.YEnd | ||
99 | == (regionConnections.Y * (int)Constants.RegionSize))) | ||
100 | { | ||
101 | Vector3 offset = Vector3.Zero; | ||
102 | offset.X = (((regionConnections.X * (int)Constants.RegionSize)) - | ||
103 | ((conn.X * (int)Constants.RegionSize))); | ||
104 | offset.Y = (((regionConnections.Y * (int)Constants.RegionSize)) - | ||
105 | ((conn.Y * (int)Constants.RegionSize))); | ||
106 | |||
107 | Vector3 extents = Vector3.Zero; | ||
108 | extents.Y = regionConnections.YEnd + conn.YEnd; | ||
109 | extents.X = conn.XEnd; | ||
110 | |||
111 | m_log.DebugFormat("Scene: {0} to the north of Scene{1}. Offset: {2}. Extents:{3}", | ||
112 | conn.RegionScene.RegionInfo.RegionName, | ||
113 | regionConnections.RegionScene.RegionInfo.RegionName, offset, extents); | ||
114 | |||
115 | scene.PhysicsScene.Combine(conn.RegionScene.PhysicsScene, offset, extents); | ||
116 | connectedYN = true; | ||
117 | break; | ||
118 | } | ||
119 | */ | ||
120 | |||
121 | /* | ||
122 | // If we're one region over -x +y | ||
123 | //xxx | ||
124 | //xxx | ||
125 | //yxx | ||
126 | if ((((int)conn.X * (int)Constants.RegionSize) - conn.XEnd | ||
127 | == (regionConnections.X * (int)Constants.RegionSize)) | ||
128 | && (((int)conn.Y * (int)Constants.RegionSize) - conn.YEnd | ||
129 | == (regionConnections.Y * (int)Constants.RegionSize))) | ||
130 | { | ||
131 | Vector3 offset = Vector3.Zero; | ||
132 | offset.X = (((regionConnections.X * (int)Constants.RegionSize)) - | ||
133 | ((conn.X * (int)Constants.RegionSize))); | ||
134 | offset.Y = (((regionConnections.Y * (int)Constants.RegionSize)) - | ||
135 | ((conn.Y * (int)Constants.RegionSize))); | ||
136 | |||
137 | Vector3 extents = Vector3.Zero; | ||
138 | extents.Y = regionConnections.YEnd + conn.YEnd; | ||
139 | extents.X = conn.XEnd + conn.XEnd; | ||
140 | |||
141 | m_log.DebugFormat("Scene: {0} to the northeast of Scene. Offset: {2}. Extents:{3}", | ||
142 | conn.RegionScene.RegionInfo.RegionName, | ||
143 | regionConnections.RegionScene.RegionInfo.RegionName, offset, extents); | ||
144 | |||
145 | scene.PhysicsScene.Combine(conn.RegionScene.PhysicsScene, offset, extents); | ||
146 | |||
147 | |||
148 | connectedYN = true; | ||
149 | break; | ||
150 | } | ||
151 | */ | ||
152 | |||
153 | /* | ||
154 | // If we're one region over -x y | ||
155 | //xxx | ||
156 | //yxx | ||
157 | //xxx | ||
158 | if ((((int)conn.X * (int)Constants.RegionSize) - conn.XEnd | ||
159 | == (regionConnections.X * (int)Constants.RegionSize)) | ||
160 | && (((int)conn.Y * (int)Constants.RegionSize) | ||
161 | == (regionConnections.Y * (int)Constants.RegionSize))) | ||
162 | { | ||
163 | Vector3 offset = Vector3.Zero; | ||
164 | offset.X = (((regionConnections.X * (int)Constants.RegionSize)) - | ||
165 | ((conn.X * (int)Constants.RegionSize))); | ||
166 | offset.Y = (((regionConnections.Y * (int)Constants.RegionSize)) - | ||
167 | ((conn.Y * (int)Constants.RegionSize))); | ||
168 | |||
169 | Vector3 extents = Vector3.Zero; | ||
170 | extents.Y = regionConnections.YEnd; | ||
171 | extents.X = conn.XEnd + conn.XEnd; | ||
172 | |||
173 | m_log.DebugFormat("Scene: {0} to the east of Scene{1} Offset: {2}. Extents:{3}", | ||
174 | conn.RegionScene.RegionInfo.RegionName, | ||
175 | regionConnections.RegionScene.RegionInfo.RegionName, offset, extents); | ||
176 | |||
177 | scene.PhysicsScene.Combine(conn.RegionScene.PhysicsScene, offset, extents); | ||
178 | |||
179 | connectedYN = true; | ||
180 | break; | ||
181 | } | ||
182 | */ | ||
183 | |||
184 | /* | ||
185 | // If we're one region over -x -y | ||
186 | //yxx | ||
187 | //xxx | ||
188 | //xxx | ||
189 | if ((((int)conn.X * (int)Constants.RegionSize) - conn.XEnd | ||
190 | == (regionConnections.X * (int)Constants.RegionSize)) | ||
191 | && (((int)conn.Y * (int)Constants.RegionSize) + conn.YEnd | ||
192 | == (regionConnections.Y * (int)Constants.RegionSize))) | ||
193 | { | ||
194 | Vector3 offset = Vector3.Zero; | ||
195 | offset.X = (((regionConnections.X * (int)Constants.RegionSize)) - | ||
196 | ((conn.X * (int)Constants.RegionSize))); | ||
197 | offset.Y = (((regionConnections.Y * (int)Constants.RegionSize)) - | ||
198 | ((conn.Y * (int)Constants.RegionSize))); | ||
199 | |||
200 | Vector3 extents = Vector3.Zero; | ||
201 | extents.Y = regionConnections.YEnd + conn.YEnd; | ||
202 | extents.X = conn.XEnd + conn.XEnd; | ||
203 | |||
204 | m_log.DebugFormat("Scene: {0} to the northeast of Scene{1} Offset: {2}. Extents:{3}", | ||
205 | conn.RegionScene.RegionInfo.RegionName, | ||
206 | regionConnections.RegionScene.RegionInfo.RegionName, offset, extents); | ||
207 | |||
208 | scene.PhysicsScene.Combine(conn.RegionScene.PhysicsScene, offset, extents); | ||
209 | |||
210 | connectedYN = true; | ||
211 | break; | ||
212 | } | ||
213 | */ | ||
214 | #endregion | ||
215 | |||
216 | // If we're one region over +x y | ||
217 | //xxx | ||
218 | //xxy | ||
219 | //xxx | ||
220 | if ((((int)conn.X * (int)Constants.RegionSize) + conn.XEnd | ||
221 | >= (regionConnections.X * (int)Constants.RegionSize)) | ||
222 | && (((int)conn.Y * (int)Constants.RegionSize) | ||
223 | >= (regionConnections.Y * (int)Constants.RegionSize))) | ||
224 | { | ||
225 | Vector3 offset = Vector3.Zero; | ||
226 | offset.X = (((regionConnections.X * (int)Constants.RegionSize)) - | ||
227 | ((conn.X * (int)Constants.RegionSize))); | ||
228 | offset.Y = (((regionConnections.Y * (int)Constants.RegionSize)) - | ||
229 | ((conn.Y * (int)Constants.RegionSize))); | ||
230 | |||
231 | Vector3 extents = Vector3.Zero; | ||
232 | extents.Y = conn.YEnd; | ||
233 | extents.X = conn.XEnd + regionConnections.XEnd; | ||
234 | |||
235 | conn.UpdateExtents(extents); | ||
236 | |||
237 | |||
238 | m_log.DebugFormat("Scene: {0} to the west of Scene{1} Offset: {2}. Extents:{3}", | ||
239 | conn.RegionScene.RegionInfo.RegionName, | ||
240 | regionConnections.RegionScene.RegionInfo.RegionName, offset, extents); | ||
241 | |||
242 | |||
243 | scene.BordersLocked = true; | ||
244 | conn.RegionScene.BordersLocked = true; | ||
245 | |||
246 | RegionData ConnectedRegion = new RegionData(); | ||
247 | ConnectedRegion.Offset = offset; | ||
248 | ConnectedRegion.RegionId = scene.RegionInfo.originRegionID; | ||
249 | ConnectedRegion.RegionScene = scene; | ||
250 | conn.ConnectedRegions.Add(ConnectedRegion); | ||
251 | |||
252 | conn.RegionScene.PhysicsScene.Combine(null, Vector3.Zero, extents); | ||
253 | scene.PhysicsScene.Combine(conn.RegionScene.PhysicsScene, offset, Vector3.Zero); | ||
254 | |||
255 | lock (conn.RegionScene.EastBorders) | ||
256 | conn.RegionScene.EastBorders[0].BorderLine.Z += (int)Constants.RegionSize; | ||
257 | |||
258 | lock (conn.RegionScene.NorthBorders) | ||
259 | conn.RegionScene.NorthBorders[0].BorderLine.Y += (int)Constants.RegionSize; | ||
260 | |||
261 | lock (conn.RegionScene.SouthBorders) | ||
262 | conn.RegionScene.SouthBorders[0].BorderLine.Y += (int)Constants.RegionSize; | ||
263 | |||
264 | lock (scene.WestBorders) | ||
265 | scene.WestBorders[0].BorderLine.Z += (int)Constants.RegionSize; //auto teleport West | ||
266 | |||
267 | // Reset Terrain.. since terrain normally loads first. | ||
268 | // | ||
269 | scene.PhysicsScene.SetTerrain(scene.Heightmap.GetFloatsSerialised()); | ||
270 | //conn.RegionScene.PhysicsScene.SetTerrain(conn.RegionScene.Heightmap.GetFloatsSerialised()); | ||
271 | |||
272 | conn.RegionScene.BordersLocked = false; | ||
273 | scene.BordersLocked = false; | ||
274 | connectedYN = true; | ||
275 | break; | ||
276 | } | ||
277 | |||
278 | |||
279 | |||
280 | // If we're one region over x +y | ||
281 | //xyx | ||
282 | //xxx | ||
283 | //xxx | ||
284 | if ((((int)conn.X * (int)Constants.RegionSize) | ||
285 | >= (regionConnections.X * (int)Constants.RegionSize)) | ||
286 | && (((int)conn.Y * (int)Constants.RegionSize) + conn.YEnd | ||
287 | >= (regionConnections.Y * (int)Constants.RegionSize))) | ||
288 | { | ||
289 | Vector3 offset = Vector3.Zero; | ||
290 | offset.X = (((regionConnections.X * (int)Constants.RegionSize)) - | ||
291 | ((conn.X * (int)Constants.RegionSize))); | ||
292 | offset.Y = (((regionConnections.Y * (int)Constants.RegionSize)) - | ||
293 | ((conn.Y * (int)Constants.RegionSize))); | ||
294 | |||
295 | Vector3 extents = Vector3.Zero; | ||
296 | extents.Y = regionConnections.YEnd + conn.YEnd; | ||
297 | extents.X = conn.XEnd; | ||
298 | conn.UpdateExtents(extents); | ||
299 | |||
300 | |||
301 | scene.BordersLocked = true; | ||
302 | conn.RegionScene.BordersLocked = true; | ||
303 | |||
304 | RegionData ConnectedRegion = new RegionData(); | ||
305 | ConnectedRegion.Offset = offset; | ||
306 | ConnectedRegion.RegionId = scene.RegionInfo.originRegionID; | ||
307 | ConnectedRegion.RegionScene = scene; | ||
308 | conn.ConnectedRegions.Add(ConnectedRegion); | ||
309 | |||
310 | m_log.DebugFormat("Scene: {0} to the northeast of Scene{1} Offset: {2}. Extents:{3}", | ||
311 | conn.RegionScene.RegionInfo.RegionName, | ||
312 | regionConnections.RegionScene.RegionInfo.RegionName, offset, extents); | ||
313 | conn.RegionScene.PhysicsScene.Combine(null,Vector3.Zero,extents); | ||
314 | scene.PhysicsScene.Combine(conn.RegionScene.PhysicsScene, offset, Vector3.Zero); | ||
315 | |||
316 | lock(conn.RegionScene.NorthBorders) | ||
317 | conn.RegionScene.NorthBorders[0].BorderLine.Z += (int)Constants.RegionSize; | ||
318 | lock(conn.RegionScene.EastBorders) | ||
319 | conn.RegionScene.EastBorders[0].BorderLine.Y += (int)Constants.RegionSize; | ||
320 | lock(conn.RegionScene.WestBorders) | ||
321 | conn.RegionScene.WestBorders[0].BorderLine.Y += (int)Constants.RegionSize; | ||
322 | lock(scene.SouthBorders) | ||
323 | scene.SouthBorders[0].BorderLine.Z += (int)Constants.RegionSize; //auto teleport south | ||
324 | |||
325 | // Reset Terrain.. since terrain normally loads first. | ||
326 | //conn.RegionScene.PhysicsScene.SetTerrain(conn.RegionScene.Heightmap.GetFloatsSerialised()); | ||
327 | scene.PhysicsScene.SetTerrain(scene.Heightmap.GetFloatsSerialised()); | ||
328 | //conn.RegionScene.PhysicsScene.SetTerrain(conn.RegionScene.Heightmap.GetFloatsSerialised()); | ||
329 | |||
330 | scene.BordersLocked = false; | ||
331 | conn.RegionScene.BordersLocked = false; | ||
332 | |||
333 | connectedYN = true; | ||
334 | break; | ||
335 | } | ||
336 | |||
337 | // If we're one region over +x +y | ||
338 | //xxy | ||
339 | //xxx | ||
340 | //xxx | ||
341 | if ((((int)conn.X * (int)Constants.RegionSize) + conn.YEnd | ||
342 | >= (regionConnections.X * (int)Constants.RegionSize)) | ||
343 | && (((int)conn.Y * (int)Constants.RegionSize) + conn.YEnd | ||
344 | >= (regionConnections.Y * (int)Constants.RegionSize))) | ||
345 | { | ||
346 | Vector3 offset = Vector3.Zero; | ||
347 | offset.X = (((regionConnections.X * (int)Constants.RegionSize)) - | ||
348 | ((conn.X * (int)Constants.RegionSize))); | ||
349 | offset.Y = (((regionConnections.Y * (int)Constants.RegionSize)) - | ||
350 | ((conn.Y * (int)Constants.RegionSize))); | ||
351 | |||
352 | Vector3 extents = Vector3.Zero; | ||
353 | extents.Y = regionConnections.YEnd + conn.YEnd; | ||
354 | extents.X = regionConnections.XEnd + conn.XEnd; | ||
355 | conn.UpdateExtents(extents); | ||
356 | |||
357 | scene.BordersLocked = true; | ||
358 | conn.RegionScene.BordersLocked = true; | ||
359 | |||
360 | RegionData ConnectedRegion = new RegionData(); | ||
361 | ConnectedRegion.Offset = offset; | ||
362 | ConnectedRegion.RegionId = scene.RegionInfo.originRegionID; | ||
363 | ConnectedRegion.RegionScene = scene; | ||
364 | |||
365 | conn.ConnectedRegions.Add(ConnectedRegion); | ||
366 | |||
367 | m_log.DebugFormat("Scene: {0} to the NorthEast of Scene{1} Offset: {2}. Extents:{3}", | ||
368 | conn.RegionScene.RegionInfo.RegionName, | ||
369 | regionConnections.RegionScene.RegionInfo.RegionName, offset, extents); | ||
370 | |||
371 | conn.RegionScene.PhysicsScene.Combine(null, Vector3.Zero, extents); | ||
372 | scene.PhysicsScene.Combine(conn.RegionScene.PhysicsScene, offset, Vector3.Zero); | ||
373 | lock(conn.RegionScene.NorthBorders) | ||
374 | if (conn.RegionScene.NorthBorders.Count == 1)// && 2) | ||
375 | { | ||
376 | //compound border | ||
377 | // already locked above | ||
378 | conn.RegionScene.NorthBorders[0].BorderLine.Z += (int)Constants.RegionSize; | ||
379 | |||
380 | lock(conn.RegionScene.EastBorders) | ||
381 | conn.RegionScene.EastBorders[0].BorderLine.Y += (int)Constants.RegionSize; | ||
382 | lock(conn.RegionScene.WestBorders) | ||
383 | conn.RegionScene.WestBorders[0].BorderLine.Y += (int)Constants.RegionSize; | ||
384 | |||
385 | |||
386 | |||
387 | } | ||
388 | lock(scene.SouthBorders) | ||
389 | scene.SouthBorders[0].BorderLine.Z += (int)Constants.RegionSize; //auto teleport south | ||
390 | |||
391 | lock(conn.RegionScene.EastBorders) | ||
392 | if (conn.RegionScene.EastBorders.Count == 1)// && conn.RegionScene.EastBorders.Count == 2) | ||
393 | { | ||
394 | |||
395 | conn.RegionScene.EastBorders[0].BorderLine.Z += (int)Constants.RegionSize; | ||
396 | lock(conn.RegionScene.NorthBorders) | ||
397 | conn.RegionScene.NorthBorders[0].BorderLine.Y += (int)Constants.RegionSize; | ||
398 | lock(conn.RegionScene.SouthBorders) | ||
399 | conn.RegionScene.SouthBorders[0].BorderLine.Y += (int)Constants.RegionSize; | ||
400 | |||
401 | |||
402 | } | ||
403 | |||
404 | lock (scene.WestBorders) | ||
405 | scene.WestBorders[0].BorderLine.Z += (int)Constants.RegionSize; //auto teleport West | ||
406 | /* | ||
407 | else | ||
408 | { | ||
409 | conn.RegionScene.NorthBorders[0].BorderLine.Z += (int)Constants.RegionSize; | ||
410 | conn.RegionScene.EastBorders[0].BorderLine.Y += (int)Constants.RegionSize; | ||
411 | conn.RegionScene.WestBorders[0].BorderLine.Y += (int)Constants.RegionSize; | ||
412 | scene.SouthBorders[0].BorderLine.Z += (int)Constants.RegionSize; //auto teleport south | ||
413 | } | ||
414 | */ | ||
415 | |||
416 | |||
417 | // Reset Terrain.. since terrain normally loads first. | ||
418 | //conn.RegionScene.PhysicsScene.SetTerrain(conn.RegionScene.Heightmap.GetFloatsSerialised()); | ||
419 | scene.PhysicsScene.SetTerrain(scene.Heightmap.GetFloatsSerialised()); | ||
420 | //conn.RegionScene.PhysicsScene.SetTerrain(conn.RegionScene.Heightmap.GetFloatsSerialised()); | ||
421 | scene.BordersLocked = false; | ||
422 | conn.RegionScene.BordersLocked = false; | ||
423 | |||
424 | connectedYN = true; | ||
425 | |||
426 | //scene.PhysicsScene.Combine(conn.RegionScene.PhysicsScene, offset,extents); | ||
427 | |||
428 | break; | ||
429 | } | ||
430 | |||
431 | |||
432 | } | ||
433 | if (!connectedYN) | ||
434 | { | ||
435 | RegionData rdata = new RegionData(); | ||
436 | rdata.Offset = Vector3.Zero; | ||
437 | rdata.RegionId = scene.RegionInfo.originRegionID; | ||
438 | rdata.RegionScene = scene; | ||
439 | regionConnections.RegionLandChannel = scene.LandChannel; | ||
440 | |||
441 | LargeLandChannel lnd = new LargeLandChannel(rdata,scene.LandChannel,regionConnections.ConnectedRegions); | ||
442 | scene.LandChannel = lnd; | ||
443 | |||
444 | m_regions.Add(scene.RegionInfo.originRegionID,regionConnections); | ||
445 | } | ||
446 | |||
447 | } | ||
448 | } | ||
449 | |||
450 | public void RemoveRegion(Scene scene) | ||
451 | { | ||
452 | |||
453 | } | ||
454 | |||
455 | public void RegionLoaded(Scene scene) | ||
456 | { | ||
457 | |||
458 | } | ||
459 | |||
460 | public void PostInitialise() | ||
461 | { | ||
462 | |||
463 | } | ||
464 | public void OnFrame() | ||
465 | { | ||
466 | |||
467 | } | ||
468 | |||
469 | |||
470 | public RegionData GetRegionFromPosition(Vector3 pPosition) | ||
471 | { | ||
472 | pPosition = pPosition/(int) Constants.RegionSize; | ||
473 | int OffsetX = (int) pPosition.X; | ||
474 | int OffsetY = (int) pPosition.Y; | ||
475 | foreach (RegionConnections regConn in m_regions.Values) | ||
476 | { | ||
477 | foreach (RegionData reg in regConn.ConnectedRegions) | ||
478 | { | ||
479 | if (reg.Offset.X == OffsetX && reg.Offset.Y == OffsetY) | ||
480 | return reg; | ||
481 | } | ||
482 | } | ||
483 | return new RegionData(); | ||
484 | } | ||
485 | } | ||
486 | public class RegionConnections | ||
487 | { | ||
488 | public UUID RegionId; | ||
489 | public Scene RegionScene; | ||
490 | public ILandChannel RegionLandChannel; | ||
491 | public uint X; | ||
492 | public uint Y; | ||
493 | public int XEnd; | ||
494 | public int YEnd; | ||
495 | public List<RegionData> ConnectedRegions; | ||
496 | public void UpdateExtents(Vector3 extents) | ||
497 | { | ||
498 | XEnd = (int)extents.X; | ||
499 | YEnd = (int)extents.Y; | ||
500 | } | ||
501 | |||
502 | } | ||
503 | |||
504 | public class RegionData | ||
505 | { | ||
506 | public UUID RegionId; | ||
507 | public Scene RegionScene; | ||
508 | public Vector3 Offset; | ||
509 | |||
510 | } | ||
511 | |||
512 | public class LargeLandChannel : ILandChannel | ||
513 | { | ||
514 | private static readonly ILog m_log = | ||
515 | LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | ||
516 | private RegionData RegData; | ||
517 | private ILandChannel RootRegionLandChannel; | ||
518 | private readonly List<RegionData> RegionConnections; | ||
519 | |||
520 | #region ILandChannel Members | ||
521 | |||
522 | public LargeLandChannel(RegionData regData, ILandChannel rootRegionLandChannel,List<RegionData> regionConnections) | ||
523 | { | ||
524 | RegData = regData; | ||
525 | RootRegionLandChannel = rootRegionLandChannel; | ||
526 | RegionConnections = regionConnections; | ||
527 | } | ||
528 | |||
529 | public List<ILandObject> ParcelsNearPoint(Vector3 position) | ||
530 | { | ||
531 | m_log.DebugFormat("[LANDPARCELNEARPOINT]: {0}>", position); | ||
532 | return RootRegionLandChannel.ParcelsNearPoint(position - RegData.Offset); | ||
533 | } | ||
534 | |||
535 | public List<ILandObject> AllParcels() | ||
536 | { | ||
537 | |||
538 | return RootRegionLandChannel.AllParcels(); | ||
539 | |||
540 | } | ||
541 | |||
542 | public ILandObject GetLandObject(int x, int y) | ||
543 | { | ||
544 | m_log.DebugFormat("[BIGLANDTESTINT]: <{0},{1}>", x, y); | ||
545 | |||
546 | if (x > 0 && x <= (int)Constants.RegionSize && y > 0 && y <= (int)Constants.RegionSize) | ||
547 | { | ||
548 | return RootRegionLandChannel.GetLandObject(x, y); | ||
549 | } | ||
550 | else | ||
551 | { | ||
552 | int offsetX = (x / (int)Constants.RegionSize); | ||
553 | int offsetY = (x / (int)Constants.RegionSize); | ||
554 | offsetX *= (int)Constants.RegionSize; | ||
555 | offsetY *= (int)Constants.RegionSize; | ||
556 | |||
557 | foreach (RegionData regionData in RegionConnections) | ||
558 | { | ||
559 | if (regionData.Offset.X == offsetX && regionData.Offset.Y == offsetY) | ||
560 | { | ||
561 | return regionData.RegionScene.LandChannel.GetLandObject(x - offsetX, y - offsetY); | ||
562 | } | ||
563 | } | ||
564 | ILandObject obj = new LandObject(UUID.Zero, false, RegData.RegionScene); | ||
565 | obj.landData.Name = "NO LAND"; | ||
566 | return obj; | ||
567 | } | ||
568 | } | ||
569 | |||
570 | public ILandObject GetLandObject(int localID) | ||
571 | { | ||
572 | return RootRegionLandChannel.GetLandObject(localID); | ||
573 | } | ||
574 | |||
575 | public ILandObject GetLandObject(float x, float y) | ||
576 | { | ||
577 | m_log.DebugFormat("[BIGLANDTESTFLOAT]: <{0},{1}>", x, y); | ||
578 | |||
579 | if (x > 0 && x <= (int)Constants.RegionSize && y > 0 && y <= (int)Constants.RegionSize) | ||
580 | { | ||
581 | return RootRegionLandChannel.GetLandObject(x, y); | ||
582 | } | ||
583 | else | ||
584 | { | ||
585 | int offsetX = (int)(x/(int) Constants.RegionSize); | ||
586 | int offsetY = (int)(x/(int) Constants.RegionSize); | ||
587 | offsetX *= (int) Constants.RegionSize; | ||
588 | offsetY *= (int) Constants.RegionSize; | ||
589 | |||
590 | foreach (RegionData regionData in RegionConnections) | ||
591 | { | ||
592 | if (regionData.Offset.X == offsetX && regionData.Offset.Y == offsetY) | ||
593 | { | ||
594 | return regionData.RegionScene.LandChannel.GetLandObject(x - offsetX, y - offsetY); | ||
595 | } | ||
596 | } | ||
597 | ILandObject obj = new LandObject(UUID.Zero, false, RegData.RegionScene); | ||
598 | obj.landData.Name = "NO LAND"; | ||
599 | return obj; | ||
600 | } | ||
601 | } | ||
602 | |||
603 | public bool IsLandPrimCountTainted() | ||
604 | { | ||
605 | return RootRegionLandChannel.IsLandPrimCountTainted(); | ||
606 | } | ||
607 | |||
608 | public bool IsForcefulBansAllowed() | ||
609 | { | ||
610 | return RootRegionLandChannel.IsForcefulBansAllowed(); | ||
611 | } | ||
612 | |||
613 | public void UpdateLandObject(int localID, LandData data) | ||
614 | { | ||
615 | RootRegionLandChannel.UpdateLandObject(localID, data); | ||
616 | } | ||
617 | |||
618 | public void ReturnObjectsInParcel(int localID, uint returnType, UUID[] agentIDs, UUID[] taskIDs, IClientAPI remoteClient) | ||
619 | { | ||
620 | RootRegionLandChannel.ReturnObjectsInParcel(localID, returnType, agentIDs, taskIDs, remoteClient); | ||
621 | } | ||
622 | |||
623 | public void setParcelObjectMaxOverride(overrideParcelMaxPrimCountDelegate overrideDel) | ||
624 | { | ||
625 | RootRegionLandChannel.setParcelObjectMaxOverride(overrideDel); | ||
626 | } | ||
627 | |||
628 | public void setSimulatorObjectMaxOverride(overrideSimulatorMaxPrimCountDelegate overrideDel) | ||
629 | { | ||
630 | RootRegionLandChannel.setSimulatorObjectMaxOverride(overrideDel); | ||
631 | } | ||
632 | |||
633 | public void SetParcelOtherCleanTime(IClientAPI remoteClient, int localID, int otherCleanTime) | ||
634 | { | ||
635 | RootRegionLandChannel.SetParcelOtherCleanTime(remoteClient, localID, otherCleanTime); | ||
636 | } | ||
637 | |||
638 | #endregion | ||
639 | } | ||
640 | } | ||