aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Framework/Scenes
diff options
context:
space:
mode:
authorUbitUmarov2017-06-07 20:12:49 +0100
committerUbitUmarov2017-06-07 20:12:49 +0100
commit7bea4f1578751e2c6f09aafcb3975133145ff306 (patch)
tree1a803b593cd72d596fa2d84a0269c34290d9f72f /OpenSim/Region/Framework/Scenes
parentsome changes on pollevent (diff)
parentso no real need for Maintenance thread.. so removed (diff)
downloadopensim-SC-7bea4f1578751e2c6f09aafcb3975133145ff306.zip
opensim-SC-7bea4f1578751e2c6f09aafcb3975133145ff306.tar.gz
opensim-SC-7bea4f1578751e2c6f09aafcb3975133145ff306.tar.bz2
opensim-SC-7bea4f1578751e2c6f09aafcb3975133145ff306.tar.xz
Merge branch 'master' into httptests
Diffstat (limited to 'OpenSim/Region/Framework/Scenes')
-rwxr-xr-xOpenSim/Region/Framework/Scenes/Scene.cs191
1 files changed, 18 insertions, 173 deletions
diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs
index 826cda1..e1e06d0 100755
--- a/OpenSim/Region/Framework/Scenes/Scene.cs
+++ b/OpenSim/Region/Framework/Scenes/Scene.cs
@@ -257,37 +257,7 @@ namespace OpenSim.Region.Framework.Scenes
257 public bool m_useFlySlow; 257 public bool m_useFlySlow;
258 public bool m_useTrashOnDelete = true; 258 public bool m_useTrashOnDelete = true;
259 259
260 /// <summary> 260 protected float m_defaultDrawDistance = 255f;
261 /// Temporarily setting to trigger appearance resends at 60 second intervals.
262 /// </summary>
263 public bool SendPeriodicAppearanceUpdates { get; set; }
264
265 /// <summary>
266 /// How much a root agent has to change position before updates are sent to viewers.
267 /// </summary>
268 public float RootPositionUpdateTolerance { get; set; }
269
270 /// <summary>
271 /// How much a root agent has to rotate before updates are sent to viewers.
272 /// </summary>
273 public float RootRotationUpdateTolerance { get; set; }
274
275 /// <summary>
276 /// How much a root agent has to change velocity before updates are sent to viewers.
277 /// </summary>
278 public float RootVelocityUpdateTolerance { get; set; }
279
280 /// <summary>
281 /// If greater than 1, we only send terse updates to other root agents on every n updates.
282 /// </summary>
283 public int RootTerseUpdatePeriod { get; set; }
284
285 /// <summary>
286 /// If greater than 1, we only send terse updates to child agents on every n updates.
287 /// </summary>
288 public int ChildTerseUpdatePeriod { get; set; }
289
290 protected float m_defaultDrawDistance = 255f;
291 protected float m_defaultCullingDrawDistance = 16f; 261 protected float m_defaultCullingDrawDistance = 16f;
292 public float DefaultDrawDistance 262 public float DefaultDrawDistance
293 { 263 {
@@ -376,11 +346,6 @@ namespace OpenSim.Region.Framework.Scenes
376 } 346 }
377 347
378 /// <summary> 348 /// <summary>
379 /// Current maintenance run number
380 /// </summary>
381 public uint MaintenanceRun { get; private set; }
382
383 /// <summary>
384 /// Frame time 349 /// Frame time
385 /// </remarks> 350 /// </remarks>
386 public float FrameTime { get; private set; } 351 public float FrameTime { get; private set; }
@@ -391,14 +356,6 @@ namespace OpenSim.Region.Framework.Scenes
391 // see SimStatsReporter.cs 356 // see SimStatsReporter.cs
392 public bool Normalized55FPS { get; private set; } 357 public bool Normalized55FPS { get; private set; }
393 358
394 /// <summary>
395 /// The minimum length of time in seconds that will be taken for a scene frame.
396 /// </summary>
397 /// <remarks>
398 /// Always derived from MinFrameTicks.
399 /// </remarks>
400 public float MinMaintenanceTime { get; private set; }
401
402 private int m_update_physics = 1; 359 private int m_update_physics = 1;
403 private int m_update_entitymovement = 1; 360 private int m_update_entitymovement = 1;
404 private int m_update_objects = 1; 361 private int m_update_objects = 1;
@@ -407,9 +364,8 @@ namespace OpenSim.Region.Framework.Scenes
407 private int m_update_backup = 200; 364 private int m_update_backup = 200;
408 365
409 private int m_update_terrain = 1000; 366 private int m_update_terrain = 1000;
410 private int m_update_land = 10;
411 367
412 private int m_update_coarse_locations = 50; 368 private int m_update_coarse_locations = 5;
413 private int m_update_temp_cleaning = 180; 369 private int m_update_temp_cleaning = 180;
414 370
415 private float agentMS; 371 private float agentMS;
@@ -429,11 +385,6 @@ namespace OpenSim.Region.Framework.Scenes
429 private int m_lastFrameTick; 385 private int m_lastFrameTick;
430 386
431 /// <summary> 387 /// <summary>
432 /// Tick at which the last maintenance run occurred.
433 /// </summary>
434 private int m_lastMaintenanceTick;
435
436 /// <summary>
437 /// Total script execution time (in Stopwatch Ticks) since the last frame 388 /// Total script execution time (in Stopwatch Ticks) since the last frame
438 /// </summary> 389 /// </summary>
439 private long m_scriptExecutionTime = 0; 390 private long m_scriptExecutionTime = 0;
@@ -449,11 +400,6 @@ namespace OpenSim.Region.Framework.Scenes
449 /// </summary> 400 /// </summary>
450 private ManualResetEvent m_updateWaitEvent = new ManualResetEvent(false); 401 private ManualResetEvent m_updateWaitEvent = new ManualResetEvent(false);
451 402
452 /// <summary>
453 /// Used to control maintenance thread runs.
454 /// </summary>
455 private ManualResetEvent m_maintenanceWaitEvent = new ManualResetEvent(false);
456
457 // TODO: Possibly stop other classes being able to manipulate this directly. 403 // TODO: Possibly stop other classes being able to manipulate this directly.
458 private SceneGraph m_sceneGraph; 404 private SceneGraph m_sceneGraph;
459 private readonly Timer m_restartTimer = new Timer(15000); // Wait before firing 405 private readonly Timer m_restartTimer = new Timer(15000); // Wait before firing
@@ -497,7 +443,7 @@ namespace OpenSim.Region.Framework.Scenes
497 /// Is the scene active? 443 /// Is the scene active?
498 /// </summary> 444 /// </summary>
499 /// <remarks> 445 /// <remarks>
500 /// If false, maintenance and update loops are not being run, though after setting to false update may still 446 /// If false, update loop is not being run, though after setting to false update may still
501 /// be active for a period (and IsRunning will still be true). Updates can still be triggered manually if 447 /// be active for a period (and IsRunning will still be true). Updates can still be triggered manually if
502 /// the scene is not active. 448 /// the scene is not active.
503 /// </remarks> 449 /// </remarks>
@@ -527,7 +473,6 @@ namespace OpenSim.Region.Framework.Scenes
527 public bool IsRunning { get { return m_isRunning; } } 473 public bool IsRunning { get { return m_isRunning; } }
528 private volatile bool m_isRunning; 474 private volatile bool m_isRunning;
529 475
530// private int m_lastUpdate;
531 private bool m_firstHeartbeat = true; 476 private bool m_firstHeartbeat = true;
532 477
533// private UpdatePrioritizationSchemes m_priorityScheme = UpdatePrioritizationSchemes.Time; 478// private UpdatePrioritizationSchemes m_priorityScheme = UpdatePrioritizationSchemes.Time;
@@ -883,7 +828,6 @@ namespace OpenSim.Region.Framework.Scenes
883 FrameTimeWarnPercent = 60; 828 FrameTimeWarnPercent = 60;
884 FrameTimeCritPercent = 40; 829 FrameTimeCritPercent = 40;
885 Normalized55FPS = true; 830 Normalized55FPS = true;
886 MinMaintenanceTime = 1;
887 SeeIntoRegion = true; 831 SeeIntoRegion = true;
888 832
889 Random random = new Random(); 833 Random random = new Random();
@@ -1147,17 +1091,6 @@ namespace OpenSim.Region.Framework.Scenes
1147 1091
1148 } 1092 }
1149 1093
1150
1151 // FIXME: Ultimately this should be in a module.
1152 SendPeriodicAppearanceUpdates = false;
1153
1154 IConfig appearanceConfig = m_config.Configs["Appearance"];
1155 if (appearanceConfig != null)
1156 {
1157 SendPeriodicAppearanceUpdates
1158 = appearanceConfig.GetBoolean("ResendAppearanceUpdates", SendPeriodicAppearanceUpdates);
1159 }
1160
1161 #endregion Region Config 1094 #endregion Region Config
1162 1095
1163 IConfig entityTransferConfig = m_config.Configs["EntityTransfer"]; 1096 IConfig entityTransferConfig = m_config.Configs["EntityTransfer"];
@@ -1197,16 +1130,6 @@ namespace OpenSim.Region.Framework.Scenes
1197 ObjectsCullingByDistance 1130 ObjectsCullingByDistance
1198 = interestConfig.GetBoolean("ObjectsCullingByDistance", ObjectsCullingByDistance); 1131 = interestConfig.GetBoolean("ObjectsCullingByDistance", ObjectsCullingByDistance);
1199 1132
1200
1201 RootTerseUpdatePeriod = interestConfig.GetInt("RootTerseUpdatePeriod", RootTerseUpdatePeriod);
1202 ChildTerseUpdatePeriod = interestConfig.GetInt("ChildTerseUpdatePeriod", ChildTerseUpdatePeriod);
1203
1204 RootPositionUpdateTolerance
1205 = interestConfig.GetFloat("RootPositionUpdateTolerance", RootPositionUpdateTolerance);
1206 RootRotationUpdateTolerance
1207 = interestConfig.GetFloat("RootRotationUpdateTolerance", RootRotationUpdateTolerance);
1208 RootVelocityUpdateTolerance
1209 = interestConfig.GetFloat("RootVelocityUpdateTolerance", RootVelocityUpdateTolerance);
1210 } 1133 }
1211 1134
1212 m_log.DebugFormat("[SCENE]: Using the {0} prioritization scheme", UpdatePrioritizationScheme); 1135 m_log.DebugFormat("[SCENE]: Using the {0} prioritization scheme", UpdatePrioritizationScheme);
@@ -1275,9 +1198,6 @@ namespace OpenSim.Region.Framework.Scenes
1275 UpdatePrioritizationScheme = UpdatePrioritizationSchemes.Time; 1198 UpdatePrioritizationScheme = UpdatePrioritizationSchemes.Time;
1276 ReprioritizationInterval = 5000; 1199 ReprioritizationInterval = 5000;
1277 1200
1278 RootRotationUpdateTolerance = 0.1f;
1279 RootVelocityUpdateTolerance = 0.001f;
1280 RootPositionUpdateTolerance = 0.05f;
1281 ReprioritizationDistance = m_minReprioritizationDistance; 1201 ReprioritizationDistance = m_minReprioritizationDistance;
1282 1202
1283 m_eventManager = new EventManager(); 1203 m_eventManager = new EventManager();
@@ -1668,100 +1588,12 @@ namespace OpenSim.Region.Framework.Scenes
1668 // alarms for scenes with many objects. 1588 // alarms for scenes with many objects.
1669 Update(1); 1589 Update(1);
1670 1590
1671 WorkManager.StartThread(
1672 Maintenance, string.Format("Maintenance ({0})", RegionInfo.RegionName), ThreadPriority.Normal, false, true);
1673
1674 Watchdog.GetCurrentThreadInfo().AlarmIfTimeout = true; 1591 Watchdog.GetCurrentThreadInfo().AlarmIfTimeout = true;
1675 m_lastFrameTick = Util.EnvironmentTickCount(); 1592 m_lastFrameTick = Util.EnvironmentTickCount();
1676 Update(-1); 1593 Update(-1);
1677
1678 Watchdog.RemoveThread(); 1594 Watchdog.RemoveThread();
1679 } 1595 }
1680 1596
1681 private void Maintenance()
1682 {
1683 DoMaintenance(-1);
1684
1685 Watchdog.RemoveThread();
1686 }
1687
1688 public void DoMaintenance(int runs)
1689 {
1690 long? endRun = null;
1691 int runtc, tmpMS;
1692 int previousMaintenanceTick;
1693
1694 if (runs >= 0)
1695 endRun = MaintenanceRun + runs;
1696
1697 List<Vector3> coarseLocations;
1698 List<UUID> avatarUUIDs;
1699
1700 while (!m_shuttingDown && ((endRun == null && Active) || MaintenanceRun < endRun))
1701 {
1702 runtc = Util.EnvironmentTickCount();
1703 ++MaintenanceRun;
1704
1705 // m_log.DebugFormat("[SCENE]: Maintenance run {0} in {1}", MaintenanceRun, Name);
1706
1707 // Coarse locations relate to positions of green dots on the mini-map (on a SecondLife client)
1708 if (MaintenanceRun % (m_update_coarse_locations / 10) == 0)
1709 {
1710 SceneGraph.GetCoarseLocations(out coarseLocations, out avatarUUIDs, 60);
1711 // Send coarse locations to clients
1712 ForEachScenePresence(delegate(ScenePresence presence)
1713 {
1714 presence.SendCoarseLocations(coarseLocations, avatarUUIDs);
1715 });
1716 }
1717
1718 if (SendPeriodicAppearanceUpdates && MaintenanceRun % 60 == 0)
1719 {
1720 // m_log.DebugFormat("[SCENE]: Sending periodic appearance updates");
1721
1722 if (AvatarFactory != null)
1723 {
1724 ForEachRootScenePresence(sp => AvatarFactory.SendAppearance(sp.UUID));
1725 }
1726 }
1727
1728 // Delete temp-on-rez stuff
1729 if (MaintenanceRun % m_update_temp_cleaning == 0 && !m_cleaningTemps)
1730 {
1731 // m_log.DebugFormat("[SCENE]: Running temp-on-rez cleaning in {0}", Name);
1732 tmpMS = Util.EnvironmentTickCount();
1733 m_cleaningTemps = true;
1734
1735 WorkManager.RunInThread(
1736 delegate { CleanTempObjects(); m_cleaningTemps = false; },
1737 null,
1738 string.Format("CleanTempObjects ({0})", Name));
1739
1740 tempOnRezMS = Util.EnvironmentTickCountSubtract(tmpMS);
1741 }
1742
1743 Watchdog.UpdateThread();
1744
1745 previousMaintenanceTick = m_lastMaintenanceTick;
1746 m_lastMaintenanceTick = Util.EnvironmentTickCount();
1747 runtc = Util.EnvironmentTickCountSubtract(m_lastMaintenanceTick, runtc);
1748 runtc = (int)(MinMaintenanceTime * 1000) - runtc;
1749
1750 if (runtc > 0)
1751 m_maintenanceWaitEvent.WaitOne(runtc);
1752
1753 // Optionally warn if a frame takes double the amount of time that it should.
1754 if (DebugUpdates
1755 && Util.EnvironmentTickCountSubtract(
1756 m_lastMaintenanceTick, previousMaintenanceTick) > (int)(MinMaintenanceTime * 1000 * 2))
1757 m_log.WarnFormat(
1758 "[SCENE]: Maintenance took {0} ms (desired max {1} ms) in {2}",
1759 Util.EnvironmentTickCountSubtract(m_lastMaintenanceTick, previousMaintenanceTick),
1760 MinMaintenanceTime * 1000,
1761 RegionInfo.RegionName);
1762 }
1763 }
1764
1765 public override void Update(int frames) 1597 public override void Update(int frames)
1766 { 1598 {
1767 long? endFrame = null; 1599 long? endFrame = null;
@@ -1822,6 +1654,18 @@ namespace OpenSim.Region.Framework.Scenes
1822 if (Frame % m_update_entitymovement == 0) 1654 if (Frame % m_update_entitymovement == 0)
1823 m_sceneGraph.UpdateScenePresenceMovement(); 1655 m_sceneGraph.UpdateScenePresenceMovement();
1824 1656
1657 if (Frame % (m_update_coarse_locations) == 0)
1658 {
1659 List<Vector3> coarseLocations;
1660 List<UUID> avatarUUIDs;
1661
1662 SceneGraph.GetCoarseLocations(out coarseLocations, out avatarUUIDs, 60);
1663 // Send coarse locations to clients
1664 ForEachScenePresence(delegate(ScenePresence presence)
1665 {
1666 presence.SendCoarseLocations(coarseLocations, avatarUUIDs);
1667 });
1668 }
1825 // Get the simulation frame time that the avatar force input 1669 // Get the simulation frame time that the avatar force input
1826 // took 1670 // took
1827 tmpMS2 = Util.GetTimeStampMS(); 1671 tmpMS2 = Util.GetTimeStampMS();
@@ -1864,7 +1708,8 @@ namespace OpenSim.Region.Framework.Scenes
1864 if (Frame % m_update_temp_cleaning == 0 && !m_cleaningTemps) 1708 if (Frame % m_update_temp_cleaning == 0 && !m_cleaningTemps)
1865 { 1709 {
1866 m_cleaningTemps = true; 1710 m_cleaningTemps = true;
1867 Util.FireAndForget(delegate { CleanTempObjects(); m_cleaningTemps = false; }); 1711 WorkManager.RunInThread(
1712 delegate { CleanTempObjects(); m_cleaningTemps = false; }, null, string.Format("CleanTempObjects ({0})", Name));
1868 tmpMS2 = Util.GetTimeStampMS(); 1713 tmpMS2 = Util.GetTimeStampMS();
1869 tempOnRezMS = (float)(tmpMS2 - tmpMS); // bad.. counts the FireAndForget, not CleanTempObjects 1714 tempOnRezMS = (float)(tmpMS2 - tmpMS); // bad.. counts the FireAndForget, not CleanTempObjects
1870 tmpMS = tmpMS2; 1715 tmpMS = tmpMS2;
@@ -2091,7 +1936,7 @@ namespace OpenSim.Region.Framework.Scenes
2091 if (!m_backingup) 1936 if (!m_backingup)
2092 { 1937 {
2093 m_backingup = true; 1938 m_backingup = true;
2094 WorkManager.RunInThread(o => Backup(false), null, string.Format("BackupWaitCallback ({0})", Name)); 1939 WorkManager.RunInThread(o => Backup(false), null, string.Format("BackupWorker ({0})", Name));
2095 } 1940 }
2096 } 1941 }
2097 1942