diff options
author | Sean McNamara | 2011-02-28 15:08:35 -0500 |
---|---|---|
committer | Sean McNamara | 2011-02-28 15:08:35 -0500 |
commit | 60989521a6a60bb5610784936797df0683a55527 (patch) | |
tree | 51fd99afe41459221ff74a78be965001ff680df9 /OpenSim/Region | |
parent | Fix small bug with remove region; update settings docs. (diff) | |
parent | Fix a few little things (diff) | |
download | opensim-SC_OLD-60989521a6a60bb5610784936797df0683a55527.zip opensim-SC_OLD-60989521a6a60bb5610784936797df0683a55527.tar.gz opensim-SC_OLD-60989521a6a60bb5610784936797df0683a55527.tar.bz2 opensim-SC_OLD-60989521a6a60bb5610784936797df0683a55527.tar.xz |
Merge git://opensimulator.org/git/opensim
Diffstat (limited to '')
13 files changed, 552 insertions, 290 deletions
diff --git a/OpenSim/Region/ClientStack/LindenUDP/LLUDPServer.cs b/OpenSim/Region/ClientStack/LindenUDP/LLUDPServer.cs index 584c577..583214c 100644 --- a/OpenSim/Region/ClientStack/LindenUDP/LLUDPServer.cs +++ b/OpenSim/Region/ClientStack/LindenUDP/LLUDPServer.cs | |||
@@ -845,7 +845,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
845 | 845 | ||
846 | private void HandleUseCircuitCode(object o) | 846 | private void HandleUseCircuitCode(object o) |
847 | { | 847 | { |
848 | DateTime startTime = DateTime.Now; | 848 | // DateTime startTime = DateTime.Now; |
849 | object[] array = (object[])o; | 849 | object[] array = (object[])o; |
850 | UDPPacketBuffer buffer = (UDPPacketBuffer)array[0]; | 850 | UDPPacketBuffer buffer = (UDPPacketBuffer)array[0]; |
851 | UseCircuitCodePacket packet = (UseCircuitCodePacket)array[1]; | 851 | UseCircuitCodePacket packet = (UseCircuitCodePacket)array[1]; |
diff --git a/OpenSim/Region/CoreModules/Asset/FlotsamAssetCache.cs b/OpenSim/Region/CoreModules/Asset/FlotsamAssetCache.cs index 6ed4867..9adb68b 100644 --- a/OpenSim/Region/CoreModules/Asset/FlotsamAssetCache.cs +++ b/OpenSim/Region/CoreModules/Asset/FlotsamAssetCache.cs | |||
@@ -92,9 +92,9 @@ namespace Flotsam.RegionModules.AssetCache | |||
92 | // Expiration is expressed in hours. | 92 | // Expiration is expressed in hours. |
93 | private const double m_DefaultMemoryExpiration = 1.0; | 93 | private const double m_DefaultMemoryExpiration = 1.0; |
94 | private const double m_DefaultFileExpiration = 48; | 94 | private const double m_DefaultFileExpiration = 48; |
95 | private TimeSpan m_MemoryExpiration = TimeSpan.Zero; | 95 | private TimeSpan m_MemoryExpiration = TimeSpan.FromHours(m_DefaultMemoryExpiration); |
96 | private TimeSpan m_FileExpiration = TimeSpan.Zero; | 96 | private TimeSpan m_FileExpiration = TimeSpan.FromHours(m_DefaultFileExpiration); |
97 | private TimeSpan m_FileExpirationCleanupTimer = TimeSpan.Zero; | 97 | private TimeSpan m_FileExpirationCleanupTimer = TimeSpan.FromHours(m_DefaultFileExpiration); |
98 | 98 | ||
99 | private static int m_CacheDirectoryTiers = 1; | 99 | private static int m_CacheDirectoryTiers = 1; |
100 | private static int m_CacheDirectoryTierLen = 3; | 100 | private static int m_CacheDirectoryTierLen = 3; |
@@ -147,7 +147,7 @@ namespace Flotsam.RegionModules.AssetCache | |||
147 | } | 147 | } |
148 | 148 | ||
149 | m_CacheDirectory = assetConfig.GetString("CacheDirectory", m_DefaultCacheDirectory); | 149 | m_CacheDirectory = assetConfig.GetString("CacheDirectory", m_DefaultCacheDirectory); |
150 | m_log.InfoFormat("[FLOTSAM ASSET CACHE]: Cache Directory", m_DefaultCacheDirectory); | 150 | m_log.InfoFormat("[FLOTSAM ASSET CACHE]: Cache Directory", m_CacheDirectory); |
151 | 151 | ||
152 | m_MemoryCacheEnabled = assetConfig.GetBoolean("MemoryCacheEnabled", false); | 152 | m_MemoryCacheEnabled = assetConfig.GetBoolean("MemoryCacheEnabled", false); |
153 | m_MemoryExpiration = TimeSpan.FromHours(assetConfig.GetDouble("MemoryCacheTimeout", m_DefaultMemoryExpiration)); | 153 | m_MemoryExpiration = TimeSpan.FromHours(assetConfig.GetDouble("MemoryCacheTimeout", m_DefaultMemoryExpiration)); |
@@ -245,16 +245,7 @@ namespace Flotsam.RegionModules.AssetCache | |||
245 | private void UpdateMemoryCache(string key, AssetBase asset) | 245 | private void UpdateMemoryCache(string key, AssetBase asset) |
246 | { | 246 | { |
247 | if (m_MemoryCacheEnabled) | 247 | if (m_MemoryCacheEnabled) |
248 | { | 248 | m_MemoryCache.AddOrUpdate(key, asset, m_MemoryExpiration); |
249 | if (m_MemoryExpiration > TimeSpan.Zero) | ||
250 | { | ||
251 | m_MemoryCache.AddOrUpdate(key, asset, m_MemoryExpiration); | ||
252 | } | ||
253 | else | ||
254 | { | ||
255 | m_MemoryCache.AddOrUpdate(key, asset, Double.MaxValue); | ||
256 | } | ||
257 | } | ||
258 | } | 249 | } |
259 | 250 | ||
260 | public void Cache(AssetBase asset) | 251 | public void Cache(AssetBase asset) |
@@ -450,7 +441,7 @@ namespace Flotsam.RegionModules.AssetCache | |||
450 | private void CleanupExpiredFiles(object source, ElapsedEventArgs e) | 441 | private void CleanupExpiredFiles(object source, ElapsedEventArgs e) |
451 | { | 442 | { |
452 | if (m_LogLevel >= 2) | 443 | if (m_LogLevel >= 2) |
453 | m_log.DebugFormat("[FLOTSAM ASSET CACHE]: Checking for expired files older then {0}.", m_FileExpiration.ToString()); | 444 | m_log.DebugFormat("[FLOTSAM ASSET CACHE]: Checking for expired files older then {0}.", m_FileExpiration); |
454 | 445 | ||
455 | // Purge all files last accessed prior to this point | 446 | // Purge all files last accessed prior to this point |
456 | DateTime purgeLine = DateTime.Now - m_FileExpiration; | 447 | DateTime purgeLine = DateTime.Now - m_FileExpiration; |
diff --git a/OpenSim/Region/CoreModules/Avatar/AvatarFactory/AvatarFactoryModule.cs b/OpenSim/Region/CoreModules/Avatar/AvatarFactory/AvatarFactoryModule.cs index f8ce444..08ac624 100644 --- a/OpenSim/Region/CoreModules/Avatar/AvatarFactory/AvatarFactoryModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/AvatarFactory/AvatarFactoryModule.cs | |||
@@ -167,7 +167,7 @@ namespace OpenSim.Region.CoreModules.Avatar.AvatarFactory | |||
167 | } | 167 | } |
168 | } | 168 | } |
169 | 169 | ||
170 | m_log.InfoFormat("[AVFACTORY]: complete texture check for {0}", client.AgentId); | 170 | m_log.DebugFormat("[AVFACTORY]: complete texture check for {0}", client.AgentId); |
171 | 171 | ||
172 | // If we only found default textures, then the appearance is not cached | 172 | // If we only found default textures, then the appearance is not cached |
173 | return (defonly ? false : true); | 173 | return (defonly ? false : true); |
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/CoreModules/Framework/InventoryAccess/InventoryAccessModule.cs b/OpenSim/Region/CoreModules/Framework/InventoryAccess/InventoryAccessModule.cs index 7bb8789..798547a 100644 --- a/OpenSim/Region/CoreModules/Framework/InventoryAccess/InventoryAccessModule.cs +++ b/OpenSim/Region/CoreModules/Framework/InventoryAccess/InventoryAccessModule.cs | |||
@@ -148,6 +148,9 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess | |||
148 | InventoryItemBase item = new InventoryItemBase(itemID, remoteClient.AgentId); | 148 | InventoryItemBase item = new InventoryItemBase(itemID, remoteClient.AgentId); |
149 | item = m_Scene.InventoryService.GetItem(item); | 149 | item = m_Scene.InventoryService.GetItem(item); |
150 | 150 | ||
151 | if (item.Owner != remoteClient.AgentId) | ||
152 | return UUID.Zero; | ||
153 | |||
151 | if (item != null) | 154 | if (item != null) |
152 | { | 155 | { |
153 | if ((InventoryType)item.InvType == InventoryType.Notecard) | 156 | if ((InventoryType)item.InvType == InventoryType.Notecard) |
@@ -524,6 +527,8 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess | |||
524 | 527 | ||
525 | if (item != null) | 528 | if (item != null) |
526 | { | 529 | { |
530 | item.Owner = remoteClient.AgentId; | ||
531 | |||
527 | AssetBase rezAsset = m_Scene.AssetService.Get(item.AssetID.ToString()); | 532 | AssetBase rezAsset = m_Scene.AssetService.Get(item.AssetID.ToString()); |
528 | 533 | ||
529 | if (rezAsset != null) | 534 | if (rezAsset != null) |
diff --git a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs index e2d96d9..fcbcf59 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs | |||
@@ -321,6 +321,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
321 | // Passing something to another avatar or a an object will already | 321 | // Passing something to another avatar or a an object will already |
322 | InventoryItemBase item = new InventoryItemBase(itemID, remoteClient.AgentId); | 322 | InventoryItemBase item = new InventoryItemBase(itemID, remoteClient.AgentId); |
323 | item = InventoryService.GetItem(item); | 323 | item = InventoryService.GetItem(item); |
324 | if (item.Owner != remoteClient.AgentId) | ||
325 | return; | ||
324 | 326 | ||
325 | if (item != null) | 327 | if (item != null) |
326 | { | 328 | { |
diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs index 02a0268..1a6a70b 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; |
@@ -129,7 +136,16 @@ namespace OpenSim.Region.Framework.Scenes | |||
129 | protected ICapabilitiesModule m_capsModule; | 136 | protected ICapabilitiesModule m_capsModule; |
130 | // Central Update Loop | 137 | // Central Update Loop |
131 | protected int m_fps = 10; | 138 | protected int m_fps = 10; |
132 | protected uint m_frame; | 139 | |
140 | /// <summary> | ||
141 | /// Current scene frame number | ||
142 | /// </summary> | ||
143 | public uint Frame | ||
144 | { | ||
145 | get; | ||
146 | protected set; | ||
147 | } | ||
148 | |||
133 | protected float m_timespan = 0.089f; | 149 | protected float m_timespan = 0.089f; |
134 | protected DateTime m_lastupdate = DateTime.UtcNow; | 150 | protected DateTime m_lastupdate = DateTime.UtcNow; |
135 | 151 | ||
@@ -618,6 +634,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
618 | // | 634 | // |
619 | IConfig startupConfig = m_config.Configs["Startup"]; | 635 | IConfig startupConfig = m_config.Configs["Startup"]; |
620 | 636 | ||
637 | m_defaultDrawDistance = startupConfig.GetFloat("DefaultDrawDistance",m_defaultDrawDistance); | ||
638 | |||
621 | //Animation states | 639 | //Animation states |
622 | m_useFlySlow = startupConfig.GetBoolean("enableflyslow", false); | 640 | m_useFlySlow = startupConfig.GetBoolean("enableflyslow", false); |
623 | // TODO: Change default to true once the feature is supported | 641 | // TODO: Change default to true once the feature is supported |
@@ -1183,7 +1201,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
1183 | 1201 | ||
1184 | try | 1202 | try |
1185 | { | 1203 | { |
1186 | Update(); | 1204 | while (!shuttingdown) |
1205 | Update(); | ||
1187 | 1206 | ||
1188 | m_lastUpdate = Util.EnvironmentTickCount(); | 1207 | m_lastUpdate = Util.EnvironmentTickCount(); |
1189 | m_firstHeartbeat = false; | 1208 | m_firstHeartbeat = false; |
@@ -1200,187 +1219,176 @@ namespace OpenSim.Region.Framework.Scenes | |||
1200 | Watchdog.RemoveThread(); | 1219 | Watchdog.RemoveThread(); |
1201 | } | 1220 | } |
1202 | 1221 | ||
1203 | /// <summary> | ||
1204 | /// Performs per-frame updates on the scene, this should be the central scene loop | ||
1205 | /// </summary> | ||
1206 | public override void Update() | 1222 | public override void Update() |
1207 | { | 1223 | { |
1208 | float physicsFPS; | 1224 | TimeSpan SinceLastFrame = DateTime.UtcNow - m_lastupdate; |
1209 | int maintc; | 1225 | float physicsFPS = 0f; |
1226 | |||
1227 | int maintc = Util.EnvironmentTickCount(); | ||
1228 | int tmpFrameMS = maintc; | ||
1229 | tempOnRezMS = eventMS = backupMS = terrainMS = landMS = 0; | ||
1230 | |||
1231 | // Increment the frame counter | ||
1232 | ++Frame; | ||
1210 | 1233 | ||
1211 | while (!shuttingdown) | 1234 | try |
1212 | { | 1235 | { |
1213 | TimeSpan SinceLastFrame = DateTime.UtcNow - m_lastupdate; | 1236 | // Check if any objects have reached their targets |
1214 | physicsFPS = 0f; | 1237 | CheckAtTargets(); |
1215 | 1238 | ||
1216 | maintc = Util.EnvironmentTickCount(); | 1239 | // Update SceneObjectGroups that have scheduled themselves for updates |
1217 | int tmpFrameMS = maintc; | 1240 | // Objects queue their updates onto all scene presences |
1218 | tempOnRezMS = eventMS = backupMS = terrainMS = landMS = 0; | 1241 | if (Frame % m_update_objects == 0) |
1242 | m_sceneGraph.UpdateObjectGroups(); | ||
1219 | 1243 | ||
1220 | // Increment the frame counter | 1244 | // Run through all ScenePresences looking for updates |
1221 | ++m_frame; | 1245 | // Presence updates and queued object updates for each presence are sent to clients |
1246 | if (Frame % m_update_presences == 0) | ||
1247 | m_sceneGraph.UpdatePresences(); | ||
1222 | 1248 | ||
1223 | try | 1249 | // Coarse locations relate to positions of green dots on the mini-map (on a SecondLife client) |
1250 | if (Frame % m_update_coarse_locations == 0) | ||
1224 | { | 1251 | { |
1225 | // Check if any objects have reached their targets | 1252 | List<Vector3> coarseLocations; |
1226 | CheckAtTargets(); | 1253 | List<UUID> avatarUUIDs; |
1227 | 1254 | SceneGraph.GetCoarseLocations(out coarseLocations, out avatarUUIDs, 60); | |
1228 | // Update SceneObjectGroups that have scheduled themselves for updates | 1255 | // Send coarse locations to clients |
1229 | // Objects queue their updates onto all scene presences | 1256 | ForEachScenePresence(delegate(ScenePresence presence) |
1230 | if (m_frame % m_update_objects == 0) | 1257 | { |
1231 | m_sceneGraph.UpdateObjectGroups(); | 1258 | presence.SendCoarseLocations(coarseLocations, avatarUUIDs); |
1259 | }); | ||
1260 | } | ||
1232 | 1261 | ||
1233 | // Run through all ScenePresences looking for updates | 1262 | int tmpPhysicsMS2 = Util.EnvironmentTickCount(); |
1234 | // Presence updates and queued object updates for each presence are sent to clients | 1263 | if ((Frame % m_update_physics == 0) && m_physics_enabled) |
1235 | if (m_frame % m_update_presences == 0) | 1264 | m_sceneGraph.UpdatePreparePhysics(); |
1236 | m_sceneGraph.UpdatePresences(); | 1265 | physicsMS2 = Util.EnvironmentTickCountSubtract(tmpPhysicsMS2); |
1237 | 1266 | ||
1238 | // Coarse locations relate to positions of green dots on the mini-map (on a SecondLife client) | 1267 | // Apply any pending avatar force input to the avatar's velocity |
1239 | if (m_frame % m_update_coarse_locations == 0) | 1268 | if (Frame % m_update_entitymovement == 0) |
1240 | { | 1269 | m_sceneGraph.UpdateScenePresenceMovement(); |
1241 | List<Vector3> coarseLocations; | ||
1242 | List<UUID> avatarUUIDs; | ||
1243 | SceneGraph.GetCoarseLocations(out coarseLocations, out avatarUUIDs, 60); | ||
1244 | // Send coarse locations to clients | ||
1245 | ForEachScenePresence(delegate(ScenePresence presence) | ||
1246 | { | ||
1247 | presence.SendCoarseLocations(coarseLocations, avatarUUIDs); | ||
1248 | }); | ||
1249 | } | ||
1250 | 1270 | ||
1251 | int tmpPhysicsMS2 = Util.EnvironmentTickCount(); | 1271 | // Perform the main physics update. This will do the actual work of moving objects and avatars according to their |
1252 | if ((m_frame % m_update_physics == 0) && m_physics_enabled) | 1272 | // velocity |
1253 | m_sceneGraph.UpdatePreparePhysics(); | 1273 | int tmpPhysicsMS = Util.EnvironmentTickCount(); |
1254 | physicsMS2 = Util.EnvironmentTickCountSubtract(tmpPhysicsMS2); | 1274 | if (Frame % m_update_physics == 0) |
1275 | { | ||
1276 | if (m_physics_enabled) | ||
1277 | physicsFPS = m_sceneGraph.UpdatePhysics(Math.Max(SinceLastFrame.TotalSeconds, m_timespan)); | ||
1278 | if (SynchronizeScene != null) | ||
1279 | SynchronizeScene(this); | ||
1280 | } | ||
1281 | physicsMS = Util.EnvironmentTickCountSubtract(tmpPhysicsMS); | ||
1255 | 1282 | ||
1256 | // Apply any pending avatar force input to the avatar's velocity | 1283 | // Delete temp-on-rez stuff |
1257 | if (m_frame % m_update_entitymovement == 0) | 1284 | if (Frame % 1000 == 0 && !m_cleaningTemps) |
1258 | m_sceneGraph.UpdateScenePresenceMovement(); | 1285 | { |
1286 | int tmpTempOnRezMS = Util.EnvironmentTickCount(); | ||
1287 | m_cleaningTemps = true; | ||
1288 | Util.FireAndForget(delegate { CleanTempObjects(); m_cleaningTemps = false; }); | ||
1289 | tempOnRezMS = Util.EnvironmentTickCountSubtract(tmpTempOnRezMS); | ||
1290 | } | ||
1259 | 1291 | ||
1260 | // Perform the main physics update. This will do the actual work of moving objects and avatars according to their | 1292 | if (RegionStatus != RegionStatus.SlaveScene) |
1261 | // velocity | 1293 | { |
1262 | int tmpPhysicsMS = Util.EnvironmentTickCount(); | 1294 | if (Frame % m_update_events == 0) |
1263 | if (m_frame % m_update_physics == 0) | ||
1264 | { | 1295 | { |
1265 | if (m_physics_enabled) | 1296 | int evMS = Util.EnvironmentTickCount(); |
1266 | physicsFPS = m_sceneGraph.UpdatePhysics(Math.Max(SinceLastFrame.TotalSeconds, m_timespan)); | 1297 | UpdateEvents(); |
1267 | if (SynchronizeScene != null) | 1298 | eventMS = Util.EnvironmentTickCountSubtract(evMS); ; |
1268 | SynchronizeScene(this); | ||
1269 | } | 1299 | } |
1270 | physicsMS = Util.EnvironmentTickCountSubtract(tmpPhysicsMS); | ||
1271 | 1300 | ||
1272 | // Delete temp-on-rez stuff | 1301 | if (Frame % m_update_backup == 0) |
1273 | if (m_frame % 1000 == 0 && !m_cleaningTemps) | ||
1274 | { | 1302 | { |
1275 | int tmpTempOnRezMS = Util.EnvironmentTickCount(); | 1303 | int backMS = Util.EnvironmentTickCount(); |
1276 | m_cleaningTemps = true; | 1304 | UpdateStorageBackup(); |
1277 | Util.FireAndForget(delegate { CleanTempObjects(); m_cleaningTemps = false; }); | 1305 | backupMS = Util.EnvironmentTickCountSubtract(backMS); |
1278 | tempOnRezMS = Util.EnvironmentTickCountSubtract(tmpTempOnRezMS); | ||
1279 | } | 1306 | } |
1280 | 1307 | ||
1281 | if (RegionStatus != RegionStatus.SlaveScene) | 1308 | if (Frame % m_update_terrain == 0) |
1282 | { | 1309 | { |
1283 | if (m_frame % m_update_events == 0) | 1310 | int terMS = Util.EnvironmentTickCount(); |
1284 | { | 1311 | UpdateTerrain(); |
1285 | int evMS = Util.EnvironmentTickCount(); | 1312 | terrainMS = Util.EnvironmentTickCountSubtract(terMS); |
1286 | UpdateEvents(); | 1313 | } |
1287 | eventMS = Util.EnvironmentTickCountSubtract(evMS); ; | ||
1288 | } | ||
1289 | |||
1290 | if (m_frame % m_update_backup == 0) | ||
1291 | { | ||
1292 | int backMS = Util.EnvironmentTickCount(); | ||
1293 | UpdateStorageBackup(); | ||
1294 | backupMS = Util.EnvironmentTickCountSubtract(backMS); | ||
1295 | } | ||
1296 | 1314 | ||
1297 | if (m_frame % m_update_terrain == 0) | 1315 | //if (Frame % m_update_land == 0) |
1298 | { | 1316 | //{ |
1299 | int terMS = Util.EnvironmentTickCount(); | 1317 | // int ldMS = Util.EnvironmentTickCount(); |
1300 | UpdateTerrain(); | 1318 | // UpdateLand(); |
1301 | terrainMS = Util.EnvironmentTickCountSubtract(terMS); | 1319 | // landMS = Util.EnvironmentTickCountSubtract(ldMS); |
1302 | } | 1320 | //} |
1303 | 1321 | ||
1304 | //if (m_frame % m_update_land == 0) | 1322 | frameMS = Util.EnvironmentTickCountSubtract(tmpFrameMS); |
1305 | //{ | 1323 | otherMS = tempOnRezMS + eventMS + backupMS + terrainMS + landMS; |
1306 | // int ldMS = Util.EnvironmentTickCount(); | 1324 | lastCompletedFrame = Util.EnvironmentTickCount(); |
1307 | // UpdateLand(); | 1325 | |
1308 | // landMS = Util.EnvironmentTickCountSubtract(ldMS); | 1326 | // if (Frame%m_update_avatars == 0) |
1309 | //} | 1327 | // UpdateInWorldTime(); |
1328 | StatsReporter.AddPhysicsFPS(physicsFPS); | ||
1329 | StatsReporter.AddTimeDilation(TimeDilation); | ||
1330 | StatsReporter.AddFPS(1); | ||
1331 | StatsReporter.SetRootAgents(m_sceneGraph.GetRootAgentCount()); | ||
1332 | StatsReporter.SetChildAgents(m_sceneGraph.GetChildAgentCount()); | ||
1333 | StatsReporter.SetObjects(m_sceneGraph.GetTotalObjectsCount()); | ||
1334 | StatsReporter.SetActiveObjects(m_sceneGraph.GetActiveObjectsCount()); | ||
1335 | StatsReporter.addFrameMS(frameMS); | ||
1336 | StatsReporter.addPhysicsMS(physicsMS + physicsMS2); | ||
1337 | StatsReporter.addOtherMS(otherMS); | ||
1338 | StatsReporter.SetActiveScripts(m_sceneGraph.GetActiveScriptsCount()); | ||
1339 | StatsReporter.addScriptLines(m_sceneGraph.GetScriptLPS()); | ||
1340 | } | ||
1310 | 1341 | ||
1311 | frameMS = Util.EnvironmentTickCountSubtract(tmpFrameMS); | 1342 | if (LoginsDisabled && Frame == 20) |
1312 | otherMS = tempOnRezMS + eventMS + backupMS + terrainMS + landMS; | 1343 | { |
1313 | lastCompletedFrame = Util.EnvironmentTickCount(); | 1344 | // In 99.9% of cases it is a bad idea to manually force garbage collection. However, |
1314 | 1345 | // this is a rare case where we know we have just went through a long cycle of heap | |
1315 | // if (m_frame%m_update_avatars == 0) | 1346 | // allocations, and there is no more work to be done until someone logs in |
1316 | // UpdateInWorldTime(); | 1347 | GC.Collect(); |
1317 | StatsReporter.AddPhysicsFPS(physicsFPS); | ||
1318 | StatsReporter.AddTimeDilation(TimeDilation); | ||
1319 | StatsReporter.AddFPS(1); | ||
1320 | StatsReporter.SetRootAgents(m_sceneGraph.GetRootAgentCount()); | ||
1321 | StatsReporter.SetChildAgents(m_sceneGraph.GetChildAgentCount()); | ||
1322 | StatsReporter.SetObjects(m_sceneGraph.GetTotalObjectsCount()); | ||
1323 | StatsReporter.SetActiveObjects(m_sceneGraph.GetActiveObjectsCount()); | ||
1324 | StatsReporter.addFrameMS(frameMS); | ||
1325 | StatsReporter.addPhysicsMS(physicsMS + physicsMS2); | ||
1326 | StatsReporter.addOtherMS(otherMS); | ||
1327 | StatsReporter.SetActiveScripts(m_sceneGraph.GetActiveScriptsCount()); | ||
1328 | StatsReporter.addScriptLines(m_sceneGraph.GetScriptLPS()); | ||
1329 | } | ||
1330 | 1348 | ||
1331 | if (LoginsDisabled && m_frame == 20) | 1349 | IConfig startupConfig = m_config.Configs["Startup"]; |
1350 | if (startupConfig == null || !startupConfig.GetBoolean("StartDisabled", false)) | ||
1332 | { | 1351 | { |
1333 | // In 99.9% of cases it is a bad idea to manually force garbage collection. However, | 1352 | m_log.DebugFormat("[REGION]: Enabling logins for {0}", RegionInfo.RegionName); |
1334 | // this is a rare case where we know we have just went through a long cycle of heap | 1353 | LoginsDisabled = false; |
1335 | // allocations, and there is no more work to be done until someone logs in | 1354 | m_sceneGridService.InformNeighborsThatRegionisUp(RequestModuleInterface<INeighbourService>(), RegionInfo); |
1336 | GC.Collect(); | ||
1337 | |||
1338 | IConfig startupConfig = m_config.Configs["Startup"]; | ||
1339 | if (startupConfig == null || !startupConfig.GetBoolean("StartDisabled", false)) | ||
1340 | { | ||
1341 | m_log.DebugFormat("[REGION]: Enabling logins for {0}", RegionInfo.RegionName); | ||
1342 | LoginsDisabled = false; | ||
1343 | m_sceneGridService.InformNeighborsThatRegionisUp(RequestModuleInterface<INeighbourService>(), RegionInfo); | ||
1344 | } | ||
1345 | } | 1355 | } |
1346 | } | 1356 | } |
1347 | catch (NotImplementedException) | 1357 | } |
1348 | { | 1358 | catch (NotImplementedException) |
1349 | throw; | 1359 | { |
1350 | } | 1360 | throw; |
1351 | catch (AccessViolationException e) | 1361 | } |
1352 | { | 1362 | catch (AccessViolationException e) |
1353 | m_log.Error("[REGION]: Failed with exception " + e.ToString() + " On Region: " + RegionInfo.RegionName); | 1363 | { |
1354 | } | 1364 | m_log.Error("[REGION]: Failed with exception " + e.ToString() + " On Region: " + RegionInfo.RegionName); |
1355 | //catch (NullReferenceException e) | 1365 | } |
1356 | //{ | 1366 | //catch (NullReferenceException e) |
1357 | // m_log.Error("[REGION]: Failed with exception " + e.ToString() + " On Region: " + RegionInfo.RegionName); | 1367 | //{ |
1358 | //} | 1368 | // m_log.Error("[REGION]: Failed with exception " + e.ToString() + " On Region: " + RegionInfo.RegionName); |
1359 | catch (InvalidOperationException e) | 1369 | //} |
1360 | { | 1370 | catch (InvalidOperationException e) |
1361 | m_log.Error("[REGION]: Failed with exception " + e.ToString() + " On Region: " + RegionInfo.RegionName); | 1371 | { |
1362 | } | 1372 | m_log.Error("[REGION]: Failed with exception " + e.ToString() + " On Region: " + RegionInfo.RegionName); |
1363 | catch (Exception e) | 1373 | } |
1364 | { | 1374 | catch (Exception e) |
1365 | m_log.Error("[REGION]: Failed with exception " + e.ToString() + " On Region: " + RegionInfo.RegionName); | 1375 | { |
1366 | } | 1376 | m_log.Error("[REGION]: Failed with exception " + e.ToString() + " On Region: " + RegionInfo.RegionName); |
1367 | finally | 1377 | } |
1368 | { | 1378 | finally |
1369 | m_lastupdate = DateTime.UtcNow; | 1379 | { |
1370 | } | 1380 | m_lastupdate = DateTime.UtcNow; |
1371 | 1381 | } | |
1372 | maintc = Util.EnvironmentTickCountSubtract(maintc); | ||
1373 | maintc = (int)(m_timespan * 1000) - maintc; | ||
1374 | 1382 | ||
1375 | if (maintc > 0) | 1383 | maintc = Util.EnvironmentTickCountSubtract(maintc); |
1376 | Thread.Sleep(maintc); | 1384 | maintc = (int)(m_timespan * 1000) - maintc; |
1377 | 1385 | ||
1378 | // Tell the watchdog that this thread is still alive | 1386 | if (maintc > 0) |
1379 | Watchdog.UpdateThread(); | 1387 | Thread.Sleep(maintc); |
1380 | } | ||
1381 | } | ||
1382 | 1388 | ||
1383 | 1389 | // Tell the watchdog that this thread is still alive | |
1390 | Watchdog.UpdateThread(); | ||
1391 | } | ||
1384 | 1392 | ||
1385 | public void AddGroupTarget(SceneObjectGroup grp) | 1393 | public void AddGroupTarget(SceneObjectGroup grp) |
1386 | { | 1394 | { |
@@ -3011,7 +3019,9 @@ namespace OpenSim.Region.Framework.Scenes | |||
3011 | (childagentYN ? "child" : "root"), agentID, RegionInfo.RegionName); | 3019 | (childagentYN ? "child" : "root"), agentID, RegionInfo.RegionName); |
3012 | 3020 | ||
3013 | m_sceneGraph.removeUserCount(!childagentYN); | 3021 | m_sceneGraph.removeUserCount(!childagentYN); |
3014 | CapsModule.RemoveCapsHandler(agentID); | 3022 | |
3023 | if (CapsModule != null) | ||
3024 | CapsModule.RemoveCapsHandler(agentID); | ||
3015 | 3025 | ||
3016 | // REFACTORING PROBLEM -- well not really a problem, but just to point out that whatever | 3026 | // REFACTORING PROBLEM -- well not really a problem, but just to point out that whatever |
3017 | // this method is doing is HORRIBLE!!! | 3027 | // this method is doing is HORRIBLE!!! |
@@ -3200,7 +3210,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
3200 | // TeleportFlags.ViaLandmark | TeleportFlags.ViaLocation | TeleportFlags.ViaLandmark | TeleportFlags.Default - Regular Teleport | 3210 | // TeleportFlags.ViaLandmark | TeleportFlags.ViaLocation | TeleportFlags.ViaLandmark | TeleportFlags.Default - Regular Teleport |
3201 | 3211 | ||
3202 | // Don't disable this log message - it's too helpful | 3212 | // Don't disable this log message - it's too helpful |
3203 | m_log.InfoFormat( | 3213 | m_log.DebugFormat( |
3204 | "[CONNECTION BEGIN]: Region {0} told of incoming {1} agent {2} {3} {4} (circuit code {5}, teleportflags {6})", | 3214 | "[CONNECTION BEGIN]: Region {0} told of incoming {1} agent {2} {3} {4} (circuit code {5}, teleportflags {6})", |
3205 | RegionInfo.RegionName, (agent.child ? "child" : "root"), agent.firstname, agent.lastname, | 3215 | RegionInfo.RegionName, (agent.child ? "child" : "root"), agent.firstname, agent.lastname, |
3206 | agent.AgentID, agent.circuitcode, teleportFlags); | 3216 | agent.AgentID, agent.circuitcode, teleportFlags); |
@@ -3266,8 +3276,11 @@ namespace OpenSim.Region.Framework.Scenes | |||
3266 | RegionInfo.RegionName, (agent.child ? "child" : "root"), agent.firstname, agent.lastname, | 3276 | RegionInfo.RegionName, (agent.child ? "child" : "root"), agent.firstname, agent.lastname, |
3267 | agent.AgentID, agent.circuitcode); | 3277 | agent.AgentID, agent.circuitcode); |
3268 | 3278 | ||
3269 | CapsModule.NewUserConnection(agent); | 3279 | if (CapsModule != null) |
3270 | CapsModule.AddCapsHandler(agent.AgentID); | 3280 | { |
3281 | CapsModule.NewUserConnection(agent); | ||
3282 | CapsModule.AddCapsHandler(agent.AgentID); | ||
3283 | } | ||
3271 | } | 3284 | } |
3272 | else | 3285 | else |
3273 | { | 3286 | { |
@@ -3282,7 +3295,9 @@ namespace OpenSim.Region.Framework.Scenes | |||
3282 | agent.AgentID, RegionInfo.RegionName); | 3295 | agent.AgentID, RegionInfo.RegionName); |
3283 | 3296 | ||
3284 | sp.AdjustKnownSeeds(); | 3297 | sp.AdjustKnownSeeds(); |
3285 | CapsModule.NewUserConnection(agent); | 3298 | |
3299 | if (CapsModule != null) | ||
3300 | CapsModule.NewUserConnection(agent); | ||
3286 | } | 3301 | } |
3287 | } | 3302 | } |
3288 | 3303 | ||
diff --git a/OpenSim/Region/Framework/Scenes/SceneGraph.cs b/OpenSim/Region/Framework/Scenes/SceneGraph.cs index 969ff13..734ba22 100644 --- a/OpenSim/Region/Framework/Scenes/SceneGraph.cs +++ b/OpenSim/Region/Framework/Scenes/SceneGraph.cs | |||
@@ -204,9 +204,10 @@ namespace OpenSim.Region.Framework.Scenes | |||
204 | for (int i = 0; i < Math.Min(presences.Count, maxLocations); ++i) | 204 | for (int i = 0; i < Math.Min(presences.Count, maxLocations); ++i) |
205 | { | 205 | { |
206 | ScenePresence sp = presences[i]; | 206 | ScenePresence sp = presences[i]; |
207 | |||
207 | // If this presence is a child agent, we don't want its coarse locations | 208 | // If this presence is a child agent, we don't want its coarse locations |
208 | if (sp.IsChildAgent) | 209 | if (sp.IsChildAgent) |
209 | return; | 210 | continue; |
210 | 211 | ||
211 | if (sp.ParentID != 0) | 212 | if (sp.ParentID != 0) |
212 | { | 213 | { |
diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index cd70de8..00a1487 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; |
@@ -1161,7 +1162,9 @@ namespace OpenSim.Region.Framework.Scenes | |||
1161 | if (m_agentTransfer != null) | 1162 | if (m_agentTransfer != null) |
1162 | m_agentTransfer.EnableChildAgents(this); | 1163 | m_agentTransfer.EnableChildAgents(this); |
1163 | else | 1164 | else |
1164 | m_log.DebugFormat("[SCENE PRESENCE]: Unable to create child agents in neighbours, because AgentTransferModule is not active"); | 1165 | m_log.DebugFormat( |
1166 | "[SCENE PRESENCE]: Unable to create child agents in neighbours, because AgentTransferModule is not active for region {0}", | ||
1167 | m_scene.RegionInfo.RegionName); | ||
1165 | 1168 | ||
1166 | IFriendsModule friendsModule = m_scene.RequestModuleInterface<IFriendsModule>(); | 1169 | IFriendsModule friendsModule = m_scene.RequestModuleInterface<IFriendsModule>(); |
1167 | if (friendsModule != null) | 1170 | if (friendsModule != null) |
@@ -1277,7 +1280,11 @@ namespace OpenSim.Region.Framework.Scenes | |||
1277 | m_CameraUpAxis = agentData.CameraUpAxis; | 1280 | m_CameraUpAxis = agentData.CameraUpAxis; |
1278 | 1281 | ||
1279 | // The Agent's Draw distance setting | 1282 | // The Agent's Draw distance setting |
1280 | 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; | ||
1281 | 1288 | ||
1282 | // Check if Client has camera in 'follow cam' or 'build' mode. | 1289 | // Check if Client has camera in 'follow cam' or 'build' mode. |
1283 | Vector3 camdif = (Vector3.One * m_bodyRot - Vector3.One * CameraRotation); | 1290 | Vector3 camdif = (Vector3.One * m_bodyRot - Vector3.One * CameraRotation); |
@@ -2435,7 +2442,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
2435 | // If we are using the the cached appearance then send it out to everyone | 2442 | // If we are using the the cached appearance then send it out to everyone |
2436 | if (cachedappearance) | 2443 | if (cachedappearance) |
2437 | { | 2444 | { |
2438 | m_log.InfoFormat("[SCENEPRESENCE]: baked textures are in the cache for {0}", Name); | 2445 | m_log.DebugFormat("[SCENEPRESENCE]: baked textures are in the cache for {0}", Name); |
2439 | 2446 | ||
2440 | // If the avatars baked textures are all in the cache, then we have a | 2447 | // If the avatars baked textures are all in the cache, then we have a |
2441 | // complete appearance... send it out, if not, then we'll send it when | 2448 | // complete appearance... send it out, if not, then we'll send it when |
@@ -2652,8 +2659,11 @@ namespace OpenSim.Region.Framework.Scenes | |||
2652 | #region Border Crossing Methods | 2659 | #region Border Crossing Methods |
2653 | 2660 | ||
2654 | /// <summary> | 2661 | /// <summary> |
2655 | /// Checks to see if the avatar is in range of a border and calls CrossToNewRegion | 2662 | /// Starts the process of moving an avatar into another region if they are crossing the border. |
2656 | /// </summary> | 2663 | /// </summary> |
2664 | /// <remarks> | ||
2665 | /// Also removes the avatar from the physical scene if transit has started. | ||
2666 | /// </remarks> | ||
2657 | protected void CheckForBorderCrossing() | 2667 | protected void CheckForBorderCrossing() |
2658 | { | 2668 | { |
2659 | if (IsChildAgent) | 2669 | if (IsChildAgent) |
@@ -2721,7 +2731,6 @@ namespace OpenSim.Region.Framework.Scenes | |||
2721 | neighbor = HaveNeighbor(Cardinals.N, ref fix); | 2731 | neighbor = HaveNeighbor(Cardinals.N, ref fix); |
2722 | } | 2732 | } |
2723 | 2733 | ||
2724 | |||
2725 | // Makes sure avatar does not end up outside region | 2734 | // Makes sure avatar does not end up outside region |
2726 | if (neighbor <= 0) | 2735 | if (neighbor <= 0) |
2727 | { | 2736 | { |
@@ -2776,6 +2785,13 @@ namespace OpenSim.Region.Framework.Scenes | |||
2776 | } | 2785 | } |
2777 | else | 2786 | else |
2778 | { | 2787 | { |
2788 | // We must remove the agent from the physical scene if it has been placed in transit. If we don't, | ||
2789 | // then this method continues to be called from ScenePresence.Update() until the handover of the client between | ||
2790 | // regions is completed. Since this handover can take more than 1000ms (due to the 1000ms | ||
2791 | // event queue polling response from the server), this results in the avatar pausing on the border | ||
2792 | // for the handover period. | ||
2793 | RemoveFromPhysicalScene(); | ||
2794 | |||
2779 | // This constant has been inferred from experimentation | 2795 | // This constant has been inferred from experimentation |
2780 | // I'm not sure what this value should be, so I tried a few values. | 2796 | // I'm not sure what this value should be, so I tried a few values. |
2781 | timeStep = 0.04f; | 2797 | timeStep = 0.04f; |
@@ -2787,6 +2803,15 @@ namespace OpenSim.Region.Framework.Scenes | |||
2787 | } | 2803 | } |
2788 | } | 2804 | } |
2789 | 2805 | ||
2806 | /// <summary> | ||
2807 | /// Checks whether this region has a neighbour in the given direction. | ||
2808 | /// </summary> | ||
2809 | /// <param name="car"></param> | ||
2810 | /// <param name="fix"></param> | ||
2811 | /// <returns> | ||
2812 | /// An integer which represents a compass point. N == 1, going clockwise until we reach NW == 8. | ||
2813 | /// Returns a positive integer if there is a region in that direction, a negative integer if not. | ||
2814 | /// </returns> | ||
2790 | protected int HaveNeighbor(Cardinals car, ref int[] fix) | 2815 | protected int HaveNeighbor(Cardinals car, ref int[] fix) |
2791 | { | 2816 | { |
2792 | uint neighbourx = m_regionInfo.RegionLocX; | 2817 | uint neighbourx = m_regionInfo.RegionLocX; |
@@ -2893,7 +2918,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
2893 | 2918 | ||
2894 | //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))); |
2895 | //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))); |
2896 | if (Util.IsOutsideView(x, newRegionX, y, newRegionY)) | 2921 | if (Util.IsOutsideView(DrawDistance, x, newRegionX, y, newRegionY)) |
2897 | { | 2922 | { |
2898 | byebyeRegions.Add(handle); | 2923 | byebyeRegions.Add(handle); |
2899 | } | 2924 | } |
@@ -2969,7 +2994,12 @@ namespace OpenSim.Region.Framework.Scenes | |||
2969 | 2994 | ||
2970 | Vector3 offset = new Vector3(shiftx, shifty, 0f); | 2995 | Vector3 offset = new Vector3(shiftx, shifty, 0f); |
2971 | 2996 | ||
2972 | 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 | |||
2973 | if (cAgentData.Position != new Vector3(-1f, -1f, -1f)) // UGH!! | 3003 | if (cAgentData.Position != new Vector3(-1f, -1f, -1f)) // UGH!! |
2974 | m_pos = cAgentData.Position + offset; | 3004 | m_pos = cAgentData.Position + offset; |
2975 | 3005 | ||
@@ -3119,7 +3149,11 @@ namespace OpenSim.Region.Framework.Scenes | |||
3119 | m_CameraLeftAxis = cAgent.LeftAxis; | 3149 | m_CameraLeftAxis = cAgent.LeftAxis; |
3120 | m_CameraUpAxis = cAgent.UpAxis; | 3150 | m_CameraUpAxis = cAgent.UpAxis; |
3121 | 3151 | ||
3122 | 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; | ||
3123 | 3157 | ||
3124 | if ((cAgent.Throttles != null) && cAgent.Throttles.Length > 0) | 3158 | if ((cAgent.Throttles != null) && cAgent.Throttles.Length > 0) |
3125 | ControllingClient.SetChildAgentThrottle(cAgent.Throttles); | 3159 | ControllingClient.SetChildAgentThrottle(cAgent.Throttles); |
diff --git a/OpenSim/Region/Framework/Scenes/Tests/AttachmentTests.cs b/OpenSim/Region/Framework/Scenes/Tests/AttachmentTests.cs new file mode 100644 index 0000000..af44640 --- /dev/null +++ b/OpenSim/Region/Framework/Scenes/Tests/AttachmentTests.cs | |||
@@ -0,0 +1,174 @@ | |||
1 | /* | ||
2 | * Copyright (c) Contributors, http://opensimulator.org/ | ||
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | ||
4 | * | ||
5 | * Redistribution and use in source and binary forms, with or without | ||
6 | * modification, are permitted provided that the following conditions are met: | ||
7 | * * Redistributions of source code must retain the above copyright | ||
8 | * notice, this list of conditions and the following disclaimer. | ||
9 | * * Redistributions in binary form must reproduce the above copyright | ||
10 | * notice, this list of conditions and the following disclaimer in the | ||
11 | * documentation and/or other materials provided with the distribution. | ||
12 | * * Neither the name of the OpenSimulator Project nor the | ||
13 | * names of its contributors may be used to endorse or promote products | ||
14 | * derived from this software without specific prior written permission. | ||
15 | * | ||
16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY | ||
17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | ||
18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY | ||
20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | ||
21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | ||
23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | ||
25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
26 | */ | ||
27 | |||
28 | using System; | ||
29 | using System.Collections.Generic; | ||
30 | using System.Reflection; | ||
31 | using System.Text; | ||
32 | using System.Threading; | ||
33 | using System.Timers; | ||
34 | using Timer=System.Timers.Timer; | ||
35 | using Nini.Config; | ||
36 | using NUnit.Framework; | ||
37 | using NUnit.Framework.SyntaxHelpers; | ||
38 | using OpenMetaverse; | ||
39 | using OpenSim.Framework; | ||
40 | using OpenSim.Framework.Communications; | ||
41 | using OpenSim.Region.Framework.Scenes; | ||
42 | using OpenSim.Region.Framework.Interfaces; | ||
43 | using OpenSim.Region.CoreModules.World.Serialiser; | ||
44 | using OpenSim.Region.CoreModules.ServiceConnectorsOut.Simulation; | ||
45 | using OpenSim.Tests.Common; | ||
46 | using OpenSim.Tests.Common.Mock; | ||
47 | using OpenSim.Tests.Common.Setup; | ||
48 | |||
49 | namespace OpenSim.Region.Framework.Scenes.Tests | ||
50 | { | ||
51 | /// <summary> | ||
52 | /// Attachment tests | ||
53 | /// </summary> | ||
54 | [TestFixture] | ||
55 | public class AttachmentTests | ||
56 | { | ||
57 | public Scene scene, scene2; | ||
58 | public UUID agent1; | ||
59 | public static Random random; | ||
60 | public ulong region1, region2; | ||
61 | public AgentCircuitData acd1; | ||
62 | public SceneObjectGroup sog1, sog2, sog3; | ||
63 | |||
64 | [TestFixtureSetUp] | ||
65 | public void Init() | ||
66 | { | ||
67 | TestHelper.InMethod(); | ||
68 | |||
69 | scene = SceneSetupHelpers.SetupScene("Neighbour x", UUID.Random(), 1000, 1000); | ||
70 | scene2 = SceneSetupHelpers.SetupScene("Neighbour x+1", UUID.Random(), 1001, 1000); | ||
71 | |||
72 | ISharedRegionModule interregionComms = new LocalSimulationConnectorModule(); | ||
73 | interregionComms.Initialise(new IniConfigSource()); | ||
74 | interregionComms.PostInitialise(); | ||
75 | SceneSetupHelpers.SetupSceneModules(scene, new IniConfigSource(), interregionComms); | ||
76 | SceneSetupHelpers.SetupSceneModules(scene2, new IniConfigSource(), interregionComms); | ||
77 | |||
78 | agent1 = UUID.Random(); | ||
79 | random = new Random(); | ||
80 | sog1 = NewSOG(UUID.Random(), scene, agent1); | ||
81 | sog2 = NewSOG(UUID.Random(), scene, agent1); | ||
82 | sog3 = NewSOG(UUID.Random(), scene, agent1); | ||
83 | |||
84 | //ulong neighbourHandle = Utils.UIntsToLong((uint)(neighbourx * Constants.RegionSize), (uint)(neighboury * Constants.RegionSize)); | ||
85 | region1 = scene.RegionInfo.RegionHandle; | ||
86 | region2 = scene2.RegionInfo.RegionHandle; | ||
87 | |||
88 | SceneSetupHelpers.AddRootAgent(scene, agent1); | ||
89 | } | ||
90 | |||
91 | [Test] | ||
92 | public void T030_TestAddAttachments() | ||
93 | { | ||
94 | TestHelper.InMethod(); | ||
95 | |||
96 | ScenePresence presence = scene.GetScenePresence(agent1); | ||
97 | |||
98 | presence.AddAttachment(sog1); | ||
99 | presence.AddAttachment(sog2); | ||
100 | presence.AddAttachment(sog3); | ||
101 | |||
102 | Assert.That(presence.HasAttachments(), Is.True); | ||
103 | Assert.That(presence.ValidateAttachments(), Is.True); | ||
104 | } | ||
105 | |||
106 | [Test] | ||
107 | public void T031_RemoveAttachments() | ||
108 | { | ||
109 | TestHelper.InMethod(); | ||
110 | |||
111 | ScenePresence presence = scene.GetScenePresence(agent1); | ||
112 | presence.RemoveAttachment(sog1); | ||
113 | presence.RemoveAttachment(sog2); | ||
114 | presence.RemoveAttachment(sog3); | ||
115 | Assert.That(presence.HasAttachments(), Is.False); | ||
116 | } | ||
117 | |||
118 | // I'm commenting this test because scene setup NEEDS InventoryService to | ||
119 | // be non-null | ||
120 | //[Test] | ||
121 | public void T032_CrossAttachments() | ||
122 | { | ||
123 | TestHelper.InMethod(); | ||
124 | |||
125 | ScenePresence presence = scene.GetScenePresence(agent1); | ||
126 | ScenePresence presence2 = scene2.GetScenePresence(agent1); | ||
127 | presence2.AddAttachment(sog1); | ||
128 | presence2.AddAttachment(sog2); | ||
129 | |||
130 | ISharedRegionModule serialiser = new SerialiserModule(); | ||
131 | SceneSetupHelpers.SetupSceneModules(scene, new IniConfigSource(), serialiser); | ||
132 | SceneSetupHelpers.SetupSceneModules(scene2, new IniConfigSource(), serialiser); | ||
133 | |||
134 | Assert.That(presence.HasAttachments(), Is.False, "Presence has attachments before cross"); | ||
135 | |||
136 | //Assert.That(presence2.CrossAttachmentsIntoNewRegion(region1, true), Is.True, "Cross was not successful"); | ||
137 | Assert.That(presence2.HasAttachments(), Is.False, "Presence2 objects were not deleted"); | ||
138 | Assert.That(presence.HasAttachments(), Is.True, "Presence has not received new objects"); | ||
139 | } | ||
140 | |||
141 | private SceneObjectGroup NewSOG(UUID uuid, Scene scene, UUID agent) | ||
142 | { | ||
143 | SceneObjectPart sop = new SceneObjectPart(); | ||
144 | sop.Name = RandomName(); | ||
145 | sop.Description = RandomName(); | ||
146 | sop.Text = RandomName(); | ||
147 | sop.SitName = RandomName(); | ||
148 | sop.TouchName = RandomName(); | ||
149 | sop.UUID = uuid; | ||
150 | sop.Shape = PrimitiveBaseShape.Default; | ||
151 | sop.Shape.State = 1; | ||
152 | sop.OwnerID = agent; | ||
153 | |||
154 | SceneObjectGroup sog = new SceneObjectGroup(sop); | ||
155 | sog.SetScene(scene); | ||
156 | |||
157 | return sog; | ||
158 | } | ||
159 | |||
160 | private static string RandomName() | ||
161 | { | ||
162 | StringBuilder name = new StringBuilder(); | ||
163 | int size = random.Next(5,12); | ||
164 | char ch; | ||
165 | for (int i = 0; i < size; i++) | ||
166 | { | ||
167 | ch = Convert.ToChar(Convert.ToInt32(Math.Floor(26 * random.NextDouble() + 65))) ; | ||
168 | name.Append(ch); | ||
169 | } | ||
170 | |||
171 | return name.ToString(); | ||
172 | } | ||
173 | } | ||
174 | } \ No newline at end of file | ||
diff --git a/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceTests.cs b/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceTests.cs index ef52363..fd2d6fa 100644 --- a/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceTests.cs +++ b/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceTests.cs | |||
@@ -40,6 +40,7 @@ using OpenSim.Framework; | |||
40 | using OpenSim.Framework.Communications; | 40 | using OpenSim.Framework.Communications; |
41 | using OpenSim.Region.Framework.Scenes; | 41 | using OpenSim.Region.Framework.Scenes; |
42 | using OpenSim.Region.Framework.Interfaces; | 42 | using OpenSim.Region.Framework.Interfaces; |
43 | using OpenSim.Region.CoreModules.Framework.EntityTransfer; | ||
43 | using OpenSim.Region.CoreModules.World.Serialiser; | 44 | using OpenSim.Region.CoreModules.World.Serialiser; |
44 | using OpenSim.Region.CoreModules.ServiceConnectorsOut.Simulation; | 45 | using OpenSim.Region.CoreModules.ServiceConnectorsOut.Simulation; |
45 | using OpenSim.Tests.Common; | 46 | using OpenSim.Tests.Common; |
@@ -116,9 +117,6 @@ namespace OpenSim.Region.Framework.Scenes.Tests | |||
116 | agent.ChildrenCapSeeds = new Dictionary<ulong, string>(); | 117 | agent.ChildrenCapSeeds = new Dictionary<ulong, string>(); |
117 | agent.child = true; | 118 | agent.child = true; |
118 | 119 | ||
119 | if (scene.PresenceService == null) | ||
120 | Console.WriteLine("Presence Service is null"); | ||
121 | |||
122 | scene.PresenceService.LoginAgent(agent.AgentID.ToString(), agent.SessionID, agent.SecureSessionID); | 120 | scene.PresenceService.LoginAgent(agent.AgentID.ToString(), agent.SessionID, agent.SecureSessionID); |
123 | 121 | ||
124 | string reason; | 122 | string reason; |
@@ -175,25 +173,6 @@ namespace OpenSim.Region.Framework.Scenes.Tests | |||
175 | 173 | ||
176 | Assert.That(neighbours.Count, Is.EqualTo(2)); | 174 | Assert.That(neighbours.Count, Is.EqualTo(2)); |
177 | } | 175 | } |
178 | |||
179 | public void fixNullPresence() | ||
180 | { | ||
181 | string firstName = "testfirstname"; | ||
182 | |||
183 | AgentCircuitData agent = new AgentCircuitData(); | ||
184 | agent.AgentID = agent1; | ||
185 | agent.firstname = firstName; | ||
186 | agent.lastname = "testlastname"; | ||
187 | agent.SessionID = UUID.Zero; | ||
188 | agent.SecureSessionID = UUID.Zero; | ||
189 | agent.circuitcode = 123; | ||
190 | agent.BaseFolder = UUID.Zero; | ||
191 | agent.InventoryFolder = UUID.Zero; | ||
192 | agent.startpos = Vector3.Zero; | ||
193 | agent.CapsPath = GetRandomCapsObjectPath(); | ||
194 | |||
195 | acd1 = agent; | ||
196 | } | ||
197 | 176 | ||
198 | [Test] | 177 | [Test] |
199 | public void T013_TestRemoveNeighbourRegion() | 178 | public void T013_TestRemoveNeighbourRegion() |
@@ -211,24 +190,36 @@ namespace OpenSim.Region.Framework.Scenes.Tests | |||
211 | CompleteAvatarMovement | 190 | CompleteAvatarMovement |
212 | */ | 191 | */ |
213 | } | 192 | } |
214 | 193 | ||
215 | // I'm commenting this test, because this is not supposed to happen here | 194 | /// <summary> |
216 | //[Test] | 195 | /// Test that if a root agent logs into a region, a child agent is also established in the neighbouring region |
217 | public void T020_TestMakeRootAgent() | 196 | /// </summary> |
197 | /// <remarks> | ||
198 | /// Please note that unlike the other tests here, this doesn't rely on structures | ||
199 | /// </remarks> | ||
200 | [Test] | ||
201 | public void TestChildAgentEstablished() | ||
218 | { | 202 | { |
219 | TestHelper.InMethod(); | 203 | TestHelper.InMethod(); |
220 | 204 | // log4net.Config.XmlConfigurator.Configure(); | |
221 | ScenePresence presence = scene.GetScenePresence(agent1); | 205 | |
222 | Assert.That(presence.IsChildAgent, Is.False, "Starts out as a root agent"); | 206 | UUID agent1Id = UUID.Parse("00000000-0000-0000-0000-000000000001"); |
223 | 207 | ||
224 | presence.MakeChildAgent(); | 208 | TestScene myScene1 = SceneSetupHelpers.SetupScene("Neighbour y", UUID.Random(), 1000, 1000); |
225 | Assert.That(presence.IsChildAgent, Is.True, "Did not change to child agent after MakeChildAgent"); | 209 | TestScene myScene2 = SceneSetupHelpers.SetupScene("Neighbour y + 1", UUID.Random(), 1001, 1000); |
226 | 210 | ||
227 | // Accepts 0 but rejects Constants.RegionSize | 211 | IConfigSource configSource = new IniConfigSource(); |
228 | Vector3 pos = new Vector3(0,unchecked(Constants.RegionSize-1),0); | 212 | configSource.AddConfig("Modules").Set("EntityTransferModule", "BasicEntityTransferModule"); |
229 | presence.MakeRootAgent(pos,true); | 213 | EntityTransferModule etm = new EntityTransferModule(); |
230 | Assert.That(presence.IsChildAgent, Is.False, "Did not go back to root agent"); | 214 | |
231 | Assert.That(presence.AbsolutePosition, Is.EqualTo(pos), "Position is not the same one entered"); | 215 | SceneSetupHelpers.SetupSceneModules(myScene1, configSource, etm); |
216 | |||
217 | SceneSetupHelpers.AddRootAgent(myScene1, agent1Id); | ||
218 | ScenePresence childPresence = myScene2.GetScenePresence(agent1); | ||
219 | |||
220 | // TODO: Need to do a fair amount of work to allow synchronous establishment of child agents | ||
221 | // Assert.That(childPresence, Is.Not.Null); | ||
222 | // Assert.That(childPresence.IsChildAgent, Is.True); | ||
232 | } | 223 | } |
233 | 224 | ||
234 | // I'm commenting this test because it does not represent | 225 | // I'm commenting this test because it does not represent |
@@ -333,63 +324,26 @@ namespace OpenSim.Region.Framework.Scenes.Tests | |||
333 | Assert.That(presence2.IsChildAgent, Is.True, "Did not return from region as expected."); | 324 | Assert.That(presence2.IsChildAgent, Is.True, "Did not return from region as expected."); |
334 | Assert.That(presence.IsChildAgent, Is.False, "Presence was not made root in old region again."); | 325 | Assert.That(presence.IsChildAgent, Is.False, "Presence was not made root in old region again."); |
335 | } | 326 | } |
336 | 327 | ||
337 | [Test] | 328 | public void fixNullPresence() |
338 | public void T030_TestAddAttachments() | ||
339 | { | ||
340 | TestHelper.InMethod(); | ||
341 | |||
342 | ScenePresence presence = scene.GetScenePresence(agent1); | ||
343 | |||
344 | presence.AddAttachment(sog1); | ||
345 | presence.AddAttachment(sog2); | ||
346 | presence.AddAttachment(sog3); | ||
347 | |||
348 | Assert.That(presence.HasAttachments(), Is.True); | ||
349 | Assert.That(presence.ValidateAttachments(), Is.True); | ||
350 | } | ||
351 | |||
352 | [Test] | ||
353 | public void T031_RemoveAttachments() | ||
354 | { | ||
355 | TestHelper.InMethod(); | ||
356 | |||
357 | ScenePresence presence = scene.GetScenePresence(agent1); | ||
358 | presence.RemoveAttachment(sog1); | ||
359 | presence.RemoveAttachment(sog2); | ||
360 | presence.RemoveAttachment(sog3); | ||
361 | Assert.That(presence.HasAttachments(), Is.False); | ||
362 | } | ||
363 | |||
364 | // I'm commenting this test because scene setup NEEDS InventoryService to | ||
365 | // be non-null | ||
366 | //[Test] | ||
367 | public void T032_CrossAttachments() | ||
368 | { | 329 | { |
369 | TestHelper.InMethod(); | 330 | string firstName = "testfirstname"; |
370 | |||
371 | ScenePresence presence = scene.GetScenePresence(agent1); | ||
372 | ScenePresence presence2 = scene2.GetScenePresence(agent1); | ||
373 | presence2.AddAttachment(sog1); | ||
374 | presence2.AddAttachment(sog2); | ||
375 | |||
376 | ISharedRegionModule serialiser = new SerialiserModule(); | ||
377 | SceneSetupHelpers.SetupSceneModules(scene, new IniConfigSource(), serialiser); | ||
378 | SceneSetupHelpers.SetupSceneModules(scene2, new IniConfigSource(), serialiser); | ||
379 | |||
380 | Assert.That(presence.HasAttachments(), Is.False, "Presence has attachments before cross"); | ||
381 | 331 | ||
382 | //Assert.That(presence2.CrossAttachmentsIntoNewRegion(region1, true), Is.True, "Cross was not successful"); | 332 | AgentCircuitData agent = new AgentCircuitData(); |
383 | Assert.That(presence2.HasAttachments(), Is.False, "Presence2 objects were not deleted"); | 333 | agent.AgentID = agent1; |
384 | Assert.That(presence.HasAttachments(), Is.True, "Presence has not received new objects"); | 334 | agent.firstname = firstName; |
385 | } | 335 | agent.lastname = "testlastname"; |
336 | agent.SessionID = UUID.Zero; | ||
337 | agent.SecureSessionID = UUID.Zero; | ||
338 | agent.circuitcode = 123; | ||
339 | agent.BaseFolder = UUID.Zero; | ||
340 | agent.InventoryFolder = UUID.Zero; | ||
341 | agent.startpos = Vector3.Zero; | ||
342 | agent.CapsPath = GetRandomCapsObjectPath(); | ||
386 | 343 | ||
387 | [TearDown] | 344 | acd1 = agent; |
388 | public void TearDown() | ||
389 | { | ||
390 | if (MainServer.Instance != null) MainServer.Instance.Stop(); | ||
391 | } | 345 | } |
392 | 346 | ||
393 | public static string GetRandomCapsObjectPath() | 347 | public static string GetRandomCapsObjectPath() |
394 | { | 348 | { |
395 | UUID caps = UUID.Random(); | 349 | UUID caps = UUID.Random(); |
diff --git a/OpenSim/Region/Framework/Scenes/Tests/SceneTests.cs b/OpenSim/Region/Framework/Scenes/Tests/SceneTests.cs new file mode 100644 index 0000000..9aba8a8 --- /dev/null +++ b/OpenSim/Region/Framework/Scenes/Tests/SceneTests.cs | |||
@@ -0,0 +1,71 @@ | |||
1 | /* | ||
2 | * Copyright (c) Contributors, http://opensimulator.org/ | ||
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | ||
4 | * | ||
5 | * Redistribution and use in source and binary forms, with or without | ||
6 | * modification, are permitted provided that the following conditions are met: | ||
7 | * * Redistributions of source code must retain the above copyright | ||
8 | * notice, this list of conditions and the following disclaimer. | ||
9 | * * Redistributions in binary form must reproduce the above copyright | ||
10 | * notice, this list of conditions and the following disclaimer in the | ||
11 | * documentation and/or other materials provided with the distribution. | ||
12 | * * Neither the name of the OpenSimulator Project nor the | ||
13 | * names of its contributors may be used to endorse or promote products | ||
14 | * derived from this software without specific prior written permission. | ||
15 | * | ||
16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY | ||
17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | ||
18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY | ||
20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | ||
21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | ||
23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | ||
25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
26 | */ | ||
27 | |||
28 | using System; | ||
29 | using System.Collections.Generic; | ||
30 | using System.Reflection; | ||
31 | using System.Text; | ||
32 | using System.Threading; | ||
33 | using System.Timers; | ||
34 | using Timer=System.Timers.Timer; | ||
35 | using Nini.Config; | ||
36 | using NUnit.Framework; | ||
37 | using NUnit.Framework.SyntaxHelpers; | ||
38 | using OpenMetaverse; | ||
39 | using OpenSim.Framework; | ||
40 | using OpenSim.Framework.Communications; | ||
41 | using OpenSim.Region.Framework.Scenes; | ||
42 | using OpenSim.Region.Framework.Interfaces; | ||
43 | using OpenSim.Region.CoreModules.World.Serialiser; | ||
44 | using OpenSim.Region.CoreModules.ServiceConnectorsOut.Simulation; | ||
45 | using OpenSim.Tests.Common; | ||
46 | using OpenSim.Tests.Common.Mock; | ||
47 | using OpenSim.Tests.Common.Setup; | ||
48 | |||
49 | namespace OpenSim.Region.Framework.Scenes.Tests | ||
50 | { | ||
51 | /// <summary> | ||
52 | /// Scene presence tests | ||
53 | /// </summary> | ||
54 | [TestFixture] | ||
55 | public class SceneTests | ||
56 | { | ||
57 | /// <summary> | ||
58 | /// Very basic scene update test. Should become more elaborate with time. | ||
59 | /// </summary> | ||
60 | [Test] | ||
61 | public void TestUpdateScene() | ||
62 | { | ||
63 | TestHelper.InMethod(); | ||
64 | |||
65 | Scene scene = SceneSetupHelpers.SetupScene(); | ||
66 | scene.Update(); | ||
67 | |||
68 | Assert.That(scene.Frame, Is.EqualTo(1)); | ||
69 | } | ||
70 | } | ||
71 | } \ No newline at end of file | ||