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 --- .../Region/Physics/Manager/PhysicsPluginManager.cs | 42 +++++++++++++++------- 1 file changed, 30 insertions(+), 12 deletions(-) (limited to 'OpenSim/Region/Physics') 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