aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/OptionalModules/RegionCombinerModule
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--OpenSim/Region/OptionalModules/RegionCombinerModule/RegionCombinerClientEventForwarder.cs (renamed from OpenSim/Region/RegionCombinerModule/RegionCombinerClientEventForwarder.cs)0
-rw-r--r--OpenSim/Region/OptionalModules/RegionCombinerModule/RegionCombinerIndividualEventForwarder.cs (renamed from OpenSim/Region/RegionCombinerModule/RegionCombinerIndividualEventForwarder.cs)6
-rw-r--r--OpenSim/Region/OptionalModules/RegionCombinerModule/RegionCombinerLargeLandChannel.cs (renamed from OpenSim/Region/RegionCombinerModule/RegionCombinerLargeLandChannel.cs)88
-rw-r--r--OpenSim/Region/OptionalModules/RegionCombinerModule/RegionCombinerModule.cs (renamed from OpenSim/Region/RegionCombinerModule/RegionCombinerModule.cs)334
-rw-r--r--OpenSim/Region/OptionalModules/RegionCombinerModule/RegionCombinerPermissionModule.cs (renamed from OpenSim/Region/RegionCombinerModule/RegionCombinerPermissionModule.cs)2
-rw-r--r--OpenSim/Region/OptionalModules/RegionCombinerModule/RegionConnections.cs (renamed from OpenSim/Region/RegionCombinerModule/RegionConnections.cs)4
-rw-r--r--OpenSim/Region/OptionalModules/RegionCombinerModule/RegionCourseLocation.cs (renamed from OpenSim/Region/RegionCombinerModule/RegionCourseLocation.cs)0
-rw-r--r--OpenSim/Region/OptionalModules/RegionCombinerModule/RegionData.cs (renamed from OpenSim/Region/RegionCombinerModule/RegionData.cs)1
8 files changed, 134 insertions, 301 deletions
diff --git a/OpenSim/Region/RegionCombinerModule/RegionCombinerClientEventForwarder.cs b/OpenSim/Region/OptionalModules/RegionCombinerModule/RegionCombinerClientEventForwarder.cs
index 721d396..721d396 100644
--- a/OpenSim/Region/RegionCombinerModule/RegionCombinerClientEventForwarder.cs
+++ b/OpenSim/Region/OptionalModules/RegionCombinerModule/RegionCombinerClientEventForwarder.cs
diff --git a/OpenSim/Region/RegionCombinerModule/RegionCombinerIndividualEventForwarder.cs b/OpenSim/Region/OptionalModules/RegionCombinerModule/RegionCombinerIndividualEventForwarder.cs
index f424e7f..83732e2 100644
--- a/OpenSim/Region/RegionCombinerModule/RegionCombinerIndividualEventForwarder.cs
+++ b/OpenSim/Region/OptionalModules/RegionCombinerModule/RegionCombinerIndividualEventForwarder.cs
@@ -51,7 +51,8 @@ namespace OpenSim.Region.RegionCombinerModule
51 m_virtScene.UnSubscribeToClientPrimEvents(client); 51 m_virtScene.UnSubscribeToClientPrimEvents(client);
52 m_virtScene.UnSubscribeToClientPrimRezEvents(client); 52 m_virtScene.UnSubscribeToClientPrimRezEvents(client);
53 m_virtScene.UnSubscribeToClientInventoryEvents(client); 53 m_virtScene.UnSubscribeToClientInventoryEvents(client);
54 ((AttachmentsModule)m_virtScene.AttachmentsModule).UnsubscribeFromClientEvents(client); 54 if(m_virtScene.AttachmentsModule != null)
55 ((AttachmentsModule)m_virtScene.AttachmentsModule).UnsubscribeFromClientEvents(client);
55 //m_virtScene.UnSubscribeToClientTeleportEvents(client); 56 //m_virtScene.UnSubscribeToClientTeleportEvents(client);
56 m_virtScene.UnSubscribeToClientScriptEvents(client); 57 m_virtScene.UnSubscribeToClientScriptEvents(client);
57 58
@@ -66,7 +67,8 @@ namespace OpenSim.Region.RegionCombinerModule
66 client.OnRezObject += LocalRezObject; 67 client.OnRezObject += LocalRezObject;
67 68
68 m_rootScene.SubscribeToClientInventoryEvents(client); 69 m_rootScene.SubscribeToClientInventoryEvents(client);
69 ((AttachmentsModule)m_rootScene.AttachmentsModule).SubscribeToClientEvents(client); 70 if (m_rootScene.AttachmentsModule != null)
71 ((AttachmentsModule)m_rootScene.AttachmentsModule).SubscribeToClientEvents(client);
70 //m_rootScene.SubscribeToClientTeleportEvents(client); 72 //m_rootScene.SubscribeToClientTeleportEvents(client);
71 m_rootScene.SubscribeToClientScriptEvents(client); 73 m_rootScene.SubscribeToClientScriptEvents(client);
72 74
diff --git a/OpenSim/Region/RegionCombinerModule/RegionCombinerLargeLandChannel.cs b/OpenSim/Region/OptionalModules/RegionCombinerModule/RegionCombinerLargeLandChannel.cs
index a133e51..4bf2a82 100644
--- a/OpenSim/Region/RegionCombinerModule/RegionCombinerLargeLandChannel.cs
+++ b/OpenSim/Region/OptionalModules/RegionCombinerModule/RegionCombinerLargeLandChannel.cs
@@ -27,6 +27,8 @@
27 27
28using System; 28using System;
29using System.Collections.Generic; 29using System.Collections.Generic;
30using System.Reflection;
31using log4net;
30using OpenMetaverse; 32using OpenMetaverse;
31using OpenSim.Framework; 33using OpenSim.Framework;
32using OpenSim.Region.Framework.Interfaces; 34using OpenSim.Region.Framework.Interfaces;
@@ -34,10 +36,10 @@ using OpenSim.Region.CoreModules.World.Land;
34 36
35namespace OpenSim.Region.RegionCombinerModule 37namespace OpenSim.Region.RegionCombinerModule
36{ 38{
37public class RegionCombinerLargeLandChannel : ILandChannel 39 public class RegionCombinerLargeLandChannel : ILandChannel
38 { 40 {
39 // private static readonly ILog m_log = 41// private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
40 // LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); 42
41 private RegionData RegData; 43 private RegionData RegData;
42 private ILandChannel RootRegionLandChannel; 44 private ILandChannel RootRegionLandChannel;
43 private readonly List<RegionData> RegionConnections; 45 private readonly List<RegionData> RegionConnections;
@@ -68,42 +70,58 @@ public class RegionCombinerLargeLandChannel : ILandChannel
68 RootRegionLandChannel.Clear(setupDefaultParcel); 70 RootRegionLandChannel.Clear(setupDefaultParcel);
69 } 71 }
70 72
71 public ILandObject GetLandObject(int x, int y) 73 public ILandObject GetLandObject(Vector3 position)
72 { 74 {
73 //m_log.DebugFormat("[BIGLANDTESTINT]: <{0},{1}>", x, y); 75 return GetLandObject(position.X, position.Y);
74 76 }
75 if (x > 0 && x <= (int)Constants.RegionSize && y > 0 && y <= (int)Constants.RegionSize)
76 {
77 return RootRegionLandChannel.GetLandObject(x, y);
78 }
79 else
80 {
81 int offsetX = (x / (int)Constants.RegionSize);
82 int offsetY = (y / (int)Constants.RegionSize);
83 offsetX *= (int)Constants.RegionSize;
84 offsetY *= (int)Constants.RegionSize;
85 77
86 foreach (RegionData regionData in RegionConnections) 78 public ILandObject GetLandObject(int x, int y)
87 { 79 {
88 if (regionData.Offset.X == offsetX && regionData.Offset.Y == offsetY) 80 return GetLandObject((float)x, (float)y);
89 { 81
90 return regionData.RegionScene.LandChannel.GetLandObject(x - offsetX, y - offsetY); 82// m_log.DebugFormat("[BIGLANDTESTINT]: <{0},{1}>", x, y);
91 } 83//
92 } 84// if (x > 0 && x <= (int)Constants.RegionSize && y > 0 && y <= (int)Constants.RegionSize)
93 ILandObject obj = new LandObject(UUID.Zero, false, RegData.RegionScene); 85// {
94 obj.LandData.Name = "NO LAND"; 86// return RootRegionLandChannel.GetLandObject(x, y);
95 return obj; 87// }
96 } 88// else
89// {
90// int offsetX = (x / (int)Constants.RegionSize);
91// int offsetY = (y / (int)Constants.RegionSize);
92// offsetX *= (int)Constants.RegionSize;
93// offsetY *= (int)Constants.RegionSize;
94//
95// foreach (RegionData regionData in RegionConnections)
96// {
97// if (regionData.Offset.X == offsetX && regionData.Offset.Y == offsetY)
98// {
99// m_log.DebugFormat(
100// "[REGION COMBINER LARGE LAND CHANNEL]: Found region {0} at offset {1},{2}",
101// regionData.RegionScene.Name, offsetX, offsetY);
102//
103// return regionData.RegionScene.LandChannel.GetLandObject(x - offsetX, y - offsetY);
104// }
105// }
106// //ILandObject obj = new LandObject(UUID.Zero, false, RegData.RegionScene);
107// //obj.LandData.Name = "NO LAND";
108// //return obj;
109// }
110//
111// m_log.DebugFormat("[REGION COMBINER LARGE LAND CHANNEL]: No region found at {0},{1}, returning null", x, y);
112//
113// return null;
97 } 114 }
98 115
99 public ILandObject GetLandObject(int localID) 116 public ILandObject GetLandObject(int localID)
100 { 117 {
118 // XXX: Possibly should be looking in every land channel, not just the root.
101 return RootRegionLandChannel.GetLandObject(localID); 119 return RootRegionLandChannel.GetLandObject(localID);
102 } 120 }
103 121
104 public ILandObject GetLandObject(float x, float y) 122 public ILandObject GetLandObject(float x, float y)
105 { 123 {
106 //m_log.DebugFormat("[BIGLANDTESTFLOAT]: <{0},{1}>", x, y); 124// m_log.DebugFormat("[BIGLANDTESTFLOAT]: <{0},{1}>", x, y);
107 125
108 if (x > 0 && x <= (int)Constants.RegionSize && y > 0 && y <= (int)Constants.RegionSize) 126 if (x > 0 && x <= (int)Constants.RegionSize && y > 0 && y <= (int)Constants.RegionSize)
109 { 127 {
@@ -120,14 +138,22 @@ public class RegionCombinerLargeLandChannel : ILandChannel
120 { 138 {
121 if (regionData.Offset.X == offsetX && regionData.Offset.Y == offsetY) 139 if (regionData.Offset.X == offsetX && regionData.Offset.Y == offsetY)
122 { 140 {
141// m_log.DebugFormat(
142// "[REGION COMBINER LARGE LAND CHANNEL]: Found region {0} at offset {1},{2}",
143// regionData.RegionScene.Name, offsetX, offsetY);
144
123 return regionData.RegionScene.LandChannel.GetLandObject(x - offsetX, y - offsetY); 145 return regionData.RegionScene.LandChannel.GetLandObject(x - offsetX, y - offsetY);
124 } 146 }
125 } 147 }
126 148
127 ILandObject obj = new LandObject(UUID.Zero, false, RegData.RegionScene); 149// ILandObject obj = new LandObject(UUID.Zero, false, RegData.RegionScene);
128 obj.LandData.Name = "NO LAND"; 150// obj.LandData.Name = "NO LAND";
129 return obj; 151// return obj;
130 } 152 }
153
154// m_log.DebugFormat("[REGION COMBINER LARGE LAND CHANNEL]: No region found at {0},{1}, returning null", x, y);
155
156 return null;
131 } 157 }
132 158
133 public bool IsForcefulBansAllowed() 159 public bool IsForcefulBansAllowed()
diff --git a/OpenSim/Region/RegionCombinerModule/RegionCombinerModule.cs b/OpenSim/Region/OptionalModules/RegionCombinerModule/RegionCombinerModule.cs
index 905540d..32eead0 100644
--- a/OpenSim/Region/RegionCombinerModule/RegionCombinerModule.cs
+++ b/OpenSim/Region/OptionalModules/RegionCombinerModule/RegionCombinerModule.cs
@@ -36,14 +36,16 @@ using OpenSim.Framework.Client;
36using OpenSim.Region.Framework.Interfaces; 36using OpenSim.Region.Framework.Interfaces;
37using OpenSim.Region.Framework.Scenes; 37using OpenSim.Region.Framework.Scenes;
38using OpenSim.Framework.Console; 38using OpenSim.Framework.Console;
39using OpenSim.Region.Physics.Manager; 39using OpenSim.Region.PhysicsModules.SharedBase;
40using Mono.Addins; 40using Mono.Addins;
41 41
42namespace OpenSim.Region.RegionCombinerModule 42namespace OpenSim.Region.RegionCombinerModule
43{ 43{
44 [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "RegionCombinerModule")]
44 public class RegionCombinerModule : ISharedRegionModule, IRegionCombinerModule 45 public class RegionCombinerModule : ISharedRegionModule, IRegionCombinerModule
45 { 46 {
46 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); 47 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
48// private static string LogHeader = "[REGION COMBINER MODULE]";
47 49
48 public string Name 50 public string Name
49 { 51 {
@@ -77,6 +79,8 @@ namespace OpenSim.Region.RegionCombinerModule
77 { 79 {
78 IConfig myConfig = source.Configs["Startup"]; 80 IConfig myConfig = source.Configs["Startup"];
79 m_combineContiguousRegions = myConfig.GetBoolean("CombineContiguousRegions", false); 81 m_combineContiguousRegions = myConfig.GetBoolean("CombineContiguousRegions", false);
82 if (m_combineContiguousRegions)
83 m_log.ErrorFormat("[REGION COMBINER MODULE]: THIS MODULE IS BEING MARKED OBSOLETE AND MAY SOON BE REMOVED. PLEASE USE VARREGIONS INSTEAD.");
80 84
81 MainConsole.Instance.Commands.AddCommand( 85 MainConsole.Instance.Commands.AddCommand(
82 "RegionCombinerModule", false, "fix-phantoms", "fix-phantoms", 86 "RegionCombinerModule", false, "fix-phantoms", "fix-phantoms",
@@ -134,6 +138,49 @@ namespace OpenSim.Region.RegionCombinerModule
134 throw new Exception(string.Format("Region with id {0} not found", regionId)); 138 throw new Exception(string.Format("Region with id {0} not found", regionId));
135 } 139 }
136 140
141 // Test to see if this postiion (relative to the region) is within the area covered
142 // by this megaregion.
143 public bool PositionIsInMegaregion(UUID currentRegion, int xx, int yy)
144 {
145 bool ret = false;
146 if (xx < 0 || yy < 0)
147 return ret;
148
149 foreach (RegionConnections rootRegion in m_regions.Values)
150 {
151 if (currentRegion == rootRegion.RegionId)
152 {
153 // The caller is in the root region so this is an easy test
154 if (xx < rootRegion.XEnd && yy < rootRegion.YEnd)
155 {
156 ret = true;
157 }
158 break;
159 }
160 else
161 {
162 // Maybe the caller is in one of the sub-regions
163 foreach (RegionData childRegion in rootRegion.ConnectedRegions)
164 {
165 if (currentRegion == childRegion.RegionId)
166 {
167 // This is a child. Diddle the offsets and check if in
168 Vector3 positionInMegaregion = childRegion.Offset;
169 positionInMegaregion.X += xx;
170 positionInMegaregion.Y += yy;
171 if (positionInMegaregion.X < rootRegion.XEnd && positionInMegaregion.Y < rootRegion.YEnd)
172 {
173 ret = true;
174 }
175 break;
176 }
177 }
178 }
179 }
180
181 return ret;
182 }
183
137 private void NewPresence(ScenePresence presence) 184 private void NewPresence(ScenePresence presence)
138 { 185 {
139 if (presence.IsChildAgent) 186 if (presence.IsChildAgent)
@@ -220,27 +267,6 @@ namespace OpenSim.Region.RegionCombinerModule
220 // 267 //
221*/ 268*/
222 269
223 // Give each region a standard set of non-infinite borders
224 Border northBorder = new Border();
225 northBorder.BorderLine = new Vector3(0, (int)Constants.RegionSize, (int)Constants.RegionSize); //<---
226 northBorder.CrossDirection = Cardinals.N;
227 scene.NorthBorders[0] = northBorder;
228
229 Border southBorder = new Border();
230 southBorder.BorderLine = new Vector3(0, (int)Constants.RegionSize, 0); //--->
231 southBorder.CrossDirection = Cardinals.S;
232 scene.SouthBorders[0] = southBorder;
233
234 Border eastBorder = new Border();
235 eastBorder.BorderLine = new Vector3(0, (int)Constants.RegionSize, (int)Constants.RegionSize); //<---
236 eastBorder.CrossDirection = Cardinals.E;
237 scene.EastBorders[0] = eastBorder;
238
239 Border westBorder = new Border();
240 westBorder.BorderLine = new Vector3(0, (int)Constants.RegionSize, 0); //--->
241 westBorder.CrossDirection = Cardinals.W;
242 scene.WestBorders[0] = westBorder;
243
244 RegionConnections newConn = new RegionConnections(); 270 RegionConnections newConn = new RegionConnections();
245 newConn.ConnectedRegions = new List<RegionData>(); 271 newConn.ConnectedRegions = new List<RegionData>();
246 newConn.RegionScene = scene; 272 newConn.RegionScene = scene;
@@ -248,8 +274,8 @@ namespace OpenSim.Region.RegionCombinerModule
248 newConn.RegionId = scene.RegionInfo.originRegionID; 274 newConn.RegionId = scene.RegionInfo.originRegionID;
249 newConn.X = scene.RegionInfo.RegionLocX; 275 newConn.X = scene.RegionInfo.RegionLocX;
250 newConn.Y = scene.RegionInfo.RegionLocY; 276 newConn.Y = scene.RegionInfo.RegionLocY;
251 newConn.XEnd = (int)Constants.RegionSize; 277 newConn.XEnd = scene.RegionInfo.RegionSizeX;
252 newConn.YEnd = (int)Constants.RegionSize; 278 newConn.YEnd = scene.RegionInfo.RegionSizeX;
253 279
254 lock (m_regions) 280 lock (m_regions)
255 { 281 {
@@ -415,36 +441,39 @@ namespace OpenSim.Region.RegionCombinerModule
415 */ 441 */
416 #endregion 442 #endregion
417 443
418 // If we're one region over +x y 444
445 // Check to see if this new region is adjacent to the root region.
446 // Note that we expect the regions to be combined from the root region outward
447 // thus the requirement for the ordering in the configuration files.
448
449 // If we're one region over +x y (i.e. root region is to the west)
419 //xxx 450 //xxx
420 //xxy 451 //xxy
421 //xxx 452 //xxx
422
423 if (rootConn.PosX + rootConn.XEnd >= newConn.PosX && rootConn.PosY >= newConn.PosY) 453 if (rootConn.PosX + rootConn.XEnd >= newConn.PosX && rootConn.PosY >= newConn.PosY)
424 { 454 {
425 connectedYN = DoWorkForOneRegionOverPlusXY(rootConn, newConn, scene); 455 connectedYN = DoWorkForOneRegionOverPlusXY(rootConn, newConn, scene);
426 break; 456 break;
427 } 457 }
428 458
429 // If we're one region over x +y 459 // If we're one region over x +y (i.e. root region is to the south)
430 //xyx 460 //xyx
431 //xxx 461 //xxx
432 //xxx 462 //xxx
433 if (rootConn.PosX >= newConn.PosX && rootConn.PosY + rootConn.YEnd >= newConn.PosY) 463 if (rootConn.PosX >= newConn.PosX && rootConn.PosY + rootConn.YEnd >= newConn.PosY)
434 { 464 {
435 connectedYN = DoWorkForOneRegionOverXPlusY(rootConn, newConn, scene); 465 connectedYN = DoWorkForOneRegionOverPlusXY(rootConn, newConn, scene);
436 break; 466 break;
437 } 467 }
438 468
439 // If we're one region over +x +y 469 // If we're one region over +x +y (i.e. root region is to the south-west)
440 //xxy 470 //xxy
441 //xxx 471 //xxx
442 //xxx 472 //xxx
443 if (rootConn.PosX + rootConn.XEnd >= newConn.PosX && rootConn.PosY + rootConn.YEnd >= newConn.PosY) 473 if (rootConn.PosX + rootConn.XEnd >= newConn.PosX && rootConn.PosY + rootConn.YEnd >= newConn.PosY)
444 { 474 {
445 connectedYN = DoWorkForOneRegionOverPlusXPlusY(rootConn, newConn, scene); 475 connectedYN = DoWorkForOneRegionOverPlusXY(rootConn, newConn, scene);
446 break; 476 break;
447
448 } 477 }
449 } 478 }
450 479
@@ -454,20 +483,20 @@ namespace OpenSim.Region.RegionCombinerModule
454 DoWorkForRootRegion(newConn, scene); 483 DoWorkForRootRegion(newConn, scene);
455 } 484 }
456 } 485 }
457
458 // Set up infinite borders around the entire AABB of the combined ConnectedRegions
459 AdjustLargeRegionBounds();
460 } 486 }
461 487
462 private bool DoWorkForOneRegionOverPlusXY(RegionConnections rootConn, RegionConnections newConn, Scene scene) 488 private bool DoWorkForOneRegionOverPlusXY(RegionConnections rootConn, RegionConnections newConn, Scene scene)
463 { 489 {
490 // Offset (in meters) from the base of this region to the base of the root region.
464 Vector3 offset = Vector3.Zero; 491 Vector3 offset = Vector3.Zero;
465 offset.X = newConn.PosX - rootConn.PosX; 492 offset.X = newConn.PosX - rootConn.PosX;
466 offset.Y = newConn.PosY - rootConn.PosY; 493 offset.Y = newConn.PosY - rootConn.PosY;
467 494
495 // The new total size of the region (in meters)
496 // We just extend the X and Y dimensions so the extent might temporarily include areas without regions.
468 Vector3 extents = Vector3.Zero; 497 Vector3 extents = Vector3.Zero;
469 extents.Y = rootConn.YEnd; 498 extents.X = Math.Max(rootConn.XEnd, offset.X + newConn.RegionScene.RegionInfo.RegionSizeX);
470 extents.X = rootConn.XEnd + newConn.XEnd; 499 extents.Y = Math.Max(rootConn.YEnd, offset.Y + newConn.RegionScene.RegionInfo.RegionSizeY);
471 500
472 rootConn.UpdateExtents(extents); 501 rootConn.UpdateExtents(extents);
473 502
@@ -476,9 +505,6 @@ namespace OpenSim.Region.RegionCombinerModule
476 rootConn.RegionScene.RegionInfo.RegionName, 505 rootConn.RegionScene.RegionInfo.RegionName,
477 newConn.RegionScene.RegionInfo.RegionName, offset, extents); 506 newConn.RegionScene.RegionInfo.RegionName, offset, extents);
478 507
479 scene.BordersLocked = true;
480 rootConn.RegionScene.BordersLocked = true;
481
482 RegionData ConnectedRegion = new RegionData(); 508 RegionData ConnectedRegion = new RegionData();
483 ConnectedRegion.Offset = offset; 509 ConnectedRegion.Offset = offset;
484 ConnectedRegion.RegionId = scene.RegionInfo.originRegionID; 510 ConnectedRegion.RegionId = scene.RegionInfo.originRegionID;
@@ -491,34 +517,10 @@ namespace OpenSim.Region.RegionCombinerModule
491 // Inform Child region that it needs to forward it's terrain to the root region 517 // Inform Child region that it needs to forward it's terrain to the root region
492 scene.PhysicsScene.Combine(rootConn.RegionScene.PhysicsScene, offset, Vector3.Zero); 518 scene.PhysicsScene.Combine(rootConn.RegionScene.PhysicsScene, offset, Vector3.Zero);
493 519
494 // Extend the borders as appropriate
495 lock (rootConn.RegionScene.EastBorders)
496 rootConn.RegionScene.EastBorders[0].BorderLine.Z += (int)Constants.RegionSize;
497
498 lock (rootConn.RegionScene.NorthBorders)
499 rootConn.RegionScene.NorthBorders[0].BorderLine.Y += (int)Constants.RegionSize;
500
501 lock (rootConn.RegionScene.SouthBorders)
502 rootConn.RegionScene.SouthBorders[0].BorderLine.Y += (int)Constants.RegionSize;
503
504 lock (scene.WestBorders)
505 {
506 scene.WestBorders[0].BorderLine.Z = (int)((scene.RegionInfo.RegionLocX - rootConn.RegionScene.RegionInfo.RegionLocX) * (int)Constants.RegionSize); //auto teleport West
507
508 // Trigger auto teleport to root region
509 scene.WestBorders[0].TriggerRegionX = rootConn.RegionScene.RegionInfo.RegionLocX;
510 scene.WestBorders[0].TriggerRegionY = rootConn.RegionScene.RegionInfo.RegionLocY;
511 }
512
513 // Reset Terrain.. since terrain loads before we get here, we need to load 520 // Reset Terrain.. since terrain loads before we get here, we need to load
514 // it again so it loads in the root region 521 // it again so it loads in the root region
515
516 scene.PhysicsScene.SetTerrain(scene.Heightmap.GetFloatsSerialised()); 522 scene.PhysicsScene.SetTerrain(scene.Heightmap.GetFloatsSerialised());
517 523
518 // Unlock borders
519 rootConn.RegionScene.BordersLocked = false;
520 scene.BordersLocked = false;
521
522 // Create a client event forwarder and add this region's events to the root region. 524 // Create a client event forwarder and add this region's events to the root region.
523 if (rootConn.ClientEventForwarder != null) 525 if (rootConn.ClientEventForwarder != null)
524 rootConn.ClientEventForwarder.AddSceneToEventForwarding(scene); 526 rootConn.ClientEventForwarder.AddSceneToEventForwarding(scene);
@@ -526,6 +528,9 @@ namespace OpenSim.Region.RegionCombinerModule
526 return true; 528 return true;
527 } 529 }
528 530
531 /*
532 * 20140215 radams1: The border stuff was removed and the addition of regions to the mega-regions
533 * was generalized. These functions are not needed for the generalized solution but left for reference.
529 private bool DoWorkForOneRegionOverXPlusY(RegionConnections rootConn, RegionConnections newConn, Scene scene) 534 private bool DoWorkForOneRegionOverXPlusY(RegionConnections rootConn, RegionConnections newConn, Scene scene)
530 { 535 {
531 Vector3 offset = Vector3.Zero; 536 Vector3 offset = Vector3.Zero;
@@ -537,9 +542,6 @@ namespace OpenSim.Region.RegionCombinerModule
537 extents.X = rootConn.XEnd; 542 extents.X = rootConn.XEnd;
538 rootConn.UpdateExtents(extents); 543 rootConn.UpdateExtents(extents);
539 544
540 scene.BordersLocked = true;
541 rootConn.RegionScene.BordersLocked = true;
542
543 RegionData ConnectedRegion = new RegionData(); 545 RegionData ConnectedRegion = new RegionData();
544 ConnectedRegion.Offset = offset; 546 ConnectedRegion.Offset = offset;
545 ConnectedRegion.RegionId = scene.RegionInfo.originRegionID; 547 ConnectedRegion.RegionId = scene.RegionInfo.originRegionID;
@@ -554,30 +556,11 @@ namespace OpenSim.Region.RegionCombinerModule
554 rootConn.RegionScene.PhysicsScene.Combine(null, Vector3.Zero, extents); 556 rootConn.RegionScene.PhysicsScene.Combine(null, Vector3.Zero, extents);
555 scene.PhysicsScene.Combine(rootConn.RegionScene.PhysicsScene, offset, Vector3.Zero); 557 scene.PhysicsScene.Combine(rootConn.RegionScene.PhysicsScene, offset, Vector3.Zero);
556 558
557 lock (rootConn.RegionScene.NorthBorders)
558 rootConn.RegionScene.NorthBorders[0].BorderLine.Z += (int)Constants.RegionSize;
559
560 lock (rootConn.RegionScene.EastBorders)
561 rootConn.RegionScene.EastBorders[0].BorderLine.Y += (int)Constants.RegionSize;
562
563 lock (rootConn.RegionScene.WestBorders)
564 rootConn.RegionScene.WestBorders[0].BorderLine.Y += (int)Constants.RegionSize;
565
566 lock (scene.SouthBorders)
567 {
568 scene.SouthBorders[0].BorderLine.Z = (int)((scene.RegionInfo.RegionLocY - rootConn.RegionScene.RegionInfo.RegionLocY) * (int)Constants.RegionSize); //auto teleport south
569 scene.SouthBorders[0].TriggerRegionX = rootConn.RegionScene.RegionInfo.RegionLocX;
570 scene.SouthBorders[0].TriggerRegionY = rootConn.RegionScene.RegionInfo.RegionLocY;
571 }
572
573 // Reset Terrain.. since terrain normally loads first. 559 // Reset Terrain.. since terrain normally loads first.
574 //conn.RegionScene.PhysicsScene.SetTerrain(conn.RegionScene.Heightmap.GetFloatsSerialised()); 560 //conn.RegionScene.PhysicsScene.SetTerrain(conn.RegionScene.Heightmap.GetFloatsSerialised());
575 scene.PhysicsScene.SetTerrain(scene.Heightmap.GetFloatsSerialised()); 561 scene.PhysicsScene.SetTerrain(scene.Heightmap.GetFloatsSerialised());
576 //conn.RegionScene.PhysicsScene.SetTerrain(conn.RegionScene.Heightmap.GetFloatsSerialised()); 562 //conn.RegionScene.PhysicsScene.SetTerrain(conn.RegionScene.Heightmap.GetFloatsSerialised());
577 563
578 scene.BordersLocked = false;
579 rootConn.RegionScene.BordersLocked = false;
580
581 if (rootConn.ClientEventForwarder != null) 564 if (rootConn.ClientEventForwarder != null)
582 rootConn.ClientEventForwarder.AddSceneToEventForwarding(scene); 565 rootConn.ClientEventForwarder.AddSceneToEventForwarding(scene);
583 566
@@ -601,9 +584,6 @@ namespace OpenSim.Region.RegionCombinerModule
601 extents.Y = rootConn.YEnd; 584 extents.Y = rootConn.YEnd;
602 extents.X = rootConn.XEnd; 585 extents.X = rootConn.XEnd;
603 586
604 scene.BordersLocked = true;
605 rootConn.RegionScene.BordersLocked = true;
606
607 RegionData ConnectedRegion = new RegionData(); 587 RegionData ConnectedRegion = new RegionData();
608 ConnectedRegion.Offset = offset; 588 ConnectedRegion.Offset = offset;
609 ConnectedRegion.RegionId = scene.RegionInfo.originRegionID; 589 ConnectedRegion.RegionId = scene.RegionInfo.originRegionID;
@@ -619,68 +599,10 @@ namespace OpenSim.Region.RegionCombinerModule
619 rootConn.RegionScene.PhysicsScene.Combine(null, Vector3.Zero, extents); 599 rootConn.RegionScene.PhysicsScene.Combine(null, Vector3.Zero, extents);
620 scene.PhysicsScene.Combine(rootConn.RegionScene.PhysicsScene, offset, Vector3.Zero); 600 scene.PhysicsScene.Combine(rootConn.RegionScene.PhysicsScene, offset, Vector3.Zero);
621 601
622 lock (rootConn.RegionScene.NorthBorders)
623 {
624 if (rootConn.RegionScene.NorthBorders.Count == 1)// && 2)
625 {
626 //compound border
627 // already locked above
628 rootConn.RegionScene.NorthBorders[0].BorderLine.Z += (int)Constants.RegionSize;
629
630 lock (rootConn.RegionScene.EastBorders)
631 rootConn.RegionScene.EastBorders[0].BorderLine.Y += (int)Constants.RegionSize;
632
633 lock (rootConn.RegionScene.WestBorders)
634 rootConn.RegionScene.WestBorders[0].BorderLine.Y += (int)Constants.RegionSize;
635 }
636 }
637
638 lock (scene.SouthBorders)
639 {
640 scene.SouthBorders[0].BorderLine.Z = (int)((scene.RegionInfo.RegionLocY - rootConn.RegionScene.RegionInfo.RegionLocY) * (int)Constants.RegionSize); //auto teleport south
641 scene.SouthBorders[0].TriggerRegionX = rootConn.RegionScene.RegionInfo.RegionLocX;
642 scene.SouthBorders[0].TriggerRegionY = rootConn.RegionScene.RegionInfo.RegionLocY;
643 }
644
645 lock (rootConn.RegionScene.EastBorders)
646 {
647 if (rootConn.RegionScene.EastBorders.Count == 1)// && conn.RegionScene.EastBorders.Count == 2)
648 {
649
650 rootConn.RegionScene.EastBorders[0].BorderLine.Z += (int)Constants.RegionSize;
651
652 lock (rootConn.RegionScene.NorthBorders)
653 rootConn.RegionScene.NorthBorders[0].BorderLine.Y += (int)Constants.RegionSize;
654
655 lock (rootConn.RegionScene.SouthBorders)
656 rootConn.RegionScene.SouthBorders[0].BorderLine.Y += (int)Constants.RegionSize;
657 }
658 }
659
660 lock (scene.WestBorders)
661 {
662 scene.WestBorders[0].BorderLine.Z = (int)((scene.RegionInfo.RegionLocX - rootConn.RegionScene.RegionInfo.RegionLocX) * (int)Constants.RegionSize); //auto teleport West
663 scene.WestBorders[0].TriggerRegionX = rootConn.RegionScene.RegionInfo.RegionLocX;
664 scene.WestBorders[0].TriggerRegionY = rootConn.RegionScene.RegionInfo.RegionLocY;
665 }
666
667 /*
668 else
669 {
670 conn.RegionScene.NorthBorders[0].BorderLine.Z += (int)Constants.RegionSize;
671 conn.RegionScene.EastBorders[0].BorderLine.Y += (int)Constants.RegionSize;
672 conn.RegionScene.WestBorders[0].BorderLine.Y += (int)Constants.RegionSize;
673 scene.SouthBorders[0].BorderLine.Z += (int)Constants.RegionSize; //auto teleport south
674 }
675 */
676
677
678 // Reset Terrain.. since terrain normally loads first. 602 // Reset Terrain.. since terrain normally loads first.
679 //conn.RegionScene.PhysicsScene.SetTerrain(conn.RegionScene.Heightmap.GetFloatsSerialised()); 603 //conn.RegionScene.PhysicsScene.SetTerrain(conn.RegionScene.Heightmap.GetFloatsSerialised());
680 scene.PhysicsScene.SetTerrain(scene.Heightmap.GetFloatsSerialised()); 604 scene.PhysicsScene.SetTerrain(scene.Heightmap.GetFloatsSerialised());
681 //conn.RegionScene.PhysicsScene.SetTerrain(conn.RegionScene.Heightmap.GetFloatsSerialised()); 605 //conn.RegionScene.PhysicsScene.SetTerrain(conn.RegionScene.Heightmap.GetFloatsSerialised());
682 scene.BordersLocked = false;
683 rootConn.RegionScene.BordersLocked = false;
684 606
685 if (rootConn.ClientEventForwarder != null) 607 if (rootConn.ClientEventForwarder != null)
686 rootConn.ClientEventForwarder.AddSceneToEventForwarding(scene); 608 rootConn.ClientEventForwarder.AddSceneToEventForwarding(scene);
@@ -689,6 +611,7 @@ namespace OpenSim.Region.RegionCombinerModule
689 611
690 //scene.PhysicsScene.Combine(conn.RegionScene.PhysicsScene, offset,extents); 612 //scene.PhysicsScene.Combine(conn.RegionScene.PhysicsScene, offset,extents);
691 } 613 }
614 */
692 615
693 private void DoWorkForRootRegion(RegionConnections rootConn, Scene scene) 616 private void DoWorkForRootRegion(RegionConnections rootConn, Scene scene)
694 { 617 {
@@ -887,125 +810,6 @@ namespace OpenSim.Region.RegionCombinerModule
887// } 810// }
888// } 811// }
889 812
890 // Create a set of infinite borders around the whole aabb of the combined island.
891 private void AdjustLargeRegionBounds()
892 {
893 lock (m_regions)
894 {
895 foreach (RegionConnections rconn in m_regions.Values)
896 {
897 Vector3 offset = Vector3.Zero;
898 rconn.RegionScene.BordersLocked = true;
899 foreach (RegionData rdata in rconn.ConnectedRegions)
900 {
901 if (rdata.Offset.X > offset.X) offset.X = rdata.Offset.X;
902 if (rdata.Offset.Y > offset.Y) offset.Y = rdata.Offset.Y;
903 }
904
905 lock (rconn.RegionScene.NorthBorders)
906 {
907 Border northBorder = null;
908 // If we don't already have an infinite border, create one.
909 if (!TryGetInfiniteBorder(rconn.RegionScene.NorthBorders, out northBorder))
910 {
911 northBorder = new Border();
912 rconn.RegionScene.NorthBorders.Add(northBorder);
913 }
914
915 northBorder.BorderLine = new Vector3(float.MinValue, float.MaxValue,
916 offset.Y + (int) Constants.RegionSize); //<---
917 northBorder.CrossDirection = Cardinals.N;
918 }
919
920 lock (rconn.RegionScene.SouthBorders)
921 {
922 Border southBorder = null;
923 // If we don't already have an infinite border, create one.
924 if (!TryGetInfiniteBorder(rconn.RegionScene.SouthBorders, out southBorder))
925 {
926 southBorder = new Border();
927 rconn.RegionScene.SouthBorders.Add(southBorder);
928 }
929 southBorder.BorderLine = new Vector3(float.MinValue, float.MaxValue, 0); //--->
930 southBorder.CrossDirection = Cardinals.S;
931 }
932
933 lock (rconn.RegionScene.EastBorders)
934 {
935 Border eastBorder = null;
936 // If we don't already have an infinite border, create one.
937 if (!TryGetInfiniteBorder(rconn.RegionScene.EastBorders, out eastBorder))
938 {
939 eastBorder = new Border();
940 rconn.RegionScene.EastBorders.Add(eastBorder);
941 }
942 eastBorder.BorderLine = new Vector3(float.MinValue, float.MaxValue, offset.X + (int)Constants.RegionSize);
943 //<---
944 eastBorder.CrossDirection = Cardinals.E;
945 }
946
947 lock (rconn.RegionScene.WestBorders)
948 {
949 Border westBorder = null;
950 // If we don't already have an infinite border, create one.
951 if (!TryGetInfiniteBorder(rconn.RegionScene.WestBorders, out westBorder))
952 {
953 westBorder = new Border();
954 rconn.RegionScene.WestBorders.Add(westBorder);
955
956 }
957 westBorder.BorderLine = new Vector3(float.MinValue, float.MaxValue, 0); //--->
958 westBorder.CrossDirection = Cardinals.W;
959 }
960
961 rconn.RegionScene.BordersLocked = false;
962 }
963 }
964 }
965
966 /// <summary>
967 /// Try and get an Infinite border out of a listT of borders
968 /// </summary>
969 /// <param name="borders"></param>
970 /// <param name="oborder"></param>
971 /// <returns></returns>
972 public static bool TryGetInfiniteBorder(List<Border> borders, out Border oborder)
973 {
974 // Warning! Should be locked before getting here!
975 foreach (Border b in borders)
976 {
977 if (b.BorderLine.X == float.MinValue && b.BorderLine.Y == float.MaxValue)
978 {
979 oborder = b;
980 return true;
981 }
982 }
983
984 oborder = null;
985 return false;
986 }
987
988 public RegionData GetRegionFromPosition(Vector3 pPosition)
989 {
990 pPosition = pPosition/(int) Constants.RegionSize;
991 int OffsetX = (int) pPosition.X;
992 int OffsetY = (int) pPosition.Y;
993
994 lock (m_regions)
995 {
996 foreach (RegionConnections regConn in m_regions.Values)
997 {
998 foreach (RegionData reg in regConn.ConnectedRegions)
999 {
1000 if (reg.Offset.X == OffsetX && reg.Offset.Y == OffsetY)
1001 return reg;
1002 }
1003 }
1004 }
1005
1006 return new RegionData();
1007 }
1008
1009 public void ForwardPermissionRequests(RegionConnections BigRegion, Scene VirtualRegion) 813 public void ForwardPermissionRequests(RegionConnections BigRegion, Scene VirtualRegion)
1010 { 814 {
1011 if (BigRegion.PermissionModule == null) 815 if (BigRegion.PermissionModule == null)
diff --git a/OpenSim/Region/RegionCombinerModule/RegionCombinerPermissionModule.cs b/OpenSim/Region/OptionalModules/RegionCombinerModule/RegionCombinerPermissionModule.cs
index 7c662c9..07dd68b 100644
--- a/OpenSim/Region/RegionCombinerModule/RegionCombinerPermissionModule.cs
+++ b/OpenSim/Region/OptionalModules/RegionCombinerModule/RegionCombinerPermissionModule.cs
@@ -34,7 +34,7 @@ using OpenSim.Region.Framework.Scenes;
34 34
35namespace OpenSim.Region.RegionCombinerModule 35namespace OpenSim.Region.RegionCombinerModule
36{ 36{
37 public class RegionCombinerPermissionModule 37 public class RegionCombinerPermissionModule
38 { 38 {
39 private Scene m_rootScene; 39 private Scene m_rootScene;
40 40
diff --git a/OpenSim/Region/RegionCombinerModule/RegionConnections.cs b/OpenSim/Region/OptionalModules/RegionCombinerModule/RegionConnections.cs
index fba51d2..62a3a91 100644
--- a/OpenSim/Region/RegionCombinerModule/RegionConnections.cs
+++ b/OpenSim/Region/OptionalModules/RegionCombinerModule/RegionConnections.cs
@@ -64,12 +64,12 @@ namespace OpenSim.Region.RegionCombinerModule
64 /// <summary> 64 /// <summary>
65 /// The X meters position of this connection. 65 /// The X meters position of this connection.
66 /// </summary> 66 /// </summary>
67 public uint PosX { get { return X * Constants.RegionSize; } } 67 public uint PosX { get { return Util.RegionToWorldLoc(X); } }
68 68
69 /// <summary> 69 /// <summary>
70 /// The Y meters co-ordinate of this connection. 70 /// The Y meters co-ordinate of this connection.
71 /// </summary> 71 /// </summary>
72 public uint PosY { get { return Y * Constants.RegionSize; } } 72 public uint PosY { get { return Util.RegionToWorldLoc(Y); } }
73 73
74 /// <summary> 74 /// <summary>
75 /// The size of the megaregion in meters. 75 /// The size of the megaregion in meters.
diff --git a/OpenSim/Region/RegionCombinerModule/RegionCourseLocation.cs b/OpenSim/Region/OptionalModules/RegionCombinerModule/RegionCourseLocation.cs
index 224ac99..224ac99 100644
--- a/OpenSim/Region/RegionCombinerModule/RegionCourseLocation.cs
+++ b/OpenSim/Region/OptionalModules/RegionCombinerModule/RegionCourseLocation.cs
diff --git a/OpenSim/Region/RegionCombinerModule/RegionData.cs b/OpenSim/Region/OptionalModules/RegionCombinerModule/RegionData.cs
index bd0e398..42fca9f 100644
--- a/OpenSim/Region/RegionCombinerModule/RegionData.cs
+++ b/OpenSim/Region/OptionalModules/RegionCombinerModule/RegionData.cs
@@ -34,6 +34,7 @@ namespace OpenSim.Region.RegionCombinerModule
34 { 34 {
35 public UUID RegionId; 35 public UUID RegionId;
36 public Scene RegionScene; 36 public Scene RegionScene;
37 // Offset of this region from the base of the root region.
37 public Vector3 Offset; 38 public Vector3 Offset;
38 } 39 }
39} \ No newline at end of file 40} \ No newline at end of file