diff options
author | Mic Bowman | 2011-02-22 13:23:54 -0800 |
---|---|---|
committer | Mic Bowman | 2011-02-22 13:23:54 -0800 |
commit | 5a16fa882c0f1a6200bc3fdb63b0f4564acf0e6d (patch) | |
tree | 0021a13a22e089fd373619f3f636199fb636ce95 /OpenSim | |
parent | GetRegion(s)ByName with SQLite behaves like it does with other databases. (diff) | |
download | opensim-SC-5a16fa882c0f1a6200bc3fdb63b0f4564acf0e6d.zip opensim-SC-5a16fa882c0f1a6200bc3fdb63b0f4564acf0e6d.tar.gz opensim-SC-5a16fa882c0f1a6200bc3fdb63b0f4564acf0e6d.tar.bz2 opensim-SC-5a16fa882c0f1a6200bc3fdb63b0f4564acf0e6d.tar.xz |
Parameterizes the view distance used to compute and manage
child agents in neighbor regions. This means you can extend
the view on a simulator beyond the default 3x3 regions.
This uses a region default draw distance and should be
replaced at some point by the avatar specified draw distance.
That will require more careful, dynamic recomputation of child
agents every time the draw distance changes.
WARNING: this is experimental and has known instabilities. specifically
all regions "within site" should be running the same default draw distance
or agents will not be closed correctly.
Diffstat (limited to '')
5 files changed, 66 insertions, 21 deletions
diff --git a/OpenSim/Framework/Util.cs b/OpenSim/Framework/Util.cs index 533e53a..5a5046e 100644 --- a/OpenSim/Framework/Util.cs +++ b/OpenSim/Framework/Util.cs | |||
@@ -459,10 +459,17 @@ namespace OpenSim.Framework | |||
459 | /// <param name="oldy">Old region y-coord</param> | 459 | /// <param name="oldy">Old region y-coord</param> |
460 | /// <param name="newy">New region y-coord</param> | 460 | /// <param name="newy">New region y-coord</param> |
461 | /// <returns></returns> | 461 | /// <returns></returns> |
462 | public static bool IsOutsideView(uint oldx, uint newx, uint oldy, uint newy) | 462 | public static bool IsOutsideView(float drawdist, uint oldx, uint newx, uint oldy, uint newy) |
463 | { | 463 | { |
464 | // Eventually this will be a function of the draw distance / camera position too. | 464 | int dd = (int)((drawdist + Constants.RegionSize - 1) / Constants.RegionSize); |
465 | return (((int)Math.Abs((int)(oldx - newx)) > 1) || ((int)Math.Abs((int)(oldy - newy)) > 1)); | 465 | |
466 | int startX = (int)oldx - dd; | ||
467 | int startY = (int)oldy - dd; | ||
468 | |||
469 | int endX = (int)oldx + dd; | ||
470 | int endY = (int)oldy + dd; | ||
471 | |||
472 | return (newx < startX || endX < newx || newy < startY || endY < newy); | ||
466 | } | 473 | } |
467 | 474 | ||
468 | public static string FieldToString(byte[] bytes) | 475 | public static string FieldToString(byte[] bytes) |
diff --git a/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs b/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs index 98aa563..95c771e 100644 --- a/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs +++ b/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs | |||
@@ -318,7 +318,7 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer | |||
318 | agentCircuit.Id0 = currentAgentCircuit.Id0; | 318 | agentCircuit.Id0 = currentAgentCircuit.Id0; |
319 | } | 319 | } |
320 | 320 | ||
321 | if (NeedsNewAgent(oldRegionX, newRegionX, oldRegionY, newRegionY)) | 321 | if (NeedsNewAgent(sp.DrawDistance, oldRegionX, newRegionX, oldRegionY, newRegionY)) |
322 | { | 322 | { |
323 | // brand new agent, let's create a new caps seed | 323 | // brand new agent, let's create a new caps seed |
324 | agentCircuit.CapsPath = CapsUtil.GetRandomCapsObjectPath(); | 324 | agentCircuit.CapsPath = CapsUtil.GetRandomCapsObjectPath(); |
@@ -336,7 +336,7 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer | |||
336 | // OK, it got this agent. Let's close some child agents | 336 | // OK, it got this agent. Let's close some child agents |
337 | sp.CloseChildAgents(newRegionX, newRegionY); | 337 | sp.CloseChildAgents(newRegionX, newRegionY); |
338 | IClientIPEndpoint ipepClient; | 338 | IClientIPEndpoint ipepClient; |
339 | if (NeedsNewAgent(oldRegionX, newRegionX, oldRegionY, newRegionY)) | 339 | if (NeedsNewAgent(sp.DrawDistance, oldRegionX, newRegionX, oldRegionY, newRegionY)) |
340 | { | 340 | { |
341 | //sp.ControllingClient.SendTeleportProgress(teleportFlags, "Creating agent..."); | 341 | //sp.ControllingClient.SendTeleportProgress(teleportFlags, "Creating agent..."); |
342 | #region IP Translation for NAT | 342 | #region IP Translation for NAT |
@@ -447,7 +447,7 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer | |||
447 | 447 | ||
448 | // Finally, let's close this previously-known-as-root agent, when the jump is outside the view zone | 448 | // Finally, let's close this previously-known-as-root agent, when the jump is outside the view zone |
449 | 449 | ||
450 | if (NeedsClosing(oldRegionX, newRegionX, oldRegionY, newRegionY, reg)) | 450 | if (NeedsClosing(sp.DrawDistance, oldRegionX, newRegionX, oldRegionY, newRegionY, reg)) |
451 | { | 451 | { |
452 | Thread.Sleep(5000); | 452 | Thread.Sleep(5000); |
453 | sp.Close(); | 453 | sp.Close(); |
@@ -521,14 +521,14 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer | |||
521 | return region; | 521 | return region; |
522 | } | 522 | } |
523 | 523 | ||
524 | protected virtual bool NeedsNewAgent(uint oldRegionX, uint newRegionX, uint oldRegionY, uint newRegionY) | 524 | protected virtual bool NeedsNewAgent(float drawdist, uint oldRegionX, uint newRegionX, uint oldRegionY, uint newRegionY) |
525 | { | 525 | { |
526 | return Util.IsOutsideView(oldRegionX, newRegionX, oldRegionY, newRegionY); | 526 | return Util.IsOutsideView(drawdist, oldRegionX, newRegionX, oldRegionY, newRegionY); |
527 | } | 527 | } |
528 | 528 | ||
529 | protected virtual bool NeedsClosing(uint oldRegionX, uint newRegionX, uint oldRegionY, uint newRegionY, GridRegion reg) | 529 | protected virtual bool NeedsClosing(float drawdist, uint oldRegionX, uint newRegionX, uint oldRegionY, uint newRegionY, GridRegion reg) |
530 | { | 530 | { |
531 | return Util.IsOutsideView(oldRegionX, newRegionX, oldRegionY, newRegionY); | 531 | return Util.IsOutsideView(drawdist, oldRegionX, newRegionX, oldRegionY, newRegionY); |
532 | } | 532 | } |
533 | 533 | ||
534 | protected virtual bool IsOutsideRegion(Scene s, Vector3 pos) | 534 | protected virtual bool IsOutsideRegion(Scene s, Vector3 pos) |
@@ -1045,7 +1045,7 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer | |||
1045 | 1045 | ||
1046 | if (m_regionInfo != null) | 1046 | if (m_regionInfo != null) |
1047 | { | 1047 | { |
1048 | neighbours = RequestNeighbours(sp.Scene, m_regionInfo.RegionLocX, m_regionInfo.RegionLocY); | 1048 | neighbours = RequestNeighbours(sp, m_regionInfo.RegionLocX, m_regionInfo.RegionLocY); |
1049 | } | 1049 | } |
1050 | else | 1050 | else |
1051 | { | 1051 | { |
@@ -1272,8 +1272,9 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer | |||
1272 | /// <param name="pRegionLocX"></param> | 1272 | /// <param name="pRegionLocX"></param> |
1273 | /// <param name="pRegionLocY"></param> | 1273 | /// <param name="pRegionLocY"></param> |
1274 | /// <returns></returns> | 1274 | /// <returns></returns> |
1275 | protected List<GridRegion> RequestNeighbours(Scene pScene, uint pRegionLocX, uint pRegionLocY) | 1275 | protected List<GridRegion> RequestNeighbours(ScenePresence avatar, uint pRegionLocX, uint pRegionLocY) |
1276 | { | 1276 | { |
1277 | Scene pScene = avatar.Scene; | ||
1277 | RegionInfo m_regionInfo = pScene.RegionInfo; | 1278 | RegionInfo m_regionInfo = pScene.RegionInfo; |
1278 | 1279 | ||
1279 | Border[] northBorders = pScene.NorthBorders.ToArray(); | 1280 | Border[] northBorders = pScene.NorthBorders.ToArray(); |
@@ -1281,10 +1282,24 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer | |||
1281 | Border[] eastBorders = pScene.EastBorders.ToArray(); | 1282 | Border[] eastBorders = pScene.EastBorders.ToArray(); |
1282 | Border[] westBorders = pScene.WestBorders.ToArray(); | 1283 | Border[] westBorders = pScene.WestBorders.ToArray(); |
1283 | 1284 | ||
1284 | // Legacy one region. Provided for simplicity while testing the all inclusive method in the else statement. | 1285 | // Leaving this as a "megaregions" computation vs "non-megaregions" computation; it isn't |
1286 | // clear what should be done with a "far view" given that megaregions already extended the | ||
1287 | // view to include everything in the megaregion | ||
1285 | if (northBorders.Length <= 1 && southBorders.Length <= 1 && eastBorders.Length <= 1 && westBorders.Length <= 1) | 1288 | if (northBorders.Length <= 1 && southBorders.Length <= 1 && eastBorders.Length <= 1 && westBorders.Length <= 1) |
1286 | { | 1289 | { |
1287 | return pScene.GridService.GetNeighbours(m_regionInfo.ScopeID, m_regionInfo.RegionID); | 1290 | int dd = avatar.DrawDistance < Constants.RegionSize ? (int)Constants.RegionSize : (int)avatar.DrawDistance; |
1291 | |||
1292 | int startX = (int)pRegionLocX * (int)Constants.RegionSize - dd + (int)(Constants.RegionSize/2); | ||
1293 | int startY = (int)pRegionLocY * (int)Constants.RegionSize - dd + (int)(Constants.RegionSize/2); | ||
1294 | |||
1295 | int endX = (int)pRegionLocX * (int)Constants.RegionSize + dd + (int)(Constants.RegionSize/2); | ||
1296 | int endY = (int)pRegionLocY * (int)Constants.RegionSize + dd + (int)(Constants.RegionSize/2); | ||
1297 | |||
1298 | List<GridRegion> neighbours = | ||
1299 | avatar.Scene.GridService.GetRegionRange(m_regionInfo.ScopeID, startX, endX, startY, endY); | ||
1300 | |||
1301 | neighbours.RemoveAll(delegate(GridRegion r) { return r.RegionID == m_regionInfo.RegionID; }); | ||
1302 | return neighbours; | ||
1288 | } | 1303 | } |
1289 | else | 1304 | else |
1290 | { | 1305 | { |
diff --git a/OpenSim/Region/CoreModules/Framework/EntityTransfer/HGEntityTransferModule.cs b/OpenSim/Region/CoreModules/Framework/EntityTransfer/HGEntityTransferModule.cs index 35dcd95..79e76b4 100644 --- a/OpenSim/Region/CoreModules/Framework/EntityTransfer/HGEntityTransferModule.cs +++ b/OpenSim/Region/CoreModules/Framework/EntityTransfer/HGEntityTransferModule.cs | |||
@@ -130,9 +130,9 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer | |||
130 | return region; | 130 | return region; |
131 | } | 131 | } |
132 | 132 | ||
133 | protected override bool NeedsClosing(uint oldRegionX, uint newRegionX, uint oldRegionY, uint newRegionY, GridRegion reg) | 133 | protected override bool NeedsClosing(float drawdist, uint oldRegionX, uint newRegionX, uint oldRegionY, uint newRegionY, GridRegion reg) |
134 | { | 134 | { |
135 | if (base.NeedsClosing(oldRegionX, newRegionX, oldRegionY, newRegionY, reg)) | 135 | if (base.NeedsClosing(drawdist, oldRegionX, newRegionX, oldRegionY, newRegionY, reg)) |
136 | return true; | 136 | return true; |
137 | 137 | ||
138 | int flags = m_aScene.GridService.GetRegionFlags(m_aScene.RegionInfo.ScopeID, reg.RegionID); | 138 | int flags = m_aScene.GridService.GetRegionFlags(m_aScene.RegionInfo.ScopeID, reg.RegionID); |
diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs index ee1e0be..7def7e9 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.cs | |||
@@ -83,6 +83,13 @@ namespace OpenSim.Region.Framework.Scenes | |||
83 | public bool m_useFlySlow; | 83 | public bool m_useFlySlow; |
84 | public bool m_usePreJump; | 84 | public bool m_usePreJump; |
85 | public bool m_seeIntoRegionFromNeighbor; | 85 | public bool m_seeIntoRegionFromNeighbor; |
86 | |||
87 | protected float m_defaultDrawDistance = 255.0f; | ||
88 | public float DefaultDrawDistance | ||
89 | { | ||
90 | get { return m_defaultDrawDistance; } | ||
91 | } | ||
92 | |||
86 | // TODO: need to figure out how allow client agents but deny | 93 | // TODO: need to figure out how allow client agents but deny |
87 | // root agents when ACL denies access to root agent | 94 | // root agents when ACL denies access to root agent |
88 | public bool m_strictAccessControl = true; | 95 | public bool m_strictAccessControl = true; |
@@ -627,6 +634,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
627 | // | 634 | // |
628 | IConfig startupConfig = m_config.Configs["Startup"]; | 635 | IConfig startupConfig = m_config.Configs["Startup"]; |
629 | 636 | ||
637 | m_defaultDrawDistance = startupConfig.GetFloat("DefaultDrawDistance",m_defaultDrawDistance); | ||
638 | |||
630 | //Animation states | 639 | //Animation states |
631 | m_useFlySlow = startupConfig.GetBoolean("enableflyslow", false); | 640 | m_useFlySlow = startupConfig.GetBoolean("enableflyslow", false); |
632 | // TODO: Change default to true once the feature is supported | 641 | // TODO: Change default to true once the feature is supported |
diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index 51b8dcc..9e9481e 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs | |||
@@ -626,7 +626,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
626 | Utils.LongToUInts(handle, out x, out y); | 626 | Utils.LongToUInts(handle, out x, out y); |
627 | x = x / Constants.RegionSize; | 627 | x = x / Constants.RegionSize; |
628 | y = y / Constants.RegionSize; | 628 | y = y / Constants.RegionSize; |
629 | if (Util.IsOutsideView(x, Scene.RegionInfo.RegionLocX, y, Scene.RegionInfo.RegionLocY)) | 629 | if (Util.IsOutsideView(DrawDistance, x, Scene.RegionInfo.RegionLocX, y, Scene.RegionInfo.RegionLocY)) |
630 | { | 630 | { |
631 | old.Add(handle); | 631 | old.Add(handle); |
632 | } | 632 | } |
@@ -700,6 +700,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
700 | 700 | ||
701 | private ScenePresence(IClientAPI client, Scene world, RegionInfo reginfo) : this() | 701 | private ScenePresence(IClientAPI client, Scene world, RegionInfo reginfo) : this() |
702 | { | 702 | { |
703 | m_DrawDistance = world.DefaultDrawDistance; | ||
703 | m_rootRegionHandle = reginfo.RegionHandle; | 704 | m_rootRegionHandle = reginfo.RegionHandle; |
704 | m_controllingClient = client; | 705 | m_controllingClient = client; |
705 | m_firstname = m_controllingClient.FirstName; | 706 | m_firstname = m_controllingClient.FirstName; |
@@ -1279,7 +1280,11 @@ namespace OpenSim.Region.Framework.Scenes | |||
1279 | m_CameraUpAxis = agentData.CameraUpAxis; | 1280 | m_CameraUpAxis = agentData.CameraUpAxis; |
1280 | 1281 | ||
1281 | // The Agent's Draw distance setting | 1282 | // The Agent's Draw distance setting |
1282 | m_DrawDistance = agentData.Far; | 1283 | // When we get to the point of re-computing neighbors everytime this |
1284 | // changes, then start using the agent's drawdistance rather than the | ||
1285 | // region's draw distance. | ||
1286 | // m_DrawDistance = agentData.Far; | ||
1287 | m_DrawDistance = Scene.DefaultDrawDistance; | ||
1283 | 1288 | ||
1284 | // Check if Client has camera in 'follow cam' or 'build' mode. | 1289 | // Check if Client has camera in 'follow cam' or 'build' mode. |
1285 | Vector3 camdif = (Vector3.One * m_bodyRot - Vector3.One * CameraRotation); | 1290 | Vector3 camdif = (Vector3.One * m_bodyRot - Vector3.One * CameraRotation); |
@@ -2913,7 +2918,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
2913 | 2918 | ||
2914 | //m_log.Debug("---> x: " + x + "; newx:" + newRegionX + "; Abs:" + (int)Math.Abs((int)(x - newRegionX))); | 2919 | //m_log.Debug("---> x: " + x + "; newx:" + newRegionX + "; Abs:" + (int)Math.Abs((int)(x - newRegionX))); |
2915 | //m_log.Debug("---> y: " + y + "; newy:" + newRegionY + "; Abs:" + (int)Math.Abs((int)(y - newRegionY))); | 2920 | //m_log.Debug("---> y: " + y + "; newy:" + newRegionY + "; Abs:" + (int)Math.Abs((int)(y - newRegionY))); |
2916 | if (Util.IsOutsideView(x, newRegionX, y, newRegionY)) | 2921 | if (Util.IsOutsideView(DrawDistance, x, newRegionX, y, newRegionY)) |
2917 | { | 2922 | { |
2918 | byebyeRegions.Add(handle); | 2923 | byebyeRegions.Add(handle); |
2919 | } | 2924 | } |
@@ -2989,7 +2994,12 @@ namespace OpenSim.Region.Framework.Scenes | |||
2989 | 2994 | ||
2990 | Vector3 offset = new Vector3(shiftx, shifty, 0f); | 2995 | Vector3 offset = new Vector3(shiftx, shifty, 0f); |
2991 | 2996 | ||
2992 | m_DrawDistance = cAgentData.Far; | 2997 | // When we get to the point of re-computing neighbors everytime this |
2998 | // changes, then start using the agent's drawdistance rather than the | ||
2999 | // region's draw distance. | ||
3000 | // m_DrawDistance = cAgentData.Far; | ||
3001 | m_DrawDistance = Scene.DefaultDrawDistance; | ||
3002 | |||
2993 | if (cAgentData.Position != new Vector3(-1f, -1f, -1f)) // UGH!! | 3003 | if (cAgentData.Position != new Vector3(-1f, -1f, -1f)) // UGH!! |
2994 | m_pos = cAgentData.Position + offset; | 3004 | m_pos = cAgentData.Position + offset; |
2995 | 3005 | ||
@@ -3139,7 +3149,11 @@ namespace OpenSim.Region.Framework.Scenes | |||
3139 | m_CameraLeftAxis = cAgent.LeftAxis; | 3149 | m_CameraLeftAxis = cAgent.LeftAxis; |
3140 | m_CameraUpAxis = cAgent.UpAxis; | 3150 | m_CameraUpAxis = cAgent.UpAxis; |
3141 | 3151 | ||
3142 | m_DrawDistance = cAgent.Far; | 3152 | // When we get to the point of re-computing neighbors everytime this |
3153 | // changes, then start using the agent's drawdistance rather than the | ||
3154 | // region's draw distance. | ||
3155 | // m_DrawDistance = cAgent.Far; | ||
3156 | m_DrawDistance = Scene.DefaultDrawDistance; | ||
3143 | 3157 | ||
3144 | if ((cAgent.Throttles != null) && cAgent.Throttles.Length > 0) | 3158 | if ((cAgent.Throttles != null) && cAgent.Throttles.Length > 0) |
3145 | ControllingClient.SetChildAgentThrottle(cAgent.Throttles); | 3159 | ControllingClient.SetChildAgentThrottle(cAgent.Throttles); |