aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Framework/Scenes/Scene.cs
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Region/Framework/Scenes/Scene.cs')
-rwxr-xr-xOpenSim/Region/Framework/Scenes/Scene.cs123
1 files changed, 70 insertions, 53 deletions
diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs
index c1da7fa..c5c2147 100755
--- a/OpenSim/Region/Framework/Scenes/Scene.cs
+++ b/OpenSim/Region/Framework/Scenes/Scene.cs
@@ -398,16 +398,16 @@ namespace OpenSim.Region.Framework.Scenes
398 private int m_update_coarse_locations = 50; 398 private int m_update_coarse_locations = 50;
399 private int m_update_temp_cleaning = 180; 399 private int m_update_temp_cleaning = 180;
400 400
401 private int agentMS; 401 private float agentMS;
402 private int frameMS; 402 private float frameMS;
403 private int physicsMS2; 403 private float physicsMS2;
404 private int physicsMS; 404 private float physicsMS;
405 private int otherMS; 405 private float otherMS;
406 private int tempOnRezMS; 406 private float tempOnRezMS;
407 private int eventMS; 407 private float eventMS;
408 private int backupMS; 408 private float backupMS;
409 private int terrainMS; 409 private float terrainMS;
410 private int landMS; 410 private float landMS;
411 411
412 // A temporary configuration flag to enable using FireAndForget to process 412 // A temporary configuration flag to enable using FireAndForget to process
413 // collisions from the physics engine. There is a problem with collisions 413 // collisions from the physics engine. There is a problem with collisions
@@ -785,15 +785,15 @@ namespace OpenSim.Region.Framework.Scenes
785 get { return m_capsModule; } 785 get { return m_capsModule; }
786 } 786 }
787 787
788 public int MonitorFrameTime { get { return frameMS; } } 788 public int MonitorFrameTime { get { return (int)frameMS; } }
789 public int MonitorPhysicsUpdateTime { get { return physicsMS; } } 789 public int MonitorPhysicsUpdateTime { get { return (int)physicsMS; } }
790 public int MonitorPhysicsSyncTime { get { return physicsMS2; } } 790 public int MonitorPhysicsSyncTime { get { return (int)physicsMS2; } }
791 public int MonitorOtherTime { get { return otherMS; } } 791 public int MonitorOtherTime { get { return (int)otherMS; } }
792 public int MonitorTempOnRezTime { get { return tempOnRezMS; } } 792 public int MonitorTempOnRezTime { get { return (int)tempOnRezMS; } }
793 public int MonitorEventTime { get { return eventMS; } } // This may need to be divided into each event? 793 public int MonitorEventTime { get { return (int)eventMS; } } // This may need to be divided into each event?
794 public int MonitorBackupTime { get { return backupMS; } } 794 public int MonitorBackupTime { get { return (int)backupMS; } }
795 public int MonitorTerrainTime { get { return terrainMS; } } 795 public int MonitorTerrainTime { get { return (int)terrainMS; } }
796 public int MonitorLandTime { get { return landMS; } } 796 public int MonitorLandTime { get { return (int)landMS; } }
797 public int MonitorLastFrameTick { get { return m_lastFrameTick; } } 797 public int MonitorLastFrameTick { get { return m_lastFrameTick; } }
798 798
799 public UpdatePrioritizationSchemes UpdatePrioritizationScheme { get; set; } 799 public UpdatePrioritizationSchemes UpdatePrioritizationScheme { get; set; }
@@ -1714,20 +1714,21 @@ namespace OpenSim.Region.Framework.Scenes
1714 1714
1715 float physicsFPS = 0f; 1715 float physicsFPS = 0f;
1716 1716
1717 int tmpMS;
1718 int previousFrameTick; 1717 int previousFrameTick;
1719 int maintc; 1718
1720 int sleepMS; 1719 double tmpMS;
1721 int framestart; 1720 double tmpMS2;
1721 double framestart;
1722 float sleepMS;
1722 1723
1723 while (!m_shuttingDown && ((endFrame == null && Active) || Frame < endFrame)) 1724 while (!m_shuttingDown && ((endFrame == null && Active) || Frame < endFrame))
1724 { 1725 {
1725 framestart = Util.EnvironmentTickCount(); 1726 framestart = Util.GetTimeStampMS();
1726 ++Frame; 1727 ++Frame;
1727 1728
1728 // m_log.DebugFormat("[SCENE]: Processing frame {0} in {1}", Frame, RegionInfo.RegionName); 1729 // m_log.DebugFormat("[SCENE]: Processing frame {0} in {1}", Frame, RegionInfo.RegionName);
1729 1730
1730 agentMS = tempOnRezMS = eventMS = backupMS = terrainMS = landMS = 0; 1731 agentMS = tempOnRezMS = eventMS = backupMS = terrainMS = landMS = 0f;
1731 1732
1732 try 1733 try
1733 { 1734 {
@@ -1735,7 +1736,8 @@ namespace OpenSim.Region.Framework.Scenes
1735 1736
1736 // Apply taints in terrain module to terrain in physics scene 1737 // Apply taints in terrain module to terrain in physics scene
1737 1738
1738 tmpMS = Util.EnvironmentTickCount(); 1739 tmpMS = Util.GetTimeStampMS();
1740
1739 if (Frame % 4 == 0) 1741 if (Frame % 4 == 0)
1740 { 1742 {
1741 CheckTerrainUpdates(); 1743 CheckTerrainUpdates();
@@ -1746,26 +1748,29 @@ namespace OpenSim.Region.Framework.Scenes
1746 UpdateTerrain(); 1748 UpdateTerrain();
1747 } 1749 }
1748 1750
1749 terrainMS = Util.EnvironmentTickCountSubtract(tmpMS); 1751 tmpMS2 = Util.GetTimeStampMS();
1750 tmpMS = Util.EnvironmentTickCount(); 1752 terrainMS = (float)(tmpMS2 - tmpMS);
1753 tmpMS = tmpMS2;
1751 1754
1752 if (PhysicsEnabled && Frame % m_update_physics == 0) 1755 if (PhysicsEnabled && Frame % m_update_physics == 0)
1753 m_sceneGraph.UpdatePreparePhysics(); 1756 m_sceneGraph.UpdatePreparePhysics();
1754 1757
1755 physicsMS2 = Util.EnvironmentTickCountSubtract(tmpMS); 1758 tmpMS2 = Util.GetTimeStampMS();
1759 physicsMS2 = (float)(tmpMS2 - tmpMS);
1760 tmpMS = tmpMS2;
1756 1761
1757 // Apply any pending avatar force input to the avatar's velocity 1762 // Apply any pending avatar force input to the avatar's velocity
1758 tmpMS = Util.EnvironmentTickCount();
1759 if (Frame % m_update_entitymovement == 0) 1763 if (Frame % m_update_entitymovement == 0)
1760 m_sceneGraph.UpdateScenePresenceMovement(); 1764 m_sceneGraph.UpdateScenePresenceMovement();
1761 1765
1762 // Get the simulation frame time that the avatar force input 1766 // Get the simulation frame time that the avatar force input
1763 // took 1767 // took
1764 agentMS = Util.EnvironmentTickCountSubtract(tmpMS); 1768 tmpMS2 = Util.GetTimeStampMS();
1769 agentMS = (float)(tmpMS2 - tmpMS);
1770 tmpMS = tmpMS2;
1765 1771
1766 // Perform the main physics update. This will do the actual work of moving objects and avatars according to their 1772 // Perform the main physics update. This will do the actual work of moving objects and avatars according to their
1767 // velocity 1773 // velocity
1768 tmpMS = Util.EnvironmentTickCount();
1769 if (Frame % m_update_physics == 0) 1774 if (Frame % m_update_physics == 0)
1770 { 1775 {
1771 if (PhysicsEnabled) 1776 if (PhysicsEnabled)
@@ -1774,12 +1779,10 @@ namespace OpenSim.Region.Framework.Scenes
1774 if (SynchronizeScene != null) 1779 if (SynchronizeScene != null)
1775 SynchronizeScene(this); 1780 SynchronizeScene(this);
1776 } 1781 }
1777 1782
1778 // Add the main physics update time to the prepare physics time 1783 tmpMS2 = Util.GetTimeStampMS();
1779 physicsMS = Util.EnvironmentTickCountSubtract(tmpMS); 1784 physicsMS = (float)(tmpMS2 - tmpMS);
1780 1785 tmpMS = tmpMS2;
1781 // Start the stopwatch for the remainder of the simulation
1782 tmpMS = Util.EnvironmentTickCount();
1783 1786
1784 // Check if any objects have reached their targets 1787 // Check if any objects have reached their targets
1785 CheckAtTargets(); 1788 CheckAtTargets();
@@ -1794,29 +1797,37 @@ namespace OpenSim.Region.Framework.Scenes
1794 if (Frame % m_update_presences == 0) 1797 if (Frame % m_update_presences == 0)
1795 m_sceneGraph.UpdatePresences(); 1798 m_sceneGraph.UpdatePresences();
1796 1799
1797 agentMS += Util.EnvironmentTickCountSubtract(tmpMS); 1800 tmpMS2 = Util.GetTimeStampMS();
1801 agentMS += (float)(tmpMS2 - tmpMS);
1802 tmpMS = tmpMS2;
1798 1803
1799 // Delete temp-on-rez stuff 1804 // Delete temp-on-rez stuff
1800 if (Frame % m_update_temp_cleaning == 0 && !m_cleaningTemps) 1805 if (Frame % m_update_temp_cleaning == 0 && !m_cleaningTemps)
1801 { 1806 {
1802 tmpMS = Util.EnvironmentTickCount(); 1807
1803 m_cleaningTemps = true; 1808 m_cleaningTemps = true;
1804 Util.FireAndForget(delegate { CleanTempObjects(); m_cleaningTemps = false; }); 1809 Util.FireAndForget(delegate { CleanTempObjects(); m_cleaningTemps = false; });
1805 tempOnRezMS = Util.EnvironmentTickCountSubtract(tmpMS); 1810 tmpMS2 = Util.GetTimeStampMS();
1811 tempOnRezMS = (float)(tmpMS2 - tmpMS); // bad.. counts the FireAndForget, not CleanTempObjects
1812 tmpMS = tmpMS2;
1806 } 1813 }
1807 1814
1808 if (Frame % m_update_events == 0) 1815 if (Frame % m_update_events == 0)
1809 { 1816 {
1810 tmpMS = Util.EnvironmentTickCount();
1811 UpdateEvents(); 1817 UpdateEvents();
1812 eventMS = Util.EnvironmentTickCountSubtract(tmpMS); 1818
1819 tmpMS2 = Util.GetTimeStampMS();
1820 eventMS = (float)(tmpMS2 - tmpMS);
1821 tmpMS = tmpMS2;
1813 } 1822 }
1814 1823
1815 if (PeriodicBackup && Frame % m_update_backup == 0) 1824 if (PeriodicBackup && Frame % m_update_backup == 0)
1816 { 1825 {
1817 tmpMS = Util.EnvironmentTickCount();
1818 UpdateStorageBackup(); 1826 UpdateStorageBackup();
1819 backupMS = Util.EnvironmentTickCountSubtract(tmpMS); 1827
1828 tmpMS2 = Util.GetTimeStampMS();
1829 backupMS = (float)(tmpMS2 - tmpMS);
1830 tmpMS = tmpMS2;
1820 } 1831 }
1821 1832
1822 //if (Frame % m_update_land == 0) 1833 //if (Frame % m_update_land == 0)
@@ -1887,20 +1898,26 @@ namespace OpenSim.Region.Framework.Scenes
1887 StatsReporter.addOtherMS(otherMS); 1898 StatsReporter.addOtherMS(otherMS);
1888 StatsReporter.addScriptLines(m_sceneGraph.GetScriptLPS()); 1899 StatsReporter.addScriptLines(m_sceneGraph.GetScriptLPS());
1889 1900
1901
1902 tmpMS = Util.GetTimeStampMS();
1903
1890 previousFrameTick = m_lastFrameTick; 1904 previousFrameTick = m_lastFrameTick;
1891 m_lastFrameTick = Util.EnvironmentTickCount(); 1905 m_lastFrameTick = (int)(tmpMS + 0.5);
1892 tmpMS = Util.EnvironmentTickCountSubtract(m_lastFrameTick, framestart); 1906
1893 tmpMS = (int)(MinFrameTime * 1000) - tmpMS; 1907 // estimate sleep time
1908 tmpMS2 = tmpMS - framestart;
1909 tmpMS2 = (double)MinFrameTime * 1000.0D - tmpMS2;
1894 1910
1895 m_firstHeartbeat = false; 1911 m_firstHeartbeat = false;
1896 1912
1897 sleepMS = Util.EnvironmentTickCount(); 1913 // sleep if we can
1914 if (tmpMS2 > 0)
1915 Thread.Sleep((int)(tmpMS2 +0.5));
1898 1916
1899 if (tmpMS > 0) 1917 tmpMS2 = Util.GetTimeStampMS();
1900 Thread.Sleep(tmpMS);
1901 1918
1902 sleepMS = Util.EnvironmentTickCountSubtract(sleepMS); 1919 sleepMS = (float)(tmpMS2 - tmpMS);
1903 frameMS = Util.EnvironmentTickCountSubtract(framestart); 1920 frameMS = (float)(tmpMS2 - framestart);
1904 StatsReporter.addSleepMS(sleepMS); 1921 StatsReporter.addSleepMS(sleepMS);
1905 StatsReporter.addFrameMS(frameMS); 1922 StatsReporter.addFrameMS(frameMS);
1906 1923