From 8b16131206818329e973faec3a9861fca37f0073 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Thu, 13 Jul 2017 20:21:18 +0100 Subject: add Util.GetTimeStamp() that returns the stamp in seconds; use it on ubOde; separed land collsions dispatch from the others... --- OpenSim/Region/PhysicsModules/ubOde/ODEScene.cs | 34 +++++++++++++------------ 1 file changed, 18 insertions(+), 16 deletions(-) (limited to 'OpenSim/Region/PhysicsModules/ubOde/ODEScene.cs') diff --git a/OpenSim/Region/PhysicsModules/ubOde/ODEScene.cs b/OpenSim/Region/PhysicsModules/ubOde/ODEScene.cs index 5758e0a..004ee7f 100644 --- a/OpenSim/Region/PhysicsModules/ubOde/ODEScene.cs +++ b/OpenSim/Region/PhysicsModules/ubOde/ODEScene.cs @@ -203,8 +203,8 @@ namespace OpenSim.Region.PhysicsModule.ubOde private float metersInSpace = 25.6f; private float m_timeDilation = 1.0f; - private DateTime m_lastframe; - private DateTime m_lastMeshExpire; + private double m_lastframe; + private double m_lastMeshExpire; public float gravityx = 0f; public float gravityy = 0f; @@ -629,8 +629,9 @@ namespace OpenSim.Region.PhysicsModule.ubOde staticPrimspaceOffRegion[i] = newspace; } - m_lastframe = DateTime.UtcNow; + m_lastframe = Util.GetTimeStamp(); m_lastMeshExpire = m_lastframe; + step_time = -1; } internal void waitForSpaceUnlock(IntPtr space) @@ -1625,6 +1626,8 @@ namespace OpenSim.Region.PhysicsModule.ubOde } m_log.InfoFormat("[ubOde] {0} prim actors loaded",_prims.Count); } + m_lastframe = Util.GetTimeStamp() + 0.5; + step_time = -0.5f; } /// @@ -1638,13 +1641,12 @@ namespace OpenSim.Region.PhysicsModule.ubOde /// public override float Simulate(float reqTimeStep) { - DateTime now = DateTime.UtcNow; - TimeSpan timedif = now - m_lastframe; - float timeStep = (float)timedif.TotalSeconds; + double now = Util.GetTimeStamp(); + double timeStep = now - m_lastframe; m_lastframe = now; // acumulate time so we can reduce error - step_time += timeStep; + step_time += (float)timeStep; if (step_time < HalfOdeStep) return 0; @@ -1853,14 +1855,6 @@ namespace OpenSim.Region.PhysicsModule.ubOde } } - timedif = now - m_lastMeshExpire; - - if (timedif.Seconds > 10) - { - mesher.ExpireReleaseMeshs(); - m_lastMeshExpire = now; - } - // information block for in debug breakpoint only /* int ntopactivegeoms = d.SpaceGetNumGeoms(ActiveSpace); @@ -1940,7 +1934,7 @@ namespace OpenSim.Region.PhysicsModule.ubOde // if we lag too much skip frames m_timeDilation = 0.0f; step_time = 0; - m_lastframe = DateTime.UtcNow; // skip also the time lost + m_lastframe = Util.GetTimeStamp(); // skip also the time lost } else { @@ -1948,6 +1942,14 @@ namespace OpenSim.Region.PhysicsModule.ubOde if (m_timeDilation > 1) m_timeDilation = 1; } + + if (m_timeDilation == 1 && now - m_lastMeshExpire > 30) + { + mesher.ExpireReleaseMeshs(); + m_lastMeshExpire = now; + } + + } return fps; -- cgit v1.1