diff options
Diffstat (limited to '')
-rw-r--r-- | OpenSim/Region/PhysicsModules/ubOde/ODEModule.cs | 97 |
1 files changed, 97 insertions, 0 deletions
diff --git a/OpenSim/Region/PhysicsModules/ubOde/ODEModule.cs b/OpenSim/Region/PhysicsModules/ubOde/ODEModule.cs new file mode 100644 index 0000000..bd66b4d --- /dev/null +++ b/OpenSim/Region/PhysicsModules/ubOde/ODEModule.cs | |||
@@ -0,0 +1,97 @@ | |||
1 | using System; | ||
2 | using System.Reflection; | ||
3 | using log4net; | ||
4 | using Nini.Config; | ||
5 | using Mono.Addins; | ||
6 | using OdeAPI; | ||
7 | using OpenSim.Framework; | ||
8 | using OpenSim.Region.Framework.Scenes; | ||
9 | using OpenSim.Region.Framework.Interfaces; | ||
10 | |||
11 | namespace OpenSim.Region.PhysicsModule.ubOde | ||
12 | { | ||
13 | [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "ubODEPhysicsScene")] | ||
14 | class ubOdeModule : 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 | private bool OSOdeLib; | ||
22 | |||
23 | #region INonSharedRegionModule | ||
24 | |||
25 | public string Name | ||
26 | { | ||
27 | get { return "ubODE"; } | ||
28 | } | ||
29 | |||
30 | public Type ReplaceableInterface | ||
31 | { | ||
32 | get { return null; } | ||
33 | } | ||
34 | |||
35 | public void Initialise(IConfigSource source) | ||
36 | { | ||
37 | IConfig config = source.Configs["Startup"]; | ||
38 | if (config != null) | ||
39 | { | ||
40 | string physics = config.GetString("physics", string.Empty); | ||
41 | if (physics == Name) | ||
42 | { | ||
43 | m_config = source; | ||
44 | m_Enabled = true; | ||
45 | } | ||
46 | } | ||
47 | } | ||
48 | |||
49 | public void Close() | ||
50 | { | ||
51 | } | ||
52 | |||
53 | public void AddRegion(Scene scene) | ||
54 | { | ||
55 | if (!m_Enabled) | ||
56 | return; | ||
57 | |||
58 | if (Util.IsWindows()) | ||
59 | Util.LoadArchSpecificWindowsDll("ode.dll"); | ||
60 | |||
61 | // Initializing ODE only when a scene is created allows alternative ODE plugins to co-habit (according to | ||
62 | // http://opensimulator.org/mantis/view.php?id=2750). | ||
63 | d.InitODE(); | ||
64 | |||
65 | string ode_config = d.GetConfiguration(); | ||
66 | if (ode_config != null && ode_config != "") | ||
67 | { | ||
68 | m_log.InfoFormat("[ubODE] ode library configuration: {0}", ode_config); | ||
69 | // ubODE still not avaiable | ||
70 | if (ode_config.Contains("ODE_OPENSIM")) | ||
71 | { | ||
72 | OSOdeLib = true; | ||
73 | } | ||
74 | } | ||
75 | |||
76 | m_scene = new ODEScene(scene, m_config, Name, OSOdeLib); | ||
77 | } | ||
78 | |||
79 | public void RemoveRegion(Scene scene) | ||
80 | { | ||
81 | if (!m_Enabled || m_scene == null) | ||
82 | return; | ||
83 | |||
84 | m_scene.Dispose(); | ||
85 | m_scene = null; | ||
86 | } | ||
87 | |||
88 | public void RegionLoaded(Scene scene) | ||
89 | { | ||
90 | if (!m_Enabled || m_scene == null) | ||
91 | return; | ||
92 | |||
93 | m_scene.RegionLoaded(); | ||
94 | } | ||
95 | #endregion | ||
96 | } | ||
97 | } | ||