From e2c807a0d0c97c9f41bf5a2d8ec0e698a63714d6 Mon Sep 17 00:00:00 2001 From: "Justin Clark-Casey (justincc)" Date: Thu, 13 Oct 2011 22:07:55 +0100 Subject: [PATCH] Tie reported FPS correction factor into the minimum frame time rather than setting separately. This makes reported FPS scale as required if min frame time changes --- OpenSim/Region/Framework/Scenes/Scene.cs | 7 ++++--- OpenSim/Region/Framework/Scenes/SimStatsReporter.cs | 12 +++++++++--- 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs index 11165682bf..2550c310e0 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.cs @@ -155,7 +155,7 @@ namespace OpenSim.Region.Framework.Scenes /// One can tweak this number to experiment. One current effect of reducing it is to make avatar animations /// occur too quickly (viewer 1) or with even more slide (viewer 2). /// - protected float m_minFrameTimespan = 0.089f; + public float MinFrameTime { get; private set; } /// /// The time of the last frame update. @@ -534,6 +534,7 @@ namespace OpenSim.Region.Framework.Scenes bool SeeIntoRegionFromNeighbor, IConfigSource config, string simulatorVersion) { m_config = config; + MinFrameTime = 0.089f; Random random = new Random(); @@ -1270,7 +1271,7 @@ namespace OpenSim.Region.Framework.Scenes if (Frame % m_update_physics == 0) { if (m_physics_enabled) - physicsFPS = m_sceneGraph.UpdatePhysics(Math.Max(SinceLastFrame.TotalSeconds, m_minFrameTimespan)); + physicsFPS = m_sceneGraph.UpdatePhysics(Math.Max(SinceLastFrame.TotalSeconds, MinFrameTime)); if (SynchronizeScene != null) SynchronizeScene(this); } @@ -1391,7 +1392,7 @@ namespace OpenSim.Region.Framework.Scenes } maintc = Util.EnvironmentTickCountSubtract(maintc); - maintc = (int)(m_minFrameTimespan * 1000) - maintc; + maintc = (int)(MinFrameTime * 1000) - maintc; if (maintc > 0) Thread.Sleep(maintc); diff --git a/OpenSim/Region/Framework/Scenes/SimStatsReporter.cs b/OpenSim/Region/Framework/Scenes/SimStatsReporter.cs index 8d62b16cd5..35cd025c01 100644 --- a/OpenSim/Region/Framework/Scenes/SimStatsReporter.cs +++ b/OpenSim/Region/Framework/Scenes/SimStatsReporter.cs @@ -106,6 +106,11 @@ namespace OpenSim.Region.Framework.Scenes private float m_timeDilation = 0; private int m_fps = 0; + /// + /// Our nominal fps target, as expected in fps stats when a sim is running normally. + /// + private float m_nominalReportedFps = 55; + /// /// Parameter to adjust reported scene fps /// @@ -114,7 +119,7 @@ namespace OpenSim.Region.Framework.Scenes /// However, we will still report an FPS that's closer to what people are used to seeing. A lower FPS might /// affect clients and monitoring scripts/software. /// - private float m_fpsCorrectionFactor = 5; + private float m_reportedFpsCorrectionFactor = 5; // saved last reported value so there is something available for llGetRegionFPS private float lastReportedSimFPS = 0; @@ -165,8 +170,9 @@ namespace OpenSim.Region.Framework.Scenes public SimStatsReporter(Scene scene) { - statsUpdateFactor = (float)(statsUpdatesEveryMS / 1000); m_scene = scene; + m_reportedFpsCorrectionFactor = scene.MinFrameTime * m_nominalReportedFps; + statsUpdateFactor = (float)(statsUpdatesEveryMS / 1000); ReportingRegion = scene.RegionInfo; m_objectCapacity = scene.RegionInfo.ObjectCapacity; @@ -212,7 +218,7 @@ namespace OpenSim.Region.Framework.Scenes // We're going to lie about the FPS because we've been lying since 2008. The actual FPS is currently // locked at a maximum of 11. Maybe at some point this can change so that we're not lying. - int reportedFPS = (int)(m_fps * m_fpsCorrectionFactor); + int reportedFPS = (int)(m_fps * m_reportedFpsCorrectionFactor); // save the reported value so there is something available for llGetRegionFPS lastReportedSimFPS = reportedFPS / statsUpdateFactor;