diff options
Diffstat (limited to 'OpenSim/Region/RegionCombinerModule/RegionCombinerModule.cs')
-rw-r--r-- | OpenSim/Region/RegionCombinerModule/RegionCombinerModule.cs | 444 |
1 files changed, 284 insertions, 160 deletions
diff --git a/OpenSim/Region/RegionCombinerModule/RegionCombinerModule.cs b/OpenSim/Region/RegionCombinerModule/RegionCombinerModule.cs index d8d9554..204c4ff 100644 --- a/OpenSim/Region/RegionCombinerModule/RegionCombinerModule.cs +++ b/OpenSim/Region/RegionCombinerModule/RegionCombinerModule.cs | |||
@@ -43,9 +43,8 @@ using Mono.Addins; | |||
43 | [assembly: AddinDependency("OpenSim", "0.5")] | 43 | [assembly: AddinDependency("OpenSim", "0.5")] |
44 | namespace OpenSim.Region.RegionCombinerModule | 44 | namespace OpenSim.Region.RegionCombinerModule |
45 | { | 45 | { |
46 | |||
47 | [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule")] | 46 | [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule")] |
48 | public class RegionCombinerModule : ISharedRegionModule | 47 | public class RegionCombinerModule : ISharedRegionModule, IRegionCombinerModule |
49 | { | 48 | { |
50 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | 49 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); |
51 | 50 | ||
@@ -59,19 +58,33 @@ namespace OpenSim.Region.RegionCombinerModule | |||
59 | get { return null; } | 58 | get { return null; } |
60 | } | 59 | } |
61 | 60 | ||
61 | /// <summary> | ||
62 | /// Is this module enabled? | ||
63 | /// </summary> | ||
64 | private bool m_combineContiguousRegions = false; | ||
65 | |||
66 | /// <summary> | ||
67 | /// This holds the root regions for the megaregions. | ||
68 | /// </summary> | ||
69 | /// <remarks> | ||
70 | /// Usually there is only ever one megaregion (and hence only one entry here). | ||
71 | /// </remarks> | ||
62 | private Dictionary<UUID, RegionConnections> m_regions = new Dictionary<UUID, RegionConnections>(); | 72 | private Dictionary<UUID, RegionConnections> m_regions = new Dictionary<UUID, RegionConnections>(); |
63 | private bool enabledYN = false; | 73 | |
74 | /// <summary> | ||
75 | /// The scenes that comprise the megaregion. | ||
76 | /// </summary> | ||
64 | private Dictionary<UUID, Scene> m_startingScenes = new Dictionary<UUID, Scene>(); | 77 | private Dictionary<UUID, Scene> m_startingScenes = new Dictionary<UUID, Scene>(); |
65 | 78 | ||
66 | public void Initialise(IConfigSource source) | 79 | public void Initialise(IConfigSource source) |
67 | { | 80 | { |
68 | IConfig myConfig = source.Configs["Startup"]; | 81 | IConfig myConfig = source.Configs["Startup"]; |
69 | enabledYN = myConfig.GetBoolean("CombineContiguousRegions", false); | 82 | m_combineContiguousRegions = myConfig.GetBoolean("CombineContiguousRegions", false); |
70 | 83 | ||
71 | if (enabledYN) | 84 | MainConsole.Instance.Commands.AddCommand( |
72 | MainConsole.Instance.Commands.AddCommand( | 85 | "RegionCombinerModule", false, "fix-phantoms", "fix-phantoms", |
73 | "RegionCombinerModule", false, "fix-phantoms", "fix-phantoms", | 86 | "Fixes phantom objects after an import to a megaregion or a change from a megaregion back to normal regions", |
74 | "Fixes phantom objects after an import to megaregions", FixPhantoms); | 87 | FixPhantoms); |
75 | } | 88 | } |
76 | 89 | ||
77 | public void Close() | 90 | public void Close() |
@@ -80,6 +93,8 @@ namespace OpenSim.Region.RegionCombinerModule | |||
80 | 93 | ||
81 | public void AddRegion(Scene scene) | 94 | public void AddRegion(Scene scene) |
82 | { | 95 | { |
96 | if (m_combineContiguousRegions) | ||
97 | scene.RegisterModuleInterface<IRegionCombinerModule>(this); | ||
83 | } | 98 | } |
84 | 99 | ||
85 | public void RemoveRegion(Scene scene) | 100 | public void RemoveRegion(Scene scene) |
@@ -88,8 +103,113 @@ namespace OpenSim.Region.RegionCombinerModule | |||
88 | 103 | ||
89 | public void RegionLoaded(Scene scene) | 104 | public void RegionLoaded(Scene scene) |
90 | { | 105 | { |
91 | if (enabledYN) | 106 | lock (m_startingScenes) |
107 | m_startingScenes.Add(scene.RegionInfo.originRegionID, scene); | ||
108 | |||
109 | if (m_combineContiguousRegions) | ||
110 | { | ||
92 | RegionLoadedDoWork(scene); | 111 | RegionLoadedDoWork(scene); |
112 | |||
113 | scene.EventManager.OnNewPresence += NewPresence; | ||
114 | } | ||
115 | } | ||
116 | |||
117 | public bool IsRootForMegaregion(UUID regionId) | ||
118 | { | ||
119 | lock (m_regions) | ||
120 | return m_regions.ContainsKey(regionId); | ||
121 | } | ||
122 | |||
123 | public Vector2 GetSizeOfMegaregion(UUID regionId) | ||
124 | { | ||
125 | lock (m_regions) | ||
126 | { | ||
127 | if (m_regions.ContainsKey(regionId)) | ||
128 | { | ||
129 | RegionConnections rootConn = m_regions[regionId]; | ||
130 | |||
131 | return new Vector2((float)rootConn.XEnd, (float)rootConn.YEnd); | ||
132 | } | ||
133 | } | ||
134 | |||
135 | throw new Exception(string.Format("Region with id {0} not found", regionId)); | ||
136 | } | ||
137 | |||
138 | private void NewPresence(ScenePresence presence) | ||
139 | { | ||
140 | if (presence.IsChildAgent) | ||
141 | { | ||
142 | byte[] throttleData; | ||
143 | |||
144 | try | ||
145 | { | ||
146 | throttleData = presence.ControllingClient.GetThrottlesPacked(1); | ||
147 | } | ||
148 | catch (NotImplementedException) | ||
149 | { | ||
150 | return; | ||
151 | } | ||
152 | |||
153 | if (throttleData == null) | ||
154 | return; | ||
155 | |||
156 | if (throttleData.Length == 0) | ||
157 | return; | ||
158 | |||
159 | if (throttleData.Length != 28) | ||
160 | return; | ||
161 | |||
162 | byte[] adjData; | ||
163 | int pos = 0; | ||
164 | |||
165 | if (!BitConverter.IsLittleEndian) | ||
166 | { | ||
167 | byte[] newData = new byte[7 * 4]; | ||
168 | Buffer.BlockCopy(throttleData, 0, newData, 0, 7 * 4); | ||
169 | |||
170 | for (int i = 0; i < 7; i++) | ||
171 | Array.Reverse(newData, i * 4, 4); | ||
172 | |||
173 | adjData = newData; | ||
174 | } | ||
175 | else | ||
176 | { | ||
177 | adjData = throttleData; | ||
178 | } | ||
179 | |||
180 | // 0.125f converts from bits to bytes | ||
181 | int resend = (int)(BitConverter.ToSingle(adjData, pos) * 0.125f); pos += 4; | ||
182 | int land = (int)(BitConverter.ToSingle(adjData, pos) * 0.125f); pos += 4; | ||
183 | int wind = (int)(BitConverter.ToSingle(adjData, pos) * 0.125f); pos += 4; | ||
184 | int cloud = (int)(BitConverter.ToSingle(adjData, pos) * 0.125f); pos += 4; | ||
185 | int task = (int)(BitConverter.ToSingle(adjData, pos) * 0.125f); pos += 4; | ||
186 | int texture = (int)(BitConverter.ToSingle(adjData, pos) * 0.125f); pos += 4; | ||
187 | int asset = (int)(BitConverter.ToSingle(adjData, pos) * 0.125f); | ||
188 | // State is a subcategory of task that we allocate a percentage to | ||
189 | |||
190 | |||
191 | //int total = resend + land + wind + cloud + task + texture + asset; | ||
192 | |||
193 | byte[] data = new byte[7 * 4]; | ||
194 | int ii = 0; | ||
195 | |||
196 | Buffer.BlockCopy(Utils.FloatToBytes(resend), 0, data, ii, 4); ii += 4; | ||
197 | Buffer.BlockCopy(Utils.FloatToBytes(land * 50), 0, data, ii, 4); ii += 4; | ||
198 | Buffer.BlockCopy(Utils.FloatToBytes(wind), 0, data, ii, 4); ii += 4; | ||
199 | Buffer.BlockCopy(Utils.FloatToBytes(cloud), 0, data, ii, 4); ii += 4; | ||
200 | Buffer.BlockCopy(Utils.FloatToBytes(task), 0, data, ii, 4); ii += 4; | ||
201 | Buffer.BlockCopy(Utils.FloatToBytes(texture), 0, data, ii, 4); ii += 4; | ||
202 | Buffer.BlockCopy(Utils.FloatToBytes(asset), 0, data, ii, 4); | ||
203 | |||
204 | try | ||
205 | { | ||
206 | presence.ControllingClient.SetChildAgentThrottle(data); | ||
207 | } | ||
208 | catch (NotImplementedException) | ||
209 | { | ||
210 | return; | ||
211 | } | ||
212 | } | ||
93 | } | 213 | } |
94 | 214 | ||
95 | private void RegionLoadedDoWork(Scene scene) | 215 | private void RegionLoadedDoWork(Scene scene) |
@@ -100,8 +220,6 @@ namespace OpenSim.Region.RegionCombinerModule | |||
100 | return; | 220 | return; |
101 | // | 221 | // |
102 | */ | 222 | */ |
103 | lock (m_startingScenes) | ||
104 | m_startingScenes.Add(scene.RegionInfo.originRegionID, scene); | ||
105 | 223 | ||
106 | // Give each region a standard set of non-infinite borders | 224 | // Give each region a standard set of non-infinite borders |
107 | Border northBorder = new Border(); | 225 | Border northBorder = new Border(); |
@@ -124,24 +242,21 @@ namespace OpenSim.Region.RegionCombinerModule | |||
124 | westBorder.CrossDirection = Cardinals.W; | 242 | westBorder.CrossDirection = Cardinals.W; |
125 | scene.WestBorders[0] = westBorder; | 243 | scene.WestBorders[0] = westBorder; |
126 | 244 | ||
127 | 245 | RegionConnections newConn = new RegionConnections(); | |
128 | 246 | newConn.ConnectedRegions = new List<RegionData>(); | |
129 | RegionConnections regionConnections = new RegionConnections(); | 247 | newConn.RegionScene = scene; |
130 | regionConnections.ConnectedRegions = new List<RegionData>(); | 248 | newConn.RegionLandChannel = scene.LandChannel; |
131 | regionConnections.RegionScene = scene; | 249 | newConn.RegionId = scene.RegionInfo.originRegionID; |
132 | regionConnections.RegionLandChannel = scene.LandChannel; | 250 | newConn.X = scene.RegionInfo.RegionLocX; |
133 | regionConnections.RegionId = scene.RegionInfo.originRegionID; | 251 | newConn.Y = scene.RegionInfo.RegionLocY; |
134 | regionConnections.X = scene.RegionInfo.RegionLocX; | 252 | newConn.XEnd = (int)Constants.RegionSize; |
135 | regionConnections.Y = scene.RegionInfo.RegionLocY; | 253 | newConn.YEnd = (int)Constants.RegionSize; |
136 | regionConnections.XEnd = (int)Constants.RegionSize; | ||
137 | regionConnections.YEnd = (int)Constants.RegionSize; | ||
138 | |||
139 | 254 | ||
140 | lock (m_regions) | 255 | lock (m_regions) |
141 | { | 256 | { |
142 | bool connectedYN = false; | 257 | bool connectedYN = false; |
143 | 258 | ||
144 | foreach (RegionConnections conn in m_regions.Values) | 259 | foreach (RegionConnections rootConn in m_regions.Values) |
145 | { | 260 | { |
146 | #region commented | 261 | #region commented |
147 | /* | 262 | /* |
@@ -306,13 +421,9 @@ namespace OpenSim.Region.RegionCombinerModule | |||
306 | //xxy | 421 | //xxy |
307 | //xxx | 422 | //xxx |
308 | 423 | ||
309 | 424 | if (rootConn.PosX + rootConn.XEnd >= newConn.PosX && rootConn.PosY >= newConn.PosY) | |
310 | if ((((int)conn.X * (int)Constants.RegionSize) + conn.XEnd | ||
311 | >= (regionConnections.X * (int)Constants.RegionSize)) | ||
312 | && (((int)conn.Y * (int)Constants.RegionSize) | ||
313 | >= (regionConnections.Y * (int)Constants.RegionSize))) | ||
314 | { | 425 | { |
315 | connectedYN = DoWorkForOneRegionOverPlusXY(conn, regionConnections, scene); | 426 | connectedYN = DoWorkForOneRegionOverPlusXY(rootConn, newConn, scene); |
316 | break; | 427 | break; |
317 | } | 428 | } |
318 | 429 | ||
@@ -320,12 +431,9 @@ namespace OpenSim.Region.RegionCombinerModule | |||
320 | //xyx | 431 | //xyx |
321 | //xxx | 432 | //xxx |
322 | //xxx | 433 | //xxx |
323 | if ((((int)conn.X * (int)Constants.RegionSize) | 434 | if (rootConn.PosX >= newConn.PosX && rootConn.PosY + rootConn.YEnd >= newConn.PosY) |
324 | >= (regionConnections.X * (int)Constants.RegionSize)) | ||
325 | && (((int)conn.Y * (int)Constants.RegionSize) + conn.YEnd | ||
326 | >= (regionConnections.Y * (int)Constants.RegionSize))) | ||
327 | { | 435 | { |
328 | connectedYN = DoWorkForOneRegionOverXPlusY(conn, regionConnections, scene); | 436 | connectedYN = DoWorkForOneRegionOverXPlusY(rootConn, newConn, scene); |
329 | break; | 437 | break; |
330 | } | 438 | } |
331 | 439 | ||
@@ -333,12 +441,9 @@ namespace OpenSim.Region.RegionCombinerModule | |||
333 | //xxy | 441 | //xxy |
334 | //xxx | 442 | //xxx |
335 | //xxx | 443 | //xxx |
336 | if ((((int)conn.X * (int)Constants.RegionSize) + conn.XEnd | 444 | if (rootConn.PosX + rootConn.XEnd >= newConn.PosX && rootConn.PosY + rootConn.YEnd >= newConn.PosY) |
337 | >= (regionConnections.X * (int)Constants.RegionSize)) | ||
338 | && (((int)conn.Y * (int)Constants.RegionSize) + conn.YEnd | ||
339 | >= (regionConnections.Y * (int)Constants.RegionSize))) | ||
340 | { | 445 | { |
341 | connectedYN = DoWorkForOneRegionOverPlusXPlusY(conn, regionConnections, scene); | 446 | connectedYN = DoWorkForOneRegionOverPlusXPlusY(rootConn, newConn, scene); |
342 | break; | 447 | break; |
343 | 448 | ||
344 | } | 449 | } |
@@ -347,66 +452,63 @@ namespace OpenSim.Region.RegionCombinerModule | |||
347 | // If !connectYN means that this region is a root region | 452 | // If !connectYN means that this region is a root region |
348 | if (!connectedYN) | 453 | if (!connectedYN) |
349 | { | 454 | { |
350 | DoWorkForRootRegion(regionConnections, scene); | 455 | DoWorkForRootRegion(newConn, scene); |
351 | |||
352 | } | 456 | } |
353 | } | 457 | } |
458 | |||
354 | // Set up infinite borders around the entire AABB of the combined ConnectedRegions | 459 | // Set up infinite borders around the entire AABB of the combined ConnectedRegions |
355 | AdjustLargeRegionBounds(); | 460 | AdjustLargeRegionBounds(); |
356 | } | 461 | } |
357 | 462 | ||
358 | private bool DoWorkForOneRegionOverPlusXY(RegionConnections conn, RegionConnections regionConnections, Scene scene) | 463 | private bool DoWorkForOneRegionOverPlusXY(RegionConnections rootConn, RegionConnections newConn, Scene scene) |
359 | { | 464 | { |
360 | Vector3 offset = Vector3.Zero; | 465 | Vector3 offset = Vector3.Zero; |
361 | offset.X = (((regionConnections.X * (int)Constants.RegionSize)) - | 466 | offset.X = newConn.PosX - rootConn.PosX; |
362 | ((conn.X * (int)Constants.RegionSize))); | 467 | offset.Y = newConn.PosY - rootConn.PosY; |
363 | offset.Y = (((regionConnections.Y * (int)Constants.RegionSize)) - | ||
364 | ((conn.Y * (int)Constants.RegionSize))); | ||
365 | 468 | ||
366 | Vector3 extents = Vector3.Zero; | 469 | Vector3 extents = Vector3.Zero; |
367 | extents.Y = conn.YEnd; | 470 | extents.Y = rootConn.YEnd; |
368 | extents.X = conn.XEnd + regionConnections.XEnd; | 471 | extents.X = rootConn.XEnd + newConn.XEnd; |
369 | 472 | ||
370 | conn.UpdateExtents(extents); | 473 | rootConn.UpdateExtents(extents); |
371 | 474 | ||
372 | m_log.DebugFormat("Scene: {0} to the west of Scene{1} Offset: {2}. Extents:{3}", | 475 | m_log.DebugFormat( |
373 | conn.RegionScene.RegionInfo.RegionName, | 476 | "[REGION COMBINER MODULE]: Root region {0} is to the west of region {1}, Offset: {2}, Extents: {3}", |
374 | regionConnections.RegionScene.RegionInfo.RegionName, offset, extents); | 477 | rootConn.RegionScene.RegionInfo.RegionName, |
478 | newConn.RegionScene.RegionInfo.RegionName, offset, extents); | ||
375 | 479 | ||
376 | scene.BordersLocked = true; | 480 | scene.BordersLocked = true; |
377 | conn.RegionScene.BordersLocked = true; | 481 | rootConn.RegionScene.BordersLocked = true; |
378 | 482 | ||
379 | RegionData ConnectedRegion = new RegionData(); | 483 | RegionData ConnectedRegion = new RegionData(); |
380 | ConnectedRegion.Offset = offset; | 484 | ConnectedRegion.Offset = offset; |
381 | ConnectedRegion.RegionId = scene.RegionInfo.originRegionID; | 485 | ConnectedRegion.RegionId = scene.RegionInfo.originRegionID; |
382 | ConnectedRegion.RegionScene = scene; | 486 | ConnectedRegion.RegionScene = scene; |
383 | conn.ConnectedRegions.Add(ConnectedRegion); | 487 | rootConn.ConnectedRegions.Add(ConnectedRegion); |
384 | 488 | ||
385 | // Inform root region Physics about the extents of this region | 489 | // Inform root region Physics about the extents of this region |
386 | conn.RegionScene.PhysicsScene.Combine(null, Vector3.Zero, extents); | 490 | rootConn.RegionScene.PhysicsScene.Combine(null, Vector3.Zero, extents); |
387 | 491 | ||
388 | // Inform Child region that it needs to forward it's terrain to the root region | 492 | // Inform Child region that it needs to forward it's terrain to the root region |
389 | scene.PhysicsScene.Combine(conn.RegionScene.PhysicsScene, offset, Vector3.Zero); | 493 | scene.PhysicsScene.Combine(rootConn.RegionScene.PhysicsScene, offset, Vector3.Zero); |
390 | 494 | ||
391 | // Extend the borders as appropriate | 495 | // Extend the borders as appropriate |
392 | lock (conn.RegionScene.EastBorders) | 496 | lock (rootConn.RegionScene.EastBorders) |
393 | conn.RegionScene.EastBorders[0].BorderLine.Z += (int)Constants.RegionSize; | 497 | rootConn.RegionScene.EastBorders[0].BorderLine.Z += (int)Constants.RegionSize; |
394 | 498 | ||
395 | lock (conn.RegionScene.NorthBorders) | 499 | lock (rootConn.RegionScene.NorthBorders) |
396 | conn.RegionScene.NorthBorders[0].BorderLine.Y += (int)Constants.RegionSize; | 500 | rootConn.RegionScene.NorthBorders[0].BorderLine.Y += (int)Constants.RegionSize; |
397 | 501 | ||
398 | lock (conn.RegionScene.SouthBorders) | 502 | lock (rootConn.RegionScene.SouthBorders) |
399 | conn.RegionScene.SouthBorders[0].BorderLine.Y += (int)Constants.RegionSize; | 503 | rootConn.RegionScene.SouthBorders[0].BorderLine.Y += (int)Constants.RegionSize; |
400 | 504 | ||
401 | lock (scene.WestBorders) | 505 | lock (scene.WestBorders) |
402 | { | 506 | { |
403 | 507 | scene.WestBorders[0].BorderLine.Z = (int)((scene.RegionInfo.RegionLocX - rootConn.RegionScene.RegionInfo.RegionLocX) * (int)Constants.RegionSize); //auto teleport West | |
404 | |||
405 | scene.WestBorders[0].BorderLine.Z = (int)((scene.RegionInfo.RegionLocX - conn.RegionScene.RegionInfo.RegionLocX) * (int)Constants.RegionSize); //auto teleport West | ||
406 | 508 | ||
407 | // Trigger auto teleport to root region | 509 | // Trigger auto teleport to root region |
408 | scene.WestBorders[0].TriggerRegionX = conn.RegionScene.RegionInfo.RegionLocX; | 510 | scene.WestBorders[0].TriggerRegionX = rootConn.RegionScene.RegionInfo.RegionLocX; |
409 | scene.WestBorders[0].TriggerRegionY = conn.RegionScene.RegionInfo.RegionLocY; | 511 | scene.WestBorders[0].TriggerRegionY = rootConn.RegionScene.RegionInfo.RegionLocY; |
410 | } | 512 | } |
411 | 513 | ||
412 | // Reset Terrain.. since terrain loads before we get here, we need to load | 514 | // Reset Terrain.. since terrain loads before we get here, we need to load |
@@ -415,56 +517,58 @@ namespace OpenSim.Region.RegionCombinerModule | |||
415 | scene.PhysicsScene.SetTerrain(scene.Heightmap.GetFloatsSerialised()); | 517 | scene.PhysicsScene.SetTerrain(scene.Heightmap.GetFloatsSerialised()); |
416 | 518 | ||
417 | // Unlock borders | 519 | // Unlock borders |
418 | conn.RegionScene.BordersLocked = false; | 520 | rootConn.RegionScene.BordersLocked = false; |
419 | scene.BordersLocked = false; | 521 | scene.BordersLocked = false; |
420 | 522 | ||
421 | // Create a client event forwarder and add this region's events to the root region. | 523 | // Create a client event forwarder and add this region's events to the root region. |
422 | if (conn.ClientEventForwarder != null) | 524 | if (rootConn.ClientEventForwarder != null) |
423 | conn.ClientEventForwarder.AddSceneToEventForwarding(scene); | 525 | rootConn.ClientEventForwarder.AddSceneToEventForwarding(scene); |
424 | 526 | ||
425 | return true; | 527 | return true; |
426 | } | 528 | } |
427 | 529 | ||
428 | private bool DoWorkForOneRegionOverXPlusY(RegionConnections conn, RegionConnections regionConnections, Scene scene) | 530 | private bool DoWorkForOneRegionOverXPlusY(RegionConnections rootConn, RegionConnections newConn, Scene scene) |
429 | { | 531 | { |
430 | Vector3 offset = Vector3.Zero; | 532 | Vector3 offset = Vector3.Zero; |
431 | offset.X = (((regionConnections.X * (int)Constants.RegionSize)) - | 533 | offset.X = newConn.PosX - rootConn.PosX; |
432 | ((conn.X * (int)Constants.RegionSize))); | 534 | offset.Y = newConn.PosY - rootConn.PosY; |
433 | offset.Y = (((regionConnections.Y * (int)Constants.RegionSize)) - | ||
434 | ((conn.Y * (int)Constants.RegionSize))); | ||
435 | 535 | ||
436 | Vector3 extents = Vector3.Zero; | 536 | Vector3 extents = Vector3.Zero; |
437 | extents.Y = regionConnections.YEnd + conn.YEnd; | 537 | extents.Y = newConn.YEnd + rootConn.YEnd; |
438 | extents.X = conn.XEnd; | 538 | extents.X = rootConn.XEnd; |
439 | conn.UpdateExtents(extents); | 539 | rootConn.UpdateExtents(extents); |
440 | 540 | ||
441 | scene.BordersLocked = true; | 541 | scene.BordersLocked = true; |
442 | conn.RegionScene.BordersLocked = true; | 542 | rootConn.RegionScene.BordersLocked = true; |
443 | 543 | ||
444 | RegionData ConnectedRegion = new RegionData(); | 544 | RegionData ConnectedRegion = new RegionData(); |
445 | ConnectedRegion.Offset = offset; | 545 | ConnectedRegion.Offset = offset; |
446 | ConnectedRegion.RegionId = scene.RegionInfo.originRegionID; | 546 | ConnectedRegion.RegionId = scene.RegionInfo.originRegionID; |
447 | ConnectedRegion.RegionScene = scene; | 547 | ConnectedRegion.RegionScene = scene; |
448 | conn.ConnectedRegions.Add(ConnectedRegion); | 548 | rootConn.ConnectedRegions.Add(ConnectedRegion); |
549 | |||
550 | m_log.DebugFormat( | ||
551 | "[REGION COMBINER MODULE]: Root region {0} is to the south of region {1}, Offset: {2}, Extents: {3}", | ||
552 | rootConn.RegionScene.RegionInfo.RegionName, | ||
553 | newConn.RegionScene.RegionInfo.RegionName, offset, extents); | ||
554 | |||
555 | rootConn.RegionScene.PhysicsScene.Combine(null, Vector3.Zero, extents); | ||
556 | scene.PhysicsScene.Combine(rootConn.RegionScene.PhysicsScene, offset, Vector3.Zero); | ||
449 | 557 | ||
450 | m_log.DebugFormat("Scene: {0} to the northeast of Scene{1} Offset: {2}. Extents:{3}", | 558 | lock (rootConn.RegionScene.NorthBorders) |
451 | conn.RegionScene.RegionInfo.RegionName, | 559 | rootConn.RegionScene.NorthBorders[0].BorderLine.Z += (int)Constants.RegionSize; |
452 | regionConnections.RegionScene.RegionInfo.RegionName, offset, extents); | ||
453 | 560 | ||
454 | conn.RegionScene.PhysicsScene.Combine(null, Vector3.Zero, extents); | 561 | lock (rootConn.RegionScene.EastBorders) |
455 | scene.PhysicsScene.Combine(conn.RegionScene.PhysicsScene, offset, Vector3.Zero); | 562 | rootConn.RegionScene.EastBorders[0].BorderLine.Y += (int)Constants.RegionSize; |
563 | |||
564 | lock (rootConn.RegionScene.WestBorders) | ||
565 | rootConn.RegionScene.WestBorders[0].BorderLine.Y += (int)Constants.RegionSize; | ||
456 | 566 | ||
457 | lock (conn.RegionScene.NorthBorders) | ||
458 | conn.RegionScene.NorthBorders[0].BorderLine.Z += (int)Constants.RegionSize; | ||
459 | lock (conn.RegionScene.EastBorders) | ||
460 | conn.RegionScene.EastBorders[0].BorderLine.Y += (int)Constants.RegionSize; | ||
461 | lock (conn.RegionScene.WestBorders) | ||
462 | conn.RegionScene.WestBorders[0].BorderLine.Y += (int)Constants.RegionSize; | ||
463 | lock (scene.SouthBorders) | 567 | lock (scene.SouthBorders) |
464 | { | 568 | { |
465 | scene.SouthBorders[0].BorderLine.Z = (int)((scene.RegionInfo.RegionLocY - conn.RegionScene.RegionInfo.RegionLocY) * (int)Constants.RegionSize); //auto teleport south | 569 | scene.SouthBorders[0].BorderLine.Z = (int)((scene.RegionInfo.RegionLocY - rootConn.RegionScene.RegionInfo.RegionLocY) * (int)Constants.RegionSize); //auto teleport south |
466 | scene.SouthBorders[0].TriggerRegionX = conn.RegionScene.RegionInfo.RegionLocX; | 570 | scene.SouthBorders[0].TriggerRegionX = rootConn.RegionScene.RegionInfo.RegionLocX; |
467 | scene.SouthBorders[0].TriggerRegionY = conn.RegionScene.RegionInfo.RegionLocY; | 571 | scene.SouthBorders[0].TriggerRegionY = rootConn.RegionScene.RegionInfo.RegionLocY; |
468 | } | 572 | } |
469 | 573 | ||
470 | // Reset Terrain.. since terrain normally loads first. | 574 | // Reset Terrain.. since terrain normally loads first. |
@@ -473,83 +577,92 @@ namespace OpenSim.Region.RegionCombinerModule | |||
473 | //conn.RegionScene.PhysicsScene.SetTerrain(conn.RegionScene.Heightmap.GetFloatsSerialised()); | 577 | //conn.RegionScene.PhysicsScene.SetTerrain(conn.RegionScene.Heightmap.GetFloatsSerialised()); |
474 | 578 | ||
475 | scene.BordersLocked = false; | 579 | scene.BordersLocked = false; |
476 | conn.RegionScene.BordersLocked = false; | 580 | rootConn.RegionScene.BordersLocked = false; |
477 | if (conn.ClientEventForwarder != null) | 581 | |
478 | conn.ClientEventForwarder.AddSceneToEventForwarding(scene); | 582 | if (rootConn.ClientEventForwarder != null) |
583 | rootConn.ClientEventForwarder.AddSceneToEventForwarding(scene); | ||
584 | |||
479 | return true; | 585 | return true; |
480 | } | 586 | } |
481 | 587 | ||
482 | private bool DoWorkForOneRegionOverPlusXPlusY(RegionConnections conn, RegionConnections regionConnections, Scene scene) | 588 | private bool DoWorkForOneRegionOverPlusXPlusY(RegionConnections rootConn, RegionConnections newConn, Scene scene) |
483 | { | 589 | { |
484 | Vector3 offset = Vector3.Zero; | 590 | Vector3 offset = Vector3.Zero; |
485 | offset.X = (((regionConnections.X * (int)Constants.RegionSize)) - | 591 | offset.X = newConn.PosX - rootConn.PosX; |
486 | ((conn.X * (int)Constants.RegionSize))); | 592 | offset.Y = newConn.PosY - rootConn.PosY; |
487 | offset.Y = (((regionConnections.Y * (int)Constants.RegionSize)) - | ||
488 | ((conn.Y * (int)Constants.RegionSize))); | ||
489 | 593 | ||
490 | Vector3 extents = Vector3.Zero; | 594 | Vector3 extents = Vector3.Zero; |
491 | extents.Y = regionConnections.YEnd + conn.YEnd; | 595 | |
492 | extents.X = regionConnections.XEnd + conn.XEnd; | 596 | // We do not want to inflate the extents for regions strictly to the NE of the root region, since this |
493 | conn.UpdateExtents(extents); | 597 | // would double count regions strictly to the north and east that have already been added. |
598 | // extents.Y = regionConnections.YEnd + conn.YEnd; | ||
599 | // extents.X = regionConnections.XEnd + conn.XEnd; | ||
600 | // conn.UpdateExtents(extents); | ||
601 | |||
602 | extents.Y = rootConn.YEnd; | ||
603 | extents.X = rootConn.XEnd; | ||
494 | 604 | ||
495 | scene.BordersLocked = true; | 605 | scene.BordersLocked = true; |
496 | conn.RegionScene.BordersLocked = true; | 606 | rootConn.RegionScene.BordersLocked = true; |
497 | 607 | ||
498 | RegionData ConnectedRegion = new RegionData(); | 608 | RegionData ConnectedRegion = new RegionData(); |
499 | ConnectedRegion.Offset = offset; | 609 | ConnectedRegion.Offset = offset; |
500 | ConnectedRegion.RegionId = scene.RegionInfo.originRegionID; | 610 | ConnectedRegion.RegionId = scene.RegionInfo.originRegionID; |
501 | ConnectedRegion.RegionScene = scene; | 611 | ConnectedRegion.RegionScene = scene; |
502 | 612 | ||
503 | conn.ConnectedRegions.Add(ConnectedRegion); | 613 | rootConn.ConnectedRegions.Add(ConnectedRegion); |
614 | |||
615 | m_log.DebugFormat( | ||
616 | "[REGION COMBINER MODULE]: Region {0} is to the southwest of Scene {1}, Offset: {2}, Extents: {3}", | ||
617 | rootConn.RegionScene.RegionInfo.RegionName, | ||
618 | newConn.RegionScene.RegionInfo.RegionName, offset, extents); | ||
504 | 619 | ||
505 | m_log.DebugFormat("Scene: {0} to the NorthEast of Scene{1} Offset: {2}. Extents:{3}", | 620 | rootConn.RegionScene.PhysicsScene.Combine(null, Vector3.Zero, extents); |
506 | conn.RegionScene.RegionInfo.RegionName, | 621 | scene.PhysicsScene.Combine(rootConn.RegionScene.PhysicsScene, offset, Vector3.Zero); |
507 | regionConnections.RegionScene.RegionInfo.RegionName, offset, extents); | ||
508 | 622 | ||
509 | conn.RegionScene.PhysicsScene.Combine(null, Vector3.Zero, extents); | 623 | lock (rootConn.RegionScene.NorthBorders) |
510 | scene.PhysicsScene.Combine(conn.RegionScene.PhysicsScene, offset, Vector3.Zero); | ||
511 | lock (conn.RegionScene.NorthBorders) | ||
512 | { | 624 | { |
513 | if (conn.RegionScene.NorthBorders.Count == 1)// && 2) | 625 | if (rootConn.RegionScene.NorthBorders.Count == 1)// && 2) |
514 | { | 626 | { |
515 | //compound border | 627 | //compound border |
516 | // already locked above | 628 | // already locked above |
517 | conn.RegionScene.NorthBorders[0].BorderLine.Z += (int)Constants.RegionSize; | 629 | rootConn.RegionScene.NorthBorders[0].BorderLine.Z += (int)Constants.RegionSize; |
630 | |||
631 | lock (rootConn.RegionScene.EastBorders) | ||
632 | rootConn.RegionScene.EastBorders[0].BorderLine.Y += (int)Constants.RegionSize; | ||
518 | 633 | ||
519 | lock (conn.RegionScene.EastBorders) | 634 | lock (rootConn.RegionScene.WestBorders) |
520 | conn.RegionScene.EastBorders[0].BorderLine.Y += (int)Constants.RegionSize; | 635 | rootConn.RegionScene.WestBorders[0].BorderLine.Y += (int)Constants.RegionSize; |
521 | lock (conn.RegionScene.WestBorders) | ||
522 | conn.RegionScene.WestBorders[0].BorderLine.Y += (int)Constants.RegionSize; | ||
523 | } | 636 | } |
524 | } | 637 | } |
525 | 638 | ||
526 | lock (scene.SouthBorders) | 639 | lock (scene.SouthBorders) |
527 | { | 640 | { |
528 | scene.SouthBorders[0].BorderLine.Z = (int)((scene.RegionInfo.RegionLocY - conn.RegionScene.RegionInfo.RegionLocY) * (int)Constants.RegionSize); //auto teleport south | 641 | scene.SouthBorders[0].BorderLine.Z = (int)((scene.RegionInfo.RegionLocY - rootConn.RegionScene.RegionInfo.RegionLocY) * (int)Constants.RegionSize); //auto teleport south |
529 | scene.SouthBorders[0].TriggerRegionX = conn.RegionScene.RegionInfo.RegionLocX; | 642 | scene.SouthBorders[0].TriggerRegionX = rootConn.RegionScene.RegionInfo.RegionLocX; |
530 | scene.SouthBorders[0].TriggerRegionY = conn.RegionScene.RegionInfo.RegionLocY; | 643 | scene.SouthBorders[0].TriggerRegionY = rootConn.RegionScene.RegionInfo.RegionLocY; |
531 | } | 644 | } |
532 | 645 | ||
533 | lock (conn.RegionScene.EastBorders) | 646 | lock (rootConn.RegionScene.EastBorders) |
534 | { | 647 | { |
535 | if (conn.RegionScene.EastBorders.Count == 1)// && conn.RegionScene.EastBorders.Count == 2) | 648 | if (rootConn.RegionScene.EastBorders.Count == 1)// && conn.RegionScene.EastBorders.Count == 2) |
536 | { | 649 | { |
537 | 650 | ||
538 | conn.RegionScene.EastBorders[0].BorderLine.Z += (int)Constants.RegionSize; | 651 | rootConn.RegionScene.EastBorders[0].BorderLine.Z += (int)Constants.RegionSize; |
539 | lock (conn.RegionScene.NorthBorders) | ||
540 | conn.RegionScene.NorthBorders[0].BorderLine.Y += (int)Constants.RegionSize; | ||
541 | lock (conn.RegionScene.SouthBorders) | ||
542 | conn.RegionScene.SouthBorders[0].BorderLine.Y += (int)Constants.RegionSize; | ||
543 | 652 | ||
653 | lock (rootConn.RegionScene.NorthBorders) | ||
654 | rootConn.RegionScene.NorthBorders[0].BorderLine.Y += (int)Constants.RegionSize; | ||
544 | 655 | ||
656 | lock (rootConn.RegionScene.SouthBorders) | ||
657 | rootConn.RegionScene.SouthBorders[0].BorderLine.Y += (int)Constants.RegionSize; | ||
545 | } | 658 | } |
546 | } | 659 | } |
547 | 660 | ||
548 | lock (scene.WestBorders) | 661 | lock (scene.WestBorders) |
549 | { | 662 | { |
550 | scene.WestBorders[0].BorderLine.Z = (int)((scene.RegionInfo.RegionLocX - conn.RegionScene.RegionInfo.RegionLocX) * (int)Constants.RegionSize); //auto teleport West | 663 | scene.WestBorders[0].BorderLine.Z = (int)((scene.RegionInfo.RegionLocX - rootConn.RegionScene.RegionInfo.RegionLocX) * (int)Constants.RegionSize); //auto teleport West |
551 | scene.WestBorders[0].TriggerRegionX = conn.RegionScene.RegionInfo.RegionLocX; | 664 | scene.WestBorders[0].TriggerRegionX = rootConn.RegionScene.RegionInfo.RegionLocX; |
552 | scene.WestBorders[0].TriggerRegionY = conn.RegionScene.RegionInfo.RegionLocY; | 665 | scene.WestBorders[0].TriggerRegionY = rootConn.RegionScene.RegionInfo.RegionLocY; |
553 | } | 666 | } |
554 | 667 | ||
555 | /* | 668 | /* |
@@ -568,46 +681,50 @@ namespace OpenSim.Region.RegionCombinerModule | |||
568 | scene.PhysicsScene.SetTerrain(scene.Heightmap.GetFloatsSerialised()); | 681 | scene.PhysicsScene.SetTerrain(scene.Heightmap.GetFloatsSerialised()); |
569 | //conn.RegionScene.PhysicsScene.SetTerrain(conn.RegionScene.Heightmap.GetFloatsSerialised()); | 682 | //conn.RegionScene.PhysicsScene.SetTerrain(conn.RegionScene.Heightmap.GetFloatsSerialised()); |
570 | scene.BordersLocked = false; | 683 | scene.BordersLocked = false; |
571 | conn.RegionScene.BordersLocked = false; | 684 | rootConn.RegionScene.BordersLocked = false; |
572 | 685 | ||
573 | if (conn.ClientEventForwarder != null) | 686 | if (rootConn.ClientEventForwarder != null) |
574 | conn.ClientEventForwarder.AddSceneToEventForwarding(scene); | 687 | rootConn.ClientEventForwarder.AddSceneToEventForwarding(scene); |
575 | 688 | ||
576 | return true; | 689 | return true; |
577 | 690 | ||
578 | //scene.PhysicsScene.Combine(conn.RegionScene.PhysicsScene, offset,extents); | 691 | //scene.PhysicsScene.Combine(conn.RegionScene.PhysicsScene, offset,extents); |
579 | |||
580 | } | 692 | } |
581 | 693 | ||
582 | private void DoWorkForRootRegion(RegionConnections regionConnections, Scene scene) | 694 | private void DoWorkForRootRegion(RegionConnections rootConn, Scene scene) |
583 | { | 695 | { |
696 | m_log.DebugFormat("[REGION COMBINER MODULE]: Adding root region {0}", scene.RegionInfo.RegionName); | ||
697 | |||
584 | RegionData rdata = new RegionData(); | 698 | RegionData rdata = new RegionData(); |
585 | rdata.Offset = Vector3.Zero; | 699 | rdata.Offset = Vector3.Zero; |
586 | rdata.RegionId = scene.RegionInfo.originRegionID; | 700 | rdata.RegionId = scene.RegionInfo.originRegionID; |
587 | rdata.RegionScene = scene; | 701 | rdata.RegionScene = scene; |
588 | // save it's land channel | 702 | // save it's land channel |
589 | regionConnections.RegionLandChannel = scene.LandChannel; | 703 | rootConn.RegionLandChannel = scene.LandChannel; |
590 | 704 | ||
591 | // Substitue our landchannel | 705 | // Substitue our landchannel |
592 | RegionCombinerLargeLandChannel lnd = new RegionCombinerLargeLandChannel(rdata, scene.LandChannel, | 706 | RegionCombinerLargeLandChannel lnd = new RegionCombinerLargeLandChannel(rdata, scene.LandChannel, |
593 | regionConnections.ConnectedRegions); | 707 | rootConn.ConnectedRegions); |
708 | |||
594 | scene.LandChannel = lnd; | 709 | scene.LandChannel = lnd; |
710 | |||
595 | // Forward the permissions modules of each of the connected regions to the root region | 711 | // Forward the permissions modules of each of the connected regions to the root region |
596 | lock (m_regions) | 712 | lock (m_regions) |
597 | { | 713 | { |
598 | foreach (RegionData r in regionConnections.ConnectedRegions) | 714 | foreach (RegionData r in rootConn.ConnectedRegions) |
599 | { | 715 | { |
600 | ForwardPermissionRequests(regionConnections, r.RegionScene); | 716 | ForwardPermissionRequests(rootConn, r.RegionScene); |
601 | } | 717 | } |
602 | } | ||
603 | // Create the root region's Client Event Forwarder | ||
604 | regionConnections.ClientEventForwarder = new RegionCombinerClientEventForwarder(regionConnections); | ||
605 | |||
606 | // Sets up the CoarseLocationUpdate forwarder for this root region | ||
607 | scene.EventManager.OnNewPresence += SetCourseLocationDelegate; | ||
608 | 718 | ||
609 | // Adds this root region to a dictionary of regions that are connectable | 719 | // Create the root region's Client Event Forwarder |
610 | m_regions.Add(scene.RegionInfo.originRegionID, regionConnections); | 720 | rootConn.ClientEventForwarder = new RegionCombinerClientEventForwarder(rootConn); |
721 | |||
722 | // Sets up the CoarseLocationUpdate forwarder for this root region | ||
723 | scene.EventManager.OnNewPresence += SetCourseLocationDelegate; | ||
724 | |||
725 | // Adds this root region to a dictionary of regions that are connectable | ||
726 | m_regions.Add(scene.RegionInfo.originRegionID, rootConn); | ||
727 | } | ||
611 | } | 728 | } |
612 | 729 | ||
613 | private void SetCourseLocationDelegate(ScenePresence presence) | 730 | private void SetCourseLocationDelegate(ScenePresence presence) |
@@ -864,6 +981,7 @@ namespace OpenSim.Region.RegionCombinerModule | |||
864 | return true; | 981 | return true; |
865 | } | 982 | } |
866 | } | 983 | } |
984 | |||
867 | oborder = null; | 985 | oborder = null; |
868 | return false; | 986 | return false; |
869 | } | 987 | } |
@@ -873,14 +991,19 @@ namespace OpenSim.Region.RegionCombinerModule | |||
873 | pPosition = pPosition/(int) Constants.RegionSize; | 991 | pPosition = pPosition/(int) Constants.RegionSize; |
874 | int OffsetX = (int) pPosition.X; | 992 | int OffsetX = (int) pPosition.X; |
875 | int OffsetY = (int) pPosition.Y; | 993 | int OffsetY = (int) pPosition.Y; |
876 | foreach (RegionConnections regConn in m_regions.Values) | 994 | |
995 | lock (m_regions) | ||
877 | { | 996 | { |
878 | foreach (RegionData reg in regConn.ConnectedRegions) | 997 | foreach (RegionConnections regConn in m_regions.Values) |
879 | { | 998 | { |
880 | if (reg.Offset.X == OffsetX && reg.Offset.Y == OffsetY) | 999 | foreach (RegionData reg in regConn.ConnectedRegions) |
881 | return reg; | 1000 | { |
1001 | if (reg.Offset.X == OffsetX && reg.Offset.Y == OffsetY) | ||
1002 | return reg; | ||
1003 | } | ||
882 | } | 1004 | } |
883 | } | 1005 | } |
1006 | |||
884 | return new RegionData(); | 1007 | return new RegionData(); |
885 | } | 1008 | } |
886 | 1009 | ||
@@ -936,18 +1059,19 @@ namespace OpenSim.Region.RegionCombinerModule | |||
936 | } | 1059 | } |
937 | 1060 | ||
938 | #region console commands | 1061 | #region console commands |
1062 | |||
939 | public void FixPhantoms(string module, string[] cmdparams) | 1063 | public void FixPhantoms(string module, string[] cmdparams) |
940 | { | 1064 | { |
941 | List<Scene> scenes = new List<Scene>(m_startingScenes.Values); | 1065 | List<Scene> scenes = new List<Scene>(m_startingScenes.Values); |
1066 | |||
942 | foreach (Scene s in scenes) | 1067 | foreach (Scene s in scenes) |
943 | { | 1068 | { |
944 | s.ForEachSOG(delegate(SceneObjectGroup e) | 1069 | MainConsole.Instance.OutputFormat("Fixing phantoms for {0}", s.RegionInfo.RegionName); |
945 | { | 1070 | |
946 | e.AbsolutePosition = e.AbsolutePosition; | 1071 | s.ForEachSOG(so => so.AbsolutePosition = so.AbsolutePosition); |
947 | } | ||
948 | ); | ||
949 | } | 1072 | } |
950 | } | 1073 | } |
1074 | |||
951 | #endregion | 1075 | #endregion |
952 | } | 1076 | } |
953 | } | 1077 | } |