From 67892343350a8af916ec4c16d341ad843550d54e Mon Sep 17 00:00:00 2001 From: Justin Clarke Casey Date: Thu, 16 Oct 2008 13:17:31 +0000 Subject: [PATCH] * Apply http://opensimulator.org/mantis/view.php?id=2405 * Implement llGetRegionFPS() * Thanks idb --- OpenSim/Region/Environment/Scenes/Scene.cs | 8 ++++++++ .../Region/Environment/Scenes/SimStatsReporter.cs | 12 ++++++++++++ .../Shared/Api/Implementation/LSL_Api.cs | 6 ++++-- 3 files changed, 24 insertions(+), 2 deletions(-) diff --git a/OpenSim/Region/Environment/Scenes/Scene.cs b/OpenSim/Region/Environment/Scenes/Scene.cs index e95b1d7a28..299d0da1ae 100644 --- a/OpenSim/Region/Environment/Scenes/Scene.cs +++ b/OpenSim/Region/Environment/Scenes/Scene.cs @@ -196,6 +196,14 @@ namespace OpenSim.Region.Environment.Scenes get { return m_timedilation; } } + /// + /// This is for llGetRegionFPS + /// + public float SimulatorFPS + { + get { return m_statsReporter.getLastReportedSimFPS(); } + } + public int TimePhase { get { return m_timePhase; } diff --git a/OpenSim/Region/Environment/Scenes/SimStatsReporter.cs b/OpenSim/Region/Environment/Scenes/SimStatsReporter.cs index 4c9c59d385..70287fc341 100644 --- a/OpenSim/Region/Environment/Scenes/SimStatsReporter.cs +++ b/OpenSim/Region/Environment/Scenes/SimStatsReporter.cs @@ -73,6 +73,8 @@ namespace OpenSim.Region.Environment.Scenes private float statsUpdateFactor = 0; private float m_timeDilation = 0; private int m_fps = 0; + // saved last reported value so there is something available for llGetRegionFPS + private float lastReportedSimFPS = 0; private float m_pfps = 0; private int m_agentUpdates = 0; @@ -155,6 +157,8 @@ namespace OpenSim.Region.Environment.Scenes // Our FPS is actually 10fps, so multiplying by 5 to get the amount that people expect there // 0-50 is pretty close to 0-45 float simfps = (int) ((m_fps * 5)); + // save the reported value so there is something available for llGetRegionFPS + lastReportedSimFPS = (float)simfps / statsUpdateFactor; //if (simfps > 45) //simfps = simfps - (simfps - 45); @@ -397,6 +401,14 @@ namespace OpenSim.Region.Environment.Scenes objectCapacity = objects; } + /// + /// This is for llGetRegionFPS + /// + public float getLastReportedSimFPS() + { + return lastReportedSimFPS; + } + #endregion } } diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs index 7d3badb9b5..9df318c434 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs @@ -4842,11 +4842,13 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api return (double)World.TimeDilation; } + /// + /// Returns the value reported in the client Statistics window + /// public LSL_Float llGetRegionFPS() { m_host.AddScriptLPS(1); - //TODO: return actual FPS - return 10.0f; + return World.SimulatorFPS; } /* particle system rules should be coming into this routine as doubles, that is