diff options
Diffstat (limited to 'OpenSim/Region/Framework/Scenes/Scene.cs')
-rw-r--r-- | OpenSim/Region/Framework/Scenes/Scene.cs | 39 |
1 files changed, 30 insertions, 9 deletions
diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs index 29a54e8..b1755ac 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.cs | |||
@@ -137,8 +137,6 @@ namespace OpenSim.Region.Framework.Scenes | |||
137 | protected IDialogModule m_dialogModule; | 137 | protected IDialogModule m_dialogModule; |
138 | protected IEntityTransferModule m_teleportModule; | 138 | protected IEntityTransferModule m_teleportModule; |
139 | protected ICapabilitiesModule m_capsModule; | 139 | protected ICapabilitiesModule m_capsModule; |
140 | // Central Update Loop | ||
141 | protected int m_fps = 10; | ||
142 | 140 | ||
143 | /// <summary> | 141 | /// <summary> |
144 | /// Current scene frame number | 142 | /// Current scene frame number |
@@ -149,8 +147,20 @@ namespace OpenSim.Region.Framework.Scenes | |||
149 | protected set; | 147 | protected set; |
150 | } | 148 | } |
151 | 149 | ||
152 | protected float m_timespan = 0.089f; | 150 | /// <summary> |
153 | protected DateTime m_lastupdate = DateTime.UtcNow; | 151 | /// The minimum length of time in seconds that will be taken for a scene frame. If the frame takes less time then we |
152 | /// will sleep for the remaining period. | ||
153 | /// </summary> | ||
154 | /// <remarks> | ||
155 | /// One can tweak this number to experiment. One current effect of reducing it is to make avatar animations | ||
156 | /// occur too quickly (viewer 1) or with even more slide (viewer 2). | ||
157 | /// </remarks> | ||
158 | protected float m_minFrameTimespan = 0.089f; | ||
159 | |||
160 | /// <summary> | ||
161 | /// The time of the last frame update. | ||
162 | /// </summary> | ||
163 | protected DateTime m_lastFrameUpdate = DateTime.UtcNow; | ||
154 | 164 | ||
155 | // TODO: Possibly stop other classes being able to manipulate this directly. | 165 | // TODO: Possibly stop other classes being able to manipulate this directly. |
156 | private SceneGraph m_sceneGraph; | 166 | private SceneGraph m_sceneGraph; |
@@ -173,6 +183,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
173 | // private int m_update_land = 1; | 183 | // private int m_update_land = 1; |
174 | private int m_update_coarse_locations = 50; | 184 | private int m_update_coarse_locations = 50; |
175 | 185 | ||
186 | private int agentMS; | ||
176 | private int frameMS; | 187 | private int frameMS; |
177 | private int physicsMS2; | 188 | private int physicsMS2; |
178 | private int physicsMS; | 189 | private int physicsMS; |
@@ -1211,17 +1222,20 @@ namespace OpenSim.Region.Framework.Scenes | |||
1211 | 1222 | ||
1212 | public override void Update() | 1223 | public override void Update() |
1213 | { | 1224 | { |
1214 | TimeSpan SinceLastFrame = DateTime.UtcNow - m_lastupdate; | 1225 | TimeSpan SinceLastFrame = DateTime.UtcNow - m_lastFrameUpdate; |
1215 | float physicsFPS = 0f; | 1226 | float physicsFPS = 0f; |
1216 | 1227 | ||
1217 | int maintc = Util.EnvironmentTickCount(); | 1228 | int maintc = Util.EnvironmentTickCount(); |
1218 | int tmpFrameMS = maintc; | 1229 | int tmpFrameMS = maintc; |
1219 | tempOnRezMS = eventMS = backupMS = terrainMS = landMS = 0; | 1230 | agentMS = tempOnRezMS = eventMS = backupMS = terrainMS = landMS = 0; |
1220 | 1231 | ||
1232 | // TODO: ADD AGENT TIME HERE | ||
1221 | // Increment the frame counter | 1233 | // Increment the frame counter |
1222 | ++Frame; | 1234 | ++Frame; |
1223 | try | 1235 | try |
1224 | { | 1236 | { |
1237 | int tmpAgentMS = Util.EnvironmentTickCount(); | ||
1238 | |||
1225 | // Check if any objects have reached their targets | 1239 | // Check if any objects have reached their targets |
1226 | CheckAtTargets(); | 1240 | CheckAtTargets(); |
1227 | 1241 | ||
@@ -1248,6 +1262,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
1248 | }); | 1262 | }); |
1249 | } | 1263 | } |
1250 | 1264 | ||
1265 | agentMS = Util.EnvironmentTickCountSubtract(tmpAgentMS); | ||
1266 | |||
1251 | int tmpPhysicsMS2 = Util.EnvironmentTickCount(); | 1267 | int tmpPhysicsMS2 = Util.EnvironmentTickCount(); |
1252 | if ((Frame % m_update_physics == 0) && m_physics_enabled) | 1268 | if ((Frame % m_update_physics == 0) && m_physics_enabled) |
1253 | m_sceneGraph.UpdatePreparePhysics(); | 1269 | m_sceneGraph.UpdatePreparePhysics(); |
@@ -1255,7 +1271,11 @@ namespace OpenSim.Region.Framework.Scenes | |||
1255 | 1271 | ||
1256 | // Apply any pending avatar force input to the avatar's velocity | 1272 | // Apply any pending avatar force input to the avatar's velocity |
1257 | if (Frame % m_update_entitymovement == 0) | 1273 | if (Frame % m_update_entitymovement == 0) |
1274 | { | ||
1275 | tmpAgentMS = Util.EnvironmentTickCount(); | ||
1258 | m_sceneGraph.UpdateScenePresenceMovement(); | 1276 | m_sceneGraph.UpdateScenePresenceMovement(); |
1277 | agentMS += Util.EnvironmentTickCountSubtract(tmpAgentMS); | ||
1278 | } | ||
1259 | 1279 | ||
1260 | // Perform the main physics update. This will do the actual work of moving objects and avatars according to their | 1280 | // Perform the main physics update. This will do the actual work of moving objects and avatars according to their |
1261 | // velocity | 1281 | // velocity |
@@ -1263,7 +1283,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
1263 | if (Frame % m_update_physics == 0) | 1283 | if (Frame % m_update_physics == 0) |
1264 | { | 1284 | { |
1265 | if (m_physics_enabled) | 1285 | if (m_physics_enabled) |
1266 | physicsFPS = m_sceneGraph.UpdatePhysics(Math.Max(SinceLastFrame.TotalSeconds, m_timespan)); | 1286 | physicsFPS = m_sceneGraph.UpdatePhysics(Math.Max(SinceLastFrame.TotalSeconds, m_minFrameTimespan)); |
1267 | if (SynchronizeScene != null) | 1287 | if (SynchronizeScene != null) |
1268 | SynchronizeScene(this); | 1288 | SynchronizeScene(this); |
1269 | } | 1289 | } |
@@ -1320,6 +1340,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
1320 | StatsReporter.SetObjects(m_sceneGraph.GetTotalObjectsCount()); | 1340 | StatsReporter.SetObjects(m_sceneGraph.GetTotalObjectsCount()); |
1321 | StatsReporter.SetActiveObjects(m_sceneGraph.GetActiveObjectsCount()); | 1341 | StatsReporter.SetActiveObjects(m_sceneGraph.GetActiveObjectsCount()); |
1322 | StatsReporter.addFrameMS(frameMS); | 1342 | StatsReporter.addFrameMS(frameMS); |
1343 | StatsReporter.addAgentMS(agentMS); | ||
1323 | StatsReporter.addPhysicsMS(physicsMS + physicsMS2); | 1344 | StatsReporter.addPhysicsMS(physicsMS + physicsMS2); |
1324 | StatsReporter.addOtherMS(otherMS); | 1345 | StatsReporter.addOtherMS(otherMS); |
1325 | StatsReporter.SetActiveScripts(m_sceneGraph.GetActiveScriptsCount()); | 1346 | StatsReporter.SetActiveScripts(m_sceneGraph.GetActiveScriptsCount()); |
@@ -1379,11 +1400,11 @@ namespace OpenSim.Region.Framework.Scenes | |||
1379 | } | 1400 | } |
1380 | finally | 1401 | finally |
1381 | { | 1402 | { |
1382 | m_lastupdate = DateTime.UtcNow; | 1403 | m_lastFrameUpdate = DateTime.UtcNow; |
1383 | } | 1404 | } |
1384 | 1405 | ||
1385 | maintc = Util.EnvironmentTickCountSubtract(maintc); | 1406 | maintc = Util.EnvironmentTickCountSubtract(maintc); |
1386 | maintc = (int)(m_timespan * 1000) - maintc; | 1407 | maintc = (int)(m_minFrameTimespan * 1000) - maintc; |
1387 | 1408 | ||
1388 | if (maintc > 0) | 1409 | if (maintc > 0) |
1389 | Thread.Sleep(maintc); | 1410 | Thread.Sleep(maintc); |