From d45f871d8f3abcc58556d6f5a834b132da6ec0ab Mon Sep 17 00:00:00 2001 From: Teravus Ovares (Dan Olivares) Date: Sat, 29 Aug 2009 03:36:41 -0400 Subject: * Only lock the Borders when they're being changed, otherwise one avatar's movement could hinder another avatar's movement. --- .../CoreModules/World/Land/PhysicsCombiner.cs | 73 ++++++--- OpenSim/Region/Framework/Scenes/Scene.cs | 179 +++++++++++++++------ 2 files changed, 184 insertions(+), 68 deletions(-) (limited to 'OpenSim/Region') diff --git a/OpenSim/Region/CoreModules/World/Land/PhysicsCombiner.cs b/OpenSim/Region/CoreModules/World/Land/PhysicsCombiner.cs index 22ef107..2fc1623 100644 --- a/OpenSim/Region/CoreModules/World/Land/PhysicsCombiner.cs +++ b/OpenSim/Region/CoreModules/World/Land/PhysicsCombiner.cs @@ -236,20 +236,31 @@ namespace OpenSim.Region.CoreModules.World.Land m_log.DebugFormat("Scene: {0} to the west of Scene{1} Offset: {2}. Extents:{3}", conn.RegionScene.RegionInfo.RegionName, regionConnections.RegionScene.RegionInfo.RegionName, offset, extents); - + + + scene.BordersLocked = true; + conn.RegionScene.BordersLocked = true; conn.RegionScene.PhysicsScene.Combine(null, Vector3.Zero, extents); scene.PhysicsScene.Combine(conn.RegionScene.PhysicsScene, offset, Vector3.Zero); - conn.RegionScene.EastBorders[0].BorderLine.Z += (int)Constants.RegionSize; - conn.RegionScene.NorthBorders[0].BorderLine.Y += (int)Constants.RegionSize; - conn.RegionScene.SouthBorders[0].BorderLine.Y += (int)Constants.RegionSize; + lock (conn.RegionScene.EastBorders) + conn.RegionScene.EastBorders[0].BorderLine.Z += (int)Constants.RegionSize; + + lock (conn.RegionScene.NorthBorders) + conn.RegionScene.NorthBorders[0].BorderLine.Y += (int)Constants.RegionSize; + + lock (conn.RegionScene.SouthBorders) + conn.RegionScene.SouthBorders[0].BorderLine.Y += (int)Constants.RegionSize; - scene.WestBorders[0].BorderLine.Z += (int)Constants.RegionSize; //auto teleport West + lock (scene.WestBorders) + scene.WestBorders[0].BorderLine.Z += (int)Constants.RegionSize; //auto teleport West // Reset Terrain.. since terrain normally loads first. // scene.PhysicsScene.SetTerrain(scene.Heightmap.GetFloatsSerialised()); //conn.RegionScene.PhysicsScene.SetTerrain(conn.RegionScene.Heightmap.GetFloatsSerialised()); + conn.RegionScene.BordersLocked = false; + scene.BordersLocked = false; connectedYN = true; break; @@ -277,23 +288,33 @@ namespace OpenSim.Region.CoreModules.World.Land extents.X = conn.XEnd; conn.UpdateExtents(extents); + + scene.BordersLocked = true; + conn.RegionScene.BordersLocked = true; + m_log.DebugFormat("Scene: {0} to the northeast of Scene{1} Offset: {2}. Extents:{3}", conn.RegionScene.RegionInfo.RegionName, regionConnections.RegionScene.RegionInfo.RegionName, offset, extents); conn.RegionScene.PhysicsScene.Combine(null,Vector3.Zero,extents); scene.PhysicsScene.Combine(conn.RegionScene.PhysicsScene, offset, Vector3.Zero); - conn.RegionScene.NorthBorders[0].BorderLine.Z += (int)Constants.RegionSize; - conn.RegionScene.EastBorders[0].BorderLine.Y += (int)Constants.RegionSize; - conn.RegionScene.WestBorders[0].BorderLine.Y += (int)Constants.RegionSize; - - scene.SouthBorders[0].BorderLine.Z += (int)Constants.RegionSize; //auto teleport south + lock(conn.RegionScene.NorthBorders) + conn.RegionScene.NorthBorders[0].BorderLine.Z += (int)Constants.RegionSize; + lock(conn.RegionScene.EastBorders) + conn.RegionScene.EastBorders[0].BorderLine.Y += (int)Constants.RegionSize; + lock(conn.RegionScene.WestBorders) + conn.RegionScene.WestBorders[0].BorderLine.Y += (int)Constants.RegionSize; + lock(scene.SouthBorders) + scene.SouthBorders[0].BorderLine.Z += (int)Constants.RegionSize; //auto teleport south // Reset Terrain.. since terrain normally loads first. //conn.RegionScene.PhysicsScene.SetTerrain(conn.RegionScene.Heightmap.GetFloatsSerialised()); scene.PhysicsScene.SetTerrain(scene.Heightmap.GetFloatsSerialised()); //conn.RegionScene.PhysicsScene.SetTerrain(conn.RegionScene.Heightmap.GetFloatsSerialised()); + scene.BordersLocked = false; + conn.RegionScene.BordersLocked = false; + connectedYN = true; break; } @@ -318,36 +339,48 @@ namespace OpenSim.Region.CoreModules.World.Land extents.X = regionConnections.XEnd + conn.XEnd; conn.UpdateExtents(extents); + scene.BordersLocked = true; + conn.RegionScene.BordersLocked = true; + m_log.DebugFormat("Scene: {0} to the NorthEast of Scene{1} Offset: {2}. Extents:{3}", conn.RegionScene.RegionInfo.RegionName, regionConnections.RegionScene.RegionInfo.RegionName, offset, extents); conn.RegionScene.PhysicsScene.Combine(null, Vector3.Zero, extents); scene.PhysicsScene.Combine(conn.RegionScene.PhysicsScene, offset, Vector3.Zero); - + lock(conn.RegionScene.NorthBorders) if (conn.RegionScene.NorthBorders.Count == 1)// && 2) { //compound border + // already locked above conn.RegionScene.NorthBorders[0].BorderLine.Z += (int)Constants.RegionSize; - conn.RegionScene.EastBorders[0].BorderLine.Y += (int)Constants.RegionSize; - conn.RegionScene.WestBorders[0].BorderLine.Y += (int)Constants.RegionSize; + + lock(conn.RegionScene.EastBorders) + conn.RegionScene.EastBorders[0].BorderLine.Y += (int)Constants.RegionSize; + lock(conn.RegionScene.WestBorders) + conn.RegionScene.WestBorders[0].BorderLine.Y += (int)Constants.RegionSize; } - - scene.SouthBorders[0].BorderLine.Z += (int)Constants.RegionSize; //auto teleport south - + lock(scene.SouthBorders) + scene.SouthBorders[0].BorderLine.Z += (int)Constants.RegionSize; //auto teleport south + + lock(conn.RegionScene.EastBorders) if (conn.RegionScene.EastBorders.Count == 1)// && conn.RegionScene.EastBorders.Count == 2) { conn.RegionScene.EastBorders[0].BorderLine.Z += (int)Constants.RegionSize; - conn.RegionScene.NorthBorders[0].BorderLine.Y += (int)Constants.RegionSize; - conn.RegionScene.SouthBorders[0].BorderLine.Y += (int)Constants.RegionSize; + lock(conn.RegionScene.NorthBorders) + conn.RegionScene.NorthBorders[0].BorderLine.Y += (int)Constants.RegionSize; + lock(conn.RegionScene.SouthBorders) + conn.RegionScene.SouthBorders[0].BorderLine.Y += (int)Constants.RegionSize; } - scene.WestBorders[0].BorderLine.Z += (int)Constants.RegionSize; //auto teleport West + + lock (scene.WestBorders) + scene.WestBorders[0].BorderLine.Z += (int)Constants.RegionSize; //auto teleport West /* else { @@ -363,6 +396,8 @@ namespace OpenSim.Region.CoreModules.World.Land //conn.RegionScene.PhysicsScene.SetTerrain(conn.RegionScene.Heightmap.GetFloatsSerialised()); scene.PhysicsScene.SetTerrain(scene.Heightmap.GetFloatsSerialised()); //conn.RegionScene.PhysicsScene.SetTerrain(conn.RegionScene.Heightmap.GetFloatsSerialised()); + scene.BordersLocked = false; + conn.RegionScene.BordersLocked = false; connectedYN = true; diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs index 2c1d0e5..3e573cf 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.cs @@ -81,6 +81,8 @@ namespace OpenSim.Region.Framework.Scenes protected List m_regionRestartNotifyList = new List(); protected List m_neighbours = new List(); + public volatile bool BordersLocked = false; + public List NorthBorders = new List(); public List EastBorders = new List(); public List SouthBorders = new List(); @@ -331,6 +333,8 @@ namespace OpenSim.Region.Framework.Scenes m_config = config; Random random = new Random(); + + BordersLocked = true; Border northBorder = new Border(); northBorder.BorderLine = new Vector3(0, (int)Constants.RegionSize, (int)Constants.RegionSize); //<--- @@ -352,6 +356,7 @@ namespace OpenSim.Region.Framework.Scenes westBorder.CrossDirection = Cardinals.W; WestBorders.Add(westBorder); + BordersLocked = false; m_lastAllocatedLocalId = (uint)(random.NextDouble() * (double)(uint.MaxValue/2))+(uint)(uint.MaxValue/4); m_moduleLoader = moduleLoader; @@ -482,6 +487,7 @@ namespace OpenSim.Region.Framework.Scenes /// public Scene(RegionInfo regInfo) { + BordersLocked = true; Border northBorder = new Border(); northBorder.BorderLine = new Vector3(0, (int)Constants.RegionSize, (int)Constants.RegionSize); //<--- northBorder.CrossDirection = Cardinals.N; @@ -501,6 +507,7 @@ namespace OpenSim.Region.Framework.Scenes westBorder.BorderLine = new Vector3(0, (int)Constants.RegionSize, 0); //---> westBorder.CrossDirection = Cardinals.W; WestBorders.Add(westBorder); + BordersLocked = false; m_regInfo = regInfo; m_eventManager = new EventManager(); @@ -1801,105 +1808,179 @@ namespace OpenSim.Region.Framework.Scenes public Border GetCrossedBorder(Vector3 position, Cardinals gridline) { + if (BordersLocked) + { + switch (gridline) + { + case Cardinals.N: + lock (NorthBorders) + { + foreach (Border b in NorthBorders) + { + if (b.TestCross(position)) + return b; + } + } + break; + case Cardinals.S: + lock (SouthBorders) + { + foreach (Border b in SouthBorders) + { + if (b.TestCross(position)) + return b; + } + } - switch (gridline) + break; + case Cardinals.E: + lock (EastBorders) + { + foreach (Border b in EastBorders) + { + if (b.TestCross(position)) + return b; + } + } + + break; + case Cardinals.W: + + lock (WestBorders) + { + foreach (Border b in WestBorders) + { + if (b.TestCross(position)) + return b; + } + } + break; + + } + } + else { - case Cardinals.N: - lock (NorthBorders) - { + switch (gridline) + { + case Cardinals.N: foreach (Border b in NorthBorders) { if (b.TestCross(position)) return b; } - } - break; - case Cardinals.S: - - - lock (SouthBorders) - { + + break; + case Cardinals.S: foreach (Border b in SouthBorders) { if (b.TestCross(position)) return b; } - } - - break; - case Cardinals.E: - lock (EastBorders) - { + break; + case Cardinals.E: foreach (Border b in EastBorders) { if (b.TestCross(position)) return b; } - } - break; - case Cardinals.W: - - lock (WestBorders) - { + break; + case Cardinals.W: foreach (Border b in WestBorders) { if (b.TestCross(position)) return b; } - } - break; + break; + } } + return null; } public bool TestBorderCross(Vector3 position, Cardinals border) { - switch (border) + if (BordersLocked) { - case Cardinals.N: - lock (NorthBorders) - { - foreach(Border b in NorthBorders) + switch (border) + { + case Cardinals.N: + lock (NorthBorders) + { + foreach (Border b in NorthBorders) + { + if (b.TestCross(position)) + return true; + } + } + break; + case Cardinals.E: + lock (EastBorders) + { + foreach (Border b in EastBorders) + { + if (b.TestCross(position)) + return true; + } + } + break; + case Cardinals.S: + lock (SouthBorders) + { + foreach (Border b in SouthBorders) + { + if (b.TestCross(position)) + return true; + } + } + break; + case Cardinals.W: + lock (WestBorders) + { + foreach (Border b in WestBorders) + { + if (b.TestCross(position)) + return true; + } + } + break; + } + } + else + { + switch (border) + { + case Cardinals.N: + foreach (Border b in NorthBorders) { if (b.TestCross(position)) return true; } - } - break; - case Cardinals.E: - lock (EastBorders) - { + break; + case Cardinals.E: foreach (Border b in EastBorders) { if (b.TestCross(position)) return true; } - } - break; - case Cardinals.S: - lock (SouthBorders) - { + break; + case Cardinals.S: foreach (Border b in SouthBorders) { if (b.TestCross(position)) return true; } - } - break; - case Cardinals.W: - lock (WestBorders) - { + break; + case Cardinals.W: foreach (Border b in WestBorders) { if (b.TestCross(position)) return true; - } - } - break; - + } + break; + } } return false; } -- cgit v1.1