aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/PhysicsModules
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Region/PhysicsModules')
-rw-r--r--OpenSim/Region/PhysicsModules/BasicPhysics/BasicPhysicsPlugin.cs64
-rw-r--r--OpenSim/Region/PhysicsModules/BasicPhysics/BasicPhysicsScene.cs6
-rw-r--r--OpenSim/Region/PhysicsModules/BulletS/BSPlugin.cs76
-rw-r--r--OpenSim/Region/PhysicsModules/BulletS/BSScene.cs2
-rw-r--r--OpenSim/Region/PhysicsModules/Ode/OdePlugin.cs90
-rw-r--r--OpenSim/Region/PhysicsModules/Ode/Tests/ODETestClass.cs1
-rw-r--r--OpenSim/Region/PhysicsModules/POS/POSPlugin.cs64
-rw-r--r--OpenSim/Region/PhysicsModules/SharedBase/PhysicsPluginManager.cs235
8 files changed, 4 insertions, 534 deletions
diff --git a/OpenSim/Region/PhysicsModules/BasicPhysics/BasicPhysicsPlugin.cs b/OpenSim/Region/PhysicsModules/BasicPhysics/BasicPhysicsPlugin.cs
deleted file mode 100644
index db02eb6..0000000
--- a/OpenSim/Region/PhysicsModules/BasicPhysics/BasicPhysicsPlugin.cs
+++ /dev/null
@@ -1,64 +0,0 @@
1/*
2 * Copyright (c) Contributors, http://opensimulator.org/
3 * See CONTRIBUTORS.TXT for a full list of copyright holders.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met:
7 * * Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * * Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
12 * * Neither the name of the OpenSimulator Project nor the
13 * names of its contributors may be used to endorse or promote products
14 * derived from this software without specific prior written permission.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
17 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */
27
28using System;
29using System.Collections.Generic;
30using Nini.Config;
31using OpenSim.Framework;
32using OpenSim.Region.PhysicsModules.SharedBase;
33
34namespace OpenSim.Region.PhysicsModule.BasicPhysics
35{
36 /// <summary>
37 /// Effectively a physics plugin that simulates no physics at all.
38 /// </summary>
39 //public class BasicPhysicsPlugin : IPhysicsPlugin
40 //{
41 // public BasicPhysicsPlugin()
42 // {
43 // }
44
45 // public bool Init()
46 // {
47 // return true;
48 // }
49
50 // public PhysicsScene GetScene(string sceneIdentifier)
51 // {
52 // return new BasicScene(GetName(), sceneIdentifier);
53 // }
54
55 // public string GetName()
56 // {
57 // return ("basicphysics");
58 // }
59
60 // public void Dispose()
61 // {
62 // }
63 //}
64}
diff --git a/OpenSim/Region/PhysicsModules/BasicPhysics/BasicPhysicsScene.cs b/OpenSim/Region/PhysicsModules/BasicPhysics/BasicPhysicsScene.cs
index 10684d1..20b337a 100644
--- a/OpenSim/Region/PhysicsModules/BasicPhysics/BasicPhysicsScene.cs
+++ b/OpenSim/Region/PhysicsModules/BasicPhysics/BasicPhysicsScene.cs
@@ -94,7 +94,7 @@ namespace OpenSim.Region.PhysicsModule.BasicPhysics
94 scene.RegisterModuleInterface<PhysicsScene>(this); 94 scene.RegisterModuleInterface<PhysicsScene>(this);
95 m_regionExtent = new Vector3(scene.RegionInfo.RegionSizeX, scene.RegionInfo.RegionSizeY, scene.RegionInfo.RegionSizeZ); 95 m_regionExtent = new Vector3(scene.RegionInfo.RegionSizeX, scene.RegionInfo.RegionSizeY, scene.RegionInfo.RegionSizeZ);
96 base.Initialise(scene.PhysicsRequestAsset, 96 base.Initialise(scene.PhysicsRequestAsset,
97 (scene.Heightmap != null ? scene.Heightmap.GetFloatsSerialised() : new float[Constants.RegionSize * Constants.RegionSize]), 97 (scene.Heightmap != null ? scene.Heightmap.GetFloatsSerialised() : new float[scene.RegionInfo.RegionSizeX * scene.RegionInfo.RegionSizeY]),
98 (float)scene.RegionInfo.RegionSettings.WaterHeight); 98 (float)scene.RegionInfo.RegionSettings.WaterHeight);
99 99
100 } 100 }
@@ -164,8 +164,8 @@ namespace OpenSim.Region.PhysicsModule.BasicPhysics
164 Vector3 actorPosition = actor.Position; 164 Vector3 actorPosition = actor.Position;
165 Vector3 actorVelocity = actor.Velocity; 165 Vector3 actorVelocity = actor.Velocity;
166 166
167// Console.WriteLine( 167 //Console.WriteLine(
168// "Processing actor {0}, starting pos {1}, starting vel {2}", i, actorPosition, actorVelocity); 168 // "Processing actor {0}, starting pos {1}, starting vel {2}", i, actorPosition, actorVelocity);
169 169
170 actorPosition.X += actor.Velocity.X * timeStep; 170 actorPosition.X += actor.Velocity.X * timeStep;
171 actorPosition.Y += actor.Velocity.Y * timeStep; 171 actorPosition.Y += actor.Velocity.Y * timeStep;
diff --git a/OpenSim/Region/PhysicsModules/BulletS/BSPlugin.cs b/OpenSim/Region/PhysicsModules/BulletS/BSPlugin.cs
deleted file mode 100644
index 7fc51f7..0000000
--- a/OpenSim/Region/PhysicsModules/BulletS/BSPlugin.cs
+++ /dev/null
@@ -1,76 +0,0 @@
1/*
2 * Copyright (c) Contributors, http://opensimulator.org/
3 * See CONTRIBUTORS.TXT for a full list of copyright holders.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met:
7 * * Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * * Redistributions in binary form must reproduce the above copyrightD
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
12 * * Neither the name of the OpenSimulator Project nor the
13 * names of its contributors may be used to endorse or promote products
14 * derived from this software without specific prior written permission.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
17 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */
27using System;
28using System.Collections.Generic;
29using OpenSim.Framework;
30using OpenSim.Region.PhysicsModules.SharedBase;
31using OpenMetaverse;
32
33namespace OpenSim.Region.PhysicsModule.BulletS
34{
35 /// <summary>
36 /// Entry for a port of Bullet (http://bulletphysics.org/) to OpenSim.
37 /// This module interfaces to an unmanaged C++ library which makes the
38 /// actual calls into the Bullet physics engine.
39 /// The unmanaged library is found in opensim-libs::trunk/unmanaged/BulletSim/.
40 /// The unmanaged library is compiled and linked statically with Bullet
41 /// to create BulletSim.dll and libBulletSim.so (for both 32 and 64 bit).
42 /// </summary>
43//public class BSPlugin : IPhysicsPlugin
44//{
45// //private static readonly log4net.ILog m_log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
46
47// private BSScene _mScene;
48
49// public BSPlugin()
50// {
51// }
52
53// public bool Init()
54// {
55// return true;
56// }
57
58// public PhysicsScene GetScene(String sceneIdentifier)
59// {
60// if (_mScene == null)
61// {
62// _mScene = new BSScene(GetName(), sceneIdentifier);
63// }
64// return (_mScene);
65// }
66
67// public string GetName()
68// {
69// return ("BulletSim");
70// }
71
72// public void Dispose()
73// {
74// }
75//}
76}
diff --git a/OpenSim/Region/PhysicsModules/BulletS/BSScene.cs b/OpenSim/Region/PhysicsModules/BulletS/BSScene.cs
index d116c3b..db4d3cf 100644
--- a/OpenSim/Region/PhysicsModules/BulletS/BSScene.cs
+++ b/OpenSim/Region/PhysicsModules/BulletS/BSScene.cs
@@ -251,7 +251,7 @@ namespace OpenSim.Region.PhysicsModule.BulletS
251 Initialise(m_Config, extent); 251 Initialise(m_Config, extent);
252 252
253 base.Initialise(scene.PhysicsRequestAsset, 253 base.Initialise(scene.PhysicsRequestAsset,
254 (scene.Heightmap != null ? scene.Heightmap.GetFloatsSerialised() : new float[Constants.RegionSize * Constants.RegionSize]), 254 (scene.Heightmap != null ? scene.Heightmap.GetFloatsSerialised() : new float[scene.RegionInfo.RegionSizeX * scene.RegionInfo.RegionSizeY]),
255 (float)scene.RegionInfo.RegionSettings.WaterHeight); 255 (float)scene.RegionInfo.RegionSettings.WaterHeight);
256 256
257 } 257 }
diff --git a/OpenSim/Region/PhysicsModules/Ode/OdePlugin.cs b/OpenSim/Region/PhysicsModules/Ode/OdePlugin.cs
deleted file mode 100644
index bb2fad9..0000000
--- a/OpenSim/Region/PhysicsModules/Ode/OdePlugin.cs
+++ /dev/null
@@ -1,90 +0,0 @@
1/*
2 * Copyright (c) Contributors, http://opensimulator.org/
3 * See CONTRIBUTORS.TXT for a full list of copyright holders.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met:
7 * * Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * * Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
12 * * Neither the name of the OpenSimulator Project nor the
13 * names of its contributors may be used to endorse or promote products
14 * derived from this software without specific prior written permission.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
17 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */
27
28using System;
29using System.Collections.Generic;
30using System.Reflection;
31using System.Runtime.InteropServices;
32using System.Threading;
33using System.IO;
34using System.Diagnostics;
35using log4net;
36using Nini.Config;
37using Ode.NET;
38using OpenSim.Framework;
39using OpenSim.Region.PhysicsModules.SharedBase;
40using OpenMetaverse;
41
42namespace OpenSim.Region.PhysicsModule.ODE
43{
44 /// <summary>
45 /// ODE plugin
46 /// </summary>
47// public class OdePlugin : IPhysicsPlugin
48// {
49//// private static readonly log4net.ILog m_log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
50
51// private OdeScene m_scene;
52
53// public bool Init()
54// {
55// return true;
56// }
57
58// public PhysicsScene GetScene(String sceneIdentifier)
59// {
60// if (m_scene == null)
61// {
62// // We do this so that OpenSimulator on Windows loads the correct native ODE library depending on whether
63// // it's running as a 32-bit process or a 64-bit one. By invoking LoadLibary here, later DLLImports
64// // will find it already loaded later on.
65// //
66// // This isn't necessary for other platforms (e.g. Mac OSX and Linux) since the DLL used can be
67// // controlled in Ode.NET.dll.config
68// if (Util.IsWindows())
69// Util.LoadArchSpecificWindowsDll("ode.dll");
70
71// // Initializing ODE only when a scene is created allows alternative ODE plugins to co-habit (according to
72// // http://opensimulator.org/mantis/view.php?id=2750).
73// d.InitODE();
74
75// m_scene = new OdeScene(GetName(), sceneIdentifier);
76// }
77
78// return m_scene;
79// }
80
81// public string GetName()
82// {
83// return ("OpenDynamicsEngine");
84// }
85
86// public void Dispose()
87// {
88// }
89// }
90} \ No newline at end of file
diff --git a/OpenSim/Region/PhysicsModules/Ode/Tests/ODETestClass.cs b/OpenSim/Region/PhysicsModules/Ode/Tests/ODETestClass.cs
index 36b65cf..6dc22bd 100644
--- a/OpenSim/Region/PhysicsModules/Ode/Tests/ODETestClass.cs
+++ b/OpenSim/Region/PhysicsModules/Ode/Tests/ODETestClass.cs
@@ -47,7 +47,6 @@ 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 IMeshingPlugin imp;
51 50
52 [SetUp] 51 [SetUp]
53 public void Initialize() 52 public void Initialize()
diff --git a/OpenSim/Region/PhysicsModules/POS/POSPlugin.cs b/OpenSim/Region/PhysicsModules/POS/POSPlugin.cs
deleted file mode 100644
index d233097..0000000
--- a/OpenSim/Region/PhysicsModules/POS/POSPlugin.cs
+++ /dev/null
@@ -1,64 +0,0 @@
1/*
2 * Copyright (c) Contributors, http://opensimulator.org/
3 * See CONTRIBUTORS.TXT for a full list of copyright holders.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met:
7 * * Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * * Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
12 * * Neither the name of the OpenSimulator Project nor the
13 * names of its contributors may be used to endorse or promote products
14 * derived from this software without specific prior written permission.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
17 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */
27
28using System;
29using System.Collections.Generic;
30using Nini.Config;
31using OpenSim.Framework;
32using OpenSim.Region.PhysicsModules.SharedBase;
33
34namespace OpenSim.Region.PhysicsModule.POS
35{
36 /// <summary>
37 /// for now will be a very POS physics engine
38 /// </summary>
39 //public class POSPlugin : IPhysicsPlugin
40 //{
41 // public POSPlugin()
42 // {
43 // }
44
45 // public bool Init()
46 // {
47 // return true;
48 // }
49
50 // public PhysicsScene GetScene(string sceneIdentifier)
51 // {
52 // return new POSScene(GetName(), sceneIdentifier);
53 // }
54
55 // public string GetName()
56 // {
57 // return ("POS");
58 // }
59
60 // public void Dispose()
61 // {
62 // }
63 //}
64}
diff --git a/OpenSim/Region/PhysicsModules/SharedBase/PhysicsPluginManager.cs b/OpenSim/Region/PhysicsModules/SharedBase/PhysicsPluginManager.cs
deleted file mode 100644
index 487582c..0000000
--- a/OpenSim/Region/PhysicsModules/SharedBase/PhysicsPluginManager.cs
+++ /dev/null
@@ -1,235 +0,0 @@
1/*
2 * Copyright (c) Contributors, http://opensimulator.org/
3 * See CONTRIBUTORS.TXT for a full list of copyright holders.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met:
7 * * Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * * Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
12 * * Neither the name of the OpenSimulator Project nor the
13 * names of its contributors may be used to endorse or promote products
14 * derived from this software without specific prior written permission.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
17 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */
27
28using System;
29using System.Collections.Generic;
30using System.IO;
31using System.Reflection;
32using Nini.Config;
33using log4net;
34using OpenSim.Framework;
35using OpenMetaverse;
36
37namespace OpenSim.Region.PhysicsModules.SharedBase
38{
39 /// <summary>
40 /// Description of MyClass.
41 /// </summary>
42 public class PhysicsPluginManager
43 {
44 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
45
46 private Dictionary<string, IPhysicsPlugin> _PhysPlugins = new Dictionary<string, IPhysicsPlugin>();
47 private Dictionary<string, IMeshingPlugin> _MeshPlugins = new Dictionary<string, IMeshingPlugin>();
48
49 /// <summary>
50 /// Constructor.
51 /// </summary>
52 public PhysicsPluginManager()
53 {
54 }
55
56 /// <summary>
57 /// Get a physics scene for the given physics engine and mesher.
58 /// </summary>
59 /// <param name="physEngineName"></param>
60 /// <param name="meshEngineName"></param>
61 /// <param name="config"></param>
62 /// <returns></returns>
63 public PhysicsScene GetPhysicsScene(string physEngineName, string meshEngineName,
64 IConfigSource config, string regionName, Vector3 regionExtent)
65 {
66 if (String.IsNullOrEmpty(physEngineName))
67 {
68 return PhysicsScene.Null;
69 }
70
71 if (String.IsNullOrEmpty(meshEngineName))
72 {
73 return PhysicsScene.Null;
74 }
75
76 IMesher meshEngine = null;
77 if (_MeshPlugins.ContainsKey(meshEngineName))
78 {
79 m_log.Info("[PHYSICS]: creating meshing engine " + meshEngineName);
80 meshEngine = _MeshPlugins[meshEngineName].GetMesher(config);
81 }
82 else
83 {
84 m_log.WarnFormat("[PHYSICS]: couldn't find meshingEngine: {0}", meshEngineName);
85 throw new ArgumentException(String.Format("couldn't find meshingEngine: {0}", meshEngineName));
86 }
87
88 if (_PhysPlugins.ContainsKey(physEngineName))
89 {
90 m_log.Info("[PHYSICS]: creating " + physEngineName);
91 PhysicsScene result = _PhysPlugins[physEngineName].GetScene(regionName);
92 //result.Initialise(meshEngine, config, regionExtent);
93 return result;
94 }
95 else
96 {
97 m_log.WarnFormat("[PHYSICS]: couldn't find physicsEngine: {0}", physEngineName);
98 throw new ArgumentException(String.Format("couldn't find physicsEngine: {0}", physEngineName));
99 }
100 }
101
102 /// <summary>
103 /// Load all plugins in assemblies at the given path
104 /// </summary>
105 /// <param name="pluginsPath"></param>
106 public void LoadPluginsFromAssemblies(string assembliesPath)
107 {
108 // Walk all assemblies (DLLs effectively) and see if they are home
109 // of a plugin that is of interest for us
110 string[] pluginFiles = Directory.GetFiles(assembliesPath, "*.dll");
111
112 for (int i = 0; i < pluginFiles.Length; i++)
113 {
114 LoadPluginsFromAssembly(pluginFiles[i]);
115 }
116 }
117
118 /// <summary>
119 /// Load plugins from an assembly at the given path
120 /// </summary>
121 /// <param name="assemblyPath"></param>
122 public void LoadPluginsFromAssembly(string assemblyPath)
123 {
124 // TODO / NOTE
125 // The assembly named 'OpenSim.Region.PhysicsModule.BasicPhysics' was loaded from
126 // 'file:///C:/OpenSim/trunk2/bin/Physics/OpenSim.Region.PhysicsModule.BasicPhysics.dll'
127 // using the LoadFrom context. The use of this context can result in unexpected behavior
128 // for serialization, casting and dependency resolution. In almost all cases, it is recommended
129 // that the LoadFrom context be avoided. This can be done by installing assemblies in the
130 // Global Assembly Cache or in the ApplicationBase directory and using Assembly.
131 // Load when explicitly loading assemblies.
132 Assembly pluginAssembly = null;
133 Type[] types = null;
134
135 try
136 {
137 pluginAssembly = Assembly.LoadFrom(assemblyPath);
138 }
139 catch (Exception ex)
140 {
141 m_log.Error("[PHYSICS]: Failed to load plugin from " + assemblyPath, ex);
142 }
143
144 if (pluginAssembly != null)
145 {
146 try
147 {
148 types = pluginAssembly.GetTypes();
149 }
150 catch (ReflectionTypeLoadException ex)
151 {
152 m_log.Error("[PHYSICS]: Failed to enumerate types in plugin from " + assemblyPath + ": " +
153 ex.LoaderExceptions[0].Message, ex);
154 }
155 catch (Exception ex)
156 {
157 m_log.Error("[PHYSICS]: Failed to enumerate types in plugin from " + assemblyPath, ex);
158 }
159
160 if (types != null)
161 {
162 foreach (Type pluginType in types)
163 {
164 if (pluginType.IsPublic)
165 {
166 if (!pluginType.IsAbstract)
167 {
168 Type physTypeInterface = pluginType.GetInterface("IPhysicsPlugin");
169
170 if (physTypeInterface != null)
171 {
172 IPhysicsPlugin plug =
173 (IPhysicsPlugin)Activator.CreateInstance(pluginAssembly.GetType(pluginType.ToString()));
174 plug.Init();
175 if (!_PhysPlugins.ContainsKey(plug.GetName()))
176 {
177 _PhysPlugins.Add(plug.GetName(), plug);
178 m_log.Info("[PHYSICS]: Added physics engine: " + plug.GetName());
179 }
180 }
181
182 Type meshTypeInterface = pluginType.GetInterface("IMeshingPlugin");
183
184 if (meshTypeInterface != null)
185 {
186 IMeshingPlugin plug =
187 (IMeshingPlugin)Activator.CreateInstance(pluginAssembly.GetType(pluginType.ToString()));
188 if (!_MeshPlugins.ContainsKey(plug.GetName()))
189 {
190 _MeshPlugins.Add(plug.GetName(), plug);
191 m_log.Info("[PHYSICS]: Added meshing engine: " + plug.GetName());
192 }
193 }
194
195 physTypeInterface = null;
196 meshTypeInterface = null;
197 }
198 }
199 }
200 }
201 }
202
203 pluginAssembly = null;
204 }
205
206 //---
207 public static void PhysicsPluginMessage(string message, bool isWarning)
208 {
209 if (isWarning)
210 {
211 m_log.Warn("[PHYSICS]: " + message);
212 }
213 else
214 {
215 m_log.Info("[PHYSICS]: " + message);
216 }
217 }
218
219 //---
220 }
221
222 public interface IPhysicsPlugin
223 {
224 bool Init();
225 PhysicsScene GetScene(String sceneIdentifier);
226 string GetName();
227 void Dispose();
228 }
229
230 public interface IMeshingPlugin
231 {
232 string GetName();
233 IMesher GetMesher(IConfigSource config);
234 }
235}