diff options
author | UbitUmarov | 2015-09-09 18:53:24 +0100 |
---|---|---|
committer | UbitUmarov | 2015-09-09 18:53:24 +0100 |
commit | 47aa8107fd49039feb8dd95ec93e8ac80088e158 (patch) | |
tree | f8b6c11b111b19dfe45b4ccec62e179d9f78c4e8 /OpenSim/Region | |
parent | found core hack to fix modules interdependencies RegionLoaded is not that ob... (diff) | |
download | opensim-SC-47aa8107fd49039feb8dd95ec93e8ac80088e158.zip opensim-SC-47aa8107fd49039feb8dd95ec93e8ac80088e158.tar.gz opensim-SC-47aa8107fd49039feb8dd95ec93e8ac80088e158.tar.bz2 opensim-SC-47aa8107fd49039feb8dd95ec93e8ac80088e158.tar.xz |
let old ode also have a Module class
Diffstat (limited to '')
-rw-r--r-- | OpenSim/Region/PhysicsModules/Ode/ODEModule.cs | 85 | ||||
-rw-r--r-- | OpenSim/Region/PhysicsModules/Ode/OdeScene.cs | 92 | ||||
-rw-r--r-- | OpenSim/Region/PhysicsModules/Ode/Tests/ODETestClass.cs | 16 |
3 files changed, 113 insertions, 80 deletions
diff --git a/OpenSim/Region/PhysicsModules/Ode/ODEModule.cs b/OpenSim/Region/PhysicsModules/Ode/ODEModule.cs new file mode 100644 index 0000000..101e8b0 --- /dev/null +++ b/OpenSim/Region/PhysicsModules/Ode/ODEModule.cs | |||
@@ -0,0 +1,85 @@ | |||
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 | using Ode.NET; | ||
10 | |||
11 | namespace OpenSim.Region.PhysicsModule.ODE | ||
12 | { | ||
13 | [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "ODEPhysicsScene")] | ||
14 | public class OdeModule : 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 | |||
22 | #region INonSharedRegionModule | ||
23 | |||
24 | public string Name | ||
25 | { | ||
26 | get { return "OpenDynamicsEngine"; } | ||
27 | } | ||
28 | |||
29 | public Type ReplaceableInterface | ||
30 | { | ||
31 | get { return null; } | ||
32 | } | ||
33 | |||
34 | public void Initialise(IConfigSource source) | ||
35 | { | ||
36 | IConfig config = source.Configs["Startup"]; | ||
37 | if (config != null) | ||
38 | { | ||
39 | string physics = config.GetString("physics", string.Empty); | ||
40 | if (physics == Name) | ||
41 | { | ||
42 | m_config = source; | ||
43 | m_Enabled = true; | ||
44 | } | ||
45 | } | ||
46 | } | ||
47 | |||
48 | public void Close() | ||
49 | { | ||
50 | } | ||
51 | |||
52 | public void AddRegion(Scene scene) | ||
53 | { | ||
54 | if (!m_Enabled) | ||
55 | return; | ||
56 | |||
57 | if (Util.IsWindows()) | ||
58 | Util.LoadArchSpecificWindowsDll("ode.dll"); | ||
59 | |||
60 | // Initializing ODE only when a scene is created allows alternative ODE plugins to co-habit (according to | ||
61 | // http://opensimulator.org/mantis/view.php?id=2750). | ||
62 | d.InitODE(); | ||
63 | |||
64 | m_scene = new OdeScene(scene, m_config, Name); | ||
65 | } | ||
66 | |||
67 | public void RemoveRegion(Scene scene) | ||
68 | { | ||
69 | if (!m_Enabled || m_scene == null) | ||
70 | return; | ||
71 | |||
72 | m_scene.Dispose(); | ||
73 | m_scene = null; | ||
74 | } | ||
75 | |||
76 | public void RegionLoaded(Scene scene) | ||
77 | { | ||
78 | if (!m_Enabled || m_scene == null) | ||
79 | return; | ||
80 | |||
81 | m_scene.RegionLoaded(); | ||
82 | } | ||
83 | #endregion | ||
84 | } | ||
85 | } | ||
diff --git a/OpenSim/Region/PhysicsModules/Ode/OdeScene.cs b/OpenSim/Region/PhysicsModules/Ode/OdeScene.cs index 1d1b710..3ea522c 100644 --- a/OpenSim/Region/PhysicsModules/Ode/OdeScene.cs +++ b/OpenSim/Region/PhysicsModules/Ode/OdeScene.cs | |||
@@ -111,11 +111,9 @@ namespace OpenSim.Region.PhysicsModule.ODE | |||
111 | Rubber = 6 | 111 | Rubber = 6 |
112 | } | 112 | } |
113 | 113 | ||
114 | [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "ODEPhysicsScene")] | 114 | public class OdeScene : PhysicsScene |
115 | public class OdeScene : PhysicsScene, INonSharedRegionModule | ||
116 | { | 115 | { |
117 | private readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType.ToString()); | 116 | private readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType.ToString()); |
118 | private bool m_Enabled = false; | ||
119 | 117 | ||
120 | // private Dictionary<string, sCollisionData> m_storedCollisions = new Dictionary<string, sCollisionData>(); | 118 | // private Dictionary<string, sCollisionData> m_storedCollisions = new Dictionary<string, sCollisionData>(); |
121 | 119 | ||
@@ -534,89 +532,37 @@ namespace OpenSim.Region.PhysicsModule.ODE | |||
534 | int spaceGridMaxY; | 532 | int spaceGridMaxY; |
535 | 533 | ||
536 | private ODERayCastRequestManager m_rayCastManager; | 534 | private ODERayCastRequestManager m_rayCastManager; |
535 | |||
536 | public Scene m_frameWorkScene = null; | ||
537 | 537 | ||
538 | public OdeScene(Scene pscene, IConfigSource psourceconfig, string pname) | ||
539 | { | ||
540 | m_config = psourceconfig; | ||
541 | m_frameWorkScene = pscene; | ||
542 | |||
543 | EngineType = pname; | ||
544 | PhysicsSceneName = EngineType + "/" + pscene.RegionInfo.RegionName; | ||
538 | 545 | ||
539 | #region INonSharedRegionModule | 546 | pscene.RegisterModuleInterface<PhysicsScene>(this); |
540 | public string Name | 547 | Vector3 extent = new Vector3(pscene.RegionInfo.RegionSizeX, pscene.RegionInfo.RegionSizeY, pscene.RegionInfo.RegionSizeZ); |
541 | { | ||
542 | get { return "OpenDynamicsEngine"; } | ||
543 | } | ||
544 | |||
545 | public Type ReplaceableInterface | ||
546 | { | ||
547 | get { return null; } | ||
548 | } | ||
549 | |||
550 | public void Initialise(IConfigSource source) | ||
551 | { | ||
552 | // TODO: Move this out of Startup | ||
553 | IConfig config = source.Configs["Startup"]; | ||
554 | if (config != null) | ||
555 | { | ||
556 | string physics = config.GetString("physics", string.Empty); | ||
557 | if (physics == Name) | ||
558 | { | ||
559 | m_Enabled = true; | ||
560 | m_config = source; | ||
561 | |||
562 | // We do this so that OpenSimulator on Windows loads the correct native ODE library depending on whether | ||
563 | // it's running as a 32-bit process or a 64-bit one. By invoking LoadLibary here, later DLLImports | ||
564 | // will find it already loaded later on. | ||
565 | // | ||
566 | // This isn't necessary for other platforms (e.g. Mac OSX and Linux) since the DLL used can be | ||
567 | // controlled in Ode.NET.dll.config | ||
568 | if (Util.IsWindows()) | ||
569 | Util.LoadArchSpecificWindowsDll("ode.dll"); | ||
570 | |||
571 | // Initializing ODE only when a scene is created allows alternative ODE plugins to co-habit (according to | ||
572 | // http://opensimulator.org/mantis/view.php?id=2750). | ||
573 | d.InitODE(); | ||
574 | |||
575 | } | ||
576 | } | ||
577 | |||
578 | } | ||
579 | |||
580 | public void Close() | ||
581 | { | ||
582 | } | ||
583 | |||
584 | public void AddRegion(Scene scene) | ||
585 | { | ||
586 | if (!m_Enabled) | ||
587 | return; | ||
588 | |||
589 | EngineType = Name; | ||
590 | PhysicsSceneName = EngineType + "/" + scene.RegionInfo.RegionName; | ||
591 | |||
592 | scene.RegisterModuleInterface<PhysicsScene>(this); | ||
593 | Vector3 extent = new Vector3(scene.RegionInfo.RegionSizeX, scene.RegionInfo.RegionSizeY, scene.RegionInfo.RegionSizeZ); | ||
594 | Initialise(extent); | 548 | Initialise(extent); |
595 | InitialiseFromConfig(m_config); | 549 | InitialiseFromConfig(m_config); |
596 | 550 | ||
597 | // This may not be that good since terrain may not be avaiable at this point | 551 | // This may not be that good since terrain may not be avaiable at this point |
598 | base.Initialise(scene.PhysicsRequestAsset, | 552 | base.Initialise(pscene.PhysicsRequestAsset, |
599 | (scene.Heightmap != null ? scene.Heightmap.GetFloatsSerialised() : new float[(int)(extent.X * extent.Y)]), | 553 | (pscene.Heightmap != null ? pscene.Heightmap.GetFloatsSerialised() : new float[(int)(extent.X * extent.Y)]), |
600 | (float)scene.RegionInfo.RegionSettings.WaterHeight); | 554 | (float)pscene.RegionInfo.RegionSettings.WaterHeight); |
601 | 555 | ||
602 | } | 556 | } |
603 | 557 | ||
604 | public void RemoveRegion(Scene scene) | 558 | public void RegionLoaded() |
605 | { | 559 | { |
606 | if (!m_Enabled) | 560 | mesher = m_frameWorkScene.RequestModuleInterface<IMesher>(); |
607 | return; | ||
608 | } | ||
609 | |||
610 | public void RegionLoaded(Scene scene) | ||
611 | { | ||
612 | if (!m_Enabled) | ||
613 | return; | ||
614 | |||
615 | mesher = scene.RequestModuleInterface<IMesher>(); | ||
616 | if (mesher == null) | 561 | if (mesher == null) |
617 | m_log.WarnFormat("[ODE SCENE]: No mesher in {0}. Things will not work well.", PhysicsSceneName); | 562 | m_log.WarnFormat("[ODE SCENE]: No mesher in {0}. Things will not work well.", PhysicsSceneName); |
563 | |||
564 | m_frameWorkScene.PhysicsEnabled = true; | ||
618 | } | 565 | } |
619 | #endregion | ||
620 | 566 | ||
621 | /// <summary> | 567 | /// <summary> |
622 | /// Initiailizes the scene | 568 | /// Initiailizes the scene |
diff --git a/OpenSim/Region/PhysicsModules/Ode/Tests/ODETestClass.cs b/OpenSim/Region/PhysicsModules/Ode/Tests/ODETestClass.cs index 483e044..2c134e7 100644 --- a/OpenSim/Region/PhysicsModules/Ode/Tests/ODETestClass.cs +++ b/OpenSim/Region/PhysicsModules/Ode/Tests/ODETestClass.cs | |||
@@ -47,6 +47,8 @@ namespace OpenSim.Region.PhysicsModule.ODE.Tests | |||
47 | 47 | ||
48 | //private OpenSim.Region.PhysicsModule.ODE.OdePlugin cbt; | 48 | //private OpenSim.Region.PhysicsModule.ODE.OdePlugin cbt; |
49 | private PhysicsScene pScene; | 49 | private PhysicsScene pScene; |
50 | private OpenSim.Region.PhysicsModule.ODE.OdeModule odemodule; | ||
51 | |||
50 | 52 | ||
51 | [SetUp] | 53 | [SetUp] |
52 | public void Initialize() | 54 | public void Initialize() |
@@ -71,13 +73,12 @@ namespace OpenSim.Region.PhysicsModule.ODE.Tests | |||
71 | //mod.AddRegion(scene); | 73 | //mod.AddRegion(scene); |
72 | //mod.RegionLoaded(scene); | 74 | //mod.RegionLoaded(scene); |
73 | 75 | ||
74 | pScene = new OdeScene(); | 76 | // pScene = new OdeScene(); |
75 | Console.WriteLine("HERE " + (pScene == null ? "Null" : "Not null")); | 77 | odemodule = new OpenSim.Region.PhysicsModule.ODE.OdeModule(); |
76 | INonSharedRegionModule mod = (pScene as INonSharedRegionModule); | 78 | Console.WriteLine("HERE " + (odemodule == null ? "Null" : "Not null")); |
77 | Console.WriteLine("HERE " + (mod == null ? "Null" : "Not null")); | 79 | odemodule.Initialise(openSimINI); |
78 | mod.Initialise(openSimINI); | 80 | odemodule.AddRegion(scene); |
79 | mod.AddRegion(scene); | 81 | odemodule.RegionLoaded(scene); |
80 | mod.RegionLoaded(scene); | ||
81 | 82 | ||
82 | // Loading ODEPlugin | 83 | // Loading ODEPlugin |
83 | //cbt = new OdePlugin(); | 84 | //cbt = new OdePlugin(); |
@@ -90,6 +91,7 @@ namespace OpenSim.Region.PhysicsModule.ODE.Tests | |||
90 | { | 91 | { |
91 | _heightmap[i] = 21f; | 92 | _heightmap[i] = 21f; |
92 | } | 93 | } |
94 | pScene = scene.PhysicsScene; | ||
93 | pScene.SetTerrain(_heightmap); | 95 | pScene.SetTerrain(_heightmap); |
94 | } | 96 | } |
95 | 97 | ||