diff options
author | UbitUmarov | 2015-09-09 17:15:04 +0100 |
---|---|---|
committer | UbitUmarov | 2015-09-09 17:15:04 +0100 |
commit | 8571736ff31ad46e46e2a6ebf342aecbe686ea36 (patch) | |
tree | a51eef352d031c5aa1dd804286aab828a2960e3c /OpenSim | |
parent | demote ConvexDecompositionDotNet to a simple dll, i had made it a region module (diff) | |
download | opensim-SC-8571736ff31ad46e46e2a6ebf342aecbe686ea36.zip opensim-SC-8571736ff31ad46e46e2a6ebf342aecbe686ea36.tar.gz opensim-SC-8571736ff31ad46e46e2a6ebf342aecbe686ea36.tar.bz2 opensim-SC-8571736ff31ad46e46e2a6ebf342aecbe686ea36.tar.xz |
split Module from its scene, so if not enabled there is no scene memory allocation. All physics modules need this ( if not others)
Diffstat (limited to 'OpenSim')
-rw-r--r-- | OpenSim/Region/PhysicsModules/UbitOde/ODEModule.cs | 88 | ||||
-rw-r--r-- | OpenSim/Region/PhysicsModules/UbitOde/OdeScene.cs | 122 |
2 files changed, 113 insertions, 97 deletions
diff --git a/OpenSim/Region/PhysicsModules/UbitOde/ODEModule.cs b/OpenSim/Region/PhysicsModules/UbitOde/ODEModule.cs new file mode 100644 index 0000000..7c3c688 --- /dev/null +++ b/OpenSim/Region/PhysicsModules/UbitOde/ODEModule.cs | |||
@@ -0,0 +1,88 @@ | |||
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.UbitOde | ||
12 | { | ||
13 | [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "UBITODEPhysicsScene")] | ||
14 | class UbitOdeModule : 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 OdeUbitLib; | ||
22 | |||
23 | #region INonSharedRegionModule | ||
24 | |||
25 | public string Name | ||
26 | { | ||
27 | get { return "UbitODE"; } | ||
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("[UbitODE] ode library configuration: {0}", ode_config); | ||
69 | |||
70 | if (ode_config.Contains("ODE_Ubit")) | ||
71 | { | ||
72 | OdeUbitLib = true; | ||
73 | } | ||
74 | } | ||
75 | |||
76 | m_scene = new ODEScene(scene, m_config, Name, OdeUbitLib); | ||
77 | } | ||
78 | |||
79 | public void RemoveRegion(Scene scene) | ||
80 | { | ||
81 | } | ||
82 | |||
83 | public void RegionLoaded(Scene scene) | ||
84 | { | ||
85 | } | ||
86 | #endregion | ||
87 | } | ||
88 | } | ||
diff --git a/OpenSim/Region/PhysicsModules/UbitOde/OdeScene.cs b/OpenSim/Region/PhysicsModules/UbitOde/OdeScene.cs index 8d3066d..58eb4b5 100644 --- a/OpenSim/Region/PhysicsModules/UbitOde/OdeScene.cs +++ b/OpenSim/Region/PhysicsModules/UbitOde/OdeScene.cs | |||
@@ -165,16 +165,13 @@ namespace OpenSim.Region.PhysicsModule.UbitOde | |||
165 | public Object arg; | 165 | public Object arg; |
166 | } | 166 | } |
167 | 167 | ||
168 | 168 | public class ODEScene : PhysicsScene | |
169 | [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "UBITODEPhysicsScene")] | ||
170 | public class ODEScene : PhysicsScene, INonSharedRegionModule | ||
171 | { | 169 | { |
172 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | 170 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); |
173 | 171 | ||
174 | private bool m_Enabled = false; | 172 | public bool m_odeUbitLib = false; |
175 | |||
176 | public bool OdeUbitLib = false; | ||
177 | public bool m_suportCombine = false; // mega suport not tested | 173 | public bool m_suportCombine = false; // mega suport not tested |
174 | public Scene m_frameWorkScene = null; | ||
178 | 175 | ||
179 | // private int threadid = 0; | 176 | // private int threadid = 0; |
180 | 177 | ||
@@ -327,112 +324,43 @@ namespace OpenSim.Region.PhysicsModule.UbitOde | |||
327 | } | 324 | } |
328 | } | 325 | } |
329 | */ | 326 | */ |
330 | #region INonSharedRegionModule | 327 | |
331 | 328 | public ODEScene(Scene pscene, IConfigSource psourceconfig, string pname, bool podeUbitLib) | |
332 | public string Name | ||
333 | { | ||
334 | get { return "UbitODE"; } | ||
335 | } | ||
336 | |||
337 | public Type ReplaceableInterface | ||
338 | { | ||
339 | get { return null; } | ||
340 | } | ||
341 | |||
342 | public void Initialise(IConfigSource source) | ||
343 | { | ||
344 | // TODO: Move this out of Startup | ||
345 | IConfig config = source.Configs["Startup"]; | ||
346 | if (config != null) | ||
347 | { | ||
348 | string physics = config.GetString("physics", string.Empty); | ||
349 | if (physics == Name) | ||
350 | { | ||
351 | m_config = source; | ||
352 | m_Enabled = true; | ||
353 | } | ||
354 | } | ||
355 | } | ||
356 | |||
357 | public void Close() | ||
358 | { | ||
359 | } | ||
360 | |||
361 | public void AddRegion(Scene scene) | ||
362 | { | 329 | { |
363 | if (!m_Enabled) | ||
364 | return; | ||
365 | |||
366 | EngineType = Name; | ||
367 | PhysicsSceneName = EngineType + "/" + scene.RegionInfo.RegionName; | ||
368 | |||
369 | OdeLock = new Object(); | 330 | OdeLock = new Object(); |
370 | 331 | ||
371 | // We do this so that OpenSimulator on Windows loads the correct native ODE library depending on whether | 332 | EngineType = pname; |
372 | // it's running as a 32-bit process or a 64-bit one. By invoking LoadLibary here, later DLLImports | 333 | PhysicsSceneName = EngineType + "/" + pscene.RegionInfo.RegionName; |
373 | // will find it already loaded later on. | ||
374 | // | ||
375 | // This isn't necessary for other platforms (e.g. Mac OSX and Linux) since the DLL used can be | ||
376 | // controlled in Ode.NET.dll.config | ||
377 | if (Util.IsWindows()) | ||
378 | Util.LoadArchSpecificWindowsDll("ode.dll"); | ||
379 | |||
380 | // Initializing ODE only when a scene is created allows alternative ODE plugins to co-habit (according to | ||
381 | // http://opensimulator.org/mantis/view.php?id=2750). | ||
382 | d.InitODE(); | ||
383 | |||
384 | string ode_config = d.GetConfiguration(); | ||
385 | if (ode_config != null && ode_config != "") | ||
386 | { | ||
387 | m_log.InfoFormat("[UbitODE] ode library configuration: {0}", ode_config); | ||
388 | |||
389 | if (ode_config.Contains("ODE_Ubit")) | ||
390 | { | ||
391 | OdeUbitLib = true; | ||
392 | } | ||
393 | } | ||
394 | 334 | ||
395 | Vector3 extent = new Vector3(scene.RegionInfo.RegionSizeX, scene.RegionInfo.RegionSizeY, scene.RegionInfo.RegionSizeZ); | 335 | m_config = psourceconfig; |
336 | m_odeUbitLib = podeUbitLib; | ||
337 | m_frameWorkScene = pscene; | ||
396 | 338 | ||
397 | mesher = scene.RequestModuleInterface<IMesher>(); | 339 | mesher = m_frameWorkScene.RequestModuleInterface<IMesher>(); |
398 | if (mesher == null) | 340 | if (mesher == null) |
399 | { | 341 | { |
400 | m_log.WarnFormat("[UbitODE] No mesher. module disabled"); | 342 | m_log.WarnFormat("[UbitODE] No mesher. module disabled"); |
401 | m_Enabled = false; | ||
402 | return; | 343 | return; |
403 | } | 344 | } |
404 | 345 | ||
405 | scene.RegisterModuleInterface<PhysicsScene>(this); | 346 | m_frameWorkScene.RegisterModuleInterface<PhysicsScene>(this); |
406 | 347 | ||
407 | Initialization(extent); | 348 | Initialization(); |
408 | 349 | ||
409 | base.Initialise(scene.PhysicsRequestAsset, | 350 | base.Initialise(m_frameWorkScene.PhysicsRequestAsset, |
410 | (scene.Heightmap != null ? scene.Heightmap.GetFloatsSerialised() : new float[scene.RegionInfo.RegionSizeX * scene.RegionInfo.RegionSizeY]), | 351 | (m_frameWorkScene.Heightmap != null ? m_frameWorkScene.Heightmap.GetFloatsSerialised() : new float[m_frameWorkScene.RegionInfo.RegionSizeX * m_frameWorkScene.RegionInfo.RegionSizeY]), |
411 | (float)scene.RegionInfo.RegionSettings.WaterHeight); | 352 | (float)m_frameWorkScene.RegionInfo.RegionSettings.WaterHeight); |
412 | 353 | ||
413 | 354 | ||
414 | scene.PhysicsEnabled = true; | 355 | m_frameWorkScene.PhysicsEnabled = true; |
415 | } | ||
416 | |||
417 | public void RemoveRegion(Scene scene) | ||
418 | { | ||
419 | // if (!m_Enabled) | ||
420 | // return; | ||
421 | } | 356 | } |
422 | 357 | ||
423 | public void RegionLoaded(Scene scene) | ||
424 | { | ||
425 | // if (!m_Enabled) | ||
426 | // return; | ||
427 | } | ||
428 | #endregion | ||
429 | |||
430 | /// <summary> | 358 | /// <summary> |
431 | /// Initiailizes the scene | 359 | /// Initiailizes the scene |
432 | /// Sets many properties that ODE requires to be stable | 360 | /// Sets many properties that ODE requires to be stable |
433 | /// These settings need to be tweaked 'exactly' right or weird stuff happens. | 361 | /// These settings need to be tweaked 'exactly' right or weird stuff happens. |
434 | /// </summary> | 362 | /// </summary> |
435 | private void Initialization(Vector3 regionExtent) | 363 | private void Initialization() |
436 | { | 364 | { |
437 | // checkThread(); | 365 | // checkThread(); |
438 | SimulationLock = new Object(); | 366 | SimulationLock = new Object(); |
@@ -441,10 +369,10 @@ namespace OpenSim.Region.PhysicsModule.UbitOde | |||
441 | 369 | ||
442 | m_rayCastManager = new ODERayCastRequestManager(this); | 370 | m_rayCastManager = new ODERayCastRequestManager(this); |
443 | 371 | ||
444 | WorldExtents.X = regionExtent.X; | 372 | WorldExtents.X = m_frameWorkScene.RegionInfo.RegionSizeX; |
445 | m_regionWidth = (uint)regionExtent.X; | 373 | m_regionWidth = (uint)WorldExtents.X; |
446 | WorldExtents.Y = regionExtent.Y; | 374 | WorldExtents.Y = m_frameWorkScene.RegionInfo.RegionSizeY; |
447 | m_regionHeight = (uint)regionExtent.Y; | 375 | m_regionHeight = (uint)WorldExtents.Y; |
448 | 376 | ||
449 | m_suportCombine = false; | 377 | m_suportCombine = false; |
450 | 378 | ||
@@ -1995,7 +1923,7 @@ namespace OpenSim.Region.PhysicsModule.UbitOde | |||
1995 | int regsizeY = (int)m_regionHeight + 3; // map size see setterrain number of samples | 1923 | int regsizeY = (int)m_regionHeight + 3; // map size see setterrain number of samples |
1996 | int regsize = regsizeX; | 1924 | int regsize = regsizeX; |
1997 | 1925 | ||
1998 | if (OdeUbitLib) | 1926 | if (m_odeUbitLib) |
1999 | { | 1927 | { |
2000 | if (x < regsizeX - 1) | 1928 | if (x < regsizeX - 1) |
2001 | { | 1929 | { |
@@ -2139,7 +2067,7 @@ namespace OpenSim.Region.PhysicsModule.UbitOde | |||
2139 | int ystep = regsizeX; | 2067 | int ystep = regsizeX; |
2140 | bool firstTri = false; | 2068 | bool firstTri = false; |
2141 | 2069 | ||
2142 | if (OdeUbitLib) | 2070 | if (m_odeUbitLib) |
2143 | { | 2071 | { |
2144 | if (x < regsizeX - 1) | 2072 | if (x < regsizeX - 1) |
2145 | { | 2073 | { |
@@ -2251,7 +2179,7 @@ namespace OpenSim.Region.PhysicsModule.UbitOde | |||
2251 | 2179 | ||
2252 | public void SetTerrain(float[] heightMap, Vector3 pOffset) | 2180 | public void SetTerrain(float[] heightMap, Vector3 pOffset) |
2253 | { | 2181 | { |
2254 | if (OdeUbitLib) | 2182 | if (m_odeUbitLib) |
2255 | UbitSetTerrain(heightMap, pOffset); | 2183 | UbitSetTerrain(heightMap, pOffset); |
2256 | else | 2184 | else |
2257 | OriSetTerrain(heightMap, pOffset); | 2185 | OriSetTerrain(heightMap, pOffset); |