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 OpenSim.Framework;
7 using OpenSim.Region.Framework.Scenes;
8 using OpenSim.Region.Framework.Interfaces;
9 
10 namespace OpenSim.Region.PhysicsModule.ODE
11 {
12  [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "ODEPhysicsScene")]
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 Type ReplaceableInterface
29  {
30  get { return null; }
31  }
32 
33  public void Initialise(IConfigSource source)
34  {
35  IConfig config = source.Configs["Startup"];
36  if (config != null)
37  {
38  string physics = config.GetString("physics", string.Empty);
39  if (physics == Name)
40  {
41  m_config = source;
42  m_Enabled = true;
43  }
44  }
45  }
46 
47  public void Close()
48  {
49  }
50 
51  public void AddRegion(Scene scene)
52  {
53  if (!m_Enabled)
54  return;
55 
56  if (Util.IsWindows())
57  Util.LoadArchSpecificWindowsDll("ode.dll");
58 
59  // Initializing ODE only when a scene is created allows alternative ODE plugins to co-habit (according to
60  // http://opensimulator.org/mantis/view.php?id=2750).
61  d.InitODE();
62 
63  m_scene = new OdeScene(scene, m_config, Name);
64  }
65 
66  public void RemoveRegion(Scene scene)
67  {
68  if (!m_Enabled || m_scene == null)
69  return;
70 
71  m_scene.Dispose();
72  m_scene = null;
73  }
74 
75  public void RegionLoaded(Scene scene)
76  {
77  if (!m_Enabled || m_scene == null)
78  return;
79 
80  m_scene.RegionLoaded();
81  }
82  #endregion
83  }
84 }
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:75
void Close()
This is the inverse to Initialise. After a Close(), this instance won't be usable anymore...
Definition: ODEModule.cs:47
void AddRegion(Scene scene)
This is called whenever a Scene is added. For shared modules, this can happen several times...
Definition: ODEModule.cs:51
void Initialise(IConfigSource source)
This is called to initialize the region module. For shared modules, this is called exactly once...
Definition: ODEModule.cs:33
void RemoveRegion(Scene scene)
This is called whenever a Scene is removed. For shared modules, this can happen several times...
Definition: ODEModule.cs:66