aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Framework
diff options
context:
space:
mode:
authorRobert Adams2014-02-15 16:01:43 -0800
committerRobert Adams2014-02-15 16:01:43 -0800
commit877bdcdce1533d8dc3e13c0def7b015080ee881e (patch)
tree38dba2a95f035eea5b64aeba9bf59385de63faee /OpenSim/Region/Framework
parentNon-functional changes of numbers into symbolic references and a few (diff)
downloadopensim-SC_OLD-877bdcdce1533d8dc3e13c0def7b015080ee881e.zip
opensim-SC_OLD-877bdcdce1533d8dc3e13c0def7b015080ee881e.tar.gz
opensim-SC_OLD-877bdcdce1533d8dc3e13c0def7b015080ee881e.tar.bz2
opensim-SC_OLD-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 'OpenSim/Region/Framework')
-rw-r--r--OpenSim/Region/Framework/Interfaces/IRegionCombinerModule.cs5
-rw-r--r--OpenSim/Region/Framework/Scenes/Scene.cs293
-rw-r--r--OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs19
-rw-r--r--OpenSim/Region/Framework/Scenes/SceneObjectPart.cs9
4 files changed, 31 insertions, 295 deletions
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 }