From cb07ba0d68eeb57bae1cb60f387483ff720cc29d Mon Sep 17 00:00:00 2001 From: Teravus Ovares Date: Sat, 10 Nov 2007 19:13:52 +0000 Subject: * Moves the Meshmerizer to a separate plugin * Experimental. Linux Prebuild needs testing. * One more update after this to remove the ODEMeshing directory.... --- .../Region/Physics/Manager/PhysicsPluginManager.cs | 67 +++++++++++++++++----- 1 file changed, 54 insertions(+), 13 deletions(-) (limited to 'OpenSim/Region/Physics/Manager/PhysicsPluginManager.cs') diff --git a/OpenSim/Region/Physics/Manager/PhysicsPluginManager.cs b/OpenSim/Region/Physics/Manager/PhysicsPluginManager.cs index 09ebf29..47c8ae0 100644 --- a/OpenSim/Region/Physics/Manager/PhysicsPluginManager.cs +++ b/OpenSim/Region/Physics/Manager/PhysicsPluginManager.cs @@ -30,6 +30,7 @@ using System.Collections.Generic; using System.IO; using System.Reflection; using OpenSim.Framework.Console; +using Nini.Config; namespace OpenSim.Region.Physics.Manager { @@ -38,28 +39,50 @@ namespace OpenSim.Region.Physics.Manager /// public class PhysicsPluginManager { - private Dictionary _plugins = new Dictionary(); + private Dictionary _PhysPlugins = new Dictionary(); + private Dictionary _MeshPlugins = new Dictionary(); public PhysicsPluginManager() { } - public PhysicsScene GetPhysicsScene(string engineName) + public PhysicsScene GetPhysicsScene(string physEngineName, string meshEngineName) { - if (String.IsNullOrEmpty(engineName)) + + if (String.IsNullOrEmpty(physEngineName)) + { + return PhysicsScene.Null; + } + + if (String.IsNullOrEmpty(meshEngineName)) { return PhysicsScene.Null; } - if (_plugins.ContainsKey(engineName)) + + IMesher meshEngine = null; + if (_MeshPlugins.ContainsKey(meshEngineName)) { - MainLog.Instance.Verbose("PHYSICS", "creating " + engineName); - return _plugins[engineName].GetScene(); + MainLog.Instance.Verbose("PHYSICS", "creating meshing engine " + meshEngineName); + meshEngine = _MeshPlugins[meshEngineName].GetMesher(); } else { - MainLog.Instance.Warn("PHYSICS", "couldn't find physicsEngine: {0}", engineName); - throw new ArgumentException(String.Format("couldn't find physicsEngine: {0}", engineName)); + MainLog.Instance.Warn("PHYSICS", "couldn't find meshingEngine: {0}", meshEngineName); + throw new ArgumentException(String.Format("couldn't find meshingEngine: {0}", meshEngineName)); + } + + if (_PhysPlugins.ContainsKey(physEngineName)) + { + MainLog.Instance.Verbose("PHYSICS", "creating " + physEngineName); + PhysicsScene result = _PhysPlugins[physEngineName].GetScene(); + result.Initialise(meshEngine); + return result; + } + else + { + MainLog.Instance.Warn("PHYSICS", "couldn't find physicsEngine: {0}", physEngineName); + throw new ArgumentException(String.Format("couldn't find physicsEngine: {0}", physEngineName)); } } @@ -85,18 +108,29 @@ namespace OpenSim.Region.Physics.Manager { if (!pluginType.IsAbstract) { - Type typeInterface = pluginType.GetInterface("IPhysicsPlugin", true); + Type physTypeInterface = pluginType.GetInterface("IPhysicsPlugin", true); - if (typeInterface != null) + if (physTypeInterface != null) { IPhysicsPlugin plug = (IPhysicsPlugin) Activator.CreateInstance(pluginAssembly.GetType(pluginType.ToString())); plug.Init(); - _plugins.Add(plug.GetName(), plug); + _PhysPlugins.Add(plug.GetName(), plug); MainLog.Instance.Verbose("PHYSICS", "Added physics engine: " + plug.GetName()); } - typeInterface = null; + Type meshTypeInterface = pluginType.GetInterface("IMeshingPlugin", true); + + if (meshTypeInterface != null) + { + IMeshingPlugin plug = + (IMeshingPlugin)Activator.CreateInstance(pluginAssembly.GetType(pluginType.ToString())); + _MeshPlugins.Add(plug.GetName(), plug); + MainLog.Instance.Verbose("PHYSICS", "Added meshing engine: " + plug.GetName()); + } + + physTypeInterface = null; + meshTypeInterface = null; } } } @@ -127,4 +161,11 @@ namespace OpenSim.Region.Physics.Manager string GetName(); void Dispose(); } -} \ No newline at end of file + + public interface IMeshingPlugin + { + string GetName(); + IMesher GetMesher(); + } + +} -- cgit v1.1