aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--OpenSim/Region/CoreModules/World/Archiver/ArchiveWriteRequestPreparation.cs38
-rw-r--r--OpenSim/Region/Framework/Interfaces/IRegionCombinerModule.cs16
-rw-r--r--OpenSim/Region/RegionCombinerModule/RegionCombinerModule.cs328
-rw-r--r--OpenSim/Region/RegionCombinerModule/RegionConnections.cs37
4 files changed, 243 insertions, 176 deletions
diff --git a/OpenSim/Region/CoreModules/World/Archiver/ArchiveWriteRequestPreparation.cs b/OpenSim/Region/CoreModules/World/Archiver/ArchiveWriteRequestPreparation.cs
index e54774b..504f09b 100644
--- a/OpenSim/Region/CoreModules/World/Archiver/ArchiveWriteRequestPreparation.cs
+++ b/OpenSim/Region/CoreModules/World/Archiver/ArchiveWriteRequestPreparation.cs
@@ -391,36 +391,46 @@ namespace OpenSim.Region.CoreModules.World.Archiver
391 xtw.WriteElementString("datetime", ((int)t.TotalSeconds).ToString()); 391 xtw.WriteElementString("datetime", ((int)t.TotalSeconds).ToString());
392 xtw.WriteElementString("id", UUID.Random().ToString()); 392 xtw.WriteElementString("id", UUID.Random().ToString());
393 xtw.WriteEndElement(); 393 xtw.WriteEndElement();
394 394
395 xtw.WriteElementString("assets_included", SaveAssets.ToString()); 395 xtw.WriteStartElement("region_info");
396 396
397 bool isMegaregion; 397 bool isMegaregion;
398 Vector2 size;
399 IRegionCombinerModule rcMod = null;
398 400
399 // FIXME: This is only here for regression test purposes since they do not supply a module. Need to fix 401 // FIXME: This is only here for regression test purposes since they do not supply a module. Need to fix
400 // this, possibly by doing control file creation somewhere else. 402 // this, possibly by doing control file creation somewhere else.
401 if (m_module != null && m_module.RegionCombinerModule != null) 403 if (m_module != null)
402 { 404 rcMod = m_module.RegionCombinerModule;
403 IRegionCombinerModule mod = m_module.RegionCombinerModule; 405
404 isMegaregion = mod.IsRootForMegaregion(m_scene.RegionInfo.RegionID); 406 if (rcMod != null)
405 } 407 isMegaregion = rcMod.IsRootForMegaregion(m_scene.RegionInfo.RegionID);
406 else 408 else
407 {
408 isMegaregion = false; 409 isMegaregion = false;
409 } 410
410 411 if (isMegaregion)
412 size = rcMod.GetSizeOfMegaregion(m_scene.RegionInfo.RegionID);
413 else
414 size = new Vector2((float)Constants.RegionSize, (float)Constants.RegionSize);
415
411 xtw.WriteElementString("is_megaregion", isMegaregion.ToString()); 416 xtw.WriteElementString("is_megaregion", isMegaregion.ToString());
417 xtw.WriteElementString("size_in_meters", string.Format("{0},{1}", size.X, size.Y));
418
419 xtw.WriteEndElement();
412 420
421 xtw.WriteElementString("assets_included", SaveAssets.ToString());
422
413 xtw.WriteEndElement(); 423 xtw.WriteEndElement();
414 424
415 xtw.Flush(); 425 xtw.Flush();
416 xtw.Close();
417 } 426 }
418 427
419 s = sw.ToString(); 428 s = sw.ToString();
420 } 429 }
421 430
422// Console.WriteLine( 431 if (m_scene != null)
423// "[ARCHIVE WRITE REQUEST PREPARATION]: Control file for {0} is: {1}", m_scene.RegionInfo.RegionName, s); 432 Console.WriteLine(
433 "[ARCHIVE WRITE REQUEST PREPARATION]: Control file for {0} is: {1}", m_scene.RegionInfo.RegionName, s);
424 434
425 return s; 435 return s;
426 } 436 }
diff --git a/OpenSim/Region/Framework/Interfaces/IRegionCombinerModule.cs b/OpenSim/Region/Framework/Interfaces/IRegionCombinerModule.cs
index ca4ed5c..e03ac5a 100644
--- a/OpenSim/Region/Framework/Interfaces/IRegionCombinerModule.cs
+++ b/OpenSim/Region/Framework/Interfaces/IRegionCombinerModule.cs
@@ -40,6 +40,20 @@ namespace OpenSim.Region.Framework.Interfaces
40 /// <summary> 40 /// <summary>
41 /// Does the given id belong to the root region of a megaregion? 41 /// Does the given id belong to the root region of a megaregion?
42 /// </summary> 42 /// </summary>
43 bool IsRootForMegaregion(UUID sceneId); 43 bool IsRootForMegaregion(UUID regionId);
44
45 /// <summary>
46 /// Gets the size of megaregion.
47 /// </summary>
48 /// <remarks>
49 /// Returns size in meters.
50 /// Do not rely on this method remaining the same - this area is actively under development.
51 /// </remarks>
52 /// <param name="sceneId">
53 /// The id of the root region for a megaregion.
54 /// This may change in the future to allow any region id that makes up a megaregion.
55 /// Currently, will throw an exception if this does not match a root region.
56 /// </param>
57 Vector2 GetSizeOfMegaregion(UUID regionId);
44 } 58 }
45} \ No newline at end of file 59} \ No newline at end of file
diff --git a/OpenSim/Region/RegionCombinerModule/RegionCombinerModule.cs b/OpenSim/Region/RegionCombinerModule/RegionCombinerModule.cs
index fadc30d..40daf13 100644
--- a/OpenSim/Region/RegionCombinerModule/RegionCombinerModule.cs
+++ b/OpenSim/Region/RegionCombinerModule/RegionCombinerModule.cs
@@ -59,6 +59,11 @@ namespace OpenSim.Region.RegionCombinerModule
59 } 59 }
60 60
61 /// <summary> 61 /// <summary>
62 /// Is this module enabled?
63 /// </summary>
64 private bool enabledYN = false;
65
66 /// <summary>
62 /// This holds the root regions for the megaregions. 67 /// This holds the root regions for the megaregions.
63 /// </summary> 68 /// </summary>
64 /// <remarks> 69 /// <remarks>
@@ -67,11 +72,6 @@ namespace OpenSim.Region.RegionCombinerModule
67 private Dictionary<UUID, RegionConnections> m_regions = new Dictionary<UUID, RegionConnections>(); 72 private Dictionary<UUID, RegionConnections> m_regions = new Dictionary<UUID, RegionConnections>();
68 73
69 /// <summary> 74 /// <summary>
70 /// Is this module enabled?
71 /// </summary>
72 private bool enabledYN = false;
73
74 /// <summary>
75 /// The scenes that comprise the megaregion. 75 /// The scenes that comprise the megaregion.
76 /// </summary> 76 /// </summary>
77 private Dictionary<UUID, Scene> m_startingScenes = new Dictionary<UUID, Scene>(); 77 private Dictionary<UUID, Scene> m_startingScenes = new Dictionary<UUID, Scene>();
@@ -113,10 +113,25 @@ namespace OpenSim.Region.RegionCombinerModule
113 } 113 }
114 } 114 }
115 115
116 public bool IsRootForMegaregion(UUID sceneId) 116 public bool IsRootForMegaregion(UUID regionId)
117 {
118 lock (m_regions)
119 return m_regions.ContainsKey(regionId);
120 }
121
122 public Vector2 GetSizeOfMegaregion(UUID regionId)
117 { 123 {
118 lock (m_regions) 124 lock (m_regions)
119 return m_regions.ContainsKey(sceneId); 125 {
126 if (m_regions.ContainsKey(regionId))
127 {
128 RegionConnections rootConn = m_regions[regionId];
129
130 return new Vector2((float)rootConn.XEnd, (float)rootConn.YEnd);
131 }
132 }
133
134 throw new Exception(string.Format("Region with id {0} not found", regionId));
120 } 135 }
121 136
122 private void NewPresence(ScenePresence presence) 137 private void NewPresence(ScenePresence presence)
@@ -229,24 +244,21 @@ namespace OpenSim.Region.RegionCombinerModule
229 westBorder.CrossDirection = Cardinals.W; 244 westBorder.CrossDirection = Cardinals.W;
230 scene.WestBorders[0] = westBorder; 245 scene.WestBorders[0] = westBorder;
231 246
232 247 RegionConnections newConn = new RegionConnections();
233 248 newConn.ConnectedRegions = new List<RegionData>();
234 RegionConnections regionConnections = new RegionConnections(); 249 newConn.RegionScene = scene;
235 regionConnections.ConnectedRegions = new List<RegionData>(); 250 newConn.RegionLandChannel = scene.LandChannel;
236 regionConnections.RegionScene = scene; 251 newConn.RegionId = scene.RegionInfo.originRegionID;
237 regionConnections.RegionLandChannel = scene.LandChannel; 252 newConn.X = scene.RegionInfo.RegionLocX;
238 regionConnections.RegionId = scene.RegionInfo.originRegionID; 253 newConn.Y = scene.RegionInfo.RegionLocY;
239 regionConnections.X = scene.RegionInfo.RegionLocX; 254 newConn.XEnd = (int)Constants.RegionSize;
240 regionConnections.Y = scene.RegionInfo.RegionLocY; 255 newConn.YEnd = (int)Constants.RegionSize;
241 regionConnections.XEnd = (int)Constants.RegionSize;
242 regionConnections.YEnd = (int)Constants.RegionSize;
243
244 256
245 lock (m_regions) 257 lock (m_regions)
246 { 258 {
247 bool connectedYN = false; 259 bool connectedYN = false;
248 260
249 foreach (RegionConnections conn in m_regions.Values) 261 foreach (RegionConnections rootConn in m_regions.Values)
250 { 262 {
251 #region commented 263 #region commented
252 /* 264 /*
@@ -411,13 +423,9 @@ namespace OpenSim.Region.RegionCombinerModule
411 //xxy 423 //xxy
412 //xxx 424 //xxx
413 425
414 426 if (rootConn.PosX + rootConn.XEnd >= newConn.PosX && rootConn.PosY >= newConn.PosY)
415 if ((((int)conn.X * (int)Constants.RegionSize) + conn.XEnd
416 >= (regionConnections.X * (int)Constants.RegionSize))
417 && (((int)conn.Y * (int)Constants.RegionSize)
418 >= (regionConnections.Y * (int)Constants.RegionSize)))
419 { 427 {
420 connectedYN = DoWorkForOneRegionOverPlusXY(conn, regionConnections, scene); 428 connectedYN = DoWorkForOneRegionOverPlusXY(rootConn, newConn, scene);
421 break; 429 break;
422 } 430 }
423 431
@@ -425,12 +433,9 @@ namespace OpenSim.Region.RegionCombinerModule
425 //xyx 433 //xyx
426 //xxx 434 //xxx
427 //xxx 435 //xxx
428 if ((((int)conn.X * (int)Constants.RegionSize) 436 if (rootConn.PosX >= newConn.PosX && rootConn.PosY + rootConn.YEnd >= newConn.PosY)
429 >= (regionConnections.X * (int)Constants.RegionSize))
430 && (((int)conn.Y * (int)Constants.RegionSize) + conn.YEnd
431 >= (regionConnections.Y * (int)Constants.RegionSize)))
432 { 437 {
433 connectedYN = DoWorkForOneRegionOverXPlusY(conn, regionConnections, scene); 438 connectedYN = DoWorkForOneRegionOverXPlusY(rootConn, newConn, scene);
434 break; 439 break;
435 } 440 }
436 441
@@ -438,12 +443,9 @@ namespace OpenSim.Region.RegionCombinerModule
438 //xxy 443 //xxy
439 //xxx 444 //xxx
440 //xxx 445 //xxx
441 if ((((int)conn.X * (int)Constants.RegionSize) + conn.XEnd 446 if (rootConn.PosX + rootConn.XEnd >= newConn.PosX && rootConn.PosY + rootConn.YEnd >= newConn.PosY)
442 >= (regionConnections.X * (int)Constants.RegionSize))
443 && (((int)conn.Y * (int)Constants.RegionSize) + conn.YEnd
444 >= (regionConnections.Y * (int)Constants.RegionSize)))
445 { 447 {
446 connectedYN = DoWorkForOneRegionOverPlusXPlusY(conn, regionConnections, scene); 448 connectedYN = DoWorkForOneRegionOverPlusXPlusY(rootConn, newConn, scene);
447 break; 449 break;
448 450
449 } 451 }
@@ -452,7 +454,7 @@ namespace OpenSim.Region.RegionCombinerModule
452 // If !connectYN means that this region is a root region 454 // If !connectYN means that this region is a root region
453 if (!connectedYN) 455 if (!connectedYN)
454 { 456 {
455 DoWorkForRootRegion(regionConnections, scene); 457 DoWorkForRootRegion(newConn, scene);
456 } 458 }
457 } 459 }
458 460
@@ -460,59 +462,55 @@ namespace OpenSim.Region.RegionCombinerModule
460 AdjustLargeRegionBounds(); 462 AdjustLargeRegionBounds();
461 } 463 }
462 464
463 private bool DoWorkForOneRegionOverPlusXY(RegionConnections conn, RegionConnections regionConnections, Scene scene) 465 private bool DoWorkForOneRegionOverPlusXY(RegionConnections rootConn, RegionConnections newConn, Scene scene)
464 { 466 {
465 Vector3 offset = Vector3.Zero; 467 Vector3 offset = Vector3.Zero;
466 offset.X = (((regionConnections.X * (int)Constants.RegionSize)) - 468 offset.X = newConn.PosX - rootConn.PosX;
467 ((conn.X * (int)Constants.RegionSize))); 469 offset.Y = newConn.PosY - rootConn.PosY;
468 offset.Y = (((regionConnections.Y * (int)Constants.RegionSize)) -
469 ((conn.Y * (int)Constants.RegionSize)));
470 470
471 Vector3 extents = Vector3.Zero; 471 Vector3 extents = Vector3.Zero;
472 extents.Y = conn.YEnd; 472 extents.Y = rootConn.YEnd;
473 extents.X = conn.XEnd + regionConnections.XEnd; 473 extents.X = rootConn.XEnd + newConn.XEnd;
474 474
475 conn.UpdateExtents(extents); 475 rootConn.UpdateExtents(extents);
476 476
477 m_log.DebugFormat( 477 m_log.DebugFormat(
478 "[REGION COMBINER MODULE]: Scene {0} to the west of Scene {1}, Offset: {2}, Extents: {3}", 478 "[REGION COMBINER MODULE]: Root region {0} is to the west of region {1}, Offset: {2}, Extents: {3}",
479 conn.RegionScene.RegionInfo.RegionName, 479 rootConn.RegionScene.RegionInfo.RegionName,
480 regionConnections.RegionScene.RegionInfo.RegionName, offset, extents); 480 newConn.RegionScene.RegionInfo.RegionName, offset, extents);
481 481
482 scene.BordersLocked = true; 482 scene.BordersLocked = true;
483 conn.RegionScene.BordersLocked = true; 483 rootConn.RegionScene.BordersLocked = true;
484 484
485 RegionData ConnectedRegion = new RegionData(); 485 RegionData ConnectedRegion = new RegionData();
486 ConnectedRegion.Offset = offset; 486 ConnectedRegion.Offset = offset;
487 ConnectedRegion.RegionId = scene.RegionInfo.originRegionID; 487 ConnectedRegion.RegionId = scene.RegionInfo.originRegionID;
488 ConnectedRegion.RegionScene = scene; 488 ConnectedRegion.RegionScene = scene;
489 conn.ConnectedRegions.Add(ConnectedRegion); 489 rootConn.ConnectedRegions.Add(ConnectedRegion);
490 490
491 // Inform root region Physics about the extents of this region 491 // Inform root region Physics about the extents of this region
492 conn.RegionScene.PhysicsScene.Combine(null, Vector3.Zero, extents); 492 rootConn.RegionScene.PhysicsScene.Combine(null, Vector3.Zero, extents);
493 493
494 // Inform Child region that it needs to forward it's terrain to the root region 494 // Inform Child region that it needs to forward it's terrain to the root region
495 scene.PhysicsScene.Combine(conn.RegionScene.PhysicsScene, offset, Vector3.Zero); 495 scene.PhysicsScene.Combine(rootConn.RegionScene.PhysicsScene, offset, Vector3.Zero);
496 496
497 // Extend the borders as appropriate 497 // Extend the borders as appropriate
498 lock (conn.RegionScene.EastBorders) 498 lock (rootConn.RegionScene.EastBorders)
499 conn.RegionScene.EastBorders[0].BorderLine.Z += (int)Constants.RegionSize; 499 rootConn.RegionScene.EastBorders[0].BorderLine.Z += (int)Constants.RegionSize;
500 500
501 lock (conn.RegionScene.NorthBorders) 501 lock (rootConn.RegionScene.NorthBorders)
502 conn.RegionScene.NorthBorders[0].BorderLine.Y += (int)Constants.RegionSize; 502 rootConn.RegionScene.NorthBorders[0].BorderLine.Y += (int)Constants.RegionSize;
503 503
504 lock (conn.RegionScene.SouthBorders) 504 lock (rootConn.RegionScene.SouthBorders)
505 conn.RegionScene.SouthBorders[0].BorderLine.Y += (int)Constants.RegionSize; 505 rootConn.RegionScene.SouthBorders[0].BorderLine.Y += (int)Constants.RegionSize;
506 506
507 lock (scene.WestBorders) 507 lock (scene.WestBorders)
508 { 508 {
509 509 scene.WestBorders[0].BorderLine.Z = (int)((scene.RegionInfo.RegionLocX - rootConn.RegionScene.RegionInfo.RegionLocX) * (int)Constants.RegionSize); //auto teleport West
510
511 scene.WestBorders[0].BorderLine.Z = (int)((scene.RegionInfo.RegionLocX - conn.RegionScene.RegionInfo.RegionLocX) * (int)Constants.RegionSize); //auto teleport West
512 510
513 // Trigger auto teleport to root region 511 // Trigger auto teleport to root region
514 scene.WestBorders[0].TriggerRegionX = conn.RegionScene.RegionInfo.RegionLocX; 512 scene.WestBorders[0].TriggerRegionX = rootConn.RegionScene.RegionInfo.RegionLocX;
515 scene.WestBorders[0].TriggerRegionY = conn.RegionScene.RegionInfo.RegionLocY; 513 scene.WestBorders[0].TriggerRegionY = rootConn.RegionScene.RegionInfo.RegionLocY;
516 } 514 }
517 515
518 // Reset Terrain.. since terrain loads before we get here, we need to load 516 // Reset Terrain.. since terrain loads before we get here, we need to load
@@ -521,57 +519,58 @@ namespace OpenSim.Region.RegionCombinerModule
521 scene.PhysicsScene.SetTerrain(scene.Heightmap.GetFloatsSerialised()); 519 scene.PhysicsScene.SetTerrain(scene.Heightmap.GetFloatsSerialised());
522 520
523 // Unlock borders 521 // Unlock borders
524 conn.RegionScene.BordersLocked = false; 522 rootConn.RegionScene.BordersLocked = false;
525 scene.BordersLocked = false; 523 scene.BordersLocked = false;
526 524
527 // Create a client event forwarder and add this region's events to the root region. 525 // Create a client event forwarder and add this region's events to the root region.
528 if (conn.ClientEventForwarder != null) 526 if (rootConn.ClientEventForwarder != null)
529 conn.ClientEventForwarder.AddSceneToEventForwarding(scene); 527 rootConn.ClientEventForwarder.AddSceneToEventForwarding(scene);
530 528
531 return true; 529 return true;
532 } 530 }
533 531
534 private bool DoWorkForOneRegionOverXPlusY(RegionConnections conn, RegionConnections regionConnections, Scene scene) 532 private bool DoWorkForOneRegionOverXPlusY(RegionConnections rootConn, RegionConnections newConn, Scene scene)
535 { 533 {
536 Vector3 offset = Vector3.Zero; 534 Vector3 offset = Vector3.Zero;
537 offset.X = (((regionConnections.X * (int)Constants.RegionSize)) - 535 offset.X = newConn.PosX - rootConn.PosX;
538 ((conn.X * (int)Constants.RegionSize))); 536 offset.Y = newConn.PosY - rootConn.PosY;
539 offset.Y = (((regionConnections.Y * (int)Constants.RegionSize)) -
540 ((conn.Y * (int)Constants.RegionSize)));
541 537
542 Vector3 extents = Vector3.Zero; 538 Vector3 extents = Vector3.Zero;
543 extents.Y = regionConnections.YEnd + conn.YEnd; 539 extents.Y = newConn.YEnd + rootConn.YEnd;
544 extents.X = conn.XEnd; 540 extents.X = rootConn.XEnd;
545 conn.UpdateExtents(extents); 541 rootConn.UpdateExtents(extents);
546 542
547 scene.BordersLocked = true; 543 scene.BordersLocked = true;
548 conn.RegionScene.BordersLocked = true; 544 rootConn.RegionScene.BordersLocked = true;
549 545
550 RegionData ConnectedRegion = new RegionData(); 546 RegionData ConnectedRegion = new RegionData();
551 ConnectedRegion.Offset = offset; 547 ConnectedRegion.Offset = offset;
552 ConnectedRegion.RegionId = scene.RegionInfo.originRegionID; 548 ConnectedRegion.RegionId = scene.RegionInfo.originRegionID;
553 ConnectedRegion.RegionScene = scene; 549 ConnectedRegion.RegionScene = scene;
554 conn.ConnectedRegions.Add(ConnectedRegion); 550 rootConn.ConnectedRegions.Add(ConnectedRegion);
555 551
556 m_log.DebugFormat( 552 m_log.DebugFormat(
557 "[REGION COMBINER MODULE]: Scene: {0} to the northeast of Scene {1}, Offset: {2}, Extents: {3}", 553 "[REGION COMBINER MODULE]: Root region {0} is to the south of region {1}, Offset: {2}, Extents: {3}",
558 conn.RegionScene.RegionInfo.RegionName, 554 rootConn.RegionScene.RegionInfo.RegionName,
559 regionConnections.RegionScene.RegionInfo.RegionName, offset, extents); 555 newConn.RegionScene.RegionInfo.RegionName, offset, extents);
560 556
561 conn.RegionScene.PhysicsScene.Combine(null, Vector3.Zero, extents); 557 rootConn.RegionScene.PhysicsScene.Combine(null, Vector3.Zero, extents);
562 scene.PhysicsScene.Combine(conn.RegionScene.PhysicsScene, offset, Vector3.Zero); 558 scene.PhysicsScene.Combine(rootConn.RegionScene.PhysicsScene, offset, Vector3.Zero);
563 559
564 lock (conn.RegionScene.NorthBorders) 560 lock (rootConn.RegionScene.NorthBorders)
565 conn.RegionScene.NorthBorders[0].BorderLine.Z += (int)Constants.RegionSize; 561 rootConn.RegionScene.NorthBorders[0].BorderLine.Z += (int)Constants.RegionSize;
566 lock (conn.RegionScene.EastBorders) 562
567 conn.RegionScene.EastBorders[0].BorderLine.Y += (int)Constants.RegionSize; 563 lock (rootConn.RegionScene.EastBorders)
568 lock (conn.RegionScene.WestBorders) 564 rootConn.RegionScene.EastBorders[0].BorderLine.Y += (int)Constants.RegionSize;
569 conn.RegionScene.WestBorders[0].BorderLine.Y += (int)Constants.RegionSize; 565
566 lock (rootConn.RegionScene.WestBorders)
567 rootConn.RegionScene.WestBorders[0].BorderLine.Y += (int)Constants.RegionSize;
568
570 lock (scene.SouthBorders) 569 lock (scene.SouthBorders)
571 { 570 {
572 scene.SouthBorders[0].BorderLine.Z = (int)((scene.RegionInfo.RegionLocY - conn.RegionScene.RegionInfo.RegionLocY) * (int)Constants.RegionSize); //auto teleport south 571 scene.SouthBorders[0].BorderLine.Z = (int)((scene.RegionInfo.RegionLocY - rootConn.RegionScene.RegionInfo.RegionLocY) * (int)Constants.RegionSize); //auto teleport south
573 scene.SouthBorders[0].TriggerRegionX = conn.RegionScene.RegionInfo.RegionLocX; 572 scene.SouthBorders[0].TriggerRegionX = rootConn.RegionScene.RegionInfo.RegionLocX;
574 scene.SouthBorders[0].TriggerRegionY = conn.RegionScene.RegionInfo.RegionLocY; 573 scene.SouthBorders[0].TriggerRegionY = rootConn.RegionScene.RegionInfo.RegionLocY;
575 } 574 }
576 575
577 // Reset Terrain.. since terrain normally loads first. 576 // Reset Terrain.. since terrain normally loads first.
@@ -580,84 +579,92 @@ namespace OpenSim.Region.RegionCombinerModule
580 //conn.RegionScene.PhysicsScene.SetTerrain(conn.RegionScene.Heightmap.GetFloatsSerialised()); 579 //conn.RegionScene.PhysicsScene.SetTerrain(conn.RegionScene.Heightmap.GetFloatsSerialised());
581 580
582 scene.BordersLocked = false; 581 scene.BordersLocked = false;
583 conn.RegionScene.BordersLocked = false; 582 rootConn.RegionScene.BordersLocked = false;
584 if (conn.ClientEventForwarder != null) 583
585 conn.ClientEventForwarder.AddSceneToEventForwarding(scene); 584 if (rootConn.ClientEventForwarder != null)
585 rootConn.ClientEventForwarder.AddSceneToEventForwarding(scene);
586
586 return true; 587 return true;
587 } 588 }
588 589
589 private bool DoWorkForOneRegionOverPlusXPlusY(RegionConnections conn, RegionConnections regionConnections, Scene scene) 590 private bool DoWorkForOneRegionOverPlusXPlusY(RegionConnections rootConn, RegionConnections newConn, Scene scene)
590 { 591 {
591 Vector3 offset = Vector3.Zero; 592 Vector3 offset = Vector3.Zero;
592 offset.X = (((regionConnections.X * (int)Constants.RegionSize)) - 593 offset.X = newConn.PosX - rootConn.PosX;
593 ((conn.X * (int)Constants.RegionSize))); 594 offset.Y = newConn.PosY - rootConn.PosY;
594 offset.Y = (((regionConnections.Y * (int)Constants.RegionSize)) -
595 ((conn.Y * (int)Constants.RegionSize)));
596 595
597 Vector3 extents = Vector3.Zero; 596 Vector3 extents = Vector3.Zero;
598 extents.Y = regionConnections.YEnd + conn.YEnd; 597
599 extents.X = regionConnections.XEnd + conn.XEnd; 598 // We do not want to inflate the extents for regions strictly to the NE of the root region, since this
600 conn.UpdateExtents(extents); 599 // would double count regions strictly to the north and east that have already been added.
600// extents.Y = regionConnections.YEnd + conn.YEnd;
601// extents.X = regionConnections.XEnd + conn.XEnd;
602// conn.UpdateExtents(extents);
603
604 extents.Y = rootConn.YEnd;
605 extents.X = rootConn.XEnd;
601 606
602 scene.BordersLocked = true; 607 scene.BordersLocked = true;
603 conn.RegionScene.BordersLocked = true; 608 rootConn.RegionScene.BordersLocked = true;
604 609
605 RegionData ConnectedRegion = new RegionData(); 610 RegionData ConnectedRegion = new RegionData();
606 ConnectedRegion.Offset = offset; 611 ConnectedRegion.Offset = offset;
607 ConnectedRegion.RegionId = scene.RegionInfo.originRegionID; 612 ConnectedRegion.RegionId = scene.RegionInfo.originRegionID;
608 ConnectedRegion.RegionScene = scene; 613 ConnectedRegion.RegionScene = scene;
609 614
610 conn.ConnectedRegions.Add(ConnectedRegion); 615 rootConn.ConnectedRegions.Add(ConnectedRegion);
611 616
612 m_log.DebugFormat( 617 m_log.DebugFormat(
613 "[REGION COMBINER MODULE]: Scene: {0} to the NorthEast of Scene {1}, Offset: {2}, Extents: {3}", 618 "[REGION COMBINER MODULE]: Region {0} is to the southwest of Scene {1}, Offset: {2}, Extents: {3}",
614 conn.RegionScene.RegionInfo.RegionName, 619 rootConn.RegionScene.RegionInfo.RegionName,
615 regionConnections.RegionScene.RegionInfo.RegionName, offset, extents); 620 newConn.RegionScene.RegionInfo.RegionName, offset, extents);
616 621
617 conn.RegionScene.PhysicsScene.Combine(null, Vector3.Zero, extents); 622 rootConn.RegionScene.PhysicsScene.Combine(null, Vector3.Zero, extents);
618 scene.PhysicsScene.Combine(conn.RegionScene.PhysicsScene, offset, Vector3.Zero); 623 scene.PhysicsScene.Combine(rootConn.RegionScene.PhysicsScene, offset, Vector3.Zero);
619 lock (conn.RegionScene.NorthBorders) 624
625 lock (rootConn.RegionScene.NorthBorders)
620 { 626 {
621 if (conn.RegionScene.NorthBorders.Count == 1)// && 2) 627 if (rootConn.RegionScene.NorthBorders.Count == 1)// && 2)
622 { 628 {
623 //compound border 629 //compound border
624 // already locked above 630 // already locked above
625 conn.RegionScene.NorthBorders[0].BorderLine.Z += (int)Constants.RegionSize; 631 rootConn.RegionScene.NorthBorders[0].BorderLine.Z += (int)Constants.RegionSize;
632
633 lock (rootConn.RegionScene.EastBorders)
634 rootConn.RegionScene.EastBorders[0].BorderLine.Y += (int)Constants.RegionSize;
626 635
627 lock (conn.RegionScene.EastBorders) 636 lock (rootConn.RegionScene.WestBorders)
628 conn.RegionScene.EastBorders[0].BorderLine.Y += (int)Constants.RegionSize; 637 rootConn.RegionScene.WestBorders[0].BorderLine.Y += (int)Constants.RegionSize;
629 lock (conn.RegionScene.WestBorders)
630 conn.RegionScene.WestBorders[0].BorderLine.Y += (int)Constants.RegionSize;
631 } 638 }
632 } 639 }
633 640
634 lock (scene.SouthBorders) 641 lock (scene.SouthBorders)
635 { 642 {
636 scene.SouthBorders[0].BorderLine.Z = (int)((scene.RegionInfo.RegionLocY - conn.RegionScene.RegionInfo.RegionLocY) * (int)Constants.RegionSize); //auto teleport south 643 scene.SouthBorders[0].BorderLine.Z = (int)((scene.RegionInfo.RegionLocY - rootConn.RegionScene.RegionInfo.RegionLocY) * (int)Constants.RegionSize); //auto teleport south
637 scene.SouthBorders[0].TriggerRegionX = conn.RegionScene.RegionInfo.RegionLocX; 644 scene.SouthBorders[0].TriggerRegionX = rootConn.RegionScene.RegionInfo.RegionLocX;
638 scene.SouthBorders[0].TriggerRegionY = conn.RegionScene.RegionInfo.RegionLocY; 645 scene.SouthBorders[0].TriggerRegionY = rootConn.RegionScene.RegionInfo.RegionLocY;
639 } 646 }
640 647
641 lock (conn.RegionScene.EastBorders) 648 lock (rootConn.RegionScene.EastBorders)
642 { 649 {
643 if (conn.RegionScene.EastBorders.Count == 1)// && conn.RegionScene.EastBorders.Count == 2) 650 if (rootConn.RegionScene.EastBorders.Count == 1)// && conn.RegionScene.EastBorders.Count == 2)
644 { 651 {
645 652
646 conn.RegionScene.EastBorders[0].BorderLine.Z += (int)Constants.RegionSize; 653 rootConn.RegionScene.EastBorders[0].BorderLine.Z += (int)Constants.RegionSize;
647 lock (conn.RegionScene.NorthBorders)
648 conn.RegionScene.NorthBorders[0].BorderLine.Y += (int)Constants.RegionSize;
649 lock (conn.RegionScene.SouthBorders)
650 conn.RegionScene.SouthBorders[0].BorderLine.Y += (int)Constants.RegionSize;
651 654
655 lock (rootConn.RegionScene.NorthBorders)
656 rootConn.RegionScene.NorthBorders[0].BorderLine.Y += (int)Constants.RegionSize;
652 657
658 lock (rootConn.RegionScene.SouthBorders)
659 rootConn.RegionScene.SouthBorders[0].BorderLine.Y += (int)Constants.RegionSize;
653 } 660 }
654 } 661 }
655 662
656 lock (scene.WestBorders) 663 lock (scene.WestBorders)
657 { 664 {
658 scene.WestBorders[0].BorderLine.Z = (int)((scene.RegionInfo.RegionLocX - conn.RegionScene.RegionInfo.RegionLocX) * (int)Constants.RegionSize); //auto teleport West 665 scene.WestBorders[0].BorderLine.Z = (int)((scene.RegionInfo.RegionLocX - rootConn.RegionScene.RegionInfo.RegionLocX) * (int)Constants.RegionSize); //auto teleport West
659 scene.WestBorders[0].TriggerRegionX = conn.RegionScene.RegionInfo.RegionLocX; 666 scene.WestBorders[0].TriggerRegionX = rootConn.RegionScene.RegionInfo.RegionLocX;
660 scene.WestBorders[0].TriggerRegionY = conn.RegionScene.RegionInfo.RegionLocY; 667 scene.WestBorders[0].TriggerRegionY = rootConn.RegionScene.RegionInfo.RegionLocY;
661 } 668 }
662 669
663 /* 670 /*
@@ -676,18 +683,17 @@ namespace OpenSim.Region.RegionCombinerModule
676 scene.PhysicsScene.SetTerrain(scene.Heightmap.GetFloatsSerialised()); 683 scene.PhysicsScene.SetTerrain(scene.Heightmap.GetFloatsSerialised());
677 //conn.RegionScene.PhysicsScene.SetTerrain(conn.RegionScene.Heightmap.GetFloatsSerialised()); 684 //conn.RegionScene.PhysicsScene.SetTerrain(conn.RegionScene.Heightmap.GetFloatsSerialised());
678 scene.BordersLocked = false; 685 scene.BordersLocked = false;
679 conn.RegionScene.BordersLocked = false; 686 rootConn.RegionScene.BordersLocked = false;
680 687
681 if (conn.ClientEventForwarder != null) 688 if (rootConn.ClientEventForwarder != null)
682 conn.ClientEventForwarder.AddSceneToEventForwarding(scene); 689 rootConn.ClientEventForwarder.AddSceneToEventForwarding(scene);
683 690
684 return true; 691 return true;
685 692
686 //scene.PhysicsScene.Combine(conn.RegionScene.PhysicsScene, offset,extents); 693 //scene.PhysicsScene.Combine(conn.RegionScene.PhysicsScene, offset,extents);
687
688 } 694 }
689 695
690 private void DoWorkForRootRegion(RegionConnections regionConnections, Scene scene) 696 private void DoWorkForRootRegion(RegionConnections rootConn, Scene scene)
691 { 697 {
692 m_log.DebugFormat("[REGION COMBINER MODULE]: Adding root region {0}", scene.RegionInfo.RegionName); 698 m_log.DebugFormat("[REGION COMBINER MODULE]: Adding root region {0}", scene.RegionInfo.RegionName);
693 699
@@ -696,28 +702,31 @@ namespace OpenSim.Region.RegionCombinerModule
696 rdata.RegionId = scene.RegionInfo.originRegionID; 702 rdata.RegionId = scene.RegionInfo.originRegionID;
697 rdata.RegionScene = scene; 703 rdata.RegionScene = scene;
698 // save it's land channel 704 // save it's land channel
699 regionConnections.RegionLandChannel = scene.LandChannel; 705 rootConn.RegionLandChannel = scene.LandChannel;
700 706
701 // Substitue our landchannel 707 // Substitue our landchannel
702 RegionCombinerLargeLandChannel lnd = new RegionCombinerLargeLandChannel(rdata, scene.LandChannel, 708 RegionCombinerLargeLandChannel lnd = new RegionCombinerLargeLandChannel(rdata, scene.LandChannel,
703 regionConnections.ConnectedRegions); 709 rootConn.ConnectedRegions);
710
704 scene.LandChannel = lnd; 711 scene.LandChannel = lnd;
712
705 // Forward the permissions modules of each of the connected regions to the root region 713 // Forward the permissions modules of each of the connected regions to the root region
706 lock (m_regions) 714 lock (m_regions)
707 { 715 {
708 foreach (RegionData r in regionConnections.ConnectedRegions) 716 foreach (RegionData r in rootConn.ConnectedRegions)
709 { 717 {
710 ForwardPermissionRequests(regionConnections, r.RegionScene); 718 ForwardPermissionRequests(rootConn, r.RegionScene);
711 } 719 }
712 }
713 // Create the root region's Client Event Forwarder
714 regionConnections.ClientEventForwarder = new RegionCombinerClientEventForwarder(regionConnections);
715
716 // Sets up the CoarseLocationUpdate forwarder for this root region
717 scene.EventManager.OnNewPresence += SetCourseLocationDelegate;
718 720
719 // Adds this root region to a dictionary of regions that are connectable 721 // Create the root region's Client Event Forwarder
720 m_regions.Add(scene.RegionInfo.originRegionID, regionConnections); 722 rootConn.ClientEventForwarder = new RegionCombinerClientEventForwarder(rootConn);
723
724 // Sets up the CoarseLocationUpdate forwarder for this root region
725 scene.EventManager.OnNewPresence += SetCourseLocationDelegate;
726
727 // Adds this root region to a dictionary of regions that are connectable
728 m_regions.Add(scene.RegionInfo.originRegionID, rootConn);
729 }
721 } 730 }
722 731
723 private void SetCourseLocationDelegate(ScenePresence presence) 732 private void SetCourseLocationDelegate(ScenePresence presence)
@@ -974,6 +983,7 @@ namespace OpenSim.Region.RegionCombinerModule
974 return true; 983 return true;
975 } 984 }
976 } 985 }
986
977 oborder = null; 987 oborder = null;
978 return false; 988 return false;
979 } 989 }
@@ -983,14 +993,19 @@ namespace OpenSim.Region.RegionCombinerModule
983 pPosition = pPosition/(int) Constants.RegionSize; 993 pPosition = pPosition/(int) Constants.RegionSize;
984 int OffsetX = (int) pPosition.X; 994 int OffsetX = (int) pPosition.X;
985 int OffsetY = (int) pPosition.Y; 995 int OffsetY = (int) pPosition.Y;
986 foreach (RegionConnections regConn in m_regions.Values) 996
997 lock (m_regions)
987 { 998 {
988 foreach (RegionData reg in regConn.ConnectedRegions) 999 foreach (RegionConnections regConn in m_regions.Values)
989 { 1000 {
990 if (reg.Offset.X == OffsetX && reg.Offset.Y == OffsetY) 1001 foreach (RegionData reg in regConn.ConnectedRegions)
991 return reg; 1002 {
1003 if (reg.Offset.X == OffsetX && reg.Offset.Y == OffsetY)
1004 return reg;
1005 }
992 } 1006 }
993 } 1007 }
1008
994 return new RegionData(); 1009 return new RegionData();
995 } 1010 }
996 1011
@@ -1046,18 +1061,17 @@ namespace OpenSim.Region.RegionCombinerModule
1046 } 1061 }
1047 1062
1048 #region console commands 1063 #region console commands
1064
1049 public void FixPhantoms(string module, string[] cmdparams) 1065 public void FixPhantoms(string module, string[] cmdparams)
1050 { 1066 {
1051 List<Scene> scenes = new List<Scene>(m_startingScenes.Values); 1067 List<Scene> scenes = new List<Scene>(m_startingScenes.Values);
1068
1052 foreach (Scene s in scenes) 1069 foreach (Scene s in scenes)
1053 { 1070 {
1054 s.ForEachSOG(delegate(SceneObjectGroup e) 1071 s.ForEachSOG(so => so.AbsolutePosition = so.AbsolutePosition);
1055 {
1056 e.AbsolutePosition = e.AbsolutePosition;
1057 }
1058 );
1059 } 1072 }
1060 } 1073 }
1074
1061 #endregion 1075 #endregion
1062 } 1076 }
1063} 1077}
diff --git a/OpenSim/Region/RegionCombinerModule/RegionConnections.cs b/OpenSim/Region/RegionCombinerModule/RegionConnections.cs
index 3aa9f20..fba51d2 100644
--- a/OpenSim/Region/RegionCombinerModule/RegionConnections.cs
+++ b/OpenSim/Region/RegionCombinerModule/RegionConnections.cs
@@ -28,6 +28,7 @@
28using System; 28using System;
29using System.Collections.Generic; 29using System.Collections.Generic;
30using OpenMetaverse; 30using OpenMetaverse;
31using OpenSim.Framework;
31using OpenSim.Region.Framework.Interfaces; 32using OpenSim.Region.Framework.Interfaces;
32using OpenSim.Region.Framework.Scenes; 33using OpenSim.Region.Framework.Scenes;
33 34
@@ -49,17 +50,45 @@ namespace OpenSim.Region.RegionCombinerModule
49 /// LargeLandChannel for combined region 50 /// LargeLandChannel for combined region
50 /// </summary> 51 /// </summary>
51 public ILandChannel RegionLandChannel; 52 public ILandChannel RegionLandChannel;
53
54 /// <summary>
55 /// The x map co-ordinate for this region (where each co-ordinate is a Constants.RegionSize block).
56 /// </summary>
52 public uint X; 57 public uint X;
58
59 /// <summary>
60 /// The y co-ordinate for this region (where each cor-odinate is a Constants.RegionSize block).
61 /// </summary>
53 public uint Y; 62 public uint Y;
54 public int XEnd; 63
55 public int YEnd; 64 /// <summary>
65 /// The X meters position of this connection.
66 /// </summary>
67 public uint PosX { get { return X * Constants.RegionSize; } }
68
69 /// <summary>
70 /// The Y meters co-ordinate of this connection.
71 /// </summary>
72 public uint PosY { get { return Y * Constants.RegionSize; } }
73
74 /// <summary>
75 /// The size of the megaregion in meters.
76 /// </summary>
77 public uint XEnd;
78
79 /// <summary>
80 /// The size of the megaregion in meters.
81 /// </summary>
82 public uint YEnd;
83
56 public List<RegionData> ConnectedRegions; 84 public List<RegionData> ConnectedRegions;
57 public RegionCombinerPermissionModule PermissionModule; 85 public RegionCombinerPermissionModule PermissionModule;
58 public RegionCombinerClientEventForwarder ClientEventForwarder; 86 public RegionCombinerClientEventForwarder ClientEventForwarder;
87
59 public void UpdateExtents(Vector3 extents) 88 public void UpdateExtents(Vector3 extents)
60 { 89 {
61 XEnd = (int)extents.X; 90 XEnd = (uint)extents.X;
62 YEnd = (int)extents.Y; 91 YEnd = (uint)extents.Y;
63 } 92 }
64 } 93 }
65} \ No newline at end of file 94} \ No newline at end of file