aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/PhysicsModules/Ode/ODERayCastRequestManager.cs
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Region/PhysicsModules/Ode/ODERayCastRequestManager.cs')
-rw-r--r--OpenSim/Region/PhysicsModules/Ode/ODERayCastRequestManager.cs97
1 files changed, 20 insertions, 77 deletions
diff --git a/OpenSim/Region/PhysicsModules/Ode/ODERayCastRequestManager.cs b/OpenSim/Region/PhysicsModules/Ode/ODERayCastRequestManager.cs
index 8d610f7..78dd7de 100644
--- a/OpenSim/Region/PhysicsModules/Ode/ODERayCastRequestManager.cs
+++ b/OpenSim/Region/PhysicsModules/Ode/ODERayCastRequestManager.cs
@@ -32,7 +32,6 @@ using System.Runtime.InteropServices;
32using System.Text; 32using System.Text;
33using OpenMetaverse; 33using OpenMetaverse;
34using OpenSim.Region.PhysicsModules.SharedBase; 34using OpenSim.Region.PhysicsModules.SharedBase;
35using Ode.NET;
36using log4net; 35using log4net;
37 36
38namespace OpenSim.Region.PhysicsModule.ODE 37namespace OpenSim.Region.PhysicsModule.ODE
@@ -76,7 +75,7 @@ namespace OpenSim.Region.PhysicsModule.ODE
76 { 75 {
77 m_scene = pScene; 76 m_scene = pScene;
78 nearCallback = near; 77 nearCallback = near;
79 78
80 } 79 }
81 80
82 /// <summary> 81 /// <summary>
@@ -137,7 +136,7 @@ namespace OpenSim.Region.PhysicsModule.ODE
137 ODERayCastRequest[] reqs = m_PendingRequests.ToArray(); 136 ODERayCastRequest[] reqs = m_PendingRequests.ToArray();
138 for (int i = 0; i < reqs.Length; i++) 137 for (int i = 0; i < reqs.Length; i++)
139 { 138 {
140 if (reqs[i].callbackMethod != null) // quick optimization here, don't raycast 139 if (reqs[i].callbackMethod != null) // quick optimization here, don't raycast
141 RayCast(reqs[i]); // if there isn't anyone to send results 140 RayCast(reqs[i]); // if there isn't anyone to send results
142 } 141 }
143 142
@@ -152,7 +151,7 @@ namespace OpenSim.Region.PhysicsModule.ODE
152 ODERayRequest[] reqs = m_PendingRayRequests.ToArray(); 151 ODERayRequest[] reqs = m_PendingRayRequests.ToArray();
153 for (int i = 0; i < reqs.Length; i++) 152 for (int i = 0; i < reqs.Length; i++)
154 { 153 {
155 if (reqs[i].callbackMethod != null) // quick optimization here, don't raycast 154 if (reqs[i].callbackMethod != null) // quick optimization here, don't raycast
156 RayCast(reqs[i]); // if there isn't anyone to send results 155 RayCast(reqs[i]); // if there isn't anyone to send results
157 } 156 }
158 157
@@ -176,11 +175,11 @@ namespace OpenSim.Region.PhysicsModule.ODE
176 // this value may still be too large, depending on machine configuration 175 // this value may still be too large, depending on machine configuration
177 // of maximum stack 176 // of maximum stack
178 float len = req.length; 177 float len = req.length;
179 if (len > 250f) 178 if (len > 100f)
180 len = 250f; 179 len = 100f;
181 180
182 // Create the ray 181 // Create the ray
183 IntPtr ray = d.CreateRay(m_scene.space, req.length); 182 IntPtr ray = d.CreateRay(m_scene.space, len);
184 d.GeomRaySet(ray, req.Origin.X, req.Origin.Y, req.Origin.Z, req.Normal.X, req.Normal.Y, req.Normal.Z); 183 d.GeomRaySet(ray, req.Origin.X, req.Origin.Y, req.Origin.Z, req.Normal.X, req.Normal.Y, req.Normal.Z);
185 184
186 // Collide test 185 // Collide test
@@ -225,8 +224,13 @@ namespace OpenSim.Region.PhysicsModule.ODE
225 /// <param name="req"></param> 224 /// <param name="req"></param>
226 private void RayCast(ODERayRequest req) 225 private void RayCast(ODERayRequest req)
227 { 226 {
227 // limit ray length or collisions will take all avaiable stack space
228 float len = req.length;
229 if (len > 100f)
230 len = 100f;
231
228 // Create the ray 232 // Create the ray
229 IntPtr ray = d.CreateRay(m_scene.space, req.length); 233 IntPtr ray = d.CreateRay(m_scene.space, len);
230 d.GeomRaySet(ray, req.Origin.X, req.Origin.Y, req.Origin.Z, req.Normal.X, req.Normal.Y, req.Normal.Z); 234 d.GeomRaySet(ray, req.Origin.X, req.Origin.Y, req.Origin.Z, req.Normal.X, req.Normal.Y, req.Normal.Z);
231 235
232 // Collide test 236 // Collide test
@@ -243,83 +247,22 @@ namespace OpenSim.Region.PhysicsModule.ODE
243 req.callbackMethod(m_contactResults); 247 req.callbackMethod(m_contactResults);
244 } 248 }
245 } 249 }
246 250
247 // This is the standard Near. Uses space AABBs to speed up detection. 251 // This is the standard Near. Uses space AABBs to speed up detection.
248 private void near(IntPtr space, IntPtr g1, IntPtr g2) 252 private void near(IntPtr space, IntPtr g1, IntPtr g2)
249 { 253 {
250 254
251 //Don't test against heightfield Geom, or you'll be sorry!
252
253 /*
254 terminate called after throwing an instance of 'std::bad_alloc'
255 what(): std::bad_alloc
256 Stacktrace:
257
258 at (wrapper managed-to-native) Ode.NET.d.Collide (intptr,intptr,int,Ode.NET.d/ContactGeom[],int) <0x00004>
259 at (wrapper managed-to-native) Ode.NET.d.Collide (intptr,intptr,int,Ode.NET.d/ContactGeom[],int) <0xffffffff>
260 at OpenSim.Region.Physics.OdePlugin.ODERayCastRequestManager.near (intptr,intptr,intptr) <0x00280>
261 at (wrapper native-to-managed) OpenSim.Region.Physics.OdePlugin.ODERayCastRequestManager.near (intptr,intptr,intptr) <0xfff
262 fffff>
263 at (wrapper managed-to-native) Ode.NET.d.SpaceCollide2 (intptr,intptr,intptr,Ode.NET.d/NearCallback) <0x00004>
264 at (wrapper managed-to-native) Ode.NET.d.SpaceCollide2 (intptr,intptr,intptr,Ode.NET.d/NearCallback) <0xffffffff>
265 at OpenSim.Region.Physics.OdePlugin.ODERayCastRequestManager.RayCast (OpenSim.Region.Physics.OdePlugin.ODERayCastRequest) <
266 0x00114>
267 at OpenSim.Region.Physics.OdePlugin.ODERayCastRequestManager.ProcessQueuedRequests () <0x000eb>
268 at OpenSim.Region.Physics.OdePlugin.OdeScene.Simulate (single) <0x017e6>
269 at OpenSim.Region.Framework.Scenes.SceneGraph.UpdatePhysics (double) <0x00042>
270 at OpenSim.Region.Framework.Scenes.Scene.Update () <0x0039e>
271 at OpenSim.Region.Framework.Scenes.Scene.Heartbeat (object) <0x00019>
272 at (wrapper runtime-invoke) object.runtime_invoke_void__this___object (object,intptr,intptr,intptr) <0xffffffff>
273
274 Native stacktrace:
275
276 mono [0x80d2a42]
277 [0xb7f5840c]
278 /lib/i686/cmov/libc.so.6(abort+0x188) [0xb7d1a018]
279 /usr/lib/libstdc++.so.6(_ZN9__gnu_cxx27__verbose_terminate_handlerEv+0x158) [0xb45fc988]
280 /usr/lib/libstdc++.so.6 [0xb45fa865]
281 /usr/lib/libstdc++.so.6 [0xb45fa8a2]
282 /usr/lib/libstdc++.so.6 [0xb45fa9da]
283 /usr/lib/libstdc++.so.6(_Znwj+0x83) [0xb45fb033]
284 /usr/lib/libstdc++.so.6(_Znaj+0x1d) [0xb45fb11d]
285 libode.so(_ZN13dxHeightfield23dCollideHeightfieldZoneEiiiiP6dxGeomiiP12dContactGeomi+0xd04) [0xb46678e4]
286 libode.so(_Z19dCollideHeightfieldP6dxGeomS0_iP12dContactGeomi+0x54b) [0xb466832b]
287 libode.so(dCollide+0x102) [0xb46571b2]
288 [0x95cfdec9]
289 [0x8ea07fe1]
290 [0xab260146]
291 libode.so [0xb465a5c4]
292 libode.so(_ZN11dxHashSpace8collide2EPvP6dxGeomPFvS0_S2_S2_E+0x75) [0xb465bcf5]
293 libode.so(dSpaceCollide2+0x177) [0xb465ac67]
294 [0x95cf978e]
295 [0x8ea07945]
296 [0x95cf2bbc]
297 [0xab2787e7]
298 [0xab419fb3]
299 [0xab416657]
300 [0xab415bda]
301 [0xb609b08e]
302 mono(mono_runtime_delegate_invoke+0x34) [0x8192534]
303 mono [0x81a2f0f]
304 mono [0x81d28b6]
305 mono [0x81ea2c6]
306 /lib/i686/cmov/libpthread.so.0 [0xb7e744c0]
307 /lib/i686/cmov/libc.so.6(clone+0x5e) [0xb7dcd6de]
308 */
309
310 // Exclude heightfield geom
311
312 if (g1 == IntPtr.Zero || g2 == IntPtr.Zero) 255 if (g1 == IntPtr.Zero || g2 == IntPtr.Zero)
313 return; 256 return;
314 if (d.GeomGetClass(g1) == d.GeomClassID.HeightfieldClass || d.GeomGetClass(g2) == d.GeomClassID.HeightfieldClass) 257// if (d.GeomGetClass(g1) == d.GeomClassID.HeightfieldClass || d.GeomGetClass(g2) == d.GeomClassID.HeightfieldClass)
315 return; 258// return;
316 259
317 // Raytest against AABBs of spaces first, then dig into the spaces it hits for actual geoms. 260 // Raytest against AABBs of spaces first, then dig into the spaces it hits for actual geoms.
318 if (d.GeomIsSpace(g1) || d.GeomIsSpace(g2)) 261 if (d.GeomIsSpace(g1) || d.GeomIsSpace(g2))
319 { 262 {
320 if (g1 == IntPtr.Zero || g2 == IntPtr.Zero) 263 if (g1 == IntPtr.Zero || g2 == IntPtr.Zero)
321 return; 264 return;
322 265
323 // Separating static prim geometry spaces. 266 // Separating static prim geometry spaces.
324 // We'll be calling near recursivly if one 267 // We'll be calling near recursivly if one
325 // of them is a space to find all of the 268 // of them is a space to find all of the
@@ -347,13 +290,13 @@ namespace OpenSim.Region.PhysicsModule.ODE
347 int count = 0; 290 int count = 0;
348 try 291 try
349 { 292 {
350 293
351 if (g1 == g2) 294 if (g1 == g2)
352 return; // Can't collide with yourself 295 return; // Can't collide with yourself
353 296
354 lock (contacts) 297 lock (contacts)
355 { 298 {
356 count = d.Collide(g1, g2, contacts.GetLength(0), contacts, d.ContactGeom.SizeOf); 299 count = d.Collide(g1, g2, contacts.GetLength(0), contacts, d.ContactGeom.unmanagedSizeOf);
357 } 300 }
358 } 301 }
359 catch (SEHException) 302 catch (SEHException)
@@ -383,7 +326,7 @@ namespace OpenSim.Region.PhysicsModule.ODE
383 if (p1 is OdePrim) 326 if (p1 is OdePrim)
384 { 327 {
385 ContactResult collisionresult = new ContactResult(); 328 ContactResult collisionresult = new ContactResult();
386 329
387 collisionresult.ConsumerID = p1.LocalID; 330 collisionresult.ConsumerID = p1.LocalID;
388 collisionresult.Pos = new Vector3(contacts[i].pos.X, contacts[i].pos.Y, contacts[i].pos.Z); 331 collisionresult.Pos = new Vector3(contacts[i].pos.X, contacts[i].pos.Y, contacts[i].pos.Z);
389 collisionresult.Depth = contacts[i].depth; 332 collisionresult.Depth = contacts[i].depth;
@@ -438,4 +381,4 @@ namespace OpenSim.Region.PhysicsModule.ODE
438 public float length; 381 public float length;
439 public RayCallback callbackMethod; 382 public RayCallback callbackMethod;
440 } 383 }
441} \ No newline at end of file 384}