From eac29396d98a4864923a69e0eb73cecdd8a225b3 Mon Sep 17 00:00:00 2001 From: Dan Lake Date: Wed, 19 Oct 2011 15:38:25 -0700 Subject: Moved HaveNeighbor utility function from ScenePresence to Scene. Fixed line endings from previous commit. --- .../Framework/Interfaces/IAvatarFactoryModule.cs | 4 +- OpenSim/Region/Framework/Scenes/Scene.cs | 40 ++++++++++++++++ OpenSim/Region/Framework/Scenes/ScenePresence.cs | 56 ++++------------------ 3 files changed, 50 insertions(+), 50 deletions(-) (limited to 'OpenSim/Region/Framework') diff --git a/OpenSim/Region/Framework/Interfaces/IAvatarFactoryModule.cs b/OpenSim/Region/Framework/Interfaces/IAvatarFactoryModule.cs index 98228e4..26bc922 100644 --- a/OpenSim/Region/Framework/Interfaces/IAvatarFactoryModule.cs +++ b/OpenSim/Region/Framework/Interfaces/IAvatarFactoryModule.cs @@ -32,8 +32,8 @@ using OpenSim.Framework; namespace OpenSim.Region.Framework.Interfaces { public interface IAvatarFactoryModule - { - + { + void SetAppearance(IScenePresence sp, Primitive.TextureEntry textureEntry, byte[] visualParams); /// diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs index 724c635..64ed6c7 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.cs @@ -960,6 +960,46 @@ namespace OpenSim.Region.Framework.Scenes return found; } + /// + /// Checks whether this region has a neighbour in the given direction. + /// + /// + /// + /// + /// An integer which represents a compass point. N == 1, going clockwise until we reach NW == 8. + /// Returns a positive integer if there is a region in that direction, a negative integer if not. + /// + public int HaveNeighbor(Cardinals car, ref int[] fix) + { + uint neighbourx = RegionInfo.RegionLocX; + uint neighboury = RegionInfo.RegionLocY; + + int dir = (int)car; + + if (dir > 1 && dir < 5) //Heading East + neighbourx++; + else if (dir > 5) // Heading West + neighbourx--; + + if (dir < 3 || dir == 8) // Heading North + neighboury++; + else if (dir > 3 && dir < 7) // Heading Sout + neighboury--; + + int x = (int)(neighbourx * Constants.RegionSize); + int y = (int)(neighboury * Constants.RegionSize); + GridRegion neighbourRegion = GridService.GetRegionByPosition(RegionInfo.ScopeID, x, y); + + if (neighbourRegion == null) + { + fix[0] = (int)(RegionInfo.RegionLocX - neighbourx); + fix[1] = (int)(RegionInfo.RegionLocY - neighboury); + return dir * (-1); + } + else + return dir; + } + // Alias IncomingHelloNeighbour OtherRegionUp, for now public GridRegion IncomingHelloNeighbour(RegionInfo neighbour) { diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index 464f8f0..8eb069f 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -2782,17 +2782,17 @@ namespace OpenSim.Region.Framework.Scenes if (m_scene.TestBorderCross(pos2, Cardinals.S)) { needsTransit = true; - neighbor = HaveNeighbor(Cardinals.SW, ref fix); + neighbor = m_scene.HaveNeighbor(Cardinals.SW, ref fix); } else if (m_scene.TestBorderCross(pos2, Cardinals.N)) { needsTransit = true; - neighbor = HaveNeighbor(Cardinals.NW, ref fix); + neighbor = m_scene.HaveNeighbor(Cardinals.NW, ref fix); } else { needsTransit = true; - neighbor = HaveNeighbor(Cardinals.W, ref fix); + neighbor = m_scene.HaveNeighbor(Cardinals.W, ref fix); } } else if (m_scene.TestBorderCross(pos2, Cardinals.E)) @@ -2800,28 +2800,28 @@ namespace OpenSim.Region.Framework.Scenes if (m_scene.TestBorderCross(pos2, Cardinals.S)) { needsTransit = true; - neighbor = HaveNeighbor(Cardinals.SE, ref fix); + neighbor = m_scene.HaveNeighbor(Cardinals.SE, ref fix); } else if (m_scene.TestBorderCross(pos2, Cardinals.N)) { needsTransit = true; - neighbor = HaveNeighbor(Cardinals.NE, ref fix); + neighbor = m_scene.HaveNeighbor(Cardinals.NE, ref fix); } else { needsTransit = true; - neighbor = HaveNeighbor(Cardinals.E, ref fix); + neighbor = m_scene.HaveNeighbor(Cardinals.E, ref fix); } } else if (m_scene.TestBorderCross(pos2, Cardinals.S)) { needsTransit = true; - neighbor = HaveNeighbor(Cardinals.S, ref fix); + neighbor = m_scene.HaveNeighbor(Cardinals.S, ref fix); } else if (m_scene.TestBorderCross(pos2, Cardinals.N)) { needsTransit = true; - neighbor = HaveNeighbor(Cardinals.N, ref fix); + neighbor = m_scene.HaveNeighbor(Cardinals.N, ref fix); } // Makes sure avatar does not end up outside region @@ -2897,46 +2897,6 @@ namespace OpenSim.Region.Framework.Scenes } /// - /// Checks whether this region has a neighbour in the given direction. - /// - /// - /// - /// - /// An integer which represents a compass point. N == 1, going clockwise until we reach NW == 8. - /// Returns a positive integer if there is a region in that direction, a negative integer if not. - /// - protected int HaveNeighbor(Cardinals car, ref int[] fix) - { - uint neighbourx = m_scene.RegionInfo.RegionLocX; - uint neighboury = m_scene.RegionInfo.RegionLocY; - - int dir = (int)car; - - if (dir > 1 && dir < 5) //Heading East - neighbourx++; - else if (dir > 5) // Heading West - neighbourx--; - - if (dir < 3 || dir == 8) // Heading North - neighboury++; - else if (dir > 3 && dir < 7) // Heading Sout - neighboury--; - - int x = (int)(neighbourx * Constants.RegionSize); - int y = (int)(neighboury * Constants.RegionSize); - GridRegion neighbourRegion = m_scene.GridService.GetRegionByPosition(m_scene.RegionInfo.ScopeID, x, y); - - if (neighbourRegion == null) - { - fix[0] = (int)(m_scene.RegionInfo.RegionLocX - neighbourx); - fix[1] = (int)(m_scene.RegionInfo.RegionLocY - neighboury); - return dir * (-1); - } - else - return dir; - } - - /// /// Moves the agent outside the region bounds /// Tells neighbor region that we're crossing to it /// If the neighbor accepts, remove the agent's viewable avatar from this scene -- cgit v1.1