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
This commit is contained in:
Justin Clark-Casey (justincc)
2011-10-13 22:07:55 +01:00
parent ceb326284e
commit a6fa15e8b6
2 changed files with 13 additions and 6 deletions

View File

@@ -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).
/// </remarks>
protected float m_minFrameTimespan = 0.089f;
public float MinFrameTime { get; private set; }
/// <summary>
/// The time of the last frame update.
@@ -533,6 +533,7 @@ namespace OpenSim.Region.Framework.Scenes
bool SeeIntoRegionFromNeighbor, IConfigSource config, string simulatorVersion)
{
m_config = config;
MinFrameTime = 0.089f;
Random random = new Random();
@@ -1268,7 +1269,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);
}
@@ -1389,7 +1390,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);

View File

@@ -106,6 +106,11 @@ namespace OpenSim.Region.Framework.Scenes
private float m_timeDilation = 0;
private int m_fps = 0;
/// <summary>
/// Our nominal fps target, as expected in fps stats when a sim is running normally.
/// </summary>
private float m_nominalReportedFps = 55;
/// <summary>
/// Parameter to adjust reported scene fps
/// </summary>
@@ -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.
/// </remarks>
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;