diff options
author | Robert Adams | 2015-03-22 21:53:02 -0700 |
---|---|---|
committer | Robert Adams | 2015-03-22 21:53:02 -0700 |
commit | 9f18e3ba80a6469b7ff03c7cca595a0a3b999592 (patch) | |
tree | c2ace74c3ffc6eab80b94bfbe4e6a2d37197eb28 /OpenSim/Region/Framework/Scenes/Scene.cs | |
parent | Allow setting the size of the wearables array from config, for core compatibi... (diff) | |
download | opensim-SC_OLD-9f18e3ba80a6469b7ff03c7cca595a0a3b999592.zip opensim-SC_OLD-9f18e3ba80a6469b7ff03c7cca595a0a3b999592.tar.gz opensim-SC_OLD-9f18e3ba80a6469b7ff03c7cca595a0a3b999592.tar.bz2 opensim-SC_OLD-9f18e3ba80a6469b7ff03c7cca595a0a3b999592.tar.xz |
Varregion: first cut at removing Border class checks for region crossings.
Added Scene.PositionIsInCurrentRegion(pos) to sense when new position needs some crossing work.
Many changes made to EntityTransferModule to accomodate new crossing sense logic.
Diffstat (limited to '')
-rw-r--r-- | OpenSim/Region/Framework/Scenes/Scene.cs | 325 |
1 files changed, 24 insertions, 301 deletions
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); |