aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Framework/Scenes/Scene.cs
diff options
context:
space:
mode:
authorUbitUmarov2015-08-19 08:48:50 +0100
committerUbitUmarov2015-08-19 08:48:50 +0100
commit0b105da626ae8c2fb519a817b827f90534ed7d08 (patch)
tree509e6d091fb12f38fd09528335e51aeedbe59c08 /OpenSim/Region/Framework/Scenes/Scene.cs
parentMerge branch 'master' into ubitworkmaster (diff)
parentvarregion: update MapImageServiceModule to upload multiple map tiles for larg... (diff)
downloadopensim-SC-0b105da626ae8c2fb519a817b827f90534ed7d08.zip
opensim-SC-0b105da626ae8c2fb519a817b827f90534ed7d08.tar.gz
opensim-SC-0b105da626ae8c2fb519a817b827f90534ed7d08.tar.bz2
opensim-SC-0b105da626ae8c2fb519a817b827f90534ed7d08.tar.xz
Merge branch 'mbworkvar2' into ubitvar
Diffstat (limited to 'OpenSim/Region/Framework/Scenes/Scene.cs')
-rw-r--r--OpenSim/Region/Framework/Scenes/Scene.cs362
1 files changed, 54 insertions, 308 deletions
diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs
index eb34f55..46c9048 100644
--- a/OpenSim/Region/Framework/Scenes/Scene.cs
+++ b/OpenSim/Region/Framework/Scenes/Scene.cs
@@ -6,7 +6,7 @@
6 * modification, are permitted provided that the following conditions are met: 6 * modification, are permitted provided that the following conditions are met:
7 * * Redistributions of source code must retain the above copyright 7 * * Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer. 8 * notice, this list of conditions and the following disclaimer.
9 * * Redistributions in binary form must reproduce the above copyrightD 9 * * Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the 10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution. 11 * documentation and/or other materials provided with the distribution.
12 * * Neither the name of the OpenSimulator Project nor the 12 * * Neither the name of the OpenSimulator Project nor the
@@ -103,7 +103,29 @@ namespace OpenSim.Region.Framework.Scenes
103 /// <summary> 103 /// <summary>
104 /// If false then physical objects are disabled, though collisions will continue as normal. 104 /// If false then physical objects are disabled, though collisions will continue as normal.
105 /// </summary> 105 /// </summary>
106 public bool PhysicsEnabled { get; set; } 106 public bool PhysicsEnabled
107 {
108 get
109 {
110 return m_physicsEnabled;
111 }
112
113 set
114 {
115 m_physicsEnabled = value;
116
117 if (PhysicsScene != null)
118 {
119 IPhysicsParameters physScene = PhysicsScene as IPhysicsParameters;
120
121 if (physScene != null)
122 physScene.SetPhysicsParameter(
123 "Active", m_physicsEnabled.ToString(), PhysParameterEntry.APPLY_TO_NONE);
124 }
125 }
126 }
127
128 private bool m_physicsEnabled;
107 129
108 /// <summary> 130 /// <summary>
109 /// If false then scripts are not enabled on the smiulator 131 /// If false then scripts are not enabled on the smiulator
@@ -160,11 +182,6 @@ namespace OpenSim.Region.Framework.Scenes
160 /// </summary> 182 /// </summary>
161 public SimStatsReporter StatsReporter { get; private set; } 183 public SimStatsReporter StatsReporter { get; private set; }
162 184
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> 185 /// <summary>
169 /// Controls whether physics can be applied to prims. Even if false, prims still have entries in a 186 /// 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 187 /// PhysicsScene in order to perform collision detection
@@ -204,15 +221,16 @@ namespace OpenSim.Region.Framework.Scenes
204 /// </summary> 221 /// </summary>
205 public int m_linksetCapacity = 0; 222 public int m_linksetCapacity = 0;
206 223
224 public bool m_clampPrimSize;
225 public bool m_trustBinaries;
226 public bool m_allowScriptCrossings = true;
227
207 /// <summary> 228 /// <summary>
208 /// Max prims an Physical object will hold 229 /// Max prims an Physical object will hold
209 /// </summary> 230 /// </summary>
210 /// 231 ///
211 public int m_linksetPhysCapacity = 0; 232 public int m_linksetPhysCapacity = 0;
212 233
213 public bool m_clampPrimSize;
214 public bool m_trustBinaries;
215 public bool m_allowScriptCrossings;
216 public bool m_useFlySlow; 234 public bool m_useFlySlow;
217 public bool m_useTrashOnDelete = true; 235 public bool m_useTrashOnDelete = true;
218 236
@@ -364,7 +382,6 @@ namespace OpenSim.Region.Framework.Scenes
364 382
365 // TODO: Possibly stop other classes being able to manipulate this directly. 383 // TODO: Possibly stop other classes being able to manipulate this directly.
366 private SceneGraph m_sceneGraph; 384 private SceneGraph m_sceneGraph;
367 private volatile int m_bordersLocked;
368 private readonly Timer m_restartTimer = new Timer(15000); // Wait before firing 385 private readonly Timer m_restartTimer = new Timer(15000); // Wait before firing
369 private volatile bool m_backingup; 386 private volatile bool m_backingup;
370 private Dictionary<UUID, ReturnInfo> m_returns = new Dictionary<UUID, ReturnInfo>(); 387 private Dictionary<UUID, ReturnInfo> m_returns = new Dictionary<UUID, ReturnInfo>();
@@ -446,18 +463,6 @@ namespace OpenSim.Region.Framework.Scenes
446 set { m_splitRegionID = value; } 463 set { m_splitRegionID = value; }
447 } 464 }
448 465
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 466 public new float TimeDilation
462 { 467 {
463 get { return m_sceneGraph.PhysicsScene.TimeDilation; } 468 get { return m_sceneGraph.PhysicsScene.TimeDilation; }
@@ -1075,28 +1080,6 @@ namespace OpenSim.Region.Framework.Scenes
1075 PeriodicBackup = true; 1080 PeriodicBackup = true;
1076 UseBackup = true; 1081 UseBackup = true;
1077 1082
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(); 1083 m_eventManager = new EventManager();
1101 1084
1102 m_permissions = new ScenePermissions(this); 1085 m_permissions = new ScenePermissions(this);
@@ -1975,7 +1958,7 @@ namespace OpenSim.Region.Framework.Scenes
1975 { 1958 {
1976 try 1959 try
1977 { 1960 {
1978 double[,] map = SimulationDataService.LoadTerrain(RegionInfo.RegionID); 1961 TerrainData map = SimulationDataService.LoadTerrain(RegionInfo.RegionID, (int)RegionInfo.RegionSizeX, (int)RegionInfo.RegionSizeY, (int)RegionInfo.RegionSizeZ);
1979 if (map == null) 1962 if (map == null)
1980 { 1963 {
1981 // This should be in the Terrain module, but it isn't because 1964 // This should be in the Terrain module, but it isn't because
@@ -1986,7 +1969,7 @@ namespace OpenSim.Region.Framework.Scenes
1986 m_InitialTerrain = terrainConfig.GetString("InitialTerrain", m_InitialTerrain); 1969 m_InitialTerrain = terrainConfig.GetString("InitialTerrain", m_InitialTerrain);
1987 1970
1988 m_log.InfoFormat("[TERRAIN]: No default terrain. Generating a new terrain {0}.", m_InitialTerrain); 1971 m_log.InfoFormat("[TERRAIN]: No default terrain. Generating a new terrain {0}.", m_InitialTerrain);
1989 Heightmap = new TerrainChannel(m_InitialTerrain); 1972 Heightmap = new TerrainChannel(m_InitialTerrain, (int)RegionInfo.RegionSizeX, (int)RegionInfo.RegionSizeY, (int)RegionInfo.RegionSizeZ);
1990 1973
1991 SimulationDataService.StoreTerrain(Heightmap.GetDoubles(), RegionInfo.RegionID); 1974 SimulationDataService.StoreTerrain(Heightmap.GetDoubles(), RegionInfo.RegionID);
1992 } 1975 }
@@ -2611,185 +2594,35 @@ namespace OpenSim.Region.Framework.Scenes
2611 EntityTransferModule.Cross(grp, attemptedPosition, silent); 2594 EntityTransferModule.Cross(grp, attemptedPosition, silent);
2612 } 2595 }
2613 2596
2614 public Border GetCrossedBorder(Vector3 position, Cardinals gridline) 2597 // Simple test to see if a position is in the current region.
2598 // This test is mostly used to see if a region crossing is necessary.
2599 // Assuming the position is relative to the region so anything outside its bounds.
2600 // Return 'true' if position inside region.
2601 public bool PositionIsInCurrentRegion(Vector3 pos)
2615 { 2602 {
2616 if (BordersLocked) 2603 bool ret = false;
2617 { 2604 int xx = (int)Math.Floor(pos.X);
2618 switch (gridline) 2605 int yy = (int)Math.Floor(pos.Y);
2619 { 2606 if (xx < 0 || yy < 0)
2620 case Cardinals.N: 2607 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 2608
2664 } 2609 IRegionCombinerModule regionCombinerModule = RequestModuleInterface<IRegionCombinerModule>();
2610 if (regionCombinerModule == null)
2611 {
2612 // Regular region. Just check for region size
2613 if (xx < RegionInfo.RegionSizeX && yy < RegionInfo.RegionSizeY )
2614 ret = true;
2665 } 2615 }
2666 else 2616 else
2667 { 2617 {
2668 switch (gridline) 2618 // We're in a mega-region so see if we are still in that larger region
2669 { 2619 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 } 2620 }
2703 2621
2704 return null; 2622 return ret;
2705 }
2706 2623
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 } 2624 }
2791 2625
2792
2793 /// <summary> 2626 /// <summary>
2794 /// Called when objects or attachments cross the border, or teleport, between regions. 2627 /// Called when objects or attachments cross the border, or teleport, between regions.
2795 /// </summary> 2628 /// </summary>
@@ -4116,60 +3949,11 @@ namespace OpenSim.Region.Framework.Scenes
4116 { 3949 {
4117// CleanDroppedAttachments(); 3950// CleanDroppedAttachments();
4118 3951
4119 if (TestBorderCross(acd.startpos, Cardinals.E)) 3952 // Make sure avatar position is in the region (why it wouldn't be is a mystery but do sanity checking)
4120 { 3953 if (acd.startpos.X < 0) acd.startpos.X = 1f;
4121 Border crossedBorder = GetCrossedBorder(acd.startpos, Cardinals.E); 3954 if (acd.startpos.X >= RegionInfo.RegionSizeX) acd.startpos.X = RegionInfo.RegionSizeX - 1f;
4122 acd.startpos.X = crossedBorder.BorderLine.Z - 1; 3955 if (acd.startpos.Y < 0) acd.startpos.Y = 1f;
4123 } 3956 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 3957
4174// m_log.DebugFormat( 3958// m_log.DebugFormat(
4175// "[SCENE]: Found telehub object {0} for new user connection {1} to {2}", 3959// "[SCENE]: Found telehub object {0} for new user connection {1} to {2}",
@@ -4883,44 +4667,6 @@ namespace OpenSim.Region.Framework.Scenes
4883 ScenePresence sp = GetScenePresence(remoteClient.AgentId); 4667 ScenePresence sp = GetScenePresence(remoteClient.AgentId);
4884 if (sp != null) 4668 if (sp != null)
4885 { 4669 {
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) 4670 if (EntityTransferModule != null)
4925 { 4671 {
4926 EntityTransferModule.Teleport(sp, regionHandle, position, lookAt, teleportFlags); 4672 EntityTransferModule.Teleport(sp, regionHandle, position, lookAt, teleportFlags);