aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Physics/Manager/PhysicsPluginManager.cs
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Region/Physics/Manager/PhysicsPluginManager.cs')
-rw-r--r--OpenSim/Region/Physics/Manager/PhysicsPluginManager.cs88
1 files changed, 59 insertions, 29 deletions
diff --git a/OpenSim/Region/Physics/Manager/PhysicsPluginManager.cs b/OpenSim/Region/Physics/Manager/PhysicsPluginManager.cs
index 3d9207f..db41251 100644
--- a/OpenSim/Region/Physics/Manager/PhysicsPluginManager.cs
+++ b/OpenSim/Region/Physics/Manager/PhysicsPluginManager.cs
@@ -115,43 +115,73 @@ namespace OpenSim.Region.Physics.Manager
115 // that the LoadFrom context be avoided. This can be done by installing assemblies in the 115 // that the LoadFrom context be avoided. This can be done by installing assemblies in the
116 // Global Assembly Cache or in the ApplicationBase directory and using Assembly. 116 // Global Assembly Cache or in the ApplicationBase directory and using Assembly.
117 // Load when explicitly loading assemblies. 117 // Load when explicitly loading assemblies.
118 Assembly pluginAssembly = Assembly.LoadFrom(FileName); 118 Assembly pluginAssembly = null;
119 Type[] types = null;
119 120
120 foreach (Type pluginType in pluginAssembly.GetTypes()) 121 try
121 { 122 {
122 if (pluginType.IsPublic) 123 pluginAssembly = Assembly.LoadFrom(FileName);
123 { 124 }
124 if (!pluginType.IsAbstract) 125 catch (Exception ex)
125 { 126 {
126 Type physTypeInterface = pluginType.GetInterface("IPhysicsPlugin", true); 127 m_log.Error("Failed to load plugin from " + FileName, ex);
127 128 }
128 if (physTypeInterface != null)
129 {
130 IPhysicsPlugin plug =
131 (IPhysicsPlugin) Activator.CreateInstance(pluginAssembly.GetType(pluginType.ToString()));
132 plug.Init();
133 if (!_PhysPlugins.ContainsKey(plug.GetName()))
134 {
135 _PhysPlugins.Add(plug.GetName(), plug);
136 m_log.Info("[PHYSICS]: Added physics engine: " + plug.GetName());
137 }
138 }
139 129
140 Type meshTypeInterface = pluginType.GetInterface("IMeshingPlugin", true); 130 if (pluginAssembly != null)
131 {
132 try
133 {
134 types = pluginAssembly.GetTypes();
135 }
136 catch (ReflectionTypeLoadException ex)
137 {
138 m_log.Error("[PHYSICS]: Failed to enumerate types in plugin from " + FileName + ": " +
139 ex.LoaderExceptions[0].Message, ex);
140 }
141 catch (Exception ex)
142 {
143 m_log.Error("[PHYSICS]: Failed to enumerate types in plugin from " + FileName, ex);
144 }
141 145
142 if (meshTypeInterface != null) 146 if (types != null)
147 {
148 foreach (Type pluginType in types)
149 {
150 if (pluginType.IsPublic)
143 { 151 {
144 IMeshingPlugin plug = 152 if (!pluginType.IsAbstract)
145 (IMeshingPlugin) Activator.CreateInstance(pluginAssembly.GetType(pluginType.ToString()));
146 if (!_MeshPlugins.ContainsKey(plug.GetName()))
147 { 153 {
148 _MeshPlugins.Add(plug.GetName(), plug); 154 Type physTypeInterface = pluginType.GetInterface("IPhysicsPlugin", true);
149 m_log.Info("[PHYSICS]: Added meshing engine: " + plug.GetName()); 155
156 if (physTypeInterface != null)
157 {
158 IPhysicsPlugin plug =
159 (IPhysicsPlugin)Activator.CreateInstance(pluginAssembly.GetType(pluginType.ToString()));
160 plug.Init();
161 if (!_PhysPlugins.ContainsKey(plug.GetName()))
162 {
163 _PhysPlugins.Add(plug.GetName(), plug);
164 m_log.Info("[PHYSICS]: Added physics engine: " + plug.GetName());
165 }
166 }
167
168 Type meshTypeInterface = pluginType.GetInterface("IMeshingPlugin", true);
169
170 if (meshTypeInterface != null)
171 {
172 IMeshingPlugin plug =
173 (IMeshingPlugin)Activator.CreateInstance(pluginAssembly.GetType(pluginType.ToString()));
174 if (!_MeshPlugins.ContainsKey(plug.GetName()))
175 {
176 _MeshPlugins.Add(plug.GetName(), plug);
177 m_log.Info("[PHYSICS]: Added meshing engine: " + plug.GetName());
178 }
179 }
180
181 physTypeInterface = null;
182 meshTypeInterface = null;
150 } 183 }
151 } 184 }
152
153 physTypeInterface = null;
154 meshTypeInterface = null;
155 } 185 }
156 } 186 }
157 } 187 }