All physics plugins are now region modules. Compiles but doesn't run.

0.8.2-post-fixes
Diva Canto 2015-08-31 13:02:51 -07:00
parent 49ab478d28
commit 134d4300f0
24 changed files with 1518 additions and 1313 deletions

View File

@ -30,7 +30,7 @@ using System.IO;
using System.Text; using System.Text;
using log4net; using log4net;
namespace OpenSim.Region.CoreModules.Framework.Statistics.Logging namespace OpenSim.Framework
{ {
/// <summary> /// <summary>
/// Class for writing a high performance, high volume log file. /// Class for writing a high performance, high volume log file.

View File

@ -27,6 +27,7 @@
using System.Reflection; using System.Reflection;
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
using Mono.Addins;
// Information about this assembly is defined by the following // Information about this assembly is defined by the following
// attributes. // attributes.
@ -34,11 +35,11 @@ using System.Runtime.InteropServices;
// change them to the information which is associated with the assembly // change them to the information which is associated with the assembly
// you compile. // you compile.
[assembly : AssemblyTitle("BasicPhysicsPlugin")] [assembly : AssemblyTitle("BasicPhysicsModule")]
[assembly : AssemblyDescription("")] [assembly : AssemblyDescription("")]
[assembly : AssemblyConfiguration("")] [assembly : AssemblyConfiguration("")]
[assembly : AssemblyCompany("http://opensimulator.org")] [assembly : AssemblyCompany("http://opensimulator.org")]
[assembly : AssemblyProduct("BasicPhysicsPlugin")] [assembly : AssemblyProduct("BasicPhysicsModule")]
[assembly : AssemblyCopyright("Copyright (c) OpenSimulator.org Developers")] [assembly : AssemblyCopyright("Copyright (c) OpenSimulator.org Developers")]
[assembly : AssemblyTrademark("")] [assembly : AssemblyTrademark("")]
[assembly : AssemblyCulture("")] [assembly : AssemblyCulture("")]
@ -56,3 +57,6 @@ using System.Runtime.InteropServices;
// numbers with the '*' character (the default): // numbers with the '*' character (the default):
[assembly : AssemblyVersion("0.8.2.*")] [assembly : AssemblyVersion("0.8.2.*")]
[assembly: Addin("OpenSim.Region.PhysicsModule.BasicPhysics", OpenSim.VersionInfo.VersionNumber)]
[assembly: AddinDependency("OpenSim.Region.Framework", OpenSim.VersionInfo.VersionNumber)]

View File

@ -36,29 +36,29 @@ namespace OpenSim.Region.PhysicsModule.BasicPhysics
/// <summary> /// <summary>
/// Effectively a physics plugin that simulates no physics at all. /// Effectively a physics plugin that simulates no physics at all.
/// </summary> /// </summary>
public class BasicPhysicsPlugin : IPhysicsPlugin //public class BasicPhysicsPlugin : IPhysicsPlugin
{ //{
public BasicPhysicsPlugin() // public BasicPhysicsPlugin()
{ // {
} // }
public bool Init() // public bool Init()
{ // {
return true; // return true;
} // }
public PhysicsScene GetScene(string sceneIdentifier) // public PhysicsScene GetScene(string sceneIdentifier)
{ // {
return new BasicScene(GetName(), sceneIdentifier); // return new BasicScene(GetName(), sceneIdentifier);
} // }
public string GetName() // public string GetName()
{ // {
return ("basicphysics"); // return ("basicphysics");
} // }
public void Dispose() // public void Dispose()
{ // {
} // }
} //}
} }

View File

@ -28,9 +28,12 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using Nini.Config; using Nini.Config;
using Mono.Addins;
using OpenMetaverse; using OpenMetaverse;
using OpenSim.Framework; using OpenSim.Framework;
using OpenSim.Region.PhysicsModules.SharedBase; using OpenSim.Region.PhysicsModules.SharedBase;
using OpenSim.Region.Framework.Scenes;
using OpenSim.Region.Framework.Interfaces;
namespace OpenSim.Region.PhysicsModule.BasicPhysics namespace OpenSim.Region.PhysicsModule.BasicPhysics
{ {
@ -41,32 +44,71 @@ namespace OpenSim.Region.PhysicsModule.BasicPhysics
/// Not useful for anything at the moment apart from some regression testing in other components where some form /// Not useful for anything at the moment apart from some regression testing in other components where some form
/// of physics plugin is needed. /// of physics plugin is needed.
/// </remarks> /// </remarks>
public class BasicScene : PhysicsScene [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "BasicPhysicsScene")]
public class BasicScene : PhysicsScene, INonSharedRegionModule
{ {
private List<BasicActor> _actors = new List<BasicActor>(); private List<BasicActor> _actors = new List<BasicActor>();
private List<BasicPhysicsPrim> _prims = new List<BasicPhysicsPrim>(); private List<BasicPhysicsPrim> _prims = new List<BasicPhysicsPrim>();
private float[] _heightMap; private float[] _heightMap;
private Vector3 m_regionExtent; private Vector3 m_regionExtent;
private bool m_Enabled = false;
//protected internal string sceneIdentifier; //protected internal string sceneIdentifier;
#region INonSharedRegionModule
public BasicScene(string engineType, string _sceneIdentifier) public string Name
{ {
EngineType = engineType; get { return "basicphysics"; }
Name = EngineType + "/" + _sceneIdentifier;
//sceneIdentifier = _sceneIdentifier;
} }
public override void Initialise(IMesher meshmerizer, IConfigSource config) public Type ReplaceableInterface
{ {
throw new Exception("Should not be called."); get { return null; }
} }
public override void Initialise(IMesher meshmerizer, IConfigSource config, Vector3 regionExtent) public void Initialise(IConfigSource source)
{ {
m_regionExtent = regionExtent; // TODO: Move this out of Startup
IConfig config = source.Configs["Startup"];
if (config != null)
{
string physics = config.GetString("physics", string.Empty);
if (physics == Name)
m_Enabled = true;
} }
}
public void Close()
{
}
public void AddRegion(Scene scene)
{
if (!m_Enabled)
return;
EngineType = Name;
PhysicsSceneName = EngineType + "/" + scene.RegionInfo.RegionName;
scene.RegisterModuleInterface<PhysicsScene>(this);
m_regionExtent = new Vector3(scene.RegionInfo.RegionSizeX, scene.RegionInfo.RegionSizeY, scene.RegionInfo.RegionSizeZ);
}
public void RemoveRegion(Scene scene)
{
if (!m_Enabled)
return;
}
public void RegionLoaded(Scene scene)
{
if (!m_Enabled)
return;
}
#endregion
public override void Dispose() {} public override void Dispose() {}
public override PhysicsActor AddPrimShape(string primName, PrimitiveBaseShape pbs, Vector3 position, public override PhysicsActor AddPrimShape(string primName, PrimitiveBaseShape pbs, Vector3 position,
@ -206,5 +248,6 @@ namespace OpenSim.Region.PhysicsModule.BasicPhysics
Dictionary<uint, float> returncolliders = new Dictionary<uint, float>(); Dictionary<uint, float> returncolliders = new Dictionary<uint, float>();
return returncolliders; return returncolliders;
} }
} }
} }

View File

@ -40,37 +40,37 @@ namespace OpenSim.Region.PhysicsModule.BulletS
/// The unmanaged library is compiled and linked statically with Bullet /// The unmanaged library is compiled and linked statically with Bullet
/// to create BulletSim.dll and libBulletSim.so (for both 32 and 64 bit). /// to create BulletSim.dll and libBulletSim.so (for both 32 and 64 bit).
/// </summary> /// </summary>
public class BSPlugin : IPhysicsPlugin //public class BSPlugin : IPhysicsPlugin
{ //{
//private static readonly log4net.ILog m_log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); // //private static readonly log4net.ILog m_log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
private BSScene _mScene; // private BSScene _mScene;
public BSPlugin() // public BSPlugin()
{ // {
} // }
public bool Init() // public bool Init()
{ // {
return true; // return true;
} // }
public PhysicsScene GetScene(String sceneIdentifier) // public PhysicsScene GetScene(String sceneIdentifier)
{ // {
if (_mScene == null) // if (_mScene == null)
{ // {
_mScene = new BSScene(GetName(), sceneIdentifier); // _mScene = new BSScene(GetName(), sceneIdentifier);
} // }
return (_mScene); // return (_mScene);
} // }
public string GetName() // public string GetName()
{ // {
return ("BulletSim"); // return ("BulletSim");
} // }
public void Dispose() // public void Dispose()
{ // {
} // }
} //}
} }

View File

@ -33,21 +33,25 @@ using System.Text;
using System.Threading; using System.Threading;
using OpenSim.Framework; using OpenSim.Framework;
using OpenSim.Framework.Monitoring; using OpenSim.Framework.Monitoring;
using OpenSim.Region.Framework; using OpenSim.Region.Framework.Scenes;
using OpenSim.Region.CoreModules; using OpenSim.Region.Framework.Interfaces;
using Logging = OpenSim.Region.CoreModules.Framework.Statistics.Logging;
using OpenSim.Region.PhysicsModules.SharedBase; using OpenSim.Region.PhysicsModules.SharedBase;
using Nini.Config; using Nini.Config;
using log4net; using log4net;
using OpenMetaverse; using OpenMetaverse;
using Mono.Addins;
namespace OpenSim.Region.PhysicsModule.BulletS namespace OpenSim.Region.PhysicsModule.BulletS
{ {
public sealed class BSScene : PhysicsScene, IPhysicsParameters [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "BulletSPhysicsScene")]
{ public sealed class BSScene : PhysicsScene, IPhysicsParameters, INonSharedRegionModule
{
internal static readonly ILog m_log = LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); internal static readonly ILog m_log = LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
internal static readonly string LogHeader = "[BULLETS SCENE]"; internal static readonly string LogHeader = "[BULLETS SCENE]";
private bool m_Enabled = false;
private IConfigSource m_Config;
// The name of the region we're working for. // The name of the region we're working for.
public string RegionName { get; private set; } public string RegionName { get; private set; }
@ -190,7 +194,7 @@ public sealed class BSScene : PhysicsScene, IPhysicsParameters
internal ConfigurationParameters[] UnmanagedParams; internal ConfigurationParameters[] UnmanagedParams;
// Sometimes you just have to log everything. // Sometimes you just have to log everything.
public Logging.LogWriter PhysicsLogging; public LogWriter PhysicsLogging;
private bool m_physicsLoggingEnabled; private bool m_physicsLoggingEnabled;
private string m_physicsLoggingDir; private string m_physicsLoggingDir;
private string m_physicsLoggingPrefix; private string m_physicsLoggingPrefix;
@ -202,31 +206,72 @@ public sealed class BSScene : PhysicsScene, IPhysicsParameters
public bool VehicleLoggingEnabled { get; private set; } public bool VehicleLoggingEnabled { get; private set; }
public bool VehiclePhysicalLoggingEnabled { get; private set; } public bool VehiclePhysicalLoggingEnabled { get; private set; }
#region Construction and Initialization #region INonSharedRegionModule
public BSScene(string engineType, string identifier) public string Name
{ {
m_initialized = false; get { return "BulletSim"; }
// The name of the region we're working for is passed to us. Keep for identification.
RegionName = identifier;
// Set identifying variables in the PhysicsScene interface.
EngineType = engineType;
Name = EngineType + "/" + RegionName;
} }
// Old version of initialization that assumes legacy sized regions (256x256) public Type ReplaceableInterface
public override void Initialise(IMesher meshmerizer, IConfigSource config)
{ {
m_log.ErrorFormat("{0} WARNING WARNING WARNING! BulletSim initialized without region extent specification. Terrain will be messed up."); get { return null; }
Vector3 regionExtent = new Vector3( Constants.RegionSize, Constants.RegionSize, Constants.RegionSize); }
Initialise(meshmerizer, config, regionExtent);
public void Initialise(IConfigSource source)
{
// TODO: Move this out of Startup
IConfig config = source.Configs["Startup"];
if (config != null)
{
string physics = config.GetString("physics", string.Empty);
if (physics == Name)
{
m_Enabled = true;
m_Config = source;
}
}
} }
public override void Initialise(IMesher meshmerizer, IConfigSource config, Vector3 regionExtent) public void Close()
{
}
public void AddRegion(Scene scene)
{
if (!m_Enabled)
return;
EngineType = Name;
RegionName = scene.RegionInfo.RegionName;
PhysicsSceneName = EngineType + "/" + RegionName;
scene.RegisterModuleInterface<PhysicsScene>(this);
Vector3 extent = new Vector3(scene.RegionInfo.RegionSizeX, scene.RegionInfo.RegionSizeY, scene.RegionInfo.RegionSizeZ);
Initialise(m_Config, extent);
}
public void RemoveRegion(Scene scene)
{
if (!m_Enabled)
return;
}
public void RegionLoaded(Scene scene)
{
if (!m_Enabled)
return;
mesher = scene.RequestModuleInterface<IMesher>();
if (mesher == null)
m_log.WarnFormat("{0} No mesher. Things will not work well.", LogHeader);
}
#endregion
#region Initialization
private void Initialise(IConfigSource config, Vector3 regionExtent)
{ {
mesher = meshmerizer;
_taintOperations = new List<TaintCallbackEntry>(); _taintOperations = new List<TaintCallbackEntry>();
_postTaintOperations = new Dictionary<string, TaintCallbackEntry>(); _postTaintOperations = new Dictionary<string, TaintCallbackEntry>();
_postStepOperations = new List<TaintCallbackEntry>(); _postStepOperations = new List<TaintCallbackEntry>();
@ -258,12 +303,12 @@ public sealed class BSScene : PhysicsScene, IPhysicsParameters
// can be left in and every call doesn't have to check for null. // can be left in and every call doesn't have to check for null.
if (m_physicsLoggingEnabled) if (m_physicsLoggingEnabled)
{ {
PhysicsLogging = new Logging.LogWriter(m_physicsLoggingDir, m_physicsLoggingPrefix, m_physicsLoggingFileMinutes, m_physicsLoggingDoFlush); PhysicsLogging = new LogWriter(m_physicsLoggingDir, m_physicsLoggingPrefix, m_physicsLoggingFileMinutes, m_physicsLoggingDoFlush);
PhysicsLogging.ErrorLogger = m_log; // for DEBUG. Let's the logger output its own error messages. PhysicsLogging.ErrorLogger = m_log; // for DEBUG. Let's the logger output its own error messages.
} }
else else
{ {
PhysicsLogging = new Logging.LogWriter(); PhysicsLogging = new LogWriter();
} }
// Allocate memory for returning of the updates and collisions from the physics engine // Allocate memory for returning of the updates and collisions from the physics engine
@ -1277,5 +1322,5 @@ public sealed class BSScene : PhysicsScene, IPhysicsParameters
// Used to fill in the LocalID when there isn't one. It's the correct number of characters. // Used to fill in the LocalID when there isn't one. It's the correct number of characters.
public const string DetailLogZero = "0000000000"; public const string DetailLogZero = "0000000000";
} }
} }

View File

@ -299,7 +299,7 @@ public abstract class BSShape
{ {
xprim.PrimAssetState = BSPhysObject.PrimAssetCondition.FailedAssetFetch; xprim.PrimAssetState = BSPhysObject.PrimAssetCondition.FailedAssetFetch;
physicsScene.Logger.ErrorFormat("{0} Physical object requires asset but no asset provider. Name={1}", physicsScene.Logger.ErrorFormat("{0} Physical object requires asset but no asset provider. Name={1}",
LogHeader, physicsScene.Name); LogHeader, physicsScene.PhysicsSceneName);
} }
} }
else else
@ -336,7 +336,7 @@ public abstract class BSShape
if (pScene != null) if (pScene != null)
{ {
buff.Append("/rgn="); buff.Append("/rgn=");
buff.Append(pScene.Name); buff.Append(pScene.PhysicsSceneName);
} }
return buff.ToString(); return buff.ToString();
} }

View File

@ -30,7 +30,6 @@ using System.Text;
using OpenSim.Framework; using OpenSim.Framework;
using OpenSim.Region.Framework; using OpenSim.Region.Framework;
using OpenSim.Region.CoreModules;
using OpenSim.Region.PhysicsModules.SharedBase; using OpenSim.Region.PhysicsModules.SharedBase;
using Nini.Config; using Nini.Config;

View File

@ -30,7 +30,6 @@ using System.Text;
using OpenSim.Framework; using OpenSim.Framework;
using OpenSim.Region.Framework; using OpenSim.Region.Framework;
using OpenSim.Region.CoreModules;
using OpenSim.Region.PhysicsModules.SharedBase; using OpenSim.Region.PhysicsModules.SharedBase;
using Nini.Config; using Nini.Config;

View File

@ -30,7 +30,6 @@ using System.Text;
using OpenSim.Framework; using OpenSim.Framework;
using OpenSim.Region.Framework; using OpenSim.Region.Framework;
using OpenSim.Region.CoreModules;
using OpenSim.Region.PhysicsModules.SharedBase; using OpenSim.Region.PhysicsModules.SharedBase;
using Nini.Config; using Nini.Config;

View File

@ -1,6 +1,7 @@
using System.Reflection; using System.Reflection;
using System.Runtime.CompilerServices; using System.Runtime.CompilerServices;
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
using Mono.Addins;
// General Information about an assembly is controlled through the following // General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information // set of attributes. Change these attribute values to modify the information
@ -31,3 +32,5 @@ using System.Runtime.InteropServices;
// //
[assembly: AssemblyVersion("0.8.2.*")] [assembly: AssemblyVersion("0.8.2.*")]
[assembly: Addin("OpenSim.Region.PhysicsModule.BulletS", OpenSim.VersionInfo.VersionNumber)]
[assembly: AddinDependency("OpenSim.Region.Framework", OpenSim.VersionInfo.VersionNumber)]

View File

@ -27,6 +27,7 @@
using System.Reflection; using System.Reflection;
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
using Mono.Addins;
// Information about this assembly is defined by the following // Information about this assembly is defined by the following
// attributes. // attributes.
@ -56,3 +57,6 @@ using System.Runtime.InteropServices;
// numbers with the '*' character (the default): // numbers with the '*' character (the default):
[assembly : AssemblyVersion("0.8.2.*")] [assembly : AssemblyVersion("0.8.2.*")]
[assembly: Addin("OpenSim.Region.PhysicsModule.ODE", OpenSim.VersionInfo.VersionNumber)]
[assembly: AddinDependency("OpenSim.Region.Framework", OpenSim.VersionInfo.VersionNumber)]

View File

@ -511,7 +511,7 @@ namespace OpenSim.Region.PhysicsModule.ODE
} }
else else
{ {
m_log.WarnFormat("[ODE CHARACTER]: Got a NaN Size for {0} in {1}", Name, _parent_scene.Name); m_log.WarnFormat("[ODE CHARACTER]: Got a NaN Size for {0} in {1}", Name, _parent_scene.PhysicsSceneName);
} }
} }

View File

@ -3380,7 +3380,7 @@ Console.WriteLine(" JointCreateFixed");
{ {
m_log.WarnFormat( m_log.WarnFormat(
"[ODE PRIM]: Could not get mesh/sculpt asset {0} for {1} at {2} in {3}", "[ODE PRIM]: Could not get mesh/sculpt asset {0} for {1} at {2} in {3}",
_pbs.SculptTexture, Name, _position, _parent_scene.Name); _pbs.SculptTexture, Name, _position, _parent_scene.PhysicsSceneName);
} }
} }
} }

View File

@ -44,47 +44,47 @@ namespace OpenSim.Region.PhysicsModule.ODE
/// <summary> /// <summary>
/// ODE plugin /// ODE plugin
/// </summary> /// </summary>
public class OdePlugin : IPhysicsPlugin // public class OdePlugin : IPhysicsPlugin
{ // {
// private static readonly log4net.ILog m_log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); //// private static readonly log4net.ILog m_log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
private OdeScene m_scene; // private OdeScene m_scene;
public bool Init() // public bool Init()
{ // {
return true; // return true;
} // }
public PhysicsScene GetScene(String sceneIdentifier) // public PhysicsScene GetScene(String sceneIdentifier)
{ // {
if (m_scene == null) // if (m_scene == null)
{ // {
// We do this so that OpenSimulator on Windows loads the correct native ODE library depending on whether // // We do this so that OpenSimulator on Windows loads the correct native ODE library depending on whether
// it's running as a 32-bit process or a 64-bit one. By invoking LoadLibary here, later DLLImports // // it's running as a 32-bit process or a 64-bit one. By invoking LoadLibary here, later DLLImports
// will find it already loaded later on. // // will find it already loaded later on.
// // //
// This isn't necessary for other platforms (e.g. Mac OSX and Linux) since the DLL used can be // // This isn't necessary for other platforms (e.g. Mac OSX and Linux) since the DLL used can be
// controlled in Ode.NET.dll.config // // controlled in Ode.NET.dll.config
if (Util.IsWindows()) // if (Util.IsWindows())
Util.LoadArchSpecificWindowsDll("ode.dll"); // Util.LoadArchSpecificWindowsDll("ode.dll");
// Initializing ODE only when a scene is created allows alternative ODE plugins to co-habit (according to // // Initializing ODE only when a scene is created allows alternative ODE plugins to co-habit (according to
// http://opensimulator.org/mantis/view.php?id=2750). // // http://opensimulator.org/mantis/view.php?id=2750).
d.InitODE(); // d.InitODE();
m_scene = new OdeScene(GetName(), sceneIdentifier); // m_scene = new OdeScene(GetName(), sceneIdentifier);
} // }
return m_scene; // return m_scene;
} // }
public string GetName() // public string GetName()
{ // {
return ("OpenDynamicsEngine"); // return ("OpenDynamicsEngine");
} // }
public void Dispose() // public void Dispose()
{ // {
} // }
} // }
} }

View File

@ -38,6 +38,7 @@ using System.Runtime.InteropServices;
using System.Threading; using System.Threading;
using log4net; using log4net;
using Nini.Config; using Nini.Config;
using Mono.Addins;
using Ode.NET; using Ode.NET;
using OpenMetaverse; using OpenMetaverse;
#if USE_DRAWSTUFF #if USE_DRAWSTUFF
@ -45,6 +46,9 @@ using Drawstuff.NET;
#endif #endif
using OpenSim.Framework; using OpenSim.Framework;
using OpenSim.Region.PhysicsModules.SharedBase; using OpenSim.Region.PhysicsModules.SharedBase;
using OpenSim.Region.Framework.Scenes;
using OpenSim.Region.Framework.Interfaces;
namespace OpenSim.Region.PhysicsModule.ODE namespace OpenSim.Region.PhysicsModule.ODE
{ {
@ -101,9 +105,12 @@ namespace OpenSim.Region.PhysicsModule.ODE
Rubber = 6 Rubber = 6
} }
[Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "ODEPhysicsScene")]
public class OdeScene : PhysicsScene public class OdeScene : PhysicsScene
{ {
private readonly ILog m_log; private readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType.ToString());
private bool m_Enabled = false;
// private Dictionary<string, sCollisionData> m_storedCollisions = new Dictionary<string, sCollisionData>(); // private Dictionary<string, sCollisionData> m_storedCollisions = new Dictionary<string, sCollisionData>();
/// <summary> /// <summary>
@ -288,7 +295,7 @@ namespace OpenSim.Region.PhysicsModule.ODE
private int framecount = 0; private int framecount = 0;
//private int m_returncollisions = 10; //private int m_returncollisions = 10;
private readonly IntPtr contactgroup; private IntPtr contactgroup;
internal IntPtr WaterGeom; internal IntPtr WaterGeom;
@ -520,19 +527,90 @@ namespace OpenSim.Region.PhysicsModule.ODE
private ODERayCastRequestManager m_rayCastManager; private ODERayCastRequestManager m_rayCastManager;
#region INonSharedRegionModule
public string Name
{
get { return "OpenDynamicsEngine"; }
}
public Type ReplaceableInterface
{
get { return null; }
}
public void Initialise(IConfigSource source)
{
// TODO: Move this out of Startup
IConfig config = source.Configs["Startup"];
if (config != null)
{
string physics = config.GetString("physics", string.Empty);
if (physics == Name)
{
m_Enabled = true;
m_config = source;
// We do this so that OpenSimulator on Windows loads the correct native ODE library depending on whether
// it's running as a 32-bit process or a 64-bit one. By invoking LoadLibary here, later DLLImports
// will find it already loaded later on.
//
// This isn't necessary for other platforms (e.g. Mac OSX and Linux) since the DLL used can be
// controlled in Ode.NET.dll.config
if (Util.IsWindows())
Util.LoadArchSpecificWindowsDll("ode.dll");
// Initializing ODE only when a scene is created allows alternative ODE plugins to co-habit (according to
// http://opensimulator.org/mantis/view.php?id=2750).
d.InitODE();
}
}
}
public void Close()
{
}
public void AddRegion(Scene scene)
{
if (!m_Enabled)
return;
EngineType = Name;
PhysicsSceneName = EngineType + "/" + scene.RegionInfo.RegionName;
scene.RegisterModuleInterface<PhysicsScene>(this);
Vector3 extent = new Vector3(scene.RegionInfo.RegionSizeX, scene.RegionInfo.RegionSizeY, scene.RegionInfo.RegionSizeZ);
Initialise();
InitialiseFromConfig(m_config);
}
public void RemoveRegion(Scene scene)
{
if (!m_Enabled)
return;
}
public void RegionLoaded(Scene scene)
{
if (!m_Enabled)
return;
mesher = scene.RequestModuleInterface<IMesher>();
if (mesher == null)
m_log.WarnFormat("[ODE SCENE]: No mesher in {0}. Things will not work well.", PhysicsSceneName);
}
#endregion
/// <summary> /// <summary>
/// Initiailizes the scene /// Initiailizes the scene
/// Sets many properties that ODE requires to be stable /// Sets many properties that ODE requires to be stable
/// These settings need to be tweaked 'exactly' right or weird stuff happens. /// These settings need to be tweaked 'exactly' right or weird stuff happens.
/// </summary> /// </summary>
/// <param value="name">Name of the scene. Useful in debug messages.</param> private void Initialise()
public OdeScene(string engineType, string name)
{ {
m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType.ToString() + "." + name);
Name = name;
EngineType = engineType;
nearCallback = near; nearCallback = near;
triCallback = TriCallback; triCallback = TriCallback;
triArrayCallback = TriArrayCallback; triArrayCallback = TriArrayCallback;
@ -572,12 +650,11 @@ namespace OpenSim.Region.PhysicsModule.ODE
} }
#endif #endif
// Initialize the mesh plugin // Initialize from configs
public override void Initialise(IMesher meshmerizer, IConfigSource config) private void InitialiseFromConfig(IConfigSource config)
{ {
InitializeExtraStats(); InitializeExtraStats();
mesher = meshmerizer;
m_config = config; m_config = config;
// Defaults // Defaults
@ -1818,7 +1895,7 @@ namespace OpenSim.Region.PhysicsModule.ODE
} }
catch (AccessViolationException) catch (AccessViolationException)
{ {
m_log.ErrorFormat("[ODE SCENE]: Unable to space collide {0}", Name); m_log.ErrorFormat("[ODE SCENE]: Unable to space collide {0}", PhysicsSceneName);
} }
//float terrainheight = GetTerrainHeightAtXY(chr.Position.X, chr.Position.Y); //float terrainheight = GetTerrainHeightAtXY(chr.Position.X, chr.Position.Y);
@ -3082,7 +3159,7 @@ namespace OpenSim.Region.PhysicsModule.ODE
{ {
m_log.ErrorFormat( m_log.ErrorFormat(
"[ODE SCENE]: Removing physics character {0} {1} from physics scene {2} due to defect found when moving", "[ODE SCENE]: Removing physics character {0} {1} from physics scene {2} due to defect found when moving",
actor.Name, actor.LocalID, Name); actor.Name, actor.LocalID, PhysicsSceneName);
RemoveCharacter(actor); RemoveCharacter(actor);
actor.DestroyOdeStructures(); actor.DestroyOdeStructures();
@ -3198,7 +3275,7 @@ namespace OpenSim.Region.PhysicsModule.ODE
{ {
m_log.ErrorFormat( m_log.ErrorFormat(
"[ODE SCENE]: Removing physics character {0} {1} from physics scene {2} due to defect found when updating position and velocity", "[ODE SCENE]: Removing physics character {0} {1} from physics scene {2} due to defect found when updating position and velocity",
actor.Name, actor.LocalID, Name); actor.Name, actor.LocalID, PhysicsSceneName);
RemoveCharacter(actor); RemoveCharacter(actor);
actor.DestroyOdeStructures(); actor.DestroyOdeStructures();
@ -3795,7 +3872,7 @@ namespace OpenSim.Region.PhysicsModule.ODE
private void SetTerrain(float[] heightMap, Vector3 pOffset) private void SetTerrain(float[] heightMap, Vector3 pOffset)
{ {
int startTime = Util.EnvironmentTickCount(); int startTime = Util.EnvironmentTickCount();
m_log.DebugFormat("[ODE SCENE]: Setting terrain for {0} with offset {1}", Name, pOffset); m_log.DebugFormat("[ODE SCENE]: Setting terrain for {0} with offset {1}", PhysicsSceneName, pOffset);
// this._heightmap[i] = (double)heightMap[i]; // this._heightmap[i] = (double)heightMap[i];
// dbm (danx0r) -- creating a buffer zone of one extra sample all around // dbm (danx0r) -- creating a buffer zone of one extra sample all around
@ -3920,7 +3997,7 @@ namespace OpenSim.Region.PhysicsModule.ODE
} }
m_log.DebugFormat( m_log.DebugFormat(
"[ODE SCENE]: Setting terrain for {0} took {1}ms", Name, Util.EnvironmentTickCountSubtract(startTime)); "[ODE SCENE]: Setting terrain for {0} took {1}ms", PhysicsSceneName, Util.EnvironmentTickCountSubtract(startTime));
} }
public override void DeleteTerrain() public override void DeleteTerrain()

View File

@ -43,7 +43,7 @@ namespace OpenSim.Region.PhysicsModule.ODE.Tests
{ {
private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
private OpenSim.Region.PhysicsModule.ODE.OdePlugin cbt; //private OpenSim.Region.PhysicsModule.ODE.OdePlugin cbt;
private PhysicsScene ps; private PhysicsScene ps;
private IMeshingPlugin imp; private IMeshingPlugin imp;
@ -55,11 +55,11 @@ namespace OpenSim.Region.PhysicsModule.ODE.Tests
config.Set("DecodedSculptMapPath","j2kDecodeCache"); config.Set("DecodedSculptMapPath","j2kDecodeCache");
// Loading ODEPlugin // Loading ODEPlugin
cbt = new OdePlugin(); //cbt = new OdePlugin();
// Getting Physics Scene // Getting Physics Scene
ps = cbt.GetScene("test"); //ps = cbt.GetScene("test");
// Initializing Physics Scene. // Initializing Physics Scene.
ps.Initialise(imp.GetMesher(TopConfig),null); //ps.Initialise(imp.GetMesher(TopConfig), null, Vector3.Zero);
float[] _heightmap = new float[(int)Constants.RegionSize * (int)Constants.RegionSize]; float[] _heightmap = new float[(int)Constants.RegionSize * (int)Constants.RegionSize];
for (int i = 0; i < ((int)Constants.RegionSize * (int)Constants.RegionSize); i++) for (int i = 0; i < ((int)Constants.RegionSize * (int)Constants.RegionSize); i++)
{ {

View File

@ -27,6 +27,7 @@
using System.Reflection; using System.Reflection;
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
using Mono.Addins;
// Information about this assembly is defined by the following // Information about this assembly is defined by the following
// attributes. // attributes.
@ -56,3 +57,6 @@ using System.Runtime.InteropServices;
// numbers with the '*' character (the default): // numbers with the '*' character (the default):
[assembly : AssemblyVersion("0.8.2.*")] [assembly : AssemblyVersion("0.8.2.*")]
[assembly: Addin("OpenSim.Region.PhysicsModule.POS", OpenSim.VersionInfo.VersionNumber)]
[assembly: AddinDependency("OpenSim.Region.Framework", OpenSim.VersionInfo.VersionNumber)]

View File

@ -36,29 +36,29 @@ namespace OpenSim.Region.PhysicsModule.POS
/// <summary> /// <summary>
/// for now will be a very POS physics engine /// for now will be a very POS physics engine
/// </summary> /// </summary>
public class POSPlugin : IPhysicsPlugin //public class POSPlugin : IPhysicsPlugin
{ //{
public POSPlugin() // public POSPlugin()
{ // {
} // }
public bool Init() // public bool Init()
{ // {
return true; // return true;
} // }
public PhysicsScene GetScene(string sceneIdentifier) // public PhysicsScene GetScene(string sceneIdentifier)
{ // {
return new POSScene(GetName(), sceneIdentifier); // return new POSScene(GetName(), sceneIdentifier);
} // }
public string GetName() // public string GetName()
{ // {
return ("POS"); // return ("POS");
} // }
public void Dispose() // public void Dispose()
{ // {
} // }
} //}
} }

View File

@ -29,11 +29,15 @@ using System;
using System.Collections.Generic; using System.Collections.Generic;
using Nini.Config; using Nini.Config;
using OpenMetaverse; using OpenMetaverse;
using Mono.Addins;
using OpenSim.Framework; using OpenSim.Framework;
using OpenSim.Region.PhysicsModules.SharedBase; using OpenSim.Region.PhysicsModules.SharedBase;
using OpenSim.Region.Framework.Scenes;
using OpenSim.Region.Framework.Interfaces;
namespace OpenSim.Region.PhysicsModule.POS namespace OpenSim.Region.PhysicsModule.POS
{ {
[Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "POSPhysicsScene")]
public class POSScene : PhysicsScene public class POSScene : PhysicsScene
{ {
private List<POSCharacter> _characters = new List<POSCharacter>(); private List<POSCharacter> _characters = new List<POSCharacter>();
@ -41,19 +45,61 @@ namespace OpenSim.Region.PhysicsModule.POS
private float[] _heightMap; private float[] _heightMap;
private const float gravity = -9.8f; private const float gravity = -9.8f;
private bool m_Enabled = false;
//protected internal string sceneIdentifier; //protected internal string sceneIdentifier;
public POSScene(string engineType, String _sceneIdentifier) #region INonSharedRegionModule
public string Name
{ {
EngineType = engineType; get { return "POS"; }
Name = EngineType + "/" + _sceneIdentifier;
//sceneIdentifier = _sceneIdentifier;
} }
public override void Initialise(IMesher meshmerizer, IConfigSource config) public Type ReplaceableInterface
{
get { return null; }
}
public void Initialise(IConfigSource source)
{
// TODO: Move this out of Startup
IConfig config = source.Configs["Startup"];
if (config != null)
{
string physics = config.GetString("physics", string.Empty);
if (physics == Name)
m_Enabled = true;
}
}
public void Close()
{ {
} }
public void AddRegion(Scene scene)
{
if (!m_Enabled)
return;
EngineType = Name;
PhysicsSceneName = EngineType + "/" + scene.RegionInfo.RegionName;
scene.RegisterModuleInterface<PhysicsScene>(this);
}
public void RemoveRegion(Scene scene)
{
if (!m_Enabled)
return;
}
public void RegionLoaded(Scene scene)
{
if (!m_Enabled)
return;
}
#endregion
public override void Dispose() public override void Dispose()
{ {
} }

View File

@ -40,11 +40,6 @@ namespace OpenSim.Region.PhysicsModules.SharedBase
private static int m_workIndicator; private static int m_workIndicator;
public override void Initialise(IMesher meshmerizer, IConfigSource config)
{
// Does nothing right now
}
public override PhysicsActor AddAvatar( public override PhysicsActor AddAvatar(
string avName, Vector3 position, Vector3 velocity, Vector3 size, bool isFlying) string avName, Vector3 position, Vector3 velocity, Vector3 size, bool isFlying)
{ {

View File

@ -89,7 +89,7 @@ namespace OpenSim.Region.PhysicsModules.SharedBase
{ {
m_log.Info("[PHYSICS]: creating " + physEngineName); m_log.Info("[PHYSICS]: creating " + physEngineName);
PhysicsScene result = _PhysPlugins[physEngineName].GetScene(regionName); PhysicsScene result = _PhysPlugins[physEngineName].GetScene(regionName);
result.Initialise(meshEngine, config, regionExtent); //result.Initialise(meshEngine, config, regionExtent);
return result; return result;
} }
else else

View File

@ -98,7 +98,7 @@ namespace OpenSim.Region.PhysicsModules.SharedBase
/// Useful in debug messages to distinguish one OdeScene instance from another. /// Useful in debug messages to distinguish one OdeScene instance from another.
/// Usually set to include the region name that the physics engine is acting for. /// Usually set to include the region name that the physics engine is acting for.
/// </summary> /// </summary>
public string Name { get; protected set; } public string PhysicsSceneName { get; protected set; }
/// <summary> /// <summary>
/// A string identifying the family of this physics engine. Most common values returned /// A string identifying the family of this physics engine. Most common values returned
@ -126,17 +126,6 @@ namespace OpenSim.Region.PhysicsModules.SharedBase
} }
} }
// Deprecated. Do not use this for new physics engines.
public abstract void Initialise(IMesher meshmerizer, IConfigSource config);
// For older physics engines that do not implement non-legacy region sizes.
// If the physics engine handles the region extent feature, it overrides this function.
public virtual void Initialise(IMesher meshmerizer, IConfigSource config, Vector3 regionExtent)
{
// If not overridden, call the old initialization entry.
Initialise(meshmerizer, config);
}
/// <summary> /// <summary>
/// Add an avatar /// Add an avatar
/// </summary> /// </summary>

View File

@ -1857,13 +1857,11 @@
<Reference name="OpenSim.Framework"/> <Reference name="OpenSim.Framework"/>
<Reference name="OpenSim.Framework.Monitoring"/> <Reference name="OpenSim.Framework.Monitoring"/>
<Reference name="OpenSim.Region.Framework"/> <Reference name="OpenSim.Region.Framework"/>
<Reference name="OpenSim.Region.CoreModules"/>
<Reference name="OpenSim.Region.OptionalModules"/> <Reference name="OpenSim.Region.OptionalModules"/>
<Reference name="OpenSim.Framework.Console"/> <Reference name="OpenSim.Framework.Console"/>
<Reference name="OpenSim.Region.PhysicsModules.SharedBase"/> <Reference name="OpenSim.Region.PhysicsModules.SharedBase"/>
<Reference name="OpenSim.Region.PhysicsModules.Meshing" path="../../../../bin/Physics/"/> <Reference name="OpenSim.Region.PhysicsModules.Meshing" path="../../../../bin/Physics/"/>
<Reference name="OpenSim.Region.PhysicsModule.ConvexDecompositionDotNet"/> <Reference name="OpenSim.Region.PhysicsModule.ConvexDecompositionDotNet"/>
<Reference name="OpenSim.Region.Framework"/>
<Reference name="Mono.Addins" path="../../../../bin/"/> <Reference name="Mono.Addins" path="../../../../bin/"/>
<Reference name="BulletXNA.dll" path="../../../../bin/"/> <Reference name="BulletXNA.dll" path="../../../../bin/"/>
<Reference name="log4net.dll" path="../../../../bin/"/> <Reference name="log4net.dll" path="../../../../bin/"/>
@ -3433,7 +3431,7 @@
<Reference name="OpenMetaverseTypes" path="../../../../../bin/"/> <Reference name="OpenMetaverseTypes" path="../../../../../bin/"/>
<Reference name="OpenSim.Framework"/> <Reference name="OpenSim.Framework"/>
<Reference name="OpenSim.Tests.Common"/> <Reference name="OpenSim.Tests.Common"/>
<Reference name="OpenSim.Region.CoreModules"/> <Reference name="OpenSim.Region.Framework"/>
<Reference name="OpenSim.Region.PhysicsModules.Meshing" path="../../../../../bin/Physics/"/> <Reference name="OpenSim.Region.PhysicsModules.Meshing" path="../../../../../bin/Physics/"/>
<Reference name="OpenSim.Region.PhysicsModules.SharedBase"/> <Reference name="OpenSim.Region.PhysicsModules.SharedBase"/>
<Reference name="OpenSim.Region.PhysicsModule.BulletS" path="../../../../../bin/Physics/"/> <Reference name="OpenSim.Region.PhysicsModule.BulletS" path="../../../../../bin/Physics/"/>