aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Framework
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--OpenSim/Region/Framework/Interfaces/IRegionCombinerModule.cs5
-rw-r--r--OpenSim/Region/Framework/Scenes/Scene.cs325
-rw-r--r--OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs10
-rw-r--r--OpenSim/Region/Framework/Scenes/SceneObjectPart.cs5
-rw-r--r--OpenSim/Region/Framework/Scenes/ScenePresence.cs60
5 files changed, 56 insertions, 349 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 eb34f55..03270d7 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
@@ -364,7 +359,6 @@ namespace OpenSim.Region.Framework.Scenes
364 359
365 // TODO: Possibly stop other classes being able to manipulate this directly. 360 // TODO: Possibly stop other classes being able to manipulate this directly.
366 private SceneGraph m_sceneGraph; 361 private SceneGraph m_sceneGraph;
367 private volatile int m_bordersLocked;
368 private readonly Timer m_restartTimer = new Timer(15000); // Wait before firing 362 private readonly Timer m_restartTimer = new Timer(15000); // Wait before firing
369 private volatile bool m_backingup; 363 private volatile bool m_backingup;
370 private Dictionary<UUID, ReturnInfo> m_returns = new Dictionary<UUID, ReturnInfo>(); 364 private Dictionary<UUID, ReturnInfo> m_returns = new Dictionary<UUID, ReturnInfo>();
@@ -446,18 +440,6 @@ namespace OpenSim.Region.Framework.Scenes
446 set { m_splitRegionID = value; } 440 set { m_splitRegionID = value; }
447 } 441 }
448 442
449 public bool BordersLocked
450 {
451 get { return m_bordersLocked == 1; }
452 set
453 {
454 if (value == true)
455 m_bordersLocked = 1;
456 else
457 m_bordersLocked = 0;
458 }
459 }
460
461 public new float TimeDilation 443 public new float TimeDilation
462 { 444 {
463 get { return m_sceneGraph.PhysicsScene.TimeDilation; } 445 get { return m_sceneGraph.PhysicsScene.TimeDilation; }
@@ -1075,28 +1057,6 @@ namespace OpenSim.Region.Framework.Scenes
1075 PeriodicBackup = true; 1057 PeriodicBackup = true;
1076 UseBackup = true; 1058 UseBackup = true;
1077 1059
1078 BordersLocked = true;
1079 Border northBorder = new Border();
1080 northBorder.BorderLine = new Vector3(float.MinValue, float.MaxValue, RegionInfo.RegionSizeY); //<---
1081 northBorder.CrossDirection = Cardinals.N;
1082 NorthBorders.Add(northBorder);
1083
1084 Border southBorder = new Border();
1085 southBorder.BorderLine = new Vector3(float.MinValue, float.MaxValue,0); //--->
1086 southBorder.CrossDirection = Cardinals.S;
1087 SouthBorders.Add(southBorder);
1088
1089 Border eastBorder = new Border();
1090 eastBorder.BorderLine = new Vector3(float.MinValue, float.MaxValue, RegionInfo.RegionSizeX); //<---
1091 eastBorder.CrossDirection = Cardinals.E;
1092 EastBorders.Add(eastBorder);
1093
1094 Border westBorder = new Border();
1095 westBorder.BorderLine = new Vector3(float.MinValue, float.MaxValue,0); //--->
1096 westBorder.CrossDirection = Cardinals.W;
1097 WestBorders.Add(westBorder);
1098 BordersLocked = false;
1099
1100 m_eventManager = new EventManager(); 1060 m_eventManager = new EventManager();
1101 1061
1102 m_permissions = new ScenePermissions(this); 1062 m_permissions = new ScenePermissions(this);
@@ -2611,185 +2571,35 @@ namespace OpenSim.Region.Framework.Scenes
2611 EntityTransferModule.Cross(grp, attemptedPosition, silent); 2571 EntityTransferModule.Cross(grp, attemptedPosition, silent);
2612 } 2572 }
2613 2573
2614 public Border GetCrossedBorder(Vector3 position, Cardinals gridline) 2574 // Simple test to see if a position is in the current region.
2575 // This test is mostly used to see if a region crossing is necessary.
2576 // Assuming the position is relative to the region so anything outside its bounds.
2577 // Return 'true' if position inside region.
2578 public bool PositionIsInCurrentRegion(Vector3 pos)
2615 { 2579 {
2616 if (BordersLocked) 2580 bool ret = false;
2617 { 2581 int xx = (int)Math.Floor(pos.X);
2618 switch (gridline) 2582 int yy = (int)Math.Floor(pos.Y);
2619 { 2583 if (xx < 0 || yy < 0)
2620 case Cardinals.N: 2584 return false;
2621 lock (NorthBorders)
2622 {
2623 foreach (Border b in NorthBorders)
2624 {
2625 if (b.TestCross(position))
2626 return b;
2627 }
2628 }
2629 break;
2630 case Cardinals.S:
2631 lock (SouthBorders)
2632 {
2633 foreach (Border b in SouthBorders)
2634 {
2635 if (b.TestCross(position))
2636 return b;
2637 }
2638 }
2639
2640 break;
2641 case Cardinals.E:
2642 lock (EastBorders)
2643 {
2644 foreach (Border b in EastBorders)
2645 {
2646 if (b.TestCross(position))
2647 return b;
2648 }
2649 }
2650
2651 break;
2652 case Cardinals.W:
2653
2654 lock (WestBorders)
2655 {
2656 foreach (Border b in WestBorders)
2657 {
2658 if (b.TestCross(position))
2659 return b;
2660 }
2661 }
2662 break;
2663 2585
2664 } 2586 IRegionCombinerModule regionCombinerModule = RequestModuleInterface<IRegionCombinerModule>();
2587 if (regionCombinerModule == null)
2588 {
2589 // Regular region. Just check for region size
2590 if (xx < RegionInfo.RegionSizeX && yy < RegionInfo.RegionSizeY )
2591 ret = true;
2665 } 2592 }
2666 else 2593 else
2667 { 2594 {
2668 switch (gridline) 2595 // We're in a mega-region so see if we are still in that larger region
2669 { 2596 ret = regionCombinerModule.PositionIsInMegaregion(this.RegionInfo.RegionID, xx, yy);
2670 case Cardinals.N:
2671 foreach (Border b in NorthBorders)
2672 {
2673 if (b.TestCross(position))
2674 return b;
2675 }
2676
2677 break;
2678 case Cardinals.S:
2679 foreach (Border b in SouthBorders)
2680 {
2681 if (b.TestCross(position))
2682 return b;
2683 }
2684 break;
2685 case Cardinals.E:
2686 foreach (Border b in EastBorders)
2687 {
2688 if (b.TestCross(position))
2689 return b;
2690 }
2691
2692 break;
2693 case Cardinals.W:
2694 foreach (Border b in WestBorders)
2695 {
2696 if (b.TestCross(position))
2697 return b;
2698 }
2699 break;
2700
2701 }
2702 } 2597 }
2703 2598
2704 return null; 2599 return ret;
2705 }
2706 2600
2707 public bool TestBorderCross(Vector3 position, Cardinals border)
2708 {
2709 if (BordersLocked)
2710 {
2711 switch (border)
2712 {
2713 case Cardinals.N:
2714 lock (NorthBorders)
2715 {
2716 foreach (Border b in NorthBorders)
2717 {
2718 if (b.TestCross(position))
2719 return true;
2720 }
2721 }
2722 break;
2723 case Cardinals.E:
2724 lock (EastBorders)
2725 {
2726 foreach (Border b in EastBorders)
2727 {
2728 if (b.TestCross(position))
2729 return true;
2730 }
2731 }
2732 break;
2733 case Cardinals.S:
2734 lock (SouthBorders)
2735 {
2736 foreach (Border b in SouthBorders)
2737 {
2738 if (b.TestCross(position))
2739 return true;
2740 }
2741 }
2742 break;
2743 case Cardinals.W:
2744 lock (WestBorders)
2745 {
2746 foreach (Border b in WestBorders)
2747 {
2748 if (b.TestCross(position))
2749 return true;
2750 }
2751 }
2752 break;
2753 }
2754 }
2755 else
2756 {
2757 switch (border)
2758 {
2759 case Cardinals.N:
2760 foreach (Border b in NorthBorders)
2761 {
2762 if (b.TestCross(position))
2763 return true;
2764 }
2765 break;
2766 case Cardinals.E:
2767 foreach (Border b in EastBorders)
2768 {
2769 if (b.TestCross(position))
2770 return true;
2771 }
2772 break;
2773 case Cardinals.S:
2774 foreach (Border b in SouthBorders)
2775 {
2776 if (b.TestCross(position))
2777 return true;
2778 }
2779 break;
2780 case Cardinals.W:
2781 foreach (Border b in WestBorders)
2782 {
2783 if (b.TestCross(position))
2784 return true;
2785 }
2786 break;
2787 }
2788 }
2789 return false;
2790 } 2601 }
2791 2602
2792
2793 /// <summary> 2603 /// <summary>
2794 /// Called when objects or attachments cross the border, or teleport, between regions. 2604 /// Called when objects or attachments cross the border, or teleport, between regions.
2795 /// </summary> 2605 /// </summary>
@@ -4116,60 +3926,11 @@ namespace OpenSim.Region.Framework.Scenes
4116 { 3926 {
4117// CleanDroppedAttachments(); 3927// CleanDroppedAttachments();
4118 3928
4119 if (TestBorderCross(acd.startpos, Cardinals.E)) 3929 // Make sure avatar position is in the region (why it wouldn't be is a mystery but do sanity checking)
4120 { 3930 if (acd.startpos.X < 0) acd.startpos.X = 1f;
4121 Border crossedBorder = GetCrossedBorder(acd.startpos, Cardinals.E); 3931 if (acd.startpos.X >= RegionInfo.RegionSizeX) acd.startpos.X = RegionInfo.RegionSizeX - 1f;
4122 acd.startpos.X = crossedBorder.BorderLine.Z - 1; 3932 if (acd.startpos.Y < 0) acd.startpos.Y = 1f;
4123 } 3933 if (acd.startpos.Y >= RegionInfo.RegionSizeY) acd.startpos.Y = RegionInfo.RegionSizeY - 1f;
4124
4125 if (TestBorderCross(acd.startpos, Cardinals.N))
4126 {
4127 Border crossedBorder = GetCrossedBorder(acd.startpos, Cardinals.N);
4128 acd.startpos.Y = crossedBorder.BorderLine.Z - 1;
4129 }
4130
4131 //Mitigate http://opensimulator.org/mantis/view.php?id=3522
4132 // Check if start position is outside of region
4133 // If it is, check the Z start position also.. if not, leave it alone.
4134 if (BordersLocked)
4135 {
4136 lock (EastBorders)
4137 {
4138 if (acd.startpos.X > EastBorders[0].BorderLine.Z)
4139 {
4140 m_log.Warn("FIX AGENT POSITION");
4141 acd.startpos.X = EastBorders[0].BorderLine.Z * 0.5f;
4142 if (acd.startpos.Z > 720)
4143 acd.startpos.Z = 720;
4144 }
4145 }
4146 lock (NorthBorders)
4147 {
4148 if (acd.startpos.Y > NorthBorders[0].BorderLine.Z)
4149 {
4150 m_log.Warn("FIX Agent POSITION");
4151 acd.startpos.Y = NorthBorders[0].BorderLine.Z * 0.5f;
4152 if (acd.startpos.Z > 720)
4153 acd.startpos.Z = 720;
4154 }
4155 }
4156 } else
4157 {
4158 if (acd.startpos.X > EastBorders[0].BorderLine.Z)
4159 {
4160 m_log.Warn("FIX AGENT POSITION");
4161 acd.startpos.X = EastBorders[0].BorderLine.Z * 0.5f;
4162 if (acd.startpos.Z > 720)
4163 acd.startpos.Z = 720;
4164 }
4165 if (acd.startpos.Y > NorthBorders[0].BorderLine.Z)
4166 {
4167 m_log.Warn("FIX Agent POSITION");
4168 acd.startpos.Y = NorthBorders[0].BorderLine.Z * 0.5f;
4169 if (acd.startpos.Z > 720)
4170 acd.startpos.Z = 720;
4171 }
4172 }
4173 3934
4174// m_log.DebugFormat( 3935// m_log.DebugFormat(
4175// "[SCENE]: Found telehub object {0} for new user connection {1} to {2}", 3936// "[SCENE]: Found telehub object {0} for new user connection {1} to {2}",
@@ -4883,44 +4644,6 @@ namespace OpenSim.Region.Framework.Scenes
4883 ScenePresence sp = GetScenePresence(remoteClient.AgentId); 4644 ScenePresence sp = GetScenePresence(remoteClient.AgentId);
4884 if (sp != null) 4645 if (sp != null)
4885 { 4646 {
4886 uint regionX = RegionInfo.RegionLocX;
4887 uint regionY = RegionInfo.RegionLocY;
4888
4889 Utils.LongToUInts(regionHandle, out regionX, out regionY);
4890
4891 int shiftx = (int) regionX - (int) RegionInfo.RegionLocX * (int)Constants.RegionSize;
4892 int shifty = (int) regionY - (int) RegionInfo.RegionLocY * (int)Constants.RegionSize;
4893
4894 position.X += shiftx;
4895 position.Y += shifty;
4896
4897 bool result = false;
4898
4899 if (TestBorderCross(position,Cardinals.N))
4900 result = true;
4901
4902 if (TestBorderCross(position, Cardinals.S))
4903 result = true;
4904
4905 if (TestBorderCross(position, Cardinals.E))
4906 result = true;
4907
4908 if (TestBorderCross(position, Cardinals.W))
4909 result = true;
4910
4911 // bordercross if position is outside of region
4912
4913 if (!result)
4914 {
4915 regionHandle = RegionInfo.RegionHandle;
4916 }
4917 else
4918 {
4919 // not in this region, undo the shift!
4920 position.X -= shiftx;
4921 position.Y -= shifty;
4922 }
4923
4924 if (EntityTransferModule != null) 4647 if (EntityTransferModule != null)
4925 { 4648 {
4926 EntityTransferModule.Teleport(sp, regionHandle, position, lookAt, teleportFlags); 4649 EntityTransferModule.Teleport(sp, regionHandle, position, lookAt, teleportFlags);
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs
index 89c7a1a..a99e469 100644
--- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs
+++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs
@@ -529,12 +529,10 @@ namespace OpenSim.Region.Framework.Scenes
529 set 529 set
530 { 530 {
531 Vector3 val = value; 531 Vector3 val = value;
532 if (Scene != null && !IsAttachmentCheckFull() 532 if (Scene != null
533 && !Scene.LoadingPrims && 533 && Scene.PositionIsInCurrentRegion(val)
534 (Scene.TestBorderCross(val, Cardinals.E) || 534 && !IsAttachmentCheckFull()
535 Scene.TestBorderCross(val, Cardinals.W) || 535 && !Scene.LoadingPrims
536 Scene.TestBorderCross(val, Cardinals.N) ||
537 Scene.TestBorderCross(val, Cardinals.S))
538 ) 536 )
539 { 537 {
540 if (!inTransit) 538 if (!inTransit)
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs
index 91293c4..8979659 100644
--- a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs
+++ b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs
@@ -2979,10 +2979,7 @@ namespace OpenSim.Region.Framework.Scenes
2979 { 2979 {
2980 Vector3 newpos = new Vector3(pa.Position.GetBytes(), 0); 2980 Vector3 newpos = new Vector3(pa.Position.GetBytes(), 0);
2981 2981
2982 if (ParentGroup.Scene.TestBorderCross(newpos, Cardinals.N) 2982 if (!ParentGroup.Scene.PositionIsInCurrentRegion(newpos))
2983 || ParentGroup.Scene.TestBorderCross(newpos, Cardinals.S)
2984 || ParentGroup.Scene.TestBorderCross(newpos, Cardinals.E)
2985 || ParentGroup.Scene.TestBorderCross(newpos, Cardinals.W))
2986 { 2983 {
2987 ParentGroup.AbsolutePosition = newpos; 2984 ParentGroup.AbsolutePosition = newpos;
2988 return; 2985 return;
diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs
index cd9dcf5..2965903 100644
--- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs
+++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs
@@ -1170,18 +1170,6 @@ namespace OpenSim.Region.Framework.Scenes
1170 1170
1171 if (ParentID == 0) 1171 if (ParentID == 0)
1172 { 1172 {
1173 if (m_scene.TestBorderCross(pos, Cardinals.E))
1174 {
1175 Border crossedBorder = m_scene.GetCrossedBorder(pos, Cardinals.E);
1176 pos.X = crossedBorder.BorderLine.Z - 1;
1177 }
1178
1179 if (m_scene.TestBorderCross(pos, Cardinals.N))
1180 {
1181 Border crossedBorder = m_scene.GetCrossedBorder(pos, Cardinals.N);
1182 pos.Y = crossedBorder.BorderLine.Z - 1;
1183 }
1184
1185 CheckAndAdjustLandingPoint(ref pos); 1173 CheckAndAdjustLandingPoint(ref pos);
1186 1174
1187 if (pos.X < 0f || pos.Y < 0f || pos.Z < 0f) 1175 if (pos.X < 0f || pos.Y < 0f || pos.Z < 0f)
@@ -3867,32 +3855,28 @@ namespace OpenSim.Region.Framework.Scenes
3867// m_log.DebugFormat( 3855// m_log.DebugFormat(
3868// "[SCENE PRESENCE]: Testing border check for projected position {0} of {1} in {2}", 3856// "[SCENE PRESENCE]: Testing border check for projected position {0} of {1} in {2}",
3869// pos2, Name, Scene.Name); 3857// pos2, Name, Scene.Name);
3870 3858
3871 if( Scene.TestBorderCross(pos2, Cardinals.E) || 3859 if (Scene.PositionIsInCurrentRegion(pos2))
3872 Scene.TestBorderCross(pos2, Cardinals.W) || 3860 return;
3873 Scene.TestBorderCross(pos2, Cardinals.N) || 3861
3874 Scene.TestBorderCross(pos2, Cardinals.S) 3862 if (!CrossToNewRegion() && m_requestedSitTargetUUID == UUID.Zero)
3875 ) 3863 {
3876 { 3864 // we don't have entity transfer module
3877 if (!CrossToNewRegion() && m_requestedSitTargetUUID == UUID.Zero) 3865 Vector3 pos = AbsolutePosition;
3878 { 3866 float px = pos.X;
3879 // we don't have entity transfer module 3867 if (px < 0)
3880 Vector3 pos = AbsolutePosition; 3868 pos.X += Velocity.X * 2;
3881 float px = pos.X; 3869 else if (px > m_scene.RegionInfo.RegionSizeX)
3882 if (px < 0) 3870 pos.X -= Velocity.X * 2;
3883 pos.X += Velocity.X * 2; 3871
3884 else if (px > m_scene.RegionInfo.RegionSizeX) 3872 float py = pos.Y;
3885 pos.X -= Velocity.X * 2; 3873 if (py < 0)
3886 3874 pos.Y += Velocity.Y * 2;
3887 float py = pos.Y; 3875 else if (py > m_scene.RegionInfo.RegionSizeY)
3888 if (py < 0) 3876 pos.Y -= Velocity.Y * 2;
3889 pos.Y += Velocity.Y * 2; 3877
3890 else if (py > m_scene.RegionInfo.RegionSizeY) 3878 Velocity = Vector3.Zero;
3891 pos.Y -= Velocity.Y * 2; 3879 AbsolutePosition = pos;
3892
3893 Velocity = Vector3.Zero;
3894 AbsolutePosition = pos;
3895 }
3896 } 3880 }
3897 } 3881 }
3898 3882