diff --git a/OpenSim/Region/Framework/Scenes/EventManager.cs b/OpenSim/Region/Framework/Scenes/EventManager.cs index eee5960a88..7916c42174 100644 --- a/OpenSim/Region/Framework/Scenes/EventManager.cs +++ b/OpenSim/Region/Framework/Scenes/EventManager.cs @@ -2458,6 +2458,7 @@ namespace OpenSim.Region.Framework.Scenes { foreach (Action d in handler.GetInvocationList()) { + m_log.InfoFormat("[EVENT MANAGER]: TriggerSceneShuttingDown invoque {0}", d.Method.Name.ToString()); try { d(s); @@ -2470,6 +2471,7 @@ namespace OpenSim.Region.Framework.Scenes } } } + m_log.Info("[EVENT MANAGER]: TriggerSceneShuttingDown done"); } public void TriggerOnRegionStarted(Scene scene) diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs index 05ce00ab31..649d54559e 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.cs @@ -1255,9 +1255,11 @@ namespace OpenSim.Region.Framework.Scenes // Stop all client threads. ForEachScenePresence(delegate(ScenePresence avatar) { avatar.ControllingClient.Close(); }); - m_log.Debug("[SCENE]: Persisting changed objects"); + m_log.Debug("[SCENE]: TriggerSceneShuttingDown"); EventManager.TriggerSceneShuttingDown(this); + m_log.Debug("[SCENE]: Persisting changed objects"); + EntityBase[] entities = GetEntities(); foreach (EntityBase entity in entities) { @@ -1267,10 +1269,12 @@ namespace OpenSim.Region.Framework.Scenes } } + m_log.Debug("[SCENE]: Graph close"); m_sceneGraph.Close(); if (PhysicsScene != null) { + m_log.Debug("[SCENE]: Dispose Physics"); PhysicsScene phys = PhysicsScene; // remove the physics engine from both Scene and SceneGraph PhysicsScene = null; @@ -1282,6 +1286,7 @@ namespace OpenSim.Region.Framework.Scenes m_log.WarnFormat("[SCENE]: Deregister from grid failed for region {0}", Name); // call the base class Close method. + m_log.Debug("[SCENE]: Base close"); base.Close(); } @@ -1317,6 +1322,9 @@ namespace OpenSim.Region.Framework.Scenes } // m_lastUpdate = Util.EnvironmentTickCount(); +// m_sceneGraph.PreparePhysicsSimulation(); + + m_heartbeatThread = Watchdog.StartThread( Heartbeat, string.Format("Heartbeat ({0})", RegionInfo.RegionName), ThreadPriority.Normal, false, false); diff --git a/OpenSim/Region/Physics/UbitOdePlugin/ODEMeshWorker.cs b/OpenSim/Region/Physics/UbitOdePlugin/ODEMeshWorker.cs index 73dd2fd49b..5030cec783 100644 --- a/OpenSim/Region/Physics/UbitOdePlugin/ODEMeshWorker.cs +++ b/OpenSim/Region/Physics/UbitOdePlugin/ODEMeshWorker.cs @@ -914,8 +914,9 @@ namespace OpenSim.Region.Physics.OdePlugin if (repData.pbs.SculptTexture != repData.assetID) return; - repData.pbs.SculptData = new byte[asset.Data.Length]; - asset.Data.CopyTo(repData.pbs.SculptData,0); +// repData.pbs.SculptData = new byte[asset.Data.Length]; +// asset.Data.CopyTo(repData.pbs.SculptData,0); + repData.pbs.SculptData = asset.Data; repData.meshState = MeshState.AssetOK; m_worker.AssetLoaded(repData); } diff --git a/OpenSim/Region/Physics/UbitOdePlugin/ODEPrim.cs b/OpenSim/Region/Physics/UbitOdePlugin/ODEPrim.cs index ce67cc469e..76e42d4417 100644 --- a/OpenSim/Region/Physics/UbitOdePlugin/ODEPrim.cs +++ b/OpenSim/Region/Physics/UbitOdePlugin/ODEPrim.cs @@ -1108,6 +1108,8 @@ namespace OpenSim.Region.Physics.OdePlugin ODEPhysRepData repData = _parent_scene.m_meshWorker.NewActorPhysRep(this, _pbs, _size, m_shapetype); primVolume = repData.volume; + m_OBB = repData.OBB; + m_OBBOffset = repData.OBBOffset; UpdatePrimBodyData(); } diff --git a/OpenSim/Region/Physics/UbitOdePlugin/OdeScene.cs b/OpenSim/Region/Physics/UbitOdePlugin/OdeScene.cs index b98f177e86..54bc29f2f8 100644 --- a/OpenSim/Region/Physics/UbitOdePlugin/OdeScene.cs +++ b/OpenSim/Region/Physics/UbitOdePlugin/OdeScene.cs @@ -1689,11 +1689,10 @@ namespace OpenSim.Region.Physics.OdePlugin /// public override float Simulate(float timeStep) { - DateTime now = DateTime.UtcNow; TimeSpan timedif = now - m_lastframe; - m_lastframe = now; timeStep = (float)timedif.TotalSeconds; + m_lastframe = now; // acumulate time so we can reduce error step_time += timeStep; @@ -1704,6 +1703,7 @@ namespace OpenSim.Region.Physics.OdePlugin if (framecount < 0) framecount = 0; + framecount++; int curphysiteractions; @@ -1714,9 +1714,8 @@ namespace OpenSim.Region.Physics.OdePlugin else curphysiteractions = m_physicsiterations; - int nodeframes = 0; - // checkThread(); + int nodeframes = 0; lock (SimulationLock) lock(OdeLock) @@ -1733,7 +1732,11 @@ namespace OpenSim.Region.Physics.OdePlugin d.WorldSetQuickStepNumIterations(world, curphysiteractions); - while (step_time > HalfOdeStep && nodeframes < 10) //limit number of steps so we don't say here for ever + int loopstartMS = Util.EnvironmentTickCount(); + int looptimeMS = 0; + + + while (step_time > HalfOdeStep) { try { @@ -1742,9 +1745,8 @@ namespace OpenSim.Region.Physics.OdePlugin if (ChangesQueue.Count > 0) { - int ttmpstart = Util.EnvironmentTickCount(); + int changestartMS = Util.EnvironmentTickCount(); int ttmp; - while (ChangesQueue.Dequeue(out item)) { if (item.actor != null) @@ -1762,7 +1764,7 @@ namespace OpenSim.Region.Physics.OdePlugin item.actor.Name, item.what.ToString()); } } - ttmp = Util.EnvironmentTickCountSubtract(ttmpstart); + ttmp = Util.EnvironmentTickCountSubtract(changestartMS); if (ttmp > 20) break; } @@ -1873,9 +1875,12 @@ namespace OpenSim.Region.Physics.OdePlugin // ode.dunlock(world); } - step_time -= ODE_STEPSIZE; nodeframes++; + + looptimeMS = Util.EnvironmentTickCountSubtract(loopstartMS); + if (looptimeMS > 100) + break; } lock (_badCharacter) @@ -1963,7 +1968,7 @@ namespace OpenSim.Region.Physics.OdePlugin // think time dilation as to do with dinamic step size that we dont' have // even so tell something to world - if (nodeframes < 10) // we did the requested loops + if (looptimeMS < 100) // we did the requested loops m_timeDilation = 1.0f; else if (step_time > 0) { @@ -1972,6 +1977,7 @@ namespace OpenSim.Region.Physics.OdePlugin m_timeDilation = 1; if (step_time > m_SkipFramesAtms) step_time = 0; + m_lastframe = DateTime.UtcNow; // skip also the time lost } } @@ -2344,7 +2350,7 @@ namespace OpenSim.Region.Physics.OdePlugin } } } - IntPtr HeightmapData = d.GeomHeightfieldDataCreate(); + IntPtr HeightmapData = d.GeomUbitTerrainDataCreate(); const int wrap = 0; float thickness = hfmin;