From d6250959597fceec30f1df6355970f385cfd4742 Mon Sep 17 00:00:00 2001 From: Justin Clarke Casey Date: Thu, 20 Nov 2008 18:28:30 +0000 Subject: * Allow physics dlls to be loaded separately, rather than just the contents of bin/Physics * This is primarily to see if not loading ODE in the unit tests will allow them to proceed, though the option of separate loading is probably a good thing in itself --- .../Environment/Scenes/Tests/SceneObjectTests.cs | 9 +++++ .../Environment/Scenes/Tests/SceneTestUtils.cs | 2 +- .../Region/Physics/Manager/PhysicsPluginManager.cs | 42 +++++++++++++++------- 3 files changed, 40 insertions(+), 13 deletions(-) (limited to 'OpenSim/Region') diff --git a/OpenSim/Region/Environment/Scenes/Tests/SceneObjectTests.cs b/OpenSim/Region/Environment/Scenes/Tests/SceneObjectTests.cs index 81d88e2..66ea59e 100644 --- a/OpenSim/Region/Environment/Scenes/Tests/SceneObjectTests.cs +++ b/OpenSim/Region/Environment/Scenes/Tests/SceneObjectTests.cs @@ -83,5 +83,14 @@ namespace OpenSim.Region.Environment.Scenes.Tests Assert.That(retrievedPart, Is.Null); } + + /// + /// Test removing an object + /// + public void TestRemoveSceneObjectAsync() + { + TestScene scene = SceneTestUtils.SetupScene(); + SceneObjectPart part = SceneTestUtils.AddSceneObject(scene); + } } } \ No newline at end of file diff --git a/OpenSim/Region/Environment/Scenes/Tests/SceneTestUtils.cs b/OpenSim/Region/Environment/Scenes/Tests/SceneTestUtils.cs index 1cdd32c..289bf87 100644 --- a/OpenSim/Region/Environment/Scenes/Tests/SceneTestUtils.cs +++ b/OpenSim/Region/Environment/Scenes/Tests/SceneTestUtils.cs @@ -63,7 +63,7 @@ namespace OpenSim.Region.Environment.Scenes.Tests testScene.LandChannel = new TestLandChannel(); PhysicsPluginManager physicsPluginManager = new PhysicsPluginManager(); - physicsPluginManager.LoadPlugins(); + physicsPluginManager.LoadPlugin("Physics/OpenSim.Region.Physics.BasicPhysicsPlugin.dll"); testScene.PhysicsScene = physicsPluginManager.GetPhysicsScene("basicphysics", "ZeroMesher", configSource); return testScene; diff --git a/OpenSim/Region/Physics/Manager/PhysicsPluginManager.cs b/OpenSim/Region/Physics/Manager/PhysicsPluginManager.cs index fc8f062..71fad02 100644 --- a/OpenSim/Region/Physics/Manager/PhysicsPluginManager.cs +++ b/OpenSim/Region/Physics/Manager/PhysicsPluginManager.cs @@ -44,10 +44,27 @@ namespace OpenSim.Region.Physics.Manager private Dictionary _PhysPlugins = new Dictionary(); private Dictionary _MeshPlugins = new Dictionary(); + /// + /// Constructor. + /// public PhysicsPluginManager() { + // Load "plugins", that are hard coded and not existing in form of an external lib, and hence always + // available + IMeshingPlugin plugHard; + plugHard = new ZeroMesherPlugin(); + _MeshPlugins.Add(plugHard.GetName(), plugHard); + + m_log.Info("[PHYSICS]: Added meshing engine: " + plugHard.GetName()); } + /// + /// Get a physics scene for the given physics engine and mesher. + /// + /// + /// + /// + /// public PhysicsScene GetPhysicsScene(string physEngineName, string meshEngineName, IConfigSource config) { if (String.IsNullOrEmpty(physEngineName)) @@ -86,14 +103,11 @@ namespace OpenSim.Region.Physics.Manager } } + /// + /// Load all built-in 'plugins' and those in the bin/Physics diretory + /// public void LoadPlugins() { - // Load "plugins", that are hard coded and not existing in form of an external lib - IMeshingPlugin plugHard; - plugHard = new ZeroMesherPlugin(); - _MeshPlugins.Add(plugHard.GetName(), plugHard); - m_log.Info("[PHYSICS]: Added meshing engine: " + plugHard.GetName()); - // And now walk all assemblies (DLLs effectively) and see if they are home // of a plugin that is of interest for us string path = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Physics"); @@ -101,11 +115,15 @@ namespace OpenSim.Region.Physics.Manager for (int i = 0; i < pluginFiles.Length; i++) { - AddPlugin(pluginFiles[i]); + LoadPlugin(pluginFiles[i]); } } - private void AddPlugin(string FileName) + /// + /// Load plugins from a dll at the given path + /// + /// + public void LoadPlugin(string dllPath) { // TODO / NOTE // The assembly named 'OpenSim.Region.Physics.BasicPhysicsPlugin' was loaded from @@ -120,11 +138,11 @@ namespace OpenSim.Region.Physics.Manager try { - pluginAssembly = Assembly.LoadFrom(FileName); + pluginAssembly = Assembly.LoadFrom(dllPath); } catch (Exception ex) { - m_log.Error("[PHYSICS]: Failed to load plugin from " + FileName, ex); + m_log.Error("[PHYSICS]: Failed to load plugin from " + dllPath, ex); } if (pluginAssembly != null) @@ -135,12 +153,12 @@ namespace OpenSim.Region.Physics.Manager } catch (ReflectionTypeLoadException ex) { - m_log.Error("[PHYSICS]: Failed to enumerate types in plugin from " + FileName + ": " + + m_log.Error("[PHYSICS]: Failed to enumerate types in plugin from " + dllPath + ": " + ex.LoaderExceptions[0].Message, ex); } catch (Exception ex) { - m_log.Error("[PHYSICS]: Failed to enumerate types in plugin from " + FileName, ex); + m_log.Error("[PHYSICS]: Failed to enumerate types in plugin from " + dllPath, ex); } if (types != null) -- cgit v1.1