From a85ff884d97c3ea56200a5070f66bc523b7c4ca3 Mon Sep 17 00:00:00 2001 From: Dan Lake Date: Sun, 30 Oct 2011 23:39:39 -0700 Subject: Experimental reorder of Heartbeat loop now simulates physics and sends updates to clients prior to sleep. Existing behavior was to sleep BEFORE sending updates. We found this patch reduced latency to clients by 1-2 heartbeat periods. --- OpenSim/Region/Framework/Scenes/Scene.cs | 56 +++++++++++++++----------------- 1 file changed, 27 insertions(+), 29 deletions(-) (limited to 'OpenSim/Region') diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs index ff05e95..fa8bf85 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.cs @@ -1230,8 +1230,32 @@ namespace OpenSim.Region.Framework.Scenes // m_log.DebugFormat("[SCENE]: Processing frame {0}", Frame); try - { - int tmpAgentMS = Util.EnvironmentTickCount(); + { + int tmpPhysicsMS2 = Util.EnvironmentTickCount(); + if ((Frame % m_update_physics == 0) && m_physics_enabled) + m_sceneGraph.UpdatePreparePhysics(); + physicsMS2 = Util.EnvironmentTickCountSubtract(tmpPhysicsMS2); + + // Apply any pending avatar force input to the avatar's velocity + int tmpAgentMS = Util.EnvironmentTickCount(); + if (Frame % m_update_entitymovement == 0) + 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 + int tmpPhysicsMS = Util.EnvironmentTickCount(); + if (Frame % m_update_physics == 0) + { + if (m_physics_enabled) + physicsFPS = m_sceneGraph.UpdatePhysics(MinFrameTime); + + if (SynchronizeScene != null) + SynchronizeScene(this); + } + physicsMS = Util.EnvironmentTickCountSubtract(tmpPhysicsMS); + + tmpAgentMS = Util.EnvironmentTickCount(); // Check if any objects have reached their targets CheckAtTargets(); @@ -1259,33 +1283,7 @@ 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(); - physicsMS2 = Util.EnvironmentTickCountSubtract(tmpPhysicsMS2); - - // 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 - int tmpPhysicsMS = Util.EnvironmentTickCount(); - if (Frame % m_update_physics == 0) - { - if (m_physics_enabled) - physicsFPS = m_sceneGraph.UpdatePhysics(MinFrameTime); - - if (SynchronizeScene != null) - SynchronizeScene(this); - } - physicsMS = Util.EnvironmentTickCountSubtract(tmpPhysicsMS); + agentMS += Util.EnvironmentTickCountSubtract(tmpAgentMS); // Delete temp-on-rez stuff if (Frame % m_update_temp_cleaning == 0 && !m_cleaningTemps) -- cgit v1.1