mirror of
https://github.com/opensim/opensim.git
synced 2026-08-06 17:32:42 +08:00
* Moves the Meshmerizer to a separate plugin
* Experimental. Linux Prebuild needs testing. * One more update after this to remove the ODEMeshing directory....
This commit is contained in:
26
OpenSim/Region/Physics/Manager/IMesher.cs
Normal file
26
OpenSim/Region/Physics/Manager/IMesher.cs
Normal file
@@ -0,0 +1,26 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
using OpenSim.Framework;
|
||||
|
||||
namespace OpenSim.Region.Physics.Manager
|
||||
{
|
||||
public interface IMesher
|
||||
{
|
||||
IMesh CreateMesh(String primName, PrimitiveBaseShape primShape, PhysicsVector size);
|
||||
}
|
||||
|
||||
public interface IVertex {
|
||||
}
|
||||
|
||||
public interface IMesh
|
||||
{
|
||||
List<PhysicsVector> getVertexList();
|
||||
int[] getIndexListAsInt();
|
||||
int[] getIndexListAsIntLocked();
|
||||
float[] getVertexListAsFloatLocked();
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
@@ -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
|
||||
/// </summary>
|
||||
public class PhysicsPluginManager
|
||||
{
|
||||
private Dictionary<string, IPhysicsPlugin> _plugins = new Dictionary<string, IPhysicsPlugin>();
|
||||
private Dictionary<string, IPhysicsPlugin> _PhysPlugins = new Dictionary<string, IPhysicsPlugin>();
|
||||
private Dictionary<string, IMeshingPlugin> _MeshPlugins = new Dictionary<string, IMeshingPlugin>();
|
||||
|
||||
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 (_plugins.ContainsKey(engineName))
|
||||
if (String.IsNullOrEmpty(meshEngineName))
|
||||
{
|
||||
MainLog.Instance.Verbose("PHYSICS", "creating " + engineName);
|
||||
return _plugins[engineName].GetScene();
|
||||
return PhysicsScene.Null;
|
||||
}
|
||||
|
||||
|
||||
IMesher meshEngine = null;
|
||||
if (_MeshPlugins.ContainsKey(meshEngineName))
|
||||
{
|
||||
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();
|
||||
}
|
||||
}
|
||||
|
||||
public interface IMeshingPlugin
|
||||
{
|
||||
string GetName();
|
||||
IMesher GetMesher();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -28,6 +28,7 @@
|
||||
using Axiom.Math;
|
||||
using OpenSim.Framework;
|
||||
using OpenSim.Framework.Console;
|
||||
using OpenSim.Region.Physics.Manager;
|
||||
|
||||
namespace OpenSim.Region.Physics.Manager
|
||||
{
|
||||
@@ -38,6 +39,8 @@ namespace OpenSim.Region.Physics.Manager
|
||||
get { return new NullPhysicsScene(); }
|
||||
}
|
||||
|
||||
public abstract void Initialise(IMesher meshmerizer);
|
||||
|
||||
public abstract PhysicsActor AddAvatar(string avName, PhysicsVector position);
|
||||
|
||||
public abstract void RemoveAvatar(PhysicsActor actor);
|
||||
@@ -63,6 +66,12 @@ namespace OpenSim.Region.Physics.Manager
|
||||
{
|
||||
private static int m_workIndicator;
|
||||
|
||||
|
||||
public override void Initialise(IMesher meshmerizer)
|
||||
{
|
||||
// Does nothing right now
|
||||
}
|
||||
|
||||
public override PhysicsActor AddAvatar(string avName, PhysicsVector position)
|
||||
{
|
||||
MainLog.Instance.Verbose("NullPhysicsScene : AddAvatar({0})", position);
|
||||
@@ -123,4 +132,4 @@ namespace OpenSim.Region.Physics.Manager
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user