* 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
0.6.1-post-fixes
Justin Clarke Casey 2008-11-20 18:28:30 +00:00
parent 96dfc1c957
commit d625095959
3 changed files with 40 additions and 13 deletions

View File

@ -83,5 +83,14 @@ namespace OpenSim.Region.Environment.Scenes.Tests
Assert.That(retrievedPart, Is.Null); Assert.That(retrievedPart, Is.Null);
} }
/// <summary>
/// Test removing an object
/// </summary>
public void TestRemoveSceneObjectAsync()
{
TestScene scene = SceneTestUtils.SetupScene();
SceneObjectPart part = SceneTestUtils.AddSceneObject(scene);
}
} }
} }

View File

@ -63,7 +63,7 @@ namespace OpenSim.Region.Environment.Scenes.Tests
testScene.LandChannel = new TestLandChannel(); testScene.LandChannel = new TestLandChannel();
PhysicsPluginManager physicsPluginManager = new PhysicsPluginManager(); PhysicsPluginManager physicsPluginManager = new PhysicsPluginManager();
physicsPluginManager.LoadPlugins(); physicsPluginManager.LoadPlugin("Physics/OpenSim.Region.Physics.BasicPhysicsPlugin.dll");
testScene.PhysicsScene = physicsPluginManager.GetPhysicsScene("basicphysics", "ZeroMesher", configSource); testScene.PhysicsScene = physicsPluginManager.GetPhysicsScene("basicphysics", "ZeroMesher", configSource);
return testScene; return testScene;

View File

@ -44,10 +44,27 @@ namespace OpenSim.Region.Physics.Manager
private Dictionary<string, IPhysicsPlugin> _PhysPlugins = new Dictionary<string, IPhysicsPlugin>(); private Dictionary<string, IPhysicsPlugin> _PhysPlugins = new Dictionary<string, IPhysicsPlugin>();
private Dictionary<string, IMeshingPlugin> _MeshPlugins = new Dictionary<string, IMeshingPlugin>(); private Dictionary<string, IMeshingPlugin> _MeshPlugins = new Dictionary<string, IMeshingPlugin>();
/// <summary>
/// Constructor.
/// </summary>
public PhysicsPluginManager() 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());
} }
/// <summary>
/// Get a physics scene for the given physics engine and mesher.
/// </summary>
/// <param name="physEngineName"></param>
/// <param name="meshEngineName"></param>
/// <param name="config"></param>
/// <returns></returns>
public PhysicsScene GetPhysicsScene(string physEngineName, string meshEngineName, IConfigSource config) public PhysicsScene GetPhysicsScene(string physEngineName, string meshEngineName, IConfigSource config)
{ {
if (String.IsNullOrEmpty(physEngineName)) if (String.IsNullOrEmpty(physEngineName))
@ -86,14 +103,11 @@ namespace OpenSim.Region.Physics.Manager
} }
} }
/// <summary>
/// Load all built-in 'plugins' and those in the bin/Physics diretory
/// </summary>
public void LoadPlugins() 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 // And now walk all assemblies (DLLs effectively) and see if they are home
// of a plugin that is of interest for us // of a plugin that is of interest for us
string path = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Physics"); 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++) for (int i = 0; i < pluginFiles.Length; i++)
{ {
AddPlugin(pluginFiles[i]); LoadPlugin(pluginFiles[i]);
} }
} }
private void AddPlugin(string FileName) /// <summary>
/// Load plugins from a dll at the given path
/// </summary>
/// <param name="dllPath"></param>
public void LoadPlugin(string dllPath)
{ {
// TODO / NOTE // TODO / NOTE
// The assembly named 'OpenSim.Region.Physics.BasicPhysicsPlugin' was loaded from // The assembly named 'OpenSim.Region.Physics.BasicPhysicsPlugin' was loaded from
@ -120,11 +138,11 @@ namespace OpenSim.Region.Physics.Manager
try try
{ {
pluginAssembly = Assembly.LoadFrom(FileName); pluginAssembly = Assembly.LoadFrom(dllPath);
} }
catch (Exception ex) 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) if (pluginAssembly != null)
@ -135,12 +153,12 @@ namespace OpenSim.Region.Physics.Manager
} }
catch (ReflectionTypeLoadException ex) 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); ex.LoaderExceptions[0].Message, ex);
} }
catch (Exception 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) if (types != null)