From 316854dc137709d4aeb0bf20351de1c75af20fe5 Mon Sep 17 00:00:00 2001
From: Melanie Thielker
Date: Wed, 21 Jul 2010 12:31:59 +0200
Subject: Allow megaregions to be used in M7, should we so decide

---
 OpenSim/Region/Framework/Scenes/Scene.cs      |  2 ++
 OpenSim/Region/Framework/Scenes/SceneGraph.cs | 47 ++++++++++++++-------------
 2 files changed, 27 insertions(+), 22 deletions(-)

diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs
index 8e860fb..8af7514 100644
--- a/OpenSim/Region/Framework/Scenes/Scene.cs
+++ b/OpenSim/Region/Framework/Scenes/Scene.cs
@@ -146,6 +146,7 @@ namespace OpenSim.Region.Framework.Scenes
         protected SceneCommunicationService m_sceneGridService;
         public bool LoginsDisabled = true;
         public bool LoadingPrims = false;
+        public bool CombineRegions = false;
 
         public new float TimeDilation
         {
@@ -656,6 +657,7 @@ namespace OpenSim.Region.Framework.Scenes
                 }
 
                 m_strictAccessControl = startupConfig.GetBoolean("StrictAccessControl", m_strictAccessControl);
+                CombineRegions = startupConfig.GetBoolean("CombineContiguousRegions", false);
 
                 IConfig interest_management_config = m_config.Configs["InterestManagement"];
                 if (interest_management_config != null)
diff --git a/OpenSim/Region/Framework/Scenes/SceneGraph.cs b/OpenSim/Region/Framework/Scenes/SceneGraph.cs
index 5a1922a..1d126b6 100644
--- a/OpenSim/Region/Framework/Scenes/SceneGraph.cs
+++ b/OpenSim/Region/Framework/Scenes/SceneGraph.cs
@@ -226,30 +226,33 @@ namespace OpenSim.Region.Framework.Scenes
         protected internal bool AddRestoredSceneObject(
             SceneObjectGroup sceneObject, bool attachToBackup, bool alreadyPersisted, bool sendClientUpdates)
         {
-        	// KF: Check for out-of-region, move inside and make static.
-			Vector3 npos = new Vector3(sceneObject.RootPart.GroupPosition.X,
-               						   sceneObject.RootPart.GroupPosition.Y,
-               						   sceneObject.RootPart.GroupPosition.Z);
-			if (!(((sceneObject.RootPart.Shape.PCode == (byte)PCode.Prim) && (sceneObject.RootPart.Shape.State != 0))) && (npos.X < 0.0 || npos.Y < 0.0 || npos.Z < 0.0 ||
-			    npos.X > Constants.RegionSize ||
-			    npos.Y > Constants.RegionSize))
-			{
-				if (npos.X < 0.0) npos.X = 1.0f;
-				if (npos.Y < 0.0) npos.Y = 1.0f;
-				if (npos.Z < 0.0) npos.Z = 0.0f;
-				if (npos.X > Constants.RegionSize) npos.X = Constants.RegionSize - 1.0f;
-				if (npos.Y > Constants.RegionSize) npos.Y = Constants.RegionSize - 1.0f;
- 
-                foreach (SceneObjectPart part in sceneObject.Children.Values)
+            if (!m_parentScene.CombineRegions)
+            {
+                // KF: Check for out-of-region, move inside and make static.
+                Vector3 npos = new Vector3(sceneObject.RootPart.GroupPosition.X,
+                                           sceneObject.RootPart.GroupPosition.Y,
+                                           sceneObject.RootPart.GroupPosition.Z);
+                if (!(((sceneObject.RootPart.Shape.PCode == (byte)PCode.Prim) && (sceneObject.RootPart.Shape.State != 0))) && (npos.X < 0.0 || npos.Y < 0.0 || npos.Z < 0.0 ||
+                    npos.X > Constants.RegionSize ||
+                    npos.Y > Constants.RegionSize))
                 {
-                	part.GroupPosition = npos;
+                    if (npos.X < 0.0) npos.X = 1.0f;
+                    if (npos.Y < 0.0) npos.Y = 1.0f;
+                    if (npos.Z < 0.0) npos.Z = 0.0f;
+                    if (npos.X > Constants.RegionSize) npos.X = Constants.RegionSize - 1.0f;
+                    if (npos.Y > Constants.RegionSize) npos.Y = Constants.RegionSize - 1.0f;
+     
+                    foreach (SceneObjectPart part in sceneObject.Children.Values)
+                    {
+                        part.GroupPosition = npos;
+                    }
+                    sceneObject.RootPart.Velocity = Vector3.Zero;
+                    sceneObject.RootPart.AngularVelocity = Vector3.Zero;
+                    sceneObject.RootPart.Acceleration = Vector3.Zero;
+                    sceneObject.RootPart.Velocity = Vector3.Zero;
                 }
-                sceneObject.RootPart.Velocity = Vector3.Zero;
-                sceneObject.RootPart.AngularVelocity = Vector3.Zero;
-                sceneObject.RootPart.Acceleration = Vector3.Zero;
-                sceneObject.RootPart.Velocity = Vector3.Zero;
-			}
-			
+            }
+
             if (!alreadyPersisted)
             {
                 sceneObject.ForceInventoryPersistence();
-- 
cgit v1.1