diff options
Diffstat (limited to 'OpenSim/Region/PhysicsModules/ubOde/ODEModule.cs')
-rw-r--r-- | OpenSim/Region/PhysicsModules/ubOde/ODEModule.cs | 112 |
1 files changed, 112 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..4cb1736 --- /dev/null +++ b/OpenSim/Region/PhysicsModules/ubOde/ODEModule.cs | |||
@@ -0,0 +1,112 @@ | |||
1 | using System; | ||
2 | using System.Collections.Generic; | ||
3 | using System.Reflection; | ||
4 | using log4net; | ||
5 | using Nini.Config; | ||
6 | using Mono.Addins; | ||
7 | using OdeAPI; | ||
8 | using OpenSim.Framework; | ||
9 | using OpenSim.Region.Framework.Scenes; | ||
10 | using OpenSim.Region.Framework.Interfaces; | ||
11 | |||
12 | namespace OpenSim.Region.PhysicsModule.ubOde | ||
13 | { | ||
14 | [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "ubODEPhysicsScene")] | ||
15 | class ubOdeModule : INonSharedRegionModule | ||
16 | { | ||
17 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | ||
18 | |||
19 | private static Dictionary<Scene, ODEScene> m_scenes = new Dictionary<Scene, ODEScene>(); | ||
20 | private bool m_Enabled = false; | ||
21 | private IConfigSource m_config; | ||
22 | private bool OSOdeLib; | ||
23 | |||
24 | |||
25 | #region INonSharedRegionModule | ||
26 | |||
27 | public string Name | ||
28 | { | ||
29 | get { return "ubODE"; } | ||
30 | } | ||
31 | |||
32 | public string Version | ||
33 | { | ||
34 | get { return "1.0"; } | ||
35 | } | ||
36 | |||
37 | public Type ReplaceableInterface | ||
38 | { | ||
39 | get { return null; } | ||
40 | } | ||
41 | |||
42 | public void Initialise(IConfigSource source) | ||
43 | { | ||
44 | IConfig config = source.Configs["Startup"]; | ||
45 | if (config != null) | ||
46 | { | ||
47 | string physics = config.GetString("physics", string.Empty); | ||
48 | if (physics == Name) | ||
49 | { | ||
50 | m_config = source; | ||
51 | m_Enabled = true; | ||
52 | |||
53 | if (Util.IsWindows()) | ||
54 | Util.LoadArchSpecificWindowsDll("ode.dll"); | ||
55 | |||
56 | d.InitODE(); | ||
57 | |||
58 | string ode_config = d.GetConfiguration(); | ||
59 | if (ode_config != null && ode_config != "") | ||
60 | { | ||
61 | m_log.InfoFormat("[ubODE] ode library configuration: {0}", ode_config); | ||
62 | |||
63 | if (ode_config.Contains("ODE_OPENSIM")) | ||
64 | { | ||
65 | OSOdeLib = true; | ||
66 | } | ||
67 | } | ||
68 | } | ||
69 | } | ||
70 | } | ||
71 | |||
72 | public void Close() | ||
73 | { | ||
74 | } | ||
75 | |||
76 | public void AddRegion(Scene scene) | ||
77 | { | ||
78 | if (!m_Enabled) | ||
79 | return; | ||
80 | |||
81 | if(m_scenes.ContainsKey(scene)) // ??? | ||
82 | return; | ||
83 | ODEScene newodescene = new ODEScene(scene, m_config, Name, Version, OSOdeLib); | ||
84 | m_scenes[scene] = newodescene; | ||
85 | } | ||
86 | |||
87 | public void RemoveRegion(Scene scene) | ||
88 | { | ||
89 | if (!m_Enabled) | ||
90 | return; | ||
91 | |||
92 | // a odescene.dispose is called later directly by scene.cs | ||
93 | // since it is seen as a module interface | ||
94 | |||
95 | if(m_scenes.ContainsKey(scene)) | ||
96 | m_scenes.Remove(scene); | ||
97 | } | ||
98 | |||
99 | public void RegionLoaded(Scene scene) | ||
100 | { | ||
101 | if (!m_Enabled) | ||
102 | return; | ||
103 | |||
104 | if(m_scenes.ContainsKey(scene)) | ||
105 | { | ||
106 | m_scenes[scene].RegionLoaded(); | ||
107 | } | ||
108 | |||
109 | } | ||
110 | #endregion | ||
111 | } | ||
112 | } | ||