OpenSim
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Events Macros
ODEModule.cs
Go to the documentation of this file.
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")]
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 }
void Close()
This is the inverse to Initialise. After a Close(), this instance won't be usable anymore...
Definition: ODEModule.cs:49
void RemoveRegion(Scene scene)
This is called whenever a Scene is removed. For shared modules, this can happen several times...
Definition: ODEModule.cs:79
void AddRegion(Scene scene)
This is called whenever a Scene is added. For shared modules, this can happen several times...
Definition: ODEModule.cs:53
void RegionLoaded(Scene scene)
This will be called once for every scene loaded. In a shared module this will be multiple times in on...
Definition: ODEModule.cs:88
void Initialise(IConfigSource source)
This is called to initialize the region module. For shared modules, this is called exactly once...
Definition: ODEModule.cs:35