mirror of
https://github.com/opensim/opensim.git
synced 2026-08-06 01:06:30 +08:00
Merge branch 'master' of ssh://opensimulator.org/var/git/opensim
Conflicts: OpenSim/Region/Framework/Scenes/ScenePresence.cs
This commit is contained in:
@@ -137,8 +137,6 @@ namespace OpenSim.Region.Framework.Scenes
|
||||
protected IDialogModule m_dialogModule;
|
||||
protected IEntityTransferModule m_teleportModule;
|
||||
protected ICapabilitiesModule m_capsModule;
|
||||
// Central Update Loop
|
||||
protected int m_fps = 10;
|
||||
|
||||
/// <summary>
|
||||
/// Current scene frame number
|
||||
@@ -149,8 +147,20 @@ namespace OpenSim.Region.Framework.Scenes
|
||||
protected set;
|
||||
}
|
||||
|
||||
protected float m_timespan = 0.089f;
|
||||
protected DateTime m_lastupdate = DateTime.UtcNow;
|
||||
/// <summary>
|
||||
/// The minimum length of time in seconds that will be taken for a scene frame. If the frame takes less time then we
|
||||
/// will sleep for the remaining period.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// 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;
|
||||
|
||||
/// <summary>
|
||||
/// The time of the last frame update.
|
||||
/// </summary>
|
||||
protected DateTime m_lastFrameUpdate = DateTime.UtcNow;
|
||||
|
||||
// TODO: Possibly stop other classes being able to manipulate this directly.
|
||||
private SceneGraph m_sceneGraph;
|
||||
@@ -173,6 +183,7 @@ namespace OpenSim.Region.Framework.Scenes
|
||||
// private int m_update_land = 1;
|
||||
private int m_update_coarse_locations = 50;
|
||||
|
||||
private int agentMS;
|
||||
private int frameMS;
|
||||
private int physicsMS2;
|
||||
private int physicsMS;
|
||||
@@ -1211,17 +1222,20 @@ namespace OpenSim.Region.Framework.Scenes
|
||||
|
||||
public override void Update()
|
||||
{
|
||||
TimeSpan SinceLastFrame = DateTime.UtcNow - m_lastupdate;
|
||||
TimeSpan SinceLastFrame = DateTime.UtcNow - m_lastFrameUpdate;
|
||||
float physicsFPS = 0f;
|
||||
|
||||
int maintc = Util.EnvironmentTickCount();
|
||||
int tmpFrameMS = maintc;
|
||||
tempOnRezMS = eventMS = backupMS = terrainMS = landMS = 0;
|
||||
agentMS = tempOnRezMS = eventMS = backupMS = terrainMS = landMS = 0;
|
||||
|
||||
// TODO: ADD AGENT TIME HERE
|
||||
// Increment the frame counter
|
||||
++Frame;
|
||||
try
|
||||
{
|
||||
int tmpAgentMS = Util.EnvironmentTickCount();
|
||||
|
||||
// Check if any objects have reached their targets
|
||||
CheckAtTargets();
|
||||
|
||||
@@ -1248,6 +1262,8 @@ namespace OpenSim.Region.Framework.Scenes
|
||||
});
|
||||
}
|
||||
|
||||
agentMS = Util.EnvironmentTickCountSubtract(tmpAgentMS);
|
||||
|
||||
int tmpPhysicsMS2 = Util.EnvironmentTickCount();
|
||||
if ((Frame % m_update_physics == 0) && m_physics_enabled)
|
||||
m_sceneGraph.UpdatePreparePhysics();
|
||||
@@ -1255,7 +1271,11 @@ namespace OpenSim.Region.Framework.Scenes
|
||||
|
||||
// Apply any pending avatar force input to the avatar's velocity
|
||||
if (Frame % m_update_entitymovement == 0)
|
||||
{
|
||||
tmpAgentMS = Util.EnvironmentTickCount();
|
||||
m_sceneGraph.UpdateScenePresenceMovement();
|
||||
agentMS += Util.EnvironmentTickCountSubtract(tmpAgentMS);
|
||||
}
|
||||
|
||||
// Perform the main physics update. This will do the actual work of moving objects and avatars according to their
|
||||
// velocity
|
||||
@@ -1263,7 +1283,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_timespan));
|
||||
physicsFPS = m_sceneGraph.UpdatePhysics(Math.Max(SinceLastFrame.TotalSeconds, m_minFrameTimespan));
|
||||
if (SynchronizeScene != null)
|
||||
SynchronizeScene(this);
|
||||
}
|
||||
@@ -1320,6 +1340,7 @@ namespace OpenSim.Region.Framework.Scenes
|
||||
StatsReporter.SetObjects(m_sceneGraph.GetTotalObjectsCount());
|
||||
StatsReporter.SetActiveObjects(m_sceneGraph.GetActiveObjectsCount());
|
||||
StatsReporter.addFrameMS(frameMS);
|
||||
StatsReporter.addAgentMS(agentMS);
|
||||
StatsReporter.addPhysicsMS(physicsMS + physicsMS2);
|
||||
StatsReporter.addOtherMS(otherMS);
|
||||
StatsReporter.SetActiveScripts(m_sceneGraph.GetActiveScriptsCount());
|
||||
@@ -1379,11 +1400,11 @@ namespace OpenSim.Region.Framework.Scenes
|
||||
}
|
||||
finally
|
||||
{
|
||||
m_lastupdate = DateTime.UtcNow;
|
||||
m_lastFrameUpdate = DateTime.UtcNow;
|
||||
}
|
||||
|
||||
maintc = Util.EnvironmentTickCountSubtract(maintc);
|
||||
maintc = (int)(m_timespan * 1000) - maintc;
|
||||
maintc = (int)(m_minFrameTimespan * 1000) - maintc;
|
||||
|
||||
if (maintc > 0)
|
||||
Thread.Sleep(maintc);
|
||||
|
||||
@@ -166,6 +166,12 @@ namespace OpenSim.Region.Framework.Scenes
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Update the position of all the scene presences.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Called only from the main scene loop.
|
||||
/// </remarks>
|
||||
protected internal void UpdatePresences()
|
||||
{
|
||||
ForEachScenePresence(delegate(ScenePresence presence)
|
||||
@@ -174,6 +180,11 @@ namespace OpenSim.Region.Framework.Scenes
|
||||
});
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Perform a physics frame update.
|
||||
/// </summary>
|
||||
/// <param name="elapsed"></param>
|
||||
/// <returns></returns>
|
||||
protected internal float UpdatePhysics(double elapsed)
|
||||
{
|
||||
lock (m_syncRoot)
|
||||
|
||||
@@ -870,11 +870,7 @@ namespace OpenSim.Region.Framework.Scenes
|
||||
/// </summary>
|
||||
public void SendPrimUpdates()
|
||||
{
|
||||
m_perfMonMS = Util.EnvironmentTickCount();
|
||||
|
||||
SceneViewer.SendPrimUpdates();
|
||||
|
||||
m_scene.StatsReporter.AddAgentTime(Util.EnvironmentTickCountSubtract(m_perfMonMS));
|
||||
}
|
||||
|
||||
#region Status Methods
|
||||
@@ -1276,7 +1272,7 @@ namespace OpenSim.Region.Framework.Scenes
|
||||
// return;
|
||||
//}
|
||||
|
||||
m_perfMonMS = Util.EnvironmentTickCount();
|
||||
// m_perfMonMS = Util.EnvironmentTickCount();
|
||||
|
||||
++m_movementUpdateCount;
|
||||
if (m_movementUpdateCount < 1)
|
||||
@@ -1565,7 +1561,8 @@ namespace OpenSim.Region.Framework.Scenes
|
||||
|
||||
m_scene.EventManager.TriggerOnClientMovement(this);
|
||||
|
||||
m_scene.StatsReporter.AddAgentTime(Util.EnvironmentTickCountSubtract(m_perfMonMS));
|
||||
// It doesn't make sense to add this to frame stats as this update is processed indepedently of the scene loop
|
||||
// m_scene.StatsReporter.AddAgentTime(Util.EnvironmentTickCountSubtract(m_perfMonMS));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -2341,8 +2338,6 @@ namespace OpenSim.Region.Framework.Scenes
|
||||
/// <param name="vec">The vector in which to move. This is relative to the rotation argument</param>
|
||||
public void AddNewMovement(Vector3 vec)
|
||||
{
|
||||
m_perfMonMS = Util.EnvironmentTickCount();
|
||||
|
||||
Vector3 direc = vec * Rotation;
|
||||
direc.Normalize();
|
||||
|
||||
@@ -2379,8 +2374,6 @@ namespace OpenSim.Region.Framework.Scenes
|
||||
|
||||
// TODO: Add the force instead of only setting it to support multiple forces per frame?
|
||||
m_forceToApply = direc;
|
||||
|
||||
m_scene.StatsReporter.AddAgentTime(Util.EnvironmentTickCountSubtract(m_perfMonMS));
|
||||
}
|
||||
|
||||
#endregion
|
||||
@@ -2443,8 +2436,6 @@ namespace OpenSim.Region.Framework.Scenes
|
||||
// server.
|
||||
if (remoteClient.IsActive)
|
||||
{
|
||||
m_perfMonMS = Util.EnvironmentTickCount();
|
||||
|
||||
Vector3 pos = m_pos;
|
||||
pos.Z += Appearance.HipOffset;
|
||||
|
||||
@@ -2455,7 +2446,6 @@ namespace OpenSim.Region.Framework.Scenes
|
||||
PrimUpdateFlags.Position | PrimUpdateFlags.Rotation | PrimUpdateFlags.Velocity
|
||||
| PrimUpdateFlags.Acceleration | PrimUpdateFlags.AngularVelocity);
|
||||
|
||||
m_scene.StatsReporter.AddAgentTime(Util.EnvironmentTickCountSubtract(m_perfMonMS));
|
||||
m_scene.StatsReporter.AddAgentUpdates(1);
|
||||
}
|
||||
}
|
||||
@@ -2496,14 +2486,11 @@ namespace OpenSim.Region.Framework.Scenes
|
||||
|| Math.Abs(distanceError) > distanceErrorThreshold
|
||||
|| velocidyDiff > 0.01f) // did velocity change from last update?
|
||||
{
|
||||
m_perfMonMS = currentTick;
|
||||
lastVelocitySentToAllClients = Velocity;
|
||||
lastTerseUpdateToAllClientsTick = currentTick;
|
||||
lastPositionSentToAllClients = OffsetPosition;
|
||||
|
||||
m_scene.ForEachClient(SendTerseUpdateToClient);
|
||||
|
||||
m_scene.StatsReporter.AddAgentTime(Util.EnvironmentTickCountSubtract(m_perfMonMS));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2524,9 +2511,7 @@ namespace OpenSim.Region.Framework.Scenes
|
||||
|
||||
public void SendCoarseLocationsDefault(UUID sceneId, ScenePresence p, List<Vector3> coarseLocations, List<UUID> avatarUUIDs)
|
||||
{
|
||||
m_perfMonMS = Util.EnvironmentTickCount();
|
||||
ControllingClient.SendCoarseLocationUpdate(avatarUUIDs, coarseLocations);
|
||||
m_scene.StatsReporter.AddAgentTime(Util.EnvironmentTickCountSubtract(m_perfMonMS));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -2587,8 +2572,6 @@ namespace OpenSim.Region.Framework.Scenes
|
||||
m_log.Warn("[SCENE PRESENCE] attempt to send avatar data from a child agent");
|
||||
return;
|
||||
}
|
||||
|
||||
m_perfMonMS = Util.EnvironmentTickCount();
|
||||
|
||||
int count = 0;
|
||||
m_scene.ForEachScenePresence(delegate(ScenePresence scenePresence)
|
||||
@@ -2598,7 +2581,6 @@ namespace OpenSim.Region.Framework.Scenes
|
||||
});
|
||||
|
||||
m_scene.StatsReporter.AddAgentUpdates(count);
|
||||
m_scene.StatsReporter.AddAgentTime(Util.EnvironmentTickCountSubtract(m_perfMonMS));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -2607,8 +2589,6 @@ namespace OpenSim.Region.Framework.Scenes
|
||||
/// </summary>
|
||||
public void SendOtherAgentsAvatarDataToMe()
|
||||
{
|
||||
m_perfMonMS = Util.EnvironmentTickCount();
|
||||
|
||||
int count = 0;
|
||||
m_scene.ForEachScenePresence(delegate(ScenePresence scenePresence)
|
||||
{
|
||||
@@ -2625,7 +2605,6 @@ namespace OpenSim.Region.Framework.Scenes
|
||||
});
|
||||
|
||||
m_scene.StatsReporter.AddAgentUpdates(count);
|
||||
m_scene.StatsReporter.AddAgentTime(Util.EnvironmentTickCountSubtract(m_perfMonMS));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -2654,8 +2633,6 @@ namespace OpenSim.Region.Framework.Scenes
|
||||
m_log.Warn("[SCENE PRESENCE] attempt to send avatar data from a child agent");
|
||||
return;
|
||||
}
|
||||
|
||||
m_perfMonMS = Util.EnvironmentTickCount();
|
||||
|
||||
int count = 0;
|
||||
m_scene.ForEachScenePresence(delegate(ScenePresence scenePresence)
|
||||
@@ -2668,7 +2645,6 @@ namespace OpenSim.Region.Framework.Scenes
|
||||
});
|
||||
|
||||
m_scene.StatsReporter.AddAgentUpdates(count);
|
||||
m_scene.StatsReporter.AddAgentTime(Util.EnvironmentTickCountSubtract(m_perfMonMS));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -2678,7 +2654,6 @@ namespace OpenSim.Region.Framework.Scenes
|
||||
public void SendOtherAgentsAppearanceToMe()
|
||||
{
|
||||
//m_log.DebugFormat("[SCENE PRESENCE] SendOtherAgentsAppearanceToMe: {0} ({1})", Name, UUID);
|
||||
m_perfMonMS = Util.EnvironmentTickCount();
|
||||
|
||||
int count = 0;
|
||||
m_scene.ForEachScenePresence(delegate(ScenePresence scenePresence)
|
||||
@@ -2696,7 +2671,6 @@ namespace OpenSim.Region.Framework.Scenes
|
||||
});
|
||||
|
||||
m_scene.StatsReporter.AddAgentUpdates(count);
|
||||
m_scene.StatsReporter.AddAgentTime(Util.EnvironmentTickCountSubtract(m_perfMonMS));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -37,6 +37,9 @@ namespace OpenSim.Region.Framework.Scenes
|
||||
{
|
||||
public class SimStatsReporter
|
||||
{
|
||||
// private static readonly log4net.ILog m_log
|
||||
// = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
|
||||
|
||||
public delegate void SendStatResult(SimStats stats);
|
||||
|
||||
public delegate void YourStatsAreWrong();
|
||||
@@ -165,18 +168,9 @@ namespace OpenSim.Region.Framework.Scenes
|
||||
|
||||
#region various statistic googly moogly
|
||||
|
||||
// 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;
|
||||
lastReportedSimFPS = (float)m_fps / statsUpdateFactor;
|
||||
|
||||
//if (simfps > 45)
|
||||
//simfps = simfps - (simfps - 45);
|
||||
//if (simfps < 0)
|
||||
//simfps = 0;
|
||||
|
||||
//
|
||||
float physfps = ((m_pfps / 1000));
|
||||
|
||||
//if (physfps > 600)
|
||||
@@ -197,7 +191,7 @@ namespace OpenSim.Region.Framework.Scenes
|
||||
// 'statsUpdateFactor' is how often stats packets are sent in seconds. Used below to change
|
||||
// values to X-per-second values.
|
||||
|
||||
for (int i = 0; i<21;i++)
|
||||
for (int i = 0; i < 21; i++)
|
||||
{
|
||||
sb[i] = new SimStatsPacket.StatBlock();
|
||||
}
|
||||
@@ -206,7 +200,7 @@ namespace OpenSim.Region.Framework.Scenes
|
||||
sb[0].StatValue = (Single.IsNaN(m_timeDilation)) ? 0.1f : m_timeDilation ; //((((m_timeDilation + (0.10f * statsUpdateFactor)) /10) / statsUpdateFactor));
|
||||
|
||||
sb[1].StatID = (uint) Stats.SimFPS;
|
||||
sb[1].StatValue = simfps/statsUpdateFactor;
|
||||
sb[1].StatValue = m_fps/statsUpdateFactor;
|
||||
|
||||
sb[2].StatID = (uint) Stats.PhysicsFPS;
|
||||
sb[2].StatValue = physfps / statsUpdateFactor;
|
||||
@@ -272,7 +266,8 @@ namespace OpenSim.Region.Framework.Scenes
|
||||
|
||||
SimStats simStats
|
||||
= new SimStats(
|
||||
ReportingRegion.RegionLocX, ReportingRegion.RegionLocY, regionFlags, (uint)m_objectCapacity, rb, sb, m_scene.RegionInfo.originRegionID);
|
||||
ReportingRegion.RegionLocX, ReportingRegion.RegionLocY, regionFlags, (uint)m_objectCapacity,
|
||||
rb, sb, m_scene.RegionInfo.originRegionID);
|
||||
|
||||
handlerSendStatResult = OnSendStatsResult;
|
||||
if (handlerSendStatResult != null)
|
||||
@@ -395,30 +390,32 @@ namespace OpenSim.Region.Framework.Scenes
|
||||
{
|
||||
m_frameMS += ms;
|
||||
}
|
||||
|
||||
public void addNetMS(int ms)
|
||||
{
|
||||
m_netMS += ms;
|
||||
}
|
||||
|
||||
public void addAgentMS(int ms)
|
||||
{
|
||||
m_agentMS += ms;
|
||||
}
|
||||
|
||||
public void addPhysicsMS(int ms)
|
||||
{
|
||||
m_physicsMS += ms;
|
||||
}
|
||||
|
||||
public void addImageMS(int ms)
|
||||
{
|
||||
m_imageMS += ms;
|
||||
}
|
||||
|
||||
public void addOtherMS(int ms)
|
||||
{
|
||||
m_otherMS += ms;
|
||||
}
|
||||
|
||||
// private static readonly log4net.ILog m_log
|
||||
// = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
|
||||
|
||||
public void AddPendingDownloads(int count)
|
||||
{
|
||||
m_pendingDownloads += count;
|
||||
@@ -455,12 +452,6 @@ namespace OpenSim.Region.Framework.Scenes
|
||||
AddOutPackets(outPackets);
|
||||
AddunAckedBytes(unAckedBytes);
|
||||
}
|
||||
|
||||
public void AddAgentTime(int ms)
|
||||
{
|
||||
addFrameMS(ms);
|
||||
addAgentMS(ms);
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user