diff options
Diffstat (limited to '')
-rw-r--r-- | OpenSim/Region/PhysicsModules/Ode/ODEModule.cs | 85 |
1 files changed, 85 insertions, 0 deletions
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 @@ | |||
1 | using System; | ||
2 | using System.Reflection; | ||
3 | using log4net; | ||
4 | using Nini.Config; | ||
5 | using Mono.Addins; | ||
6 | using OpenSim.Framework; | ||
7 | using OpenSim.Region.Framework.Scenes; | ||
8 | using OpenSim.Region.Framework.Interfaces; | ||
9 | using Ode.NET; | ||
10 | |||
11 | namespace OpenSim.Region.PhysicsModule.ODE | ||
12 | { | ||
13 | [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "ODEPhysicsScene")] | ||
14 | public class OdeModule : INonSharedRegionModule | ||
15 | { | ||
16 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | ||
17 | |||
18 | private bool m_Enabled = false; | ||
19 | private IConfigSource m_config; | ||
20 | private OdeScene m_scene; | ||
21 | |||
22 | #region INonSharedRegionModule | ||
23 | |||
24 | public string Name | ||
25 | { | ||
26 | get { return "OpenDynamicsEngine"; } | ||
27 | } | ||
28 | |||
29 | public Type ReplaceableInterface | ||
30 | { | ||
31 | get { return null; } | ||
32 | } | ||
33 | |||
34 | public void Initialise(IConfigSource source) | ||
35 | { | ||
36 | IConfig config = source.Configs["Startup"]; | ||
37 | if (config != null) | ||
38 | { | ||
39 | string physics = config.GetString("physics", string.Empty); | ||
40 | if (physics == Name) | ||
41 | { | ||
42 | m_config = source; | ||
43 | m_Enabled = true; | ||
44 | } | ||
45 | } | ||
46 | } | ||
47 | |||
48 | public void Close() | ||
49 | { | ||
50 | } | ||
51 | |||
52 | public void AddRegion(Scene scene) | ||
53 | { | ||
54 | if (!m_Enabled) | ||
55 | return; | ||
56 | |||
57 | if (Util.IsWindows()) | ||
58 | Util.LoadArchSpecificWindowsDll("ode.dll"); | ||
59 | |||
60 | // Initializing ODE only when a scene is created allows alternative ODE plugins to co-habit (according to | ||
61 | // http://opensimulator.org/mantis/view.php?id=2750). | ||
62 | d.InitODE(); | ||
63 | |||
64 | m_scene = new OdeScene(scene, m_config, Name); | ||
65 | } | ||
66 | |||
67 | public void RemoveRegion(Scene scene) | ||
68 | { | ||
69 | if (!m_Enabled || m_scene == null) | ||
70 | return; | ||
71 | |||
72 | m_scene.Dispose(); | ||
73 | m_scene = null; | ||
74 | } | ||
75 | |||
76 | public void RegionLoaded(Scene scene) | ||
77 | { | ||
78 | if (!m_Enabled || m_scene == null) | ||
79 | return; | ||
80 | |||
81 | m_scene.RegionLoaded(); | ||
82 | } | ||
83 | #endregion | ||
84 | } | ||
85 | } | ||