From 47aa8107fd49039feb8dd95ec93e8ac80088e158 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Wed, 9 Sep 2015 18:53:24 +0100 Subject: let old ode also have a Module class --- OpenSim/Region/PhysicsModules/Ode/ODEModule.cs | 85 ++++++++++++++++++++++++++ 1 file changed, 85 insertions(+) create mode 100644 OpenSim/Region/PhysicsModules/Ode/ODEModule.cs (limited to 'OpenSim/Region/PhysicsModules/Ode/ODEModule.cs') diff --git a/OpenSim/Region/PhysicsModules/Ode/ODEModule.cs b/OpenSim/Region/PhysicsModules/Ode/ODEModule.cs new file mode 100644 index 0000000..101e8b0 --- /dev/null +++ b/OpenSim/Region/PhysicsModules/Ode/ODEModule.cs @@ -0,0 +1,85 @@ +using System; +using System.Reflection; +using log4net; +using Nini.Config; +using Mono.Addins; +using OpenSim.Framework; +using OpenSim.Region.Framework.Scenes; +using OpenSim.Region.Framework.Interfaces; +using Ode.NET; + +namespace OpenSim.Region.PhysicsModule.ODE +{ + [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "ODEPhysicsScene")] + public class OdeModule : INonSharedRegionModule + { + private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); + + private bool m_Enabled = false; + private IConfigSource m_config; + private OdeScene m_scene; + + #region INonSharedRegionModule + + public string Name + { + get { return "OpenDynamicsEngine"; } + } + + public Type ReplaceableInterface + { + get { return null; } + } + + public void Initialise(IConfigSource source) + { + IConfig config = source.Configs["Startup"]; + if (config != null) + { + string physics = config.GetString("physics", string.Empty); + if (physics == Name) + { + m_config = source; + m_Enabled = true; + } + } + } + + public void Close() + { + } + + public void AddRegion(Scene scene) + { + if (!m_Enabled) + return; + + 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(); + + m_scene = new OdeScene(scene, m_config, Name); + } + + public void RemoveRegion(Scene scene) + { + if (!m_Enabled || m_scene == null) + return; + + m_scene.Dispose(); + m_scene = null; + } + + public void RegionLoaded(Scene scene) + { + if (!m_Enabled || m_scene == null) + return; + + m_scene.RegionLoaded(); + } + #endregion + } +} -- cgit v1.1