control visible regions by avatar position and view range, first dirty code
parent
07796d5ccf
commit
a56f40470e
|
@ -1932,12 +1932,7 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
|
||||||
|
|
||||||
if (seeds.ContainsKey(regionhandler))
|
if (seeds.ContainsKey(regionhandler))
|
||||||
seeds.Remove(regionhandler);
|
seeds.Remove(regionhandler);
|
||||||
/*
|
|
||||||
List<ulong> oldregions = new List<ulong>(seeds.Keys);
|
|
||||||
|
|
||||||
if (oldregions.Contains(currentRegionHandler))
|
|
||||||
oldregions.Remove(currentRegionHandler);
|
|
||||||
*/
|
|
||||||
if (!seeds.ContainsKey(currentRegionHandler))
|
if (!seeds.ContainsKey(currentRegionHandler))
|
||||||
seeds.Add(currentRegionHandler, sp.ControllingClient.RequestClientInfo().CapsPath);
|
seeds.Add(currentRegionHandler, sp.ControllingClient.RequestClientInfo().CapsPath);
|
||||||
|
|
||||||
|
@ -1975,24 +1970,7 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
|
||||||
agent.Mac = currentAgentCircuit.Mac;
|
agent.Mac = currentAgentCircuit.Mac;
|
||||||
agent.Id0 = currentAgentCircuit.Id0;
|
agent.Id0 = currentAgentCircuit.Id0;
|
||||||
}
|
}
|
||||||
/*
|
|
||||||
AgentPosition agentpos = null;
|
|
||||||
|
|
||||||
if (oldregions.Count > 0)
|
|
||||||
{
|
|
||||||
agentpos = new AgentPosition();
|
|
||||||
agentpos.AgentID = new UUID(sp.UUID.Guid);
|
|
||||||
agentpos.SessionID = sp.ControllingClient.SessionId;
|
|
||||||
agentpos.Size = sp.Appearance.AvatarSize;
|
|
||||||
agentpos.Center = sp.CameraPosition;
|
|
||||||
agentpos.Far = sp.DrawDistance;
|
|
||||||
agentpos.Position = sp.AbsolutePosition;
|
|
||||||
agentpos.Velocity = sp.Velocity;
|
|
||||||
agentpos.RegionHandle = currentRegionHandler;
|
|
||||||
agentpos.Throttles = sp.ControllingClient.GetThrottlesPacked(1);
|
|
||||||
agentpos.ChildrenCapSeeds = seeds;
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
IPEndPoint external = region.ExternalEndPoint;
|
IPEndPoint external = region.ExternalEndPoint;
|
||||||
if (external != null)
|
if (external != null)
|
||||||
{
|
{
|
||||||
|
@ -2001,20 +1979,6 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
|
||||||
InformClientOfNeighbourCompleted,
|
InformClientOfNeighbourCompleted,
|
||||||
d);
|
d);
|
||||||
}
|
}
|
||||||
/*
|
|
||||||
if(oldregions.Count >0)
|
|
||||||
{
|
|
||||||
uint neighbourx;
|
|
||||||
uint neighboury;
|
|
||||||
UUID scope = sp.Scene.RegionInfo.ScopeID;
|
|
||||||
foreach (ulong handler in oldregions)
|
|
||||||
{
|
|
||||||
Utils.LongToUInts(handler, out neighbourx, out neighboury);
|
|
||||||
GridRegion neighbour = sp.Scene.GridService.GetRegionByPosition(scope, (int)neighbourx, (int)neighboury);
|
|
||||||
sp.Scene.SimulationService.UpdateAgent(neighbour, agentpos);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
@ -2024,6 +1988,44 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
|
||||||
private delegate void InformClientOfNeighbourDelegate(
|
private delegate void InformClientOfNeighbourDelegate(
|
||||||
ScenePresence avatar, AgentCircuitData a, GridRegion reg, IPEndPoint endPoint, bool newAgent);
|
ScenePresence avatar, AgentCircuitData a, GridRegion reg, IPEndPoint endPoint, bool newAgent);
|
||||||
|
|
||||||
|
List<GridRegion> RegionsInView(Vector3 pos, RegionInfo curregion, List<GridRegion> fullneighbours, float viewrange)
|
||||||
|
{
|
||||||
|
List<GridRegion> ret = new List<GridRegion>();
|
||||||
|
if(fullneighbours.Count == 0)
|
||||||
|
return ret;
|
||||||
|
|
||||||
|
int curX = (int)Util.RegionToWorldLoc(curregion.RegionLocX) + (int)pos.X;
|
||||||
|
int minX = curX - (int)viewrange;
|
||||||
|
int maxX = curX + (int)viewrange;
|
||||||
|
int curY = (int)Util.RegionToWorldLoc(curregion.RegionLocY) + (int)pos.Y;
|
||||||
|
int minY = curY - (int)viewrange;
|
||||||
|
int maxY = curY + (int)viewrange;
|
||||||
|
int rtmp;
|
||||||
|
|
||||||
|
foreach (GridRegion r in fullneighbours)
|
||||||
|
{
|
||||||
|
OpenSim.Framework.RegionFlags? regionFlags = r.RegionFlags;
|
||||||
|
if (regionFlags != null)
|
||||||
|
{
|
||||||
|
if ((regionFlags & OpenSim.Framework.RegionFlags.RegionOnline) == 0)
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
rtmp = r.RegionLocX;
|
||||||
|
if (maxX < rtmp)
|
||||||
|
continue;
|
||||||
|
if (minX > rtmp + r.RegionSizeX)
|
||||||
|
continue;
|
||||||
|
rtmp = r.RegionLocY;
|
||||||
|
if (maxY < rtmp)
|
||||||
|
continue;
|
||||||
|
if (minY > rtmp + r.RegionSizeY)
|
||||||
|
continue;
|
||||||
|
ret.Add(r);
|
||||||
|
}
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// This informs all neighbouring regions about agent "avatar".
|
/// This informs all neighbouring regions about agent "avatar".
|
||||||
/// and as important informs the avatar about then
|
/// and as important informs the avatar about then
|
||||||
|
@ -2033,20 +2035,16 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
|
||||||
{
|
{
|
||||||
// assumes that out of view range regions are disconnected by the previus region
|
// assumes that out of view range regions are disconnected by the previus region
|
||||||
|
|
||||||
List<GridRegion> neighbours = new List<GridRegion>();
|
|
||||||
Scene spScene = sp.Scene;
|
Scene spScene = sp.Scene;
|
||||||
RegionInfo m_regionInfo = spScene.RegionInfo;
|
RegionInfo regionInfo = spScene.RegionInfo;
|
||||||
|
|
||||||
if (m_regionInfo != null)
|
if (regionInfo == null)
|
||||||
{
|
return;
|
||||||
neighbours = GetNeighbors(sp, m_regionInfo.RegionLocX, m_regionInfo.RegionLocY);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
m_log.Debug("[ENTITY TRANSFER MODULE]: m_regionInfo was null in EnableChildAgents, is this a NPC?");
|
|
||||||
}
|
|
||||||
|
|
||||||
ulong currentRegionHandler = m_regionInfo.RegionHandle;
|
ulong currentRegionHandler = regionInfo.RegionHandle;
|
||||||
|
|
||||||
|
List<GridRegion> fullneighbours = GetNeighbors(sp);
|
||||||
|
List<GridRegion> neighbours = RegionsInView(sp.AbsolutePosition, regionInfo, fullneighbours, sp.RegionViewDistance);
|
||||||
|
|
||||||
LinkedList<ulong> previousRegionNeighbourHandles;
|
LinkedList<ulong> previousRegionNeighbourHandles;
|
||||||
Dictionary<ulong, string> seeds;
|
Dictionary<ulong, string> seeds;
|
||||||
|
@ -2082,13 +2080,11 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
|
||||||
List<AgentCircuitData> cagents = new List<AgentCircuitData>();
|
List<AgentCircuitData> cagents = new List<AgentCircuitData>();
|
||||||
List<ulong> newneighbours = new List<ulong>();
|
List<ulong> newneighbours = new List<ulong>();
|
||||||
|
|
||||||
bool notHG = (sp.TeleportFlags & Constants.TeleportFlags.ViaHGLogin) == 0;
|
|
||||||
|
|
||||||
foreach (GridRegion neighbour in neighbours)
|
foreach (GridRegion neighbour in neighbours)
|
||||||
{
|
{
|
||||||
ulong handler = neighbour.RegionHandle;
|
ulong handler = neighbour.RegionHandle;
|
||||||
|
|
||||||
if (notHG && previousRegionNeighbourHandles.Contains(handler))
|
if (previousRegionNeighbourHandles.Contains(handler))
|
||||||
{
|
{
|
||||||
// agent already knows this region
|
// agent already knows this region
|
||||||
previousRegionNeighbourHandles.Remove(handler);
|
previousRegionNeighbourHandles.Remove(handler);
|
||||||
|
@ -2135,13 +2131,7 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
|
||||||
foreach (ulong handler in previousRegionNeighbourHandles)
|
foreach (ulong handler in previousRegionNeighbourHandles)
|
||||||
seeds.Remove(handler);
|
seeds.Remove(handler);
|
||||||
|
|
||||||
if(notHG) // does not work on HG
|
|
||||||
{
|
|
||||||
toclose = new List<ulong>(previousRegionNeighbourHandles);
|
toclose = new List<ulong>(previousRegionNeighbourHandles);
|
||||||
// sp.CloseChildAgents(toclose);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
toclose = new List<ulong>();
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
toclose = new List<ulong>();
|
toclose = new List<ulong>();
|
||||||
|
@ -2173,7 +2163,6 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
|
||||||
|
|
||||||
Util.FireAndForget(delegate
|
Util.FireAndForget(delegate
|
||||||
{
|
{
|
||||||
Thread.Sleep(500); // the original delay that was at InformClientOfNeighbourAsync start
|
|
||||||
int count = 0;
|
int count = 0;
|
||||||
IPEndPoint ipe;
|
IPEndPoint ipe;
|
||||||
|
|
||||||
|
@ -2196,10 +2185,12 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
|
||||||
}
|
}
|
||||||
count++;
|
count++;
|
||||||
}
|
}
|
||||||
else if (notHG && !previousRegionNeighbourHandles.Contains(handler))
|
else if (!previousRegionNeighbourHandles.Contains(handler))
|
||||||
{
|
{
|
||||||
spScene.SimulationService.UpdateAgent(neighbour, agentpos);
|
spScene.SimulationService.UpdateAgent(neighbour, agentpos);
|
||||||
}
|
}
|
||||||
|
if (sp.IsDeleted)
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
|
@ -2216,6 +2207,202 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void CheckChildAgents(ScenePresence sp)
|
||||||
|
{
|
||||||
|
// assumes that out of view range regions are disconnected by the previus region
|
||||||
|
|
||||||
|
Scene spScene = sp.Scene;
|
||||||
|
RegionInfo regionInfo = spScene.RegionInfo;
|
||||||
|
|
||||||
|
if (regionInfo == null)
|
||||||
|
return;
|
||||||
|
|
||||||
|
ulong currentRegionHandler = regionInfo.RegionHandle;
|
||||||
|
|
||||||
|
List<GridRegion> fullneighbours = GetNeighbors(sp);
|
||||||
|
List<GridRegion> neighbours = RegionsInView(sp.AbsolutePosition, regionInfo, fullneighbours, sp.RegionViewDistance);
|
||||||
|
|
||||||
|
LinkedList<ulong> previousRegionNeighbourHandles = new LinkedList<ulong>(sp.KnownRegions.Keys);
|
||||||
|
|
||||||
|
IClientAPI spClient = sp.ControllingClient;
|
||||||
|
|
||||||
|
AgentCircuitData currentAgentCircuit =
|
||||||
|
spScene.AuthenticateHandler.GetAgentCircuitData(sp.ControllingClient.CircuitCode);
|
||||||
|
|
||||||
|
List<AgentCircuitData> cagents = new List<AgentCircuitData>();
|
||||||
|
List<GridRegion> newneighbours = new List<GridRegion>();
|
||||||
|
|
||||||
|
foreach (GridRegion neighbour in neighbours)
|
||||||
|
{
|
||||||
|
ulong handler = neighbour.RegionHandle;
|
||||||
|
|
||||||
|
if (previousRegionNeighbourHandles.Contains(handler))
|
||||||
|
{
|
||||||
|
// agent already knows this region
|
||||||
|
previousRegionNeighbourHandles.Remove(handler);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (handler == currentRegionHandler)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
// a new region to add
|
||||||
|
AgentCircuitData agent = spClient.RequestClientInfo();
|
||||||
|
agent.BaseFolder = UUID.Zero;
|
||||||
|
agent.InventoryFolder = UUID.Zero;
|
||||||
|
agent.startpos = sp.AbsolutePosition + CalculateOffset(sp, neighbour);
|
||||||
|
agent.child = true;
|
||||||
|
agent.Appearance = new AvatarAppearance();
|
||||||
|
agent.Appearance.AvatarHeight = sp.Appearance.AvatarHeight;
|
||||||
|
agent.startfar = sp.DrawDistance;
|
||||||
|
if (currentAgentCircuit != null)
|
||||||
|
{
|
||||||
|
agent.ServiceURLs = currentAgentCircuit.ServiceURLs;
|
||||||
|
agent.IPAddress = currentAgentCircuit.IPAddress;
|
||||||
|
agent.Viewer = currentAgentCircuit.Viewer;
|
||||||
|
agent.Channel = currentAgentCircuit.Channel;
|
||||||
|
agent.Mac = currentAgentCircuit.Mac;
|
||||||
|
agent.Id0 = currentAgentCircuit.Id0;
|
||||||
|
}
|
||||||
|
|
||||||
|
newneighbours.Add(neighbour);
|
||||||
|
agent.CapsPath = CapsUtil.GetRandomCapsObjectPath();
|
||||||
|
sp.AddNeighbourRegion(neighbour, agent.CapsPath);
|
||||||
|
|
||||||
|
agent.ChildrenCapSeeds = null;
|
||||||
|
cagents.Add(agent);
|
||||||
|
}
|
||||||
|
|
||||||
|
List<ulong> toclose;
|
||||||
|
// previousRegionNeighbourHandles now contains regions to forget
|
||||||
|
if (previousRegionNeighbourHandles.Count > 0)
|
||||||
|
{
|
||||||
|
if (previousRegionNeighbourHandles.Contains(currentRegionHandler))
|
||||||
|
previousRegionNeighbourHandles.Remove(currentRegionHandler);
|
||||||
|
|
||||||
|
foreach (ulong handler in previousRegionNeighbourHandles)
|
||||||
|
sp.KnownRegions.Remove(handler);
|
||||||
|
|
||||||
|
toclose = new List<ulong>(previousRegionNeighbourHandles);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
toclose = new List<ulong>();
|
||||||
|
|
||||||
|
ICapabilitiesModule capsModule = spScene.CapsModule;
|
||||||
|
if (capsModule != null)
|
||||||
|
capsModule.SetChildrenSeed(sp.UUID, sp.KnownRegions);
|
||||||
|
|
||||||
|
if (toclose.Count > 0)
|
||||||
|
sp.CloseChildAgents(toclose);
|
||||||
|
|
||||||
|
if (newneighbours.Count > 0)
|
||||||
|
{
|
||||||
|
int count = 0;
|
||||||
|
IPEndPoint ipe;
|
||||||
|
|
||||||
|
foreach (GridRegion neighbour in newneighbours)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
ipe = neighbour.ExternalEndPoint;
|
||||||
|
if (ipe != null)
|
||||||
|
InformClientOfNeighbourAsync(sp, cagents[count], neighbour, ipe, true);
|
||||||
|
else
|
||||||
|
{
|
||||||
|
m_log.DebugFormat("[ENTITY TRANSFER MODULE]: lost DNS resolution for neighbour {0}", neighbour.ExternalHostName);
|
||||||
|
}
|
||||||
|
count++;
|
||||||
|
if (sp.IsDeleted)
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
m_log.ErrorFormat(
|
||||||
|
"[ENTITY TRANSFER MODULE]: Error creating child agent at {0} ({1} ({2}, {3}). {4}",
|
||||||
|
neighbour.ExternalHostName,
|
||||||
|
neighbour.RegionHandle,
|
||||||
|
neighbour.RegionLocX,
|
||||||
|
neighbour.RegionLocY,
|
||||||
|
e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void CloseOldChildAgents(ScenePresence sp)
|
||||||
|
{
|
||||||
|
Scene spScene = sp.Scene;
|
||||||
|
RegionInfo regionInfo = spScene.RegionInfo;
|
||||||
|
|
||||||
|
if (regionInfo == null)
|
||||||
|
return;
|
||||||
|
|
||||||
|
ulong currentRegionHandler = regionInfo.RegionHandle;
|
||||||
|
|
||||||
|
List<GridRegion> fullneighbours = GetNeighbors(sp);
|
||||||
|
List<GridRegion> neighbours = RegionsInView(sp.AbsolutePosition, regionInfo, fullneighbours, sp.RegionViewDistance);
|
||||||
|
|
||||||
|
LinkedList<ulong> previousRegionNeighbourHandles;
|
||||||
|
Dictionary<ulong, string> seeds;
|
||||||
|
ICapabilitiesModule capsModule = spScene.CapsModule;
|
||||||
|
|
||||||
|
if (capsModule != null)
|
||||||
|
{
|
||||||
|
seeds = new Dictionary<ulong, string>(capsModule.GetChildrenSeeds(sp.UUID));
|
||||||
|
previousRegionNeighbourHandles = new LinkedList<ulong>(seeds.Keys);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
seeds = new Dictionary<ulong, string>();
|
||||||
|
previousRegionNeighbourHandles = new LinkedList<ulong>();
|
||||||
|
}
|
||||||
|
|
||||||
|
IClientAPI spClient = sp.ControllingClient;
|
||||||
|
|
||||||
|
// This will fail if the user aborts login
|
||||||
|
try
|
||||||
|
{
|
||||||
|
if (!seeds.ContainsKey(currentRegionHandler))
|
||||||
|
seeds.Add(currentRegionHandler, spClient.RequestClientInfo().CapsPath);
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach (GridRegion neighbour in neighbours)
|
||||||
|
{
|
||||||
|
ulong handler = neighbour.RegionHandle;
|
||||||
|
|
||||||
|
if (previousRegionNeighbourHandles.Contains(handler))
|
||||||
|
previousRegionNeighbourHandles.Remove(handler);
|
||||||
|
}
|
||||||
|
|
||||||
|
List<ulong> toclose;
|
||||||
|
// previousRegionNeighbourHandles now contains regions to forget
|
||||||
|
if (previousRegionNeighbourHandles.Count == 0)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (previousRegionNeighbourHandles.Contains(currentRegionHandler))
|
||||||
|
previousRegionNeighbourHandles.Remove(currentRegionHandler);
|
||||||
|
|
||||||
|
foreach (ulong handler in previousRegionNeighbourHandles)
|
||||||
|
seeds.Remove(handler);
|
||||||
|
|
||||||
|
toclose = new List<ulong>(previousRegionNeighbourHandles);
|
||||||
|
|
||||||
|
if (capsModule != null)
|
||||||
|
capsModule.SetChildrenSeed(sp.UUID, seeds);
|
||||||
|
|
||||||
|
sp.KnownRegions = seeds;
|
||||||
|
sp.SetNeighbourRegionSizeInfo(neighbours);
|
||||||
|
|
||||||
|
Util.FireAndForget(delegate
|
||||||
|
{
|
||||||
|
sp.CloseChildAgents(toclose);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
// Computes the difference between two region bases.
|
// Computes the difference between two region bases.
|
||||||
// Returns a vector of world coordinates (meters) from base of first region to the second.
|
// Returns a vector of world coordinates (meters) from base of first region to the second.
|
||||||
// The first region is the home region of the passed scene presence.
|
// The first region is the home region of the passed scene presence.
|
||||||
|
@ -2416,6 +2603,11 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// all this code should be moved to scene replacing the now bad one there
|
||||||
|
// cache Neighbors
|
||||||
|
List<GridRegion> Neighbors = null;
|
||||||
|
DateTime LastNeighborsTime = DateTime.MinValue;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Return the list of online regions that are considered to be neighbours to the given scene.
|
/// Return the list of online regions that are considered to be neighbours to the given scene.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -2423,39 +2615,41 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
|
||||||
/// <param name="pRegionLocX"></param>
|
/// <param name="pRegionLocX"></param>
|
||||||
/// <param name="pRegionLocY"></param>
|
/// <param name="pRegionLocY"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
protected List<GridRegion> GetNeighbors(ScenePresence avatar, uint pRegionLocX, uint pRegionLocY)
|
protected List<GridRegion> GetNeighbors(ScenePresence avatar)
|
||||||
{
|
{
|
||||||
Scene pScene = avatar.Scene;
|
Scene pScene = avatar.Scene;
|
||||||
RegionInfo m_regionInfo = pScene.RegionInfo;
|
|
||||||
|
uint dd = (uint)pScene.MaxRegionViewDistance;
|
||||||
|
if(dd <= 1)
|
||||||
|
return new List<GridRegion>();
|
||||||
|
|
||||||
|
if (Neighbors != null && (DateTime.UtcNow - LastNeighborsTime).TotalSeconds < 30)
|
||||||
|
{
|
||||||
|
return Neighbors;
|
||||||
|
}
|
||||||
|
|
||||||
|
RegionInfo regionInfo = pScene.RegionInfo;
|
||||||
List<GridRegion> neighbours;
|
List<GridRegion> neighbours;
|
||||||
|
|
||||||
uint dd = (uint)avatar.RegionViewDistance;
|
dd--;
|
||||||
|
|
||||||
// until avatar movement updates client connections, we need to send at least this current region immediate neighbors
|
uint startX = Util.RegionToWorldLoc(regionInfo.RegionLocX);
|
||||||
uint ddX = Math.Max(dd, Constants.RegionSize);
|
uint endX = startX + regionInfo.RegionSizeX;
|
||||||
uint ddY = Math.Max(dd, Constants.RegionSize);
|
uint startY = Util.RegionToWorldLoc(regionInfo.RegionLocY);
|
||||||
|
uint endY = startY + regionInfo.RegionSizeY;
|
||||||
|
|
||||||
ddX--;
|
startX -= dd;
|
||||||
ddY--;
|
startY -= dd;
|
||||||
|
endX += dd;
|
||||||
|
endY += dd;
|
||||||
|
|
||||||
// reference to region edges. Should be avatar position
|
neighbours = avatar.Scene.GridService.GetRegionRange(
|
||||||
uint startX = Util.RegionToWorldLoc(pRegionLocX);
|
regionInfo.ScopeID, (int)startX, (int)endX, (int)startY, (int)endY);
|
||||||
uint endX = startX + m_regionInfo.RegionSizeX;
|
|
||||||
uint startY = Util.RegionToWorldLoc(pRegionLocY);
|
|
||||||
uint endY = startY + m_regionInfo.RegionSizeY;
|
|
||||||
|
|
||||||
startX -= ddX;
|
|
||||||
startY -= ddY;
|
|
||||||
endX += ddX;
|
|
||||||
endY += ddY;
|
|
||||||
|
|
||||||
neighbours
|
|
||||||
= avatar.Scene.GridService.GetRegionRange(
|
|
||||||
m_regionInfo.ScopeID, (int)startX, (int)endX, (int)startY, (int)endY);
|
|
||||||
|
|
||||||
// The r.RegionFlags == null check only needs to be made for simulators before 2015-01-14 (pre 0.8.1).
|
// The r.RegionFlags == null check only needs to be made for simulators before 2015-01-14 (pre 0.8.1).
|
||||||
neighbours.RemoveAll( r => r.RegionID == m_regionInfo.RegionID );
|
neighbours.RemoveAll( r => r.RegionID == regionInfo.RegionID );
|
||||||
|
Neighbors = neighbours;
|
||||||
|
LastNeighborsTime = DateTime.UtcNow;
|
||||||
return neighbours;
|
return neighbours;
|
||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
|
|
|
@ -90,6 +90,8 @@ namespace OpenSim.Region.Framework.Interfaces
|
||||||
void AgentArrivedAtDestination(UUID agent);
|
void AgentArrivedAtDestination(UUID agent);
|
||||||
|
|
||||||
void EnableChildAgents(ScenePresence agent);
|
void EnableChildAgents(ScenePresence agent);
|
||||||
|
void CheckChildAgents(ScenePresence agent);
|
||||||
|
void CloseOldChildAgents(ScenePresence agent);
|
||||||
|
|
||||||
void EnableChildAgent(ScenePresence agent, GridRegion region);
|
void EnableChildAgent(ScenePresence agent, GridRegion region);
|
||||||
|
|
||||||
|
|
|
@ -1286,7 +1286,6 @@ namespace OpenSim.Region.Framework.Scenes
|
||||||
{
|
{
|
||||||
if (RegionInfo.RegionHandle != otherRegion.RegionHandle)
|
if (RegionInfo.RegionHandle != otherRegion.RegionHandle)
|
||||||
{
|
{
|
||||||
|
|
||||||
if (isNeighborRegion(otherRegion))
|
if (isNeighborRegion(otherRegion))
|
||||||
{
|
{
|
||||||
// Let the grid service module know, so this can be cached
|
// Let the grid service module know, so this can be cached
|
||||||
|
@ -1296,9 +1295,6 @@ namespace OpenSim.Region.Framework.Scenes
|
||||||
{
|
{
|
||||||
ForEachRootScenePresence(delegate(ScenePresence agent)
|
ForEachRootScenePresence(delegate(ScenePresence agent)
|
||||||
{
|
{
|
||||||
//agent.ControllingClient.new
|
|
||||||
//this.CommsManager.InterRegion.InformRegionOfChildAgent(otherRegion.RegionHandle, agent.ControllingClient.RequestClientInfo());
|
|
||||||
|
|
||||||
List<ulong> old = new List<ulong>();
|
List<ulong> old = new List<ulong>();
|
||||||
old.Add(otherRegion.RegionHandle);
|
old.Add(otherRegion.RegionHandle);
|
||||||
agent.DropOldNeighbours(old);
|
agent.DropOldNeighbours(old);
|
||||||
|
@ -1324,7 +1320,7 @@ namespace OpenSim.Region.Framework.Scenes
|
||||||
|
|
||||||
public bool isNeighborRegion(GridRegion otherRegion)
|
public bool isNeighborRegion(GridRegion otherRegion)
|
||||||
{
|
{
|
||||||
int tmp = otherRegion.RegionLocX - (int)RegionInfo.WorldLocX; ;
|
int tmp = otherRegion.RegionLocX - (int)RegionInfo.WorldLocX;
|
||||||
|
|
||||||
if (tmp < -otherRegion.RegionSizeX && tmp > RegionInfo.RegionSizeX)
|
if (tmp < -otherRegion.RegionSizeX && tmp > RegionInfo.RegionSizeX)
|
||||||
return false;
|
return false;
|
||||||
|
|
|
@ -165,6 +165,7 @@ namespace OpenSim.Region.Framework.Scenes
|
||||||
public static readonly float MOVEMENT = .25f;
|
public static readonly float MOVEMENT = .25f;
|
||||||
public static readonly float SIGNIFICANT_MOVEMENT = 16.0f;
|
public static readonly float SIGNIFICANT_MOVEMENT = 16.0f;
|
||||||
public static readonly float CHILDUPDATES_MOVEMENT = 100.0f;
|
public static readonly float CHILDUPDATES_MOVEMENT = 100.0f;
|
||||||
|
public static readonly float CHILDAGENTSCHECK_MOVEMENT = 1024f; // 32m
|
||||||
public static readonly float CHILDUPDATES_TIME = 2000f; // min time between child updates (ms)
|
public static readonly float CHILDUPDATES_TIME = 2000f; // min time between child updates (ms)
|
||||||
|
|
||||||
private UUID m_previusParcelUUID = UUID.Zero;
|
private UUID m_previusParcelUUID = UUID.Zero;
|
||||||
|
@ -342,6 +343,7 @@ namespace OpenSim.Region.Framework.Scenes
|
||||||
private int m_lastChildAgentUpdateGodLevel;
|
private int m_lastChildAgentUpdateGodLevel;
|
||||||
private float m_lastChildAgentUpdateDrawDistance;
|
private float m_lastChildAgentUpdateDrawDistance;
|
||||||
private Vector3 m_lastChildAgentUpdatePosition;
|
private Vector3 m_lastChildAgentUpdatePosition;
|
||||||
|
private Vector3 m_lastChildAgentCheckPosition;
|
||||||
// private Vector3 m_lastChildAgentUpdateCamPosition;
|
// private Vector3 m_lastChildAgentUpdateCamPosition;
|
||||||
|
|
||||||
private Vector3 m_lastCameraRayCastCam;
|
private Vector3 m_lastCameraRayCastCam;
|
||||||
|
@ -627,7 +629,7 @@ namespace OpenSim.Region.Framework.Scenes
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
return Util.Clamp(m_drawDistance, 32f, m_scene.MaxRegionViewDistance);
|
return Util.Clamp(m_drawDistance + 64f, 64f, m_scene.MaxRegionViewDistance);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2321,6 +2323,7 @@ namespace OpenSim.Region.Framework.Scenes
|
||||||
|
|
||||||
m_lastChildUpdatesTime = Util.EnvironmentTickCount() + 10000;
|
m_lastChildUpdatesTime = Util.EnvironmentTickCount() + 10000;
|
||||||
m_lastChildAgentUpdatePosition = AbsolutePosition;
|
m_lastChildAgentUpdatePosition = AbsolutePosition;
|
||||||
|
m_lastChildAgentCheckPosition = m_lastChildAgentUpdatePosition;
|
||||||
m_lastChildAgentUpdateDrawDistance = DrawDistance;
|
m_lastChildAgentUpdateDrawDistance = DrawDistance;
|
||||||
|
|
||||||
m_lastChildAgentUpdateGodLevel = GodController.ViwerUIGodLevel;
|
m_lastChildAgentUpdateGodLevel = GodController.ViwerUIGodLevel;
|
||||||
|
@ -4049,20 +4052,11 @@ namespace OpenSim.Region.Framework.Scenes
|
||||||
//NeedInitialData = 4;
|
//NeedInitialData = 4;
|
||||||
//return;
|
//return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create child agents in neighbouring regions
|
|
||||||
IEntityTransferModule m_agentTransfer = m_scene.RequestModuleInterface<IEntityTransferModule>();
|
IEntityTransferModule m_agentTransfer = m_scene.RequestModuleInterface<IEntityTransferModule>();
|
||||||
if (m_agentTransfer != null)
|
if (m_agentTransfer != null)
|
||||||
{
|
{
|
||||||
m_agentTransfer.EnableChildAgents(this);
|
m_agentTransfer.CloseOldChildAgents(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
m_lastChildUpdatesTime = Util.EnvironmentTickCount() + 10000;
|
|
||||||
m_lastChildAgentUpdatePosition = AbsolutePosition;
|
|
||||||
m_lastChildAgentUpdateDrawDistance = DrawDistance;
|
|
||||||
|
|
||||||
m_lastChildAgentUpdateGodLevel = GodController.ViwerUIGodLevel;
|
|
||||||
m_childUpdatesBusy = false; // allow them
|
|
||||||
}
|
}
|
||||||
|
|
||||||
m_log.DebugFormat("[SCENE PRESENCE({0})]: SendInitialData for {1}", Scene.RegionInfo.RegionName, UUID);
|
m_log.DebugFormat("[SCENE PRESENCE({0})]: SendInitialData for {1}", Scene.RegionInfo.RegionName, UUID);
|
||||||
|
@ -4126,6 +4120,24 @@ namespace OpenSim.Region.Framework.Scenes
|
||||||
|
|
||||||
m_reprioritizationBusy = false;
|
m_reprioritizationBusy = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!IsChildAgent)
|
||||||
|
{
|
||||||
|
// Create child agents in neighbouring regions
|
||||||
|
IEntityTransferModule m_agentTransfer = m_scene.RequestModuleInterface<IEntityTransferModule>();
|
||||||
|
if (m_agentTransfer != null)
|
||||||
|
{
|
||||||
|
m_agentTransfer.EnableChildAgents(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
m_lastChildUpdatesTime = Util.EnvironmentTickCount() + 10000;
|
||||||
|
m_lastChildAgentUpdatePosition = AbsolutePosition;
|
||||||
|
m_lastChildAgentCheckPosition = m_lastChildAgentUpdatePosition;
|
||||||
|
m_lastChildAgentUpdateDrawDistance = DrawDistance;
|
||||||
|
|
||||||
|
m_lastChildAgentUpdateGodLevel = GodController.ViwerUIGodLevel;
|
||||||
|
m_childUpdatesBusy = false; // allow them
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -4399,19 +4411,42 @@ namespace OpenSim.Region.Framework.Scenes
|
||||||
if(m_childUpdatesBusy)
|
if(m_childUpdatesBusy)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
//possible KnownRegionHandles always contains current region and this check is not needed
|
|
||||||
int minhandles = KnownRegionHandles.Contains(RegionHandle) ? 1 : 0;
|
|
||||||
if(KnownRegionHandles.Count > minhandles)
|
|
||||||
{
|
|
||||||
int tdiff = Util.EnvironmentTickCountSubtract(m_lastChildUpdatesTime);
|
int tdiff = Util.EnvironmentTickCountSubtract(m_lastChildUpdatesTime);
|
||||||
if (tdiff < CHILDUPDATES_TIME)
|
if (tdiff < CHILDUPDATES_TIME)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
IEntityTransferModule m_agentTransfer = m_scene.RequestModuleInterface<IEntityTransferModule>();
|
||||||
|
float dx = pos.X - m_lastChildAgentCheckPosition.Y;
|
||||||
|
float dy = pos.Y - m_lastChildAgentCheckPosition.Y;
|
||||||
|
if ((m_agentTransfer != null) && ((dx * dx + dy *dy) > CHILDAGENTSCHECK_MOVEMENT))
|
||||||
|
{
|
||||||
|
m_childUpdatesBusy = true;
|
||||||
|
m_lastChildAgentCheckPosition = pos;
|
||||||
|
m_lastChildAgentUpdatePosition = pos;
|
||||||
|
m_lastChildAgentUpdateGodLevel = GodController.ViwerUIGodLevel;
|
||||||
|
m_lastChildAgentUpdateDrawDistance = DrawDistance;
|
||||||
|
// m_lastChildAgentUpdateCamPosition = CameraPosition;
|
||||||
|
|
||||||
|
Util.FireAndForget(
|
||||||
|
o =>
|
||||||
|
{
|
||||||
|
m_agentTransfer.EnableChildAgents(this);
|
||||||
|
m_lastChildUpdatesTime = Util.EnvironmentTickCount();
|
||||||
|
m_childUpdatesBusy = false;
|
||||||
|
}, null, "ScenePresence.CheckChildAgents");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
//possible KnownRegionHandles always contains current region and this check is not needed
|
||||||
|
int minhandles = KnownRegionHandles.Contains(RegionHandle) ? 1 : 0;
|
||||||
|
if(KnownRegionHandles.Count > minhandles)
|
||||||
|
{
|
||||||
bool doUpdate = false;
|
bool doUpdate = false;
|
||||||
if (m_lastChildAgentUpdateGodLevel != GodController.ViwerUIGodLevel)
|
if (m_lastChildAgentUpdateGodLevel != GodController.ViwerUIGodLevel)
|
||||||
doUpdate = true;
|
doUpdate = true;
|
||||||
|
|
||||||
if(!doUpdate && Math.Abs(DrawDistance - m_lastChildAgentUpdateDrawDistance) > 32.0f)
|
bool viewchanged = Math.Abs(DrawDistance - m_lastChildAgentUpdateDrawDistance) > 32.0f;
|
||||||
|
if (!viewchanged)
|
||||||
doUpdate = true;
|
doUpdate = true;
|
||||||
|
|
||||||
if(!doUpdate)
|
if(!doUpdate)
|
||||||
|
@ -4452,6 +4487,7 @@ namespace OpenSim.Region.Framework.Scenes
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue