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