From f603e57e9ae9d9b7e3bf6b35924d99292cf6de43 Mon Sep 17 00:00:00 2001 From: Teravus Ovares Date: Mon, 11 Feb 2008 22:54:51 +0000 Subject: * Added PhysicsScene.Dispose() * In ODE, disposing of all of the ODE objects and the ODE World to reclaim memory when the simulator restarts. --- OpenSim/Region/Environment/Scenes/Scene.cs | 5 +++++ .../Physics/BasicPhysicsPlugin/BasicPhysicsPlugin.cs | 6 +++++- .../Region/Physics/BulletXPlugin/BulletXPlugin.cs | 3 +++ OpenSim/Region/Physics/Manager/PhysicsScene.cs | 6 ++++++ OpenSim/Region/Physics/OdePlugin/OdePlugin.cs | 20 ++++++++++++++++++++ OpenSim/Region/Physics/POSPlugin/POSPlugin.cs | 3 +++ OpenSim/Region/Physics/PhysXPlugin/PhysXPlugin.cs | 3 +++ 7 files changed, 45 insertions(+), 1 deletion(-) diff --git a/OpenSim/Region/Environment/Scenes/Scene.cs b/OpenSim/Region/Environment/Scenes/Scene.cs index 88cda40..6b4f377 100644 --- a/OpenSim/Region/Environment/Scenes/Scene.cs +++ b/OpenSim/Region/Environment/Scenes/Scene.cs @@ -472,6 +472,11 @@ namespace OpenSim.Region.Environment.Scenes // This causes the region to restart immediatley. public void RestartNow() { + if (PhysicsScene != null) + { + PhysicsScene.Dispose(); + } + m_log.Error("[REGION]: Closing"); Close(); m_log.Error("[REGION]: Firing Region Restart Message"); diff --git a/OpenSim/Region/Physics/BasicPhysicsPlugin/BasicPhysicsPlugin.cs b/OpenSim/Region/Physics/BasicPhysicsPlugin/BasicPhysicsPlugin.cs index ff157d7..13b3f1a 100644 --- a/OpenSim/Region/Physics/BasicPhysicsPlugin/BasicPhysicsPlugin.cs +++ b/OpenSim/Region/Physics/BasicPhysicsPlugin/BasicPhysicsPlugin.cs @@ -69,12 +69,16 @@ namespace OpenSim.Region.Physics.BasicPhysicsPlugin public BasicScene() { } - + public override void Initialise(IMesher meshmerizer) { // Does nothing right now } + public override void Dispose() + { + + } public override PhysicsActor AddAvatar(string avName, PhysicsVector position) { BasicActor act = new BasicActor(); diff --git a/OpenSim/Region/Physics/BulletXPlugin/BulletXPlugin.cs b/OpenSim/Region/Physics/BulletXPlugin/BulletXPlugin.cs index 27ae490..fb32f93 100644 --- a/OpenSim/Region/Physics/BulletXPlugin/BulletXPlugin.cs +++ b/OpenSim/Region/Physics/BulletXPlugin/BulletXPlugin.cs @@ -409,7 +409,10 @@ namespace OpenSim.Region.Physics.BulletXPlugin mesher = meshmerizer; } + public override void Dispose() + { + } public override PhysicsActor AddAvatar(string avName, PhysicsVector position) { PhysicsVector pos = new PhysicsVector(); diff --git a/OpenSim/Region/Physics/Manager/PhysicsScene.cs b/OpenSim/Region/Physics/Manager/PhysicsScene.cs index 00c0ff1..5f08898 100644 --- a/OpenSim/Region/Physics/Manager/PhysicsScene.cs +++ b/OpenSim/Region/Physics/Manager/PhysicsScene.cs @@ -81,6 +81,8 @@ namespace OpenSim.Region.Physics.Manager public abstract void DeleteTerrain(); + public abstract void Dispose(); + public abstract bool IsThreaded { get; } private class NullPhysicsScene : PhysicsScene @@ -157,6 +159,10 @@ namespace OpenSim.Region.Physics.Manager { get { return false; } } + public override void Dispose() + { + + } } } } \ No newline at end of file diff --git a/OpenSim/Region/Physics/OdePlugin/OdePlugin.cs b/OpenSim/Region/Physics/OdePlugin/OdePlugin.cs index 2b3d186..e58984b 100644 --- a/OpenSim/Region/Physics/OdePlugin/OdePlugin.cs +++ b/OpenSim/Region/Physics/OdePlugin/OdePlugin.cs @@ -73,6 +73,8 @@ namespace OpenSim.Region.Physics.OdePlugin public void Dispose() { + + d.CloseODE(); } } @@ -1509,5 +1511,23 @@ namespace OpenSim.Region.Physics.OdePlugin public override void DeleteTerrain() { } + public override void Dispose() + { + lock (OdeLock) + { + + foreach (OdePrim prm in _prims) + { + RemovePrim(prm); + } + + foreach (OdeCharacter act in _characters) + { + RemoveAvatar(act); + } + d.WorldDestroy(world); + //d.CloseODE(); + } + } } } diff --git a/OpenSim/Region/Physics/POSPlugin/POSPlugin.cs b/OpenSim/Region/Physics/POSPlugin/POSPlugin.cs index 2b07553..079e66a 100644 --- a/OpenSim/Region/Physics/POSPlugin/POSPlugin.cs +++ b/OpenSim/Region/Physics/POSPlugin/POSPlugin.cs @@ -77,7 +77,10 @@ namespace OpenSim.Region.Physics.POSPlugin { // Does nothing right now } + public override void Dispose() + { + } public override PhysicsActor AddAvatar(string avName, PhysicsVector position) { POSCharacter act = new POSCharacter(); diff --git a/OpenSim/Region/Physics/PhysXPlugin/PhysXPlugin.cs b/OpenSim/Region/Physics/PhysXPlugin/PhysXPlugin.cs index 71bd94e..509bdfa 100644 --- a/OpenSim/Region/Physics/PhysXPlugin/PhysXPlugin.cs +++ b/OpenSim/Region/Physics/PhysXPlugin/PhysXPlugin.cs @@ -88,7 +88,10 @@ namespace OpenSim.Region.Physics.PhysXPlugin { // Does nothing right now } + public override void Dispose() + { + } public override PhysicsActor AddAvatar(string avName, PhysicsVector position) { -- cgit v1.1