diff options
author | Robert Adams | 2014-02-15 16:01:43 -0800 |
---|---|---|
committer | Robert Adams | 2014-02-15 16:01:43 -0800 |
commit | 877bdcdce1533d8dc3e13c0def7b015080ee881e (patch) | |
tree | 38dba2a95f035eea5b64aeba9bf59385de63faee | |
parent | Non-functional changes of numbers into symbolic references and a few (diff) | |
download | opensim-SC-877bdcdce1533d8dc3e13c0def7b015080ee881e.zip opensim-SC-877bdcdce1533d8dc3e13c0def7b015080ee881e.tar.gz opensim-SC-877bdcdce1533d8dc3e13c0def7b015080ee881e.tar.bz2 opensim-SC-877bdcdce1533d8dc3e13c0def7b015080ee881e.tar.xz |
Rewrite of mega-region code to use new form of border checking.
This commit eliminates all of the 'border' class and list code and replaces
it with testing if in the current region.
Impacts: can make a mega-region out of varregions of the same size; and
mega-region combinations must be rectangular (not square but rectangular)
Diffstat (limited to '')
7 files changed, 107 insertions, 619 deletions
diff --git a/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs b/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs index a038f73..3eff96e 100644 --- a/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs +++ b/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs | |||
@@ -464,7 +464,7 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer | |||
464 | sp.Name, position, sp.Scene.RegionInfo.RegionName); | 464 | sp.Name, position, sp.Scene.RegionInfo.RegionName); |
465 | 465 | ||
466 | // Teleport within the same region | 466 | // Teleport within the same region |
467 | if (IsOutsideRegion(sp.Scene, position) || position.Z < 0) | 467 | if (!sp.Scene.PositionIsInCurrentRegion(position) || position.Z < 0) |
468 | { | 468 | { |
469 | Vector3 emergencyPos = new Vector3(128, 128, 128); | 469 | Vector3 emergencyPos = new Vector3(128, 128, 128); |
470 | 470 | ||
@@ -580,7 +580,7 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer | |||
580 | MapBlockData block = new MapBlockData(); | 580 | MapBlockData block = new MapBlockData(); |
581 | block.X = (ushort)regX; | 581 | block.X = (ushort)regX; |
582 | block.Y = (ushort)regY; | 582 | block.Y = (ushort)regY; |
583 | block.Access = 254; // == not there | 583 | block.Access = (byte)SimAccess.Down; |
584 | 584 | ||
585 | List<MapBlockData> blocks = new List<MapBlockData>(); | 585 | List<MapBlockData> blocks = new List<MapBlockData>(); |
586 | blocks.Add(block); | 586 | blocks.Add(block); |
@@ -713,10 +713,9 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer | |||
713 | return; | 713 | return; |
714 | } | 714 | } |
715 | 715 | ||
716 | uint newRegionX = (uint)(reg.RegionHandle >> 40); | 716 | uint newRegionX, newRegionY, oldRegionX, oldRegionY; |
717 | uint newRegionY = (((uint)(reg.RegionHandle)) >> 8); | 717 | Util.RegionHandleToRegionLoc(reg.RegionHandle, out newRegionX, out newRegionY); |
718 | uint oldRegionX = (uint)(sp.Scene.RegionInfo.RegionHandle >> 40); | 718 | Util.RegionHandleToRegionLoc(sp.Scene.RegionInfo.RegionHandle, out oldRegionX, out oldRegionY); |
719 | uint oldRegionY = (((uint)(sp.Scene.RegionInfo.RegionHandle)) >> 8); | ||
720 | 719 | ||
721 | ulong destinationHandle = finalDestination.RegionHandle; | 720 | ulong destinationHandle = finalDestination.RegionHandle; |
722 | 721 | ||
@@ -1333,6 +1332,9 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer | |||
1333 | return region; | 1332 | return region; |
1334 | } | 1333 | } |
1335 | 1334 | ||
1335 | // This returns 'true' if the new region already has a child agent for our | ||
1336 | // incoming agent. The implication is that, if 'false', we have to create the | ||
1337 | // child and then teleport into the region. | ||
1336 | protected virtual bool NeedsNewAgent(float drawdist, uint oldRegionX, uint newRegionX, uint oldRegionY, uint newRegionY) | 1338 | protected virtual bool NeedsNewAgent(float drawdist, uint oldRegionX, uint newRegionX, uint oldRegionY, uint newRegionY) |
1337 | { | 1339 | { |
1338 | if (m_regionCombinerModule != null && m_regionCombinerModule.IsRootForMegaregion(Scene.RegionInfo.RegionID)) | 1340 | if (m_regionCombinerModule != null && m_regionCombinerModule.IsRootForMegaregion(Scene.RegionInfo.RegionID)) |
@@ -1357,20 +1359,6 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer | |||
1357 | return Util.IsOutsideView(drawdist, oldRegionX, newRegionX, oldRegionY, newRegionY); | 1359 | return Util.IsOutsideView(drawdist, oldRegionX, newRegionX, oldRegionY, newRegionY); |
1358 | } | 1360 | } |
1359 | 1361 | ||
1360 | protected virtual bool IsOutsideRegion(Scene s, Vector3 pos) | ||
1361 | { | ||
1362 | if (s.TestBorderCross(pos, Cardinals.N)) | ||
1363 | return true; | ||
1364 | if (s.TestBorderCross(pos, Cardinals.S)) | ||
1365 | return true; | ||
1366 | if (s.TestBorderCross(pos, Cardinals.E)) | ||
1367 | return true; | ||
1368 | if (s.TestBorderCross(pos, Cardinals.W)) | ||
1369 | return true; | ||
1370 | |||
1371 | return false; | ||
1372 | } | ||
1373 | |||
1374 | #endregion | 1362 | #endregion |
1375 | 1363 | ||
1376 | #region Landmark Teleport | 1364 | #region Landmark Teleport |
@@ -2077,7 +2065,7 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer | |||
2077 | public NotFoundLocationCache() | 2065 | public NotFoundLocationCache() |
2078 | { | 2066 | { |
2079 | } | 2067 | } |
2080 | // Add an area to the lost of 'not found' places. The area is the snapped region | 2068 | // Add an area to the list of 'not found' places. The area is the snapped region |
2081 | // area around the added point. | 2069 | // area around the added point. |
2082 | public void Add(double pX, double pY) | 2070 | public void Add(double pX, double pY) |
2083 | { | 2071 | { |
@@ -2305,23 +2293,15 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer | |||
2305 | /// <param name='neCorner'></param> | 2293 | /// <param name='neCorner'></param> |
2306 | private void GetMegaregionViewRange(out Vector2 swCorner, out Vector2 neCorner) | 2294 | private void GetMegaregionViewRange(out Vector2 swCorner, out Vector2 neCorner) |
2307 | { | 2295 | { |
2308 | Border[] northBorders = Scene.NorthBorders.ToArray(); | ||
2309 | Border[] eastBorders = Scene.EastBorders.ToArray(); | ||
2310 | |||
2311 | Vector2 extent = Vector2.Zero; | 2296 | Vector2 extent = Vector2.Zero; |
2312 | for (int i = 0; i < eastBorders.Length; i++) | 2297 | |
2313 | { | 2298 | if (m_regionCombinerModule != null) |
2314 | extent.X = (eastBorders[i].BorderLine.Z > extent.X) ? eastBorders[i].BorderLine.Z : extent.X; | ||
2315 | } | ||
2316 | for (int i = 0; i < northBorders.Length; i++) | ||
2317 | { | 2299 | { |
2318 | extent.Y = (northBorders[i].BorderLine.Z > extent.Y) ? northBorders[i].BorderLine.Z : extent.Y; | 2300 | Vector2 megaRegionSize = m_regionCombinerModule.GetSizeOfMegaregion(Scene.RegionInfo.RegionID); |
2301 | extent.X = (float)Util.WorldToRegionLoc((uint)megaRegionSize.X); | ||
2302 | extent.Y = (float)Util.WorldToRegionLoc((uint)megaRegionSize.Y); | ||
2319 | } | 2303 | } |
2320 | 2304 | ||
2321 | // Loss of fraction on purpose | ||
2322 | extent.X = ((int)extent.X / (int)Constants.RegionSize); | ||
2323 | extent.Y = ((int)extent.Y / (int)Constants.RegionSize); | ||
2324 | |||
2325 | swCorner.X = Scene.RegionInfo.RegionLocX - 1; | 2305 | swCorner.X = Scene.RegionInfo.RegionLocX - 1; |
2326 | swCorner.Y = Scene.RegionInfo.RegionLocY - 1; | 2306 | swCorner.Y = Scene.RegionInfo.RegionLocY - 1; |
2327 | neCorner.X = Scene.RegionInfo.RegionLocX + extent.X; | 2307 | neCorner.X = Scene.RegionInfo.RegionLocX + extent.X; |
diff --git a/OpenSim/Region/Framework/Interfaces/IRegionCombinerModule.cs b/OpenSim/Region/Framework/Interfaces/IRegionCombinerModule.cs index e03ac5a..c6f531e 100644 --- a/OpenSim/Region/Framework/Interfaces/IRegionCombinerModule.cs +++ b/OpenSim/Region/Framework/Interfaces/IRegionCombinerModule.cs | |||
@@ -55,5 +55,10 @@ namespace OpenSim.Region.Framework.Interfaces | |||
55 | /// Currently, will throw an exception if this does not match a root region. | 55 | /// Currently, will throw an exception if this does not match a root region. |
56 | /// </param> | 56 | /// </param> |
57 | Vector2 GetSizeOfMegaregion(UUID regionId); | 57 | Vector2 GetSizeOfMegaregion(UUID regionId); |
58 | |||
59 | /// <summary> | ||
60 | /// Tests to see of position (relative to the region) is within the megaregion | ||
61 | /// </summary> | ||
62 | bool PositionIsInMegaregion(UUID currentRegion, int xx, int yy); | ||
58 | } | 63 | } |
59 | } \ No newline at end of file | 64 | } \ No newline at end of file |
diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs index 2f666c0..682c2aa 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.cs | |||
@@ -160,11 +160,6 @@ namespace OpenSim.Region.Framework.Scenes | |||
160 | /// </summary> | 160 | /// </summary> |
161 | public SimStatsReporter StatsReporter { get; private set; } | 161 | public SimStatsReporter StatsReporter { get; private set; } |
162 | 162 | ||
163 | public List<Border> NorthBorders = new List<Border>(); | ||
164 | public List<Border> EastBorders = new List<Border>(); | ||
165 | public List<Border> SouthBorders = new List<Border>(); | ||
166 | public List<Border> WestBorders = new List<Border>(); | ||
167 | |||
168 | /// <summary> | 163 | /// <summary> |
169 | /// Controls whether physics can be applied to prims. Even if false, prims still have entries in a | 164 | /// Controls whether physics can be applied to prims. Even if false, prims still have entries in a |
170 | /// PhysicsScene in order to perform collision detection | 165 | /// PhysicsScene in order to perform collision detection |
@@ -349,7 +344,6 @@ namespace OpenSim.Region.Framework.Scenes | |||
349 | 344 | ||
350 | // TODO: Possibly stop other classes being able to manipulate this directly. | 345 | // TODO: Possibly stop other classes being able to manipulate this directly. |
351 | private SceneGraph m_sceneGraph; | 346 | private SceneGraph m_sceneGraph; |
352 | private volatile int m_bordersLocked; | ||
353 | private readonly Timer m_restartTimer = new Timer(15000); // Wait before firing | 347 | private readonly Timer m_restartTimer = new Timer(15000); // Wait before firing |
354 | private volatile bool m_backingup; | 348 | private volatile bool m_backingup; |
355 | private Dictionary<UUID, ReturnInfo> m_returns = new Dictionary<UUID, ReturnInfo>(); | 349 | private Dictionary<UUID, ReturnInfo> m_returns = new Dictionary<UUID, ReturnInfo>(); |
@@ -426,18 +420,6 @@ namespace OpenSim.Region.Framework.Scenes | |||
426 | set { m_splitRegionID = value; } | 420 | set { m_splitRegionID = value; } |
427 | } | 421 | } |
428 | 422 | ||
429 | public bool BordersLocked | ||
430 | { | ||
431 | get { return m_bordersLocked == 1; } | ||
432 | set | ||
433 | { | ||
434 | if (value == true) | ||
435 | m_bordersLocked = 1; | ||
436 | else | ||
437 | m_bordersLocked = 0; | ||
438 | } | ||
439 | } | ||
440 | |||
441 | public new float TimeDilation | 423 | public new float TimeDilation |
442 | { | 424 | { |
443 | get { return m_sceneGraph.PhysicsScene.TimeDilation; } | 425 | get { return m_sceneGraph.PhysicsScene.TimeDilation; } |
@@ -1031,28 +1013,6 @@ namespace OpenSim.Region.Framework.Scenes | |||
1031 | PeriodicBackup = true; | 1013 | PeriodicBackup = true; |
1032 | UseBackup = true; | 1014 | UseBackup = true; |
1033 | 1015 | ||
1034 | BordersLocked = true; | ||
1035 | Border northBorder = new Border(); | ||
1036 | northBorder.BorderLine = new Vector3(float.MinValue, float.MaxValue, (float)RegionInfo.RegionSizeY); //<--- | ||
1037 | northBorder.CrossDirection = Cardinals.N; | ||
1038 | NorthBorders.Add(northBorder); | ||
1039 | |||
1040 | Border southBorder = new Border(); | ||
1041 | southBorder.BorderLine = new Vector3(float.MinValue, float.MaxValue,0); //---> | ||
1042 | southBorder.CrossDirection = Cardinals.S; | ||
1043 | SouthBorders.Add(southBorder); | ||
1044 | |||
1045 | Border eastBorder = new Border(); | ||
1046 | eastBorder.BorderLine = new Vector3(float.MinValue, float.MaxValue, (float)RegionInfo.RegionSizeY); //<--- | ||
1047 | eastBorder.CrossDirection = Cardinals.E; | ||
1048 | EastBorders.Add(eastBorder); | ||
1049 | |||
1050 | Border westBorder = new Border(); | ||
1051 | westBorder.BorderLine = new Vector3(float.MinValue, float.MaxValue,0); //---> | ||
1052 | westBorder.CrossDirection = Cardinals.W; | ||
1053 | WestBorders.Add(westBorder); | ||
1054 | BordersLocked = false; | ||
1055 | |||
1056 | m_eventManager = new EventManager(); | 1016 | m_eventManager = new EventManager(); |
1057 | 1017 | ||
1058 | m_permissions = new ScenePermissions(this); | 1018 | m_permissions = new ScenePermissions(this); |
@@ -2445,201 +2405,34 @@ namespace OpenSim.Region.Framework.Scenes | |||
2445 | } | 2405 | } |
2446 | 2406 | ||
2447 | // Simple test to see if a position is in the current region. | 2407 | // Simple test to see if a position is in the current region. |
2448 | // Resuming the position is relative to the region so anything outside its bounds. | 2408 | // This test is mostly used to see if a region crossing is necessary. |
2409 | // Assuming the position is relative to the region so anything outside its bounds. | ||
2449 | // Return 'true' if position inside region. | 2410 | // Return 'true' if position inside region. |
2450 | public bool PositionIsInCurrentRegion(Vector3 pos) | 2411 | public bool PositionIsInCurrentRegion(Vector3 pos) |
2451 | { | 2412 | { |
2452 | bool ret = true; | 2413 | bool ret = false; |
2453 | int xx = (int)Math.Floor(pos.X); | 2414 | int xx = (int)Math.Floor(pos.X); |
2454 | int yy = (int)Math.Floor(pos.Y); | 2415 | int yy = (int)Math.Floor(pos.Y); |
2455 | if (xx < 0 | 2416 | if (xx < 0 || yy < 0) |
2456 | || xx >= RegionInfo.RegionSizeX | 2417 | return false; |
2457 | || yy < 0 | ||
2458 | || yy >= RegionInfo.RegionSizeY) | ||
2459 | ret = false; | ||
2460 | return ret; | ||
2461 | |||
2462 | } | ||
2463 | 2418 | ||
2464 | public Border GetCrossedBorder(Vector3 position, Cardinals gridline) | 2419 | IRegionCombinerModule regionCombinerModule = RequestModuleInterface<IRegionCombinerModule>(); |
2465 | { | 2420 | if (regionCombinerModule == null) |
2466 | if (BordersLocked) | ||
2467 | { | 2421 | { |
2468 | switch (gridline) | 2422 | // Regular region. Just check for region size |
2469 | { | 2423 | if (xx < RegionInfo.RegionSizeX || yy < RegionInfo.RegionSizeY ) |
2470 | case Cardinals.N: | 2424 | ret = true; |
2471 | lock (NorthBorders) | ||
2472 | { | ||
2473 | foreach (Border b in NorthBorders) | ||
2474 | { | ||
2475 | if (b.TestCross(position)) | ||
2476 | return b; | ||
2477 | } | ||
2478 | } | ||
2479 | break; | ||
2480 | case Cardinals.S: | ||
2481 | lock (SouthBorders) | ||
2482 | { | ||
2483 | foreach (Border b in SouthBorders) | ||
2484 | { | ||
2485 | if (b.TestCross(position)) | ||
2486 | return b; | ||
2487 | } | ||
2488 | } | ||
2489 | |||
2490 | break; | ||
2491 | case Cardinals.E: | ||
2492 | lock (EastBorders) | ||
2493 | { | ||
2494 | foreach (Border b in EastBorders) | ||
2495 | { | ||
2496 | if (b.TestCross(position)) | ||
2497 | return b; | ||
2498 | } | ||
2499 | } | ||
2500 | |||
2501 | break; | ||
2502 | case Cardinals.W: | ||
2503 | |||
2504 | lock (WestBorders) | ||
2505 | { | ||
2506 | foreach (Border b in WestBorders) | ||
2507 | { | ||
2508 | if (b.TestCross(position)) | ||
2509 | return b; | ||
2510 | } | ||
2511 | } | ||
2512 | break; | ||
2513 | |||
2514 | } | ||
2515 | } | 2425 | } |
2516 | else | 2426 | else |
2517 | { | 2427 | { |
2518 | switch (gridline) | 2428 | // We're in a mega-region so see if we are still in that larger region |
2519 | { | 2429 | ret = regionCombinerModule.PositionIsInMegaregion(this.RegionInfo.RegionID, xx, yy); |
2520 | case Cardinals.N: | ||
2521 | foreach (Border b in NorthBorders) | ||
2522 | { | ||
2523 | if (b.TestCross(position)) | ||
2524 | return b; | ||
2525 | } | ||
2526 | |||
2527 | break; | ||
2528 | case Cardinals.S: | ||
2529 | foreach (Border b in SouthBorders) | ||
2530 | { | ||
2531 | if (b.TestCross(position)) | ||
2532 | return b; | ||
2533 | } | ||
2534 | break; | ||
2535 | case Cardinals.E: | ||
2536 | foreach (Border b in EastBorders) | ||
2537 | { | ||
2538 | if (b.TestCross(position)) | ||
2539 | return b; | ||
2540 | } | ||
2541 | |||
2542 | break; | ||
2543 | case Cardinals.W: | ||
2544 | foreach (Border b in WestBorders) | ||
2545 | { | ||
2546 | if (b.TestCross(position)) | ||
2547 | return b; | ||
2548 | } | ||
2549 | break; | ||
2550 | |||
2551 | } | ||
2552 | } | 2430 | } |
2553 | 2431 | ||
2554 | return null; | 2432 | return ret; |
2555 | } | ||
2556 | 2433 | ||
2557 | public bool TestBorderCross(Vector3 position, Cardinals border) | ||
2558 | { | ||
2559 | if (BordersLocked) | ||
2560 | { | ||
2561 | switch (border) | ||
2562 | { | ||
2563 | case Cardinals.N: | ||
2564 | lock (NorthBorders) | ||
2565 | { | ||
2566 | foreach (Border b in NorthBorders) | ||
2567 | { | ||
2568 | if (b.TestCross(position)) | ||
2569 | return true; | ||
2570 | } | ||
2571 | } | ||
2572 | break; | ||
2573 | case Cardinals.E: | ||
2574 | lock (EastBorders) | ||
2575 | { | ||
2576 | foreach (Border b in EastBorders) | ||
2577 | { | ||
2578 | if (b.TestCross(position)) | ||
2579 | return true; | ||
2580 | } | ||
2581 | } | ||
2582 | break; | ||
2583 | case Cardinals.S: | ||
2584 | lock (SouthBorders) | ||
2585 | { | ||
2586 | foreach (Border b in SouthBorders) | ||
2587 | { | ||
2588 | if (b.TestCross(position)) | ||
2589 | return true; | ||
2590 | } | ||
2591 | } | ||
2592 | break; | ||
2593 | case Cardinals.W: | ||
2594 | lock (WestBorders) | ||
2595 | { | ||
2596 | foreach (Border b in WestBorders) | ||
2597 | { | ||
2598 | if (b.TestCross(position)) | ||
2599 | return true; | ||
2600 | } | ||
2601 | } | ||
2602 | break; | ||
2603 | } | ||
2604 | } | ||
2605 | else | ||
2606 | { | ||
2607 | switch (border) | ||
2608 | { | ||
2609 | case Cardinals.N: | ||
2610 | foreach (Border b in NorthBorders) | ||
2611 | { | ||
2612 | if (b.TestCross(position)) | ||
2613 | return true; | ||
2614 | } | ||
2615 | break; | ||
2616 | case Cardinals.E: | ||
2617 | foreach (Border b in EastBorders) | ||
2618 | { | ||
2619 | if (b.TestCross(position)) | ||
2620 | return true; | ||
2621 | } | ||
2622 | break; | ||
2623 | case Cardinals.S: | ||
2624 | foreach (Border b in SouthBorders) | ||
2625 | { | ||
2626 | if (b.TestCross(position)) | ||
2627 | return true; | ||
2628 | } | ||
2629 | break; | ||
2630 | case Cardinals.W: | ||
2631 | foreach (Border b in WestBorders) | ||
2632 | { | ||
2633 | if (b.TestCross(position)) | ||
2634 | return true; | ||
2635 | } | ||
2636 | break; | ||
2637 | } | ||
2638 | } | ||
2639 | return false; | ||
2640 | } | 2434 | } |
2641 | 2435 | ||
2642 | |||
2643 | /// <summary> | 2436 | /// <summary> |
2644 | /// Called when objects or attachments cross the border, or teleport, between regions. | 2437 | /// Called when objects or attachments cross the border, or teleport, between regions. |
2645 | /// </summary> | 2438 | /// </summary> |
@@ -3874,61 +3667,11 @@ namespace OpenSim.Region.Framework.Scenes | |||
3874 | { | 3667 | { |
3875 | // CleanDroppedAttachments(); | 3668 | // CleanDroppedAttachments(); |
3876 | 3669 | ||
3877 | if (TestBorderCross(acd.startpos, Cardinals.E)) | 3670 | // Make sure avatar position is in the region (why it wouldn't be is a mystery but do sanity checking) |
3878 | { | 3671 | if (acd.startpos.X < 0) acd.startpos.X = 1f; |
3879 | Border crossedBorder = GetCrossedBorder(acd.startpos, Cardinals.E); | 3672 | if (acd.startpos.X >= RegionInfo.RegionSizeX) acd.startpos.X = RegionInfo.RegionSizeX - 1f; |
3880 | acd.startpos.X = crossedBorder.BorderLine.Z - 1; | 3673 | if (acd.startpos.Y < 0) acd.startpos.Y = 1f; |
3881 | m_log.DebugFormat("{0} NewUserConnection Adjusted border E. startpos={1}", LogHeader, acd.startpos); | 3674 | if (acd.startpos.Y >= RegionInfo.RegionSizeY) acd.startpos.Y = RegionInfo.RegionSizeY - 1f; |
3882 | } | ||
3883 | |||
3884 | if (TestBorderCross(acd.startpos, Cardinals.N)) | ||
3885 | { | ||
3886 | Border crossedBorder = GetCrossedBorder(acd.startpos, Cardinals.N); | ||
3887 | acd.startpos.Y = crossedBorder.BorderLine.Z - 1; | ||
3888 | } | ||
3889 | |||
3890 | //Mitigate http://opensimulator.org/mantis/view.php?id=3522 | ||
3891 | // Check if start position is outside of region | ||
3892 | // If it is, check the Z start position also.. if not, leave it alone. | ||
3893 | if (BordersLocked) | ||
3894 | { | ||
3895 | lock (EastBorders) | ||
3896 | { | ||
3897 | if (acd.startpos.X > EastBorders[0].BorderLine.Z) | ||
3898 | { | ||
3899 | m_log.Warn("FIX AGENT POSITION"); | ||
3900 | acd.startpos.X = EastBorders[0].BorderLine.Z * 0.5f; | ||
3901 | if (acd.startpos.Z > 720) | ||
3902 | acd.startpos.Z = 720; | ||
3903 | } | ||
3904 | } | ||
3905 | lock (NorthBorders) | ||
3906 | { | ||
3907 | if (acd.startpos.Y > NorthBorders[0].BorderLine.Z) | ||
3908 | { | ||
3909 | m_log.Warn("FIX Agent POSITION"); | ||
3910 | acd.startpos.Y = NorthBorders[0].BorderLine.Z * 0.5f; | ||
3911 | if (acd.startpos.Z > 720) | ||
3912 | acd.startpos.Z = 720; | ||
3913 | } | ||
3914 | } | ||
3915 | } else | ||
3916 | { | ||
3917 | if (acd.startpos.X > EastBorders[0].BorderLine.Z) | ||
3918 | { | ||
3919 | m_log.Warn("FIX AGENT POSITION"); | ||
3920 | acd.startpos.X = EastBorders[0].BorderLine.Z * 0.5f; | ||
3921 | if (acd.startpos.Z > 720) | ||
3922 | acd.startpos.Z = 720; | ||
3923 | } | ||
3924 | if (acd.startpos.Y > NorthBorders[0].BorderLine.Z) | ||
3925 | { | ||
3926 | m_log.Warn("FIX Agent POSITION"); | ||
3927 | acd.startpos.Y = NorthBorders[0].BorderLine.Z * 0.5f; | ||
3928 | if (acd.startpos.Z > 720) | ||
3929 | acd.startpos.Z = 720; | ||
3930 | } | ||
3931 | } | ||
3932 | 3675 | ||
3933 | // m_log.DebugFormat( | 3676 | // m_log.DebugFormat( |
3934 | // "[SCENE]: Found telehub object {0} for new user connection {1} to {2}", | 3677 | // "[SCENE]: Found telehub object {0} for new user connection {1} to {2}", |
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs index c6b98ca..0657cbb 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs | |||
@@ -429,7 +429,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
429 | /// <returns></returns> | 429 | /// <returns></returns> |
430 | public bool IsAttachmentCheckFull() | 430 | public bool IsAttachmentCheckFull() |
431 | { | 431 | { |
432 | return (IsAttachment || (m_rootPart.Shape.PCode == 9 && m_rootPart.Shape.State != 0)); | 432 | return (IsAttachment || (m_rootPart.Shape.PCode == (byte)PCodeEnum.Primitive && m_rootPart.Shape.State != 0)); |
433 | } | 433 | } |
434 | 434 | ||
435 | private struct avtocrossInfo | 435 | private struct avtocrossInfo |
@@ -451,19 +451,10 @@ namespace OpenSim.Region.Framework.Scenes | |||
451 | if (Scene != null) | 451 | if (Scene != null) |
452 | { | 452 | { |
453 | if ( | 453 | if ( |
454 | // (Scene.TestBorderCross(val - Vector3.UnitX, Cardinals.E) | 454 | !Scene.PositionIsInCurrentRegion(val) |
455 | // || Scene.TestBorderCross(val + Vector3.UnitX, Cardinals.W) | 455 | && !IsAttachmentCheckFull() |
456 | // || Scene.TestBorderCross(val - Vector3.UnitY, Cardinals.N) | 456 | && (!Scene.LoadingPrims) |
457 | // || Scene.TestBorderCross(val + Vector3.UnitY, Cardinals.S)) | 457 | ) |
458 | // Experimental change for better border crossings. | ||
459 | // The commented out original lines above would, it seems, trigger | ||
460 | // a border crossing a little early or late depending on which | ||
461 | // direction the object was moving. | ||
462 | (Scene.TestBorderCross(val, Cardinals.E) | ||
463 | || Scene.TestBorderCross(val, Cardinals.W) | ||
464 | || Scene.TestBorderCross(val, Cardinals.N) | ||
465 | || Scene.TestBorderCross(val, Cardinals.S)) | ||
466 | && !IsAttachmentCheckFull() && (!Scene.LoadingPrims)) | ||
467 | { | 458 | { |
468 | IEntityTransferModule entityTransfer = m_scene.RequestModuleInterface<IEntityTransferModule>(); | 459 | IEntityTransferModule entityTransfer = m_scene.RequestModuleInterface<IEntityTransferModule>(); |
469 | string version = String.Empty; | 460 | string version = String.Empty; |
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs index 1cf7726..db4e285 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs | |||
@@ -2479,13 +2479,10 @@ namespace OpenSim.Region.Framework.Scenes | |||
2479 | 2479 | ||
2480 | if (pa != null) | 2480 | if (pa != null) |
2481 | { | 2481 | { |
2482 | Vector3 newpos = new Vector3(pa.Position.GetBytes(), 0); | 2482 | Vector3 newpos = pa.Position; |
2483 | 2483 | if (!ParentGroup.Scene.PositionIsInCurrentRegion(newpos)) | |
2484 | if (ParentGroup.Scene.TestBorderCross(newpos, Cardinals.N) | ||
2485 | | ParentGroup.Scene.TestBorderCross(newpos, Cardinals.S) | ||
2486 | | ParentGroup.Scene.TestBorderCross(newpos, Cardinals.E) | ||
2487 | | ParentGroup.Scene.TestBorderCross(newpos, Cardinals.W)) | ||
2488 | { | 2484 | { |
2485 | // Setting position outside current region will start region crossing | ||
2489 | ParentGroup.AbsolutePosition = newpos; | 2486 | ParentGroup.AbsolutePosition = newpos; |
2490 | return; | 2487 | return; |
2491 | } | 2488 | } |
diff --git a/OpenSim/Region/OptionalModules/World/SceneCommands/SceneCommandsModule.cs b/OpenSim/Region/OptionalModules/World/SceneCommands/SceneCommandsModule.cs index 29b39e0..5fb74b0 100644 --- a/OpenSim/Region/OptionalModules/World/SceneCommands/SceneCommandsModule.cs +++ b/OpenSim/Region/OptionalModules/World/SceneCommands/SceneCommandsModule.cs | |||
@@ -116,37 +116,6 @@ namespace OpenSim.Region.OptionalModules.Avatar.Attachments | |||
116 | + "If teleport is true then some extra teleport debug information is logged.\n" | 116 | + "If teleport is true then some extra teleport debug information is logged.\n" |
117 | + "If updates is true then any frame which exceeds double the maximum desired frame time is logged.", | 117 | + "If updates is true then any frame which exceeds double the maximum desired frame time is logged.", |
118 | HandleDebugSceneSetCommand); | 118 | HandleDebugSceneSetCommand); |
119 | |||
120 | scene.AddCommand( | ||
121 | "Regions", | ||
122 | this, "show borders", "show borders", "Show border information for regions", HandleShowBordersCommand); | ||
123 | } | ||
124 | |||
125 | private void HandleShowBordersCommand(string module, string[] args) | ||
126 | { | ||
127 | StringBuilder sb = new StringBuilder(); | ||
128 | sb.AppendFormat("Borders for {0}:\n", m_scene.Name); | ||
129 | |||
130 | ConsoleDisplayTable cdt = new ConsoleDisplayTable(); | ||
131 | cdt.AddColumn("Cross Direction", 15); | ||
132 | cdt.AddColumn("Line", 34); | ||
133 | cdt.AddColumn("Trigger Region", 14); | ||
134 | |||
135 | foreach (Border b in m_scene.NorthBorders) | ||
136 | cdt.AddRow(b.CrossDirection, b.BorderLine, string.Format("{0}, {1}", b.TriggerRegionX, b.TriggerRegionY)); | ||
137 | |||
138 | foreach (Border b in m_scene.EastBorders) | ||
139 | cdt.AddRow(b.CrossDirection, b.BorderLine, string.Format("{0}, {1}", b.TriggerRegionX, b.TriggerRegionY)); | ||
140 | |||
141 | foreach (Border b in m_scene.SouthBorders) | ||
142 | cdt.AddRow(b.CrossDirection, b.BorderLine, string.Format("{0}, {1}", b.TriggerRegionX, b.TriggerRegionY)); | ||
143 | |||
144 | foreach (Border b in m_scene.WestBorders) | ||
145 | cdt.AddRow(b.CrossDirection, b.BorderLine, string.Format("{0}, {1}", b.TriggerRegionX, b.TriggerRegionY)); | ||
146 | |||
147 | cdt.AddToStringBuilder(sb); | ||
148 | |||
149 | MainConsole.Instance.Output(sb.ToString()); | ||
150 | } | 119 | } |
151 | 120 | ||
152 | private void HandleDebugSceneGetCommand(string module, string[] args) | 121 | private void HandleDebugSceneGetCommand(string module, string[] args) |
diff --git a/OpenSim/Region/RegionCombinerModule/RegionCombinerModule.cs b/OpenSim/Region/RegionCombinerModule/RegionCombinerModule.cs index 7127c73..a7ffad0 100644 --- a/OpenSim/Region/RegionCombinerModule/RegionCombinerModule.cs +++ b/OpenSim/Region/RegionCombinerModule/RegionCombinerModule.cs | |||
@@ -44,6 +44,7 @@ namespace OpenSim.Region.RegionCombinerModule | |||
44 | public class RegionCombinerModule : ISharedRegionModule, IRegionCombinerModule | 44 | public class RegionCombinerModule : ISharedRegionModule, IRegionCombinerModule |
45 | { | 45 | { |
46 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | 46 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); |
47 | private static string LogHeader = "[REGION COMBINER MODULE]"; | ||
47 | 48 | ||
48 | public string Name | 49 | public string Name |
49 | { | 50 | { |
@@ -134,6 +135,49 @@ namespace OpenSim.Region.RegionCombinerModule | |||
134 | throw new Exception(string.Format("Region with id {0} not found", regionId)); | 135 | throw new Exception(string.Format("Region with id {0} not found", regionId)); |
135 | } | 136 | } |
136 | 137 | ||
138 | // Test to see if this postiion (relative to the region) is within the area covered | ||
139 | // by this megaregion. | ||
140 | public bool PositionIsInMegaregion(UUID currentRegion, int xx, int yy) | ||
141 | { | ||
142 | bool ret = false; | ||
143 | if (xx < 0 || yy < 0) | ||
144 | return ret; | ||
145 | |||
146 | foreach (RegionConnections rootRegion in m_regions.Values) | ||
147 | { | ||
148 | if (currentRegion == rootRegion.RegionId) | ||
149 | { | ||
150 | // The caller is in the root region so this is an easy test | ||
151 | if (xx < rootRegion.XEnd && yy < rootRegion.YEnd) | ||
152 | { | ||
153 | ret = true; | ||
154 | } | ||
155 | break; | ||
156 | } | ||
157 | else | ||
158 | { | ||
159 | // Maybe the caller is in one of the sub-regions | ||
160 | foreach (RegionData childRegion in rootRegion.ConnectedRegions) | ||
161 | { | ||
162 | if (currentRegion == childRegion.RegionId) | ||
163 | { | ||
164 | // This is a child. Diddle the offsets and check if in | ||
165 | Vector3 positionInMegaregion = childRegion.Offset; | ||
166 | positionInMegaregion.X += xx; | ||
167 | positionInMegaregion.Y += yy; | ||
168 | if (positionInMegaregion.X < rootRegion.XEnd && positionInMegaregion.Y < rootRegion.YEnd) | ||
169 | { | ||
170 | ret = true; | ||
171 | } | ||
172 | break; | ||
173 | } | ||
174 | } | ||
175 | } | ||
176 | } | ||
177 | |||
178 | return ret; | ||
179 | } | ||
180 | |||
137 | private void NewPresence(ScenePresence presence) | 181 | private void NewPresence(ScenePresence presence) |
138 | { | 182 | { |
139 | if (presence.IsChildAgent) | 183 | if (presence.IsChildAgent) |
@@ -220,27 +264,6 @@ namespace OpenSim.Region.RegionCombinerModule | |||
220 | // | 264 | // |
221 | */ | 265 | */ |
222 | 266 | ||
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(); | 267 | RegionConnections newConn = new RegionConnections(); |
245 | newConn.ConnectedRegions = new List<RegionData>(); | 268 | newConn.ConnectedRegions = new List<RegionData>(); |
246 | newConn.RegionScene = scene; | 269 | newConn.RegionScene = scene; |
@@ -248,8 +271,8 @@ namespace OpenSim.Region.RegionCombinerModule | |||
248 | newConn.RegionId = scene.RegionInfo.originRegionID; | 271 | newConn.RegionId = scene.RegionInfo.originRegionID; |
249 | newConn.X = scene.RegionInfo.RegionLocX; | 272 | newConn.X = scene.RegionInfo.RegionLocX; |
250 | newConn.Y = scene.RegionInfo.RegionLocY; | 273 | newConn.Y = scene.RegionInfo.RegionLocY; |
251 | newConn.XEnd = (int)Constants.RegionSize; | 274 | newConn.XEnd = scene.RegionInfo.RegionSizeX; |
252 | newConn.YEnd = (int)Constants.RegionSize; | 275 | newConn.YEnd = scene.RegionInfo.RegionSizeX; |
253 | 276 | ||
254 | lock (m_regions) | 277 | lock (m_regions) |
255 | { | 278 | { |
@@ -415,6 +438,11 @@ namespace OpenSim.Region.RegionCombinerModule | |||
415 | */ | 438 | */ |
416 | #endregion | 439 | #endregion |
417 | 440 | ||
441 | |||
442 | // Check to see if this new region is adjacent to the root region. | ||
443 | // Note that we expect the regions to be combined from the root region outward | ||
444 | // thus the requirement for the ordering in the configuration files. | ||
445 | |||
418 | // If we're one region over +x y (i.e. root region is to the west) | 446 | // If we're one region over +x y (i.e. root region is to the west) |
419 | //xxx | 447 | //xxx |
420 | //xxy | 448 | //xxy |
@@ -431,7 +459,7 @@ namespace OpenSim.Region.RegionCombinerModule | |||
431 | //xxx | 459 | //xxx |
432 | if (rootConn.PosX >= newConn.PosX && rootConn.PosY + rootConn.YEnd >= newConn.PosY) | 460 | if (rootConn.PosX >= newConn.PosX && rootConn.PosY + rootConn.YEnd >= newConn.PosY) |
433 | { | 461 | { |
434 | connectedYN = DoWorkForOneRegionOverXPlusY(rootConn, newConn, scene); | 462 | connectedYN = DoWorkForOneRegionOverPlusXY(rootConn, newConn, scene); |
435 | break; | 463 | break; |
436 | } | 464 | } |
437 | 465 | ||
@@ -441,9 +469,8 @@ namespace OpenSim.Region.RegionCombinerModule | |||
441 | //xxx | 469 | //xxx |
442 | if (rootConn.PosX + rootConn.XEnd >= newConn.PosX && rootConn.PosY + rootConn.YEnd >= newConn.PosY) | 470 | if (rootConn.PosX + rootConn.XEnd >= newConn.PosX && rootConn.PosY + rootConn.YEnd >= newConn.PosY) |
443 | { | 471 | { |
444 | connectedYN = DoWorkForOneRegionOverPlusXPlusY(rootConn, newConn, scene); | 472 | connectedYN = DoWorkForOneRegionOverPlusXY(rootConn, newConn, scene); |
445 | break; | 473 | break; |
446 | |||
447 | } | 474 | } |
448 | } | 475 | } |
449 | 476 | ||
@@ -453,20 +480,20 @@ namespace OpenSim.Region.RegionCombinerModule | |||
453 | DoWorkForRootRegion(newConn, scene); | 480 | DoWorkForRootRegion(newConn, scene); |
454 | } | 481 | } |
455 | } | 482 | } |
456 | |||
457 | // Set up infinite borders around the entire AABB of the combined ConnectedRegions | ||
458 | AdjustLargeRegionBounds(); | ||
459 | } | 483 | } |
460 | 484 | ||
461 | private bool DoWorkForOneRegionOverPlusXY(RegionConnections rootConn, RegionConnections newConn, Scene scene) | 485 | private bool DoWorkForOneRegionOverPlusXY(RegionConnections rootConn, RegionConnections newConn, Scene scene) |
462 | { | 486 | { |
487 | // Offset (in meters) from the base of this region to the base of the root region. | ||
463 | Vector3 offset = Vector3.Zero; | 488 | Vector3 offset = Vector3.Zero; |
464 | offset.X = newConn.PosX - rootConn.PosX; | 489 | offset.X = newConn.PosX - rootConn.PosX; |
465 | offset.Y = newConn.PosY - rootConn.PosY; | 490 | offset.Y = newConn.PosY - rootConn.PosY; |
466 | 491 | ||
492 | // The new total size of the region (in meters) | ||
493 | // We just extend the X and Y dimensions so the extent might temporarily include areas without regions. | ||
467 | Vector3 extents = Vector3.Zero; | 494 | Vector3 extents = Vector3.Zero; |
468 | extents.Y = rootConn.YEnd; | 495 | extents.X = Math.Max(rootConn.XEnd, offset.X + newConn.RegionScene.RegionInfo.RegionSizeX); |
469 | extents.X = rootConn.XEnd + newConn.XEnd; | 496 | extents.Y = Math.Max(rootConn.YEnd, offset.Y + newConn.RegionScene.RegionInfo.RegionSizeY); |
470 | 497 | ||
471 | rootConn.UpdateExtents(extents); | 498 | rootConn.UpdateExtents(extents); |
472 | 499 | ||
@@ -475,9 +502,6 @@ namespace OpenSim.Region.RegionCombinerModule | |||
475 | rootConn.RegionScene.RegionInfo.RegionName, | 502 | rootConn.RegionScene.RegionInfo.RegionName, |
476 | newConn.RegionScene.RegionInfo.RegionName, offset, extents); | 503 | newConn.RegionScene.RegionInfo.RegionName, offset, extents); |
477 | 504 | ||
478 | scene.BordersLocked = true; | ||
479 | rootConn.RegionScene.BordersLocked = true; | ||
480 | |||
481 | RegionData ConnectedRegion = new RegionData(); | 505 | RegionData ConnectedRegion = new RegionData(); |
482 | ConnectedRegion.Offset = offset; | 506 | ConnectedRegion.Offset = offset; |
483 | ConnectedRegion.RegionId = scene.RegionInfo.originRegionID; | 507 | ConnectedRegion.RegionId = scene.RegionInfo.originRegionID; |
@@ -490,34 +514,10 @@ namespace OpenSim.Region.RegionCombinerModule | |||
490 | // Inform Child region that it needs to forward it's terrain to the root region | 514 | // Inform Child region that it needs to forward it's terrain to the root region |
491 | scene.PhysicsScene.Combine(rootConn.RegionScene.PhysicsScene, offset, Vector3.Zero); | 515 | scene.PhysicsScene.Combine(rootConn.RegionScene.PhysicsScene, offset, Vector3.Zero); |
492 | 516 | ||
493 | // Extend the borders as appropriate | ||
494 | lock (rootConn.RegionScene.EastBorders) | ||
495 | rootConn.RegionScene.EastBorders[0].BorderLine.Z += (int)Constants.RegionSize; | ||
496 | |||
497 | lock (rootConn.RegionScene.NorthBorders) | ||
498 | rootConn.RegionScene.NorthBorders[0].BorderLine.Y += (int)Constants.RegionSize; | ||
499 | |||
500 | lock (rootConn.RegionScene.SouthBorders) | ||
501 | rootConn.RegionScene.SouthBorders[0].BorderLine.Y += (int)Constants.RegionSize; | ||
502 | |||
503 | lock (scene.WestBorders) | ||
504 | { | ||
505 | scene.WestBorders[0].BorderLine.Z = (int)((scene.RegionInfo.RegionLocX - rootConn.RegionScene.RegionInfo.RegionLocX) * (int)Constants.RegionSize); //auto teleport West | ||
506 | |||
507 | // Trigger auto teleport to root region | ||
508 | scene.WestBorders[0].TriggerRegionX = rootConn.RegionScene.RegionInfo.RegionLocX; | ||
509 | scene.WestBorders[0].TriggerRegionY = rootConn.RegionScene.RegionInfo.RegionLocY; | ||
510 | } | ||
511 | |||
512 | // Reset Terrain.. since terrain loads before we get here, we need to load | 517 | // Reset Terrain.. since terrain loads before we get here, we need to load |
513 | // it again so it loads in the root region | 518 | // it again so it loads in the root region |
514 | |||
515 | scene.PhysicsScene.SetTerrain(scene.Heightmap.GetFloatsSerialised()); | 519 | scene.PhysicsScene.SetTerrain(scene.Heightmap.GetFloatsSerialised()); |
516 | 520 | ||
517 | // Unlock borders | ||
518 | rootConn.RegionScene.BordersLocked = false; | ||
519 | scene.BordersLocked = false; | ||
520 | |||
521 | // Create a client event forwarder and add this region's events to the root region. | 521 | // Create a client event forwarder and add this region's events to the root region. |
522 | if (rootConn.ClientEventForwarder != null) | 522 | if (rootConn.ClientEventForwarder != null) |
523 | rootConn.ClientEventForwarder.AddSceneToEventForwarding(scene); | 523 | rootConn.ClientEventForwarder.AddSceneToEventForwarding(scene); |
@@ -525,6 +525,9 @@ namespace OpenSim.Region.RegionCombinerModule | |||
525 | return true; | 525 | return true; |
526 | } | 526 | } |
527 | 527 | ||
528 | /* | ||
529 | * 20140215 radams1: The border stuff was removed and the addition of regions to the mega-regions | ||
530 | * was generalized. These functions are not needed for the generalized solution but left for reference. | ||
528 | private bool DoWorkForOneRegionOverXPlusY(RegionConnections rootConn, RegionConnections newConn, Scene scene) | 531 | private bool DoWorkForOneRegionOverXPlusY(RegionConnections rootConn, RegionConnections newConn, Scene scene) |
529 | { | 532 | { |
530 | Vector3 offset = Vector3.Zero; | 533 | Vector3 offset = Vector3.Zero; |
@@ -536,9 +539,6 @@ namespace OpenSim.Region.RegionCombinerModule | |||
536 | extents.X = rootConn.XEnd; | 539 | extents.X = rootConn.XEnd; |
537 | rootConn.UpdateExtents(extents); | 540 | rootConn.UpdateExtents(extents); |
538 | 541 | ||
539 | scene.BordersLocked = true; | ||
540 | rootConn.RegionScene.BordersLocked = true; | ||
541 | |||
542 | RegionData ConnectedRegion = new RegionData(); | 542 | RegionData ConnectedRegion = new RegionData(); |
543 | ConnectedRegion.Offset = offset; | 543 | ConnectedRegion.Offset = offset; |
544 | ConnectedRegion.RegionId = scene.RegionInfo.originRegionID; | 544 | ConnectedRegion.RegionId = scene.RegionInfo.originRegionID; |
@@ -553,30 +553,11 @@ namespace OpenSim.Region.RegionCombinerModule | |||
553 | rootConn.RegionScene.PhysicsScene.Combine(null, Vector3.Zero, extents); | 553 | rootConn.RegionScene.PhysicsScene.Combine(null, Vector3.Zero, extents); |
554 | scene.PhysicsScene.Combine(rootConn.RegionScene.PhysicsScene, offset, Vector3.Zero); | 554 | scene.PhysicsScene.Combine(rootConn.RegionScene.PhysicsScene, offset, Vector3.Zero); |
555 | 555 | ||
556 | lock (rootConn.RegionScene.NorthBorders) | ||
557 | rootConn.RegionScene.NorthBorders[0].BorderLine.Z += (int)Constants.RegionSize; | ||
558 | |||
559 | lock (rootConn.RegionScene.EastBorders) | ||
560 | rootConn.RegionScene.EastBorders[0].BorderLine.Y += (int)Constants.RegionSize; | ||
561 | |||
562 | lock (rootConn.RegionScene.WestBorders) | ||
563 | rootConn.RegionScene.WestBorders[0].BorderLine.Y += (int)Constants.RegionSize; | ||
564 | |||
565 | lock (scene.SouthBorders) | ||
566 | { | ||
567 | scene.SouthBorders[0].BorderLine.Z = (int)((scene.RegionInfo.RegionLocY - rootConn.RegionScene.RegionInfo.RegionLocY) * (int)Constants.RegionSize); //auto teleport south | ||
568 | scene.SouthBorders[0].TriggerRegionX = rootConn.RegionScene.RegionInfo.RegionLocX; | ||
569 | scene.SouthBorders[0].TriggerRegionY = rootConn.RegionScene.RegionInfo.RegionLocY; | ||
570 | } | ||
571 | |||
572 | // Reset Terrain.. since terrain normally loads first. | 556 | // Reset Terrain.. since terrain normally loads first. |
573 | //conn.RegionScene.PhysicsScene.SetTerrain(conn.RegionScene.Heightmap.GetFloatsSerialised()); | 557 | //conn.RegionScene.PhysicsScene.SetTerrain(conn.RegionScene.Heightmap.GetFloatsSerialised()); |
574 | scene.PhysicsScene.SetTerrain(scene.Heightmap.GetFloatsSerialised()); | 558 | scene.PhysicsScene.SetTerrain(scene.Heightmap.GetFloatsSerialised()); |
575 | //conn.RegionScene.PhysicsScene.SetTerrain(conn.RegionScene.Heightmap.GetFloatsSerialised()); | 559 | //conn.RegionScene.PhysicsScene.SetTerrain(conn.RegionScene.Heightmap.GetFloatsSerialised()); |
576 | 560 | ||
577 | scene.BordersLocked = false; | ||
578 | rootConn.RegionScene.BordersLocked = false; | ||
579 | |||
580 | if (rootConn.ClientEventForwarder != null) | 561 | if (rootConn.ClientEventForwarder != null) |
581 | rootConn.ClientEventForwarder.AddSceneToEventForwarding(scene); | 562 | rootConn.ClientEventForwarder.AddSceneToEventForwarding(scene); |
582 | 563 | ||
@@ -600,9 +581,6 @@ namespace OpenSim.Region.RegionCombinerModule | |||
600 | extents.Y = rootConn.YEnd; | 581 | extents.Y = rootConn.YEnd; |
601 | extents.X = rootConn.XEnd; | 582 | extents.X = rootConn.XEnd; |
602 | 583 | ||
603 | scene.BordersLocked = true; | ||
604 | rootConn.RegionScene.BordersLocked = true; | ||
605 | |||
606 | RegionData ConnectedRegion = new RegionData(); | 584 | RegionData ConnectedRegion = new RegionData(); |
607 | ConnectedRegion.Offset = offset; | 585 | ConnectedRegion.Offset = offset; |
608 | ConnectedRegion.RegionId = scene.RegionInfo.originRegionID; | 586 | ConnectedRegion.RegionId = scene.RegionInfo.originRegionID; |
@@ -618,67 +596,10 @@ namespace OpenSim.Region.RegionCombinerModule | |||
618 | rootConn.RegionScene.PhysicsScene.Combine(null, Vector3.Zero, extents); | 596 | rootConn.RegionScene.PhysicsScene.Combine(null, Vector3.Zero, extents); |
619 | scene.PhysicsScene.Combine(rootConn.RegionScene.PhysicsScene, offset, Vector3.Zero); | 597 | scene.PhysicsScene.Combine(rootConn.RegionScene.PhysicsScene, offset, Vector3.Zero); |
620 | 598 | ||
621 | lock (rootConn.RegionScene.NorthBorders) | ||
622 | { | ||
623 | if (rootConn.RegionScene.NorthBorders.Count == 1)// && 2) | ||
624 | { | ||
625 | //compound border | ||
626 | // already locked above | ||
627 | rootConn.RegionScene.NorthBorders[0].BorderLine.Z += (int)Constants.RegionSize; | ||
628 | |||
629 | lock (rootConn.RegionScene.EastBorders) | ||
630 | rootConn.RegionScene.EastBorders[0].BorderLine.Y += (int)Constants.RegionSize; | ||
631 | |||
632 | lock (rootConn.RegionScene.WestBorders) | ||
633 | rootConn.RegionScene.WestBorders[0].BorderLine.Y += (int)Constants.RegionSize; | ||
634 | } | ||
635 | } | ||
636 | |||
637 | lock (scene.SouthBorders) | ||
638 | { | ||
639 | scene.SouthBorders[0].BorderLine.Z = (int)((scene.RegionInfo.RegionLocY - rootConn.RegionScene.RegionInfo.RegionLocY) * (int)Constants.RegionSize); //auto teleport south | ||
640 | scene.SouthBorders[0].TriggerRegionX = rootConn.RegionScene.RegionInfo.RegionLocX; | ||
641 | scene.SouthBorders[0].TriggerRegionY = rootConn.RegionScene.RegionInfo.RegionLocY; | ||
642 | } | ||
643 | |||
644 | lock (rootConn.RegionScene.EastBorders) | ||
645 | { | ||
646 | if (rootConn.RegionScene.EastBorders.Count == 1)// && conn.RegionScene.EastBorders.Count == 2) | ||
647 | { | ||
648 | rootConn.RegionScene.EastBorders[0].BorderLine.Z += (int)Constants.RegionSize; | ||
649 | |||
650 | lock (rootConn.RegionScene.NorthBorders) | ||
651 | rootConn.RegionScene.NorthBorders[0].BorderLine.Y += (int)Constants.RegionSize; | ||
652 | |||
653 | lock (rootConn.RegionScene.SouthBorders) | ||
654 | rootConn.RegionScene.SouthBorders[0].BorderLine.Y += (int)Constants.RegionSize; | ||
655 | } | ||
656 | } | ||
657 | |||
658 | lock (scene.WestBorders) | ||
659 | { | ||
660 | scene.WestBorders[0].BorderLine.Z = (int)((scene.RegionInfo.RegionLocX - rootConn.RegionScene.RegionInfo.RegionLocX) * (int)Constants.RegionSize); //auto teleport West | ||
661 | scene.WestBorders[0].TriggerRegionX = rootConn.RegionScene.RegionInfo.RegionLocX; | ||
662 | scene.WestBorders[0].TriggerRegionY = rootConn.RegionScene.RegionInfo.RegionLocY; | ||
663 | } | ||
664 | |||
665 | /* | ||
666 | else | ||
667 | { | ||
668 | conn.RegionScene.NorthBorders[0].BorderLine.Z += (int)Constants.RegionSize; | ||
669 | conn.RegionScene.EastBorders[0].BorderLine.Y += (int)Constants.RegionSize; | ||
670 | conn.RegionScene.WestBorders[0].BorderLine.Y += (int)Constants.RegionSize; | ||
671 | scene.SouthBorders[0].BorderLine.Z += (int)Constants.RegionSize; //auto teleport south | ||
672 | } | ||
673 | */ | ||
674 | |||
675 | |||
676 | // Reset Terrain.. since terrain normally loads first. | 599 | // Reset Terrain.. since terrain normally loads first. |
677 | //conn.RegionScene.PhysicsScene.SetTerrain(conn.RegionScene.Heightmap.GetFloatsSerialised()); | 600 | //conn.RegionScene.PhysicsScene.SetTerrain(conn.RegionScene.Heightmap.GetFloatsSerialised()); |
678 | scene.PhysicsScene.SetTerrain(scene.Heightmap.GetFloatsSerialised()); | 601 | scene.PhysicsScene.SetTerrain(scene.Heightmap.GetFloatsSerialised()); |
679 | //conn.RegionScene.PhysicsScene.SetTerrain(conn.RegionScene.Heightmap.GetFloatsSerialised()); | 602 | //conn.RegionScene.PhysicsScene.SetTerrain(conn.RegionScene.Heightmap.GetFloatsSerialised()); |
680 | scene.BordersLocked = false; | ||
681 | rootConn.RegionScene.BordersLocked = false; | ||
682 | 603 | ||
683 | if (rootConn.ClientEventForwarder != null) | 604 | if (rootConn.ClientEventForwarder != null) |
684 | rootConn.ClientEventForwarder.AddSceneToEventForwarding(scene); | 605 | rootConn.ClientEventForwarder.AddSceneToEventForwarding(scene); |
@@ -687,6 +608,7 @@ namespace OpenSim.Region.RegionCombinerModule | |||
687 | 608 | ||
688 | //scene.PhysicsScene.Combine(conn.RegionScene.PhysicsScene, offset,extents); | 609 | //scene.PhysicsScene.Combine(conn.RegionScene.PhysicsScene, offset,extents); |
689 | } | 610 | } |
611 | */ | ||
690 | 612 | ||
691 | private void DoWorkForRootRegion(RegionConnections rootConn, Scene scene) | 613 | private void DoWorkForRootRegion(RegionConnections rootConn, Scene scene) |
692 | { | 614 | { |
@@ -885,125 +807,6 @@ namespace OpenSim.Region.RegionCombinerModule | |||
885 | // } | 807 | // } |
886 | // } | 808 | // } |
887 | 809 | ||
888 | // Create a set of infinite borders around the whole aabb of the combined island. | ||
889 | private void AdjustLargeRegionBounds() | ||
890 | { | ||
891 | lock (m_regions) | ||
892 | { | ||
893 | foreach (RegionConnections rconn in m_regions.Values) | ||
894 | { | ||
895 | Vector3 offset = Vector3.Zero; | ||
896 | rconn.RegionScene.BordersLocked = true; | ||
897 | foreach (RegionData rdata in rconn.ConnectedRegions) | ||
898 | { | ||
899 | if (rdata.Offset.X > offset.X) offset.X = rdata.Offset.X; | ||
900 | if (rdata.Offset.Y > offset.Y) offset.Y = rdata.Offset.Y; | ||
901 | } | ||
902 | |||
903 | lock (rconn.RegionScene.NorthBorders) | ||
904 | { | ||
905 | Border northBorder = null; | ||
906 | // If we don't already have an infinite border, create one. | ||
907 | if (!TryGetInfiniteBorder(rconn.RegionScene.NorthBorders, out northBorder)) | ||
908 | { | ||
909 | northBorder = new Border(); | ||
910 | rconn.RegionScene.NorthBorders.Add(northBorder); | ||
911 | } | ||
912 | |||
913 | northBorder.BorderLine = new Vector3(float.MinValue, float.MaxValue, | ||
914 | offset.Y + (int) Constants.RegionSize); //<--- | ||
915 | northBorder.CrossDirection = Cardinals.N; | ||
916 | } | ||
917 | |||
918 | lock (rconn.RegionScene.SouthBorders) | ||
919 | { | ||
920 | Border southBorder = null; | ||
921 | // If we don't already have an infinite border, create one. | ||
922 | if (!TryGetInfiniteBorder(rconn.RegionScene.SouthBorders, out southBorder)) | ||
923 | { | ||
924 | southBorder = new Border(); | ||
925 | rconn.RegionScene.SouthBorders.Add(southBorder); | ||
926 | } | ||
927 | southBorder.BorderLine = new Vector3(float.MinValue, float.MaxValue, 0); //---> | ||
928 | southBorder.CrossDirection = Cardinals.S; | ||
929 | } | ||
930 | |||
931 | lock (rconn.RegionScene.EastBorders) | ||
932 | { | ||
933 | Border eastBorder = null; | ||
934 | // If we don't already have an infinite border, create one. | ||
935 | if (!TryGetInfiniteBorder(rconn.RegionScene.EastBorders, out eastBorder)) | ||
936 | { | ||
937 | eastBorder = new Border(); | ||
938 | rconn.RegionScene.EastBorders.Add(eastBorder); | ||
939 | } | ||
940 | eastBorder.BorderLine = new Vector3(float.MinValue, float.MaxValue, offset.X + (int)Constants.RegionSize); | ||
941 | //<--- | ||
942 | eastBorder.CrossDirection = Cardinals.E; | ||
943 | } | ||
944 | |||
945 | lock (rconn.RegionScene.WestBorders) | ||
946 | { | ||
947 | Border westBorder = null; | ||
948 | // If we don't already have an infinite border, create one. | ||
949 | if (!TryGetInfiniteBorder(rconn.RegionScene.WestBorders, out westBorder)) | ||
950 | { | ||
951 | westBorder = new Border(); | ||
952 | rconn.RegionScene.WestBorders.Add(westBorder); | ||
953 | |||
954 | } | ||
955 | westBorder.BorderLine = new Vector3(float.MinValue, float.MaxValue, 0); //---> | ||
956 | westBorder.CrossDirection = Cardinals.W; | ||
957 | } | ||
958 | |||
959 | rconn.RegionScene.BordersLocked = false; | ||
960 | } | ||
961 | } | ||
962 | } | ||
963 | |||
964 | /// <summary> | ||
965 | /// Try and get an Infinite border out of a listT of borders | ||
966 | /// </summary> | ||
967 | /// <param name="borders"></param> | ||
968 | /// <param name="oborder"></param> | ||
969 | /// <returns></returns> | ||
970 | public static bool TryGetInfiniteBorder(List<Border> borders, out Border oborder) | ||
971 | { | ||
972 | // Warning! Should be locked before getting here! | ||
973 | foreach (Border b in borders) | ||
974 | { | ||
975 | if (b.BorderLine.X == float.MinValue && b.BorderLine.Y == float.MaxValue) | ||
976 | { | ||
977 | oborder = b; | ||
978 | return true; | ||
979 | } | ||
980 | } | ||
981 | |||
982 | oborder = null; | ||
983 | return false; | ||
984 | } | ||
985 | |||
986 | public RegionData GetRegionFromPosition(Vector3 pPosition) | ||
987 | { | ||
988 | pPosition = pPosition/(int) Constants.RegionSize; | ||
989 | int OffsetX = (int) pPosition.X; | ||
990 | int OffsetY = (int) pPosition.Y; | ||
991 | |||
992 | lock (m_regions) | ||
993 | { | ||
994 | foreach (RegionConnections regConn in m_regions.Values) | ||
995 | { | ||
996 | foreach (RegionData reg in regConn.ConnectedRegions) | ||
997 | { | ||
998 | if (reg.Offset.X == OffsetX && reg.Offset.Y == OffsetY) | ||
999 | return reg; | ||
1000 | } | ||
1001 | } | ||
1002 | } | ||
1003 | |||
1004 | return new RegionData(); | ||
1005 | } | ||
1006 | |||
1007 | public void ForwardPermissionRequests(RegionConnections BigRegion, Scene VirtualRegion) | 810 | public void ForwardPermissionRequests(RegionConnections BigRegion, Scene VirtualRegion) |
1008 | { | 811 | { |
1009 | if (BigRegion.PermissionModule == null) | 812 | if (BigRegion.PermissionModule == null) |