From 5e4d6cab00cb29cd088ab7b62ab13aff103b64cb Mon Sep 17 00:00:00 2001 From: onefang Date: Sun, 19 May 2019 21:24:15 +1000 Subject: Dump OpenSim 0.9.0.1 into it's own branch. --- .../PhysicsModules/Ode/ODERayCastRequestManager.cs | 97 +++++----------------- 1 file changed, 20 insertions(+), 77 deletions(-) (limited to 'OpenSim/Region/PhysicsModules/Ode/ODERayCastRequestManager.cs') 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; using System.Text; using OpenMetaverse; using OpenSim.Region.PhysicsModules.SharedBase; -using Ode.NET; using log4net; namespace OpenSim.Region.PhysicsModule.ODE @@ -76,7 +75,7 @@ namespace OpenSim.Region.PhysicsModule.ODE { m_scene = pScene; nearCallback = near; - + } /// @@ -137,7 +136,7 @@ namespace OpenSim.Region.PhysicsModule.ODE ODERayCastRequest[] reqs = m_PendingRequests.ToArray(); for (int i = 0; i < reqs.Length; i++) { - if (reqs[i].callbackMethod != null) // quick optimization here, don't raycast + if (reqs[i].callbackMethod != null) // quick optimization here, don't raycast RayCast(reqs[i]); // if there isn't anyone to send results } @@ -152,7 +151,7 @@ namespace OpenSim.Region.PhysicsModule.ODE ODERayRequest[] reqs = m_PendingRayRequests.ToArray(); for (int i = 0; i < reqs.Length; i++) { - if (reqs[i].callbackMethod != null) // quick optimization here, don't raycast + if (reqs[i].callbackMethod != null) // quick optimization here, don't raycast RayCast(reqs[i]); // if there isn't anyone to send results } @@ -176,11 +175,11 @@ namespace OpenSim.Region.PhysicsModule.ODE // this value may still be too large, depending on machine configuration // of maximum stack float len = req.length; - if (len > 250f) - len = 250f; + if (len > 100f) + len = 100f; // Create the ray - IntPtr ray = d.CreateRay(m_scene.space, req.length); + IntPtr ray = d.CreateRay(m_scene.space, len); d.GeomRaySet(ray, req.Origin.X, req.Origin.Y, req.Origin.Z, req.Normal.X, req.Normal.Y, req.Normal.Z); // Collide test @@ -225,8 +224,13 @@ namespace OpenSim.Region.PhysicsModule.ODE /// private void RayCast(ODERayRequest req) { + // limit ray length or collisions will take all avaiable stack space + float len = req.length; + if (len > 100f) + len = 100f; + // Create the ray - IntPtr ray = d.CreateRay(m_scene.space, req.length); + IntPtr ray = d.CreateRay(m_scene.space, len); d.GeomRaySet(ray, req.Origin.X, req.Origin.Y, req.Origin.Z, req.Normal.X, req.Normal.Y, req.Normal.Z); // Collide test @@ -243,83 +247,22 @@ namespace OpenSim.Region.PhysicsModule.ODE req.callbackMethod(m_contactResults); } } - + // This is the standard Near. Uses space AABBs to speed up detection. private void near(IntPtr space, IntPtr g1, IntPtr g2) { - //Don't test against heightfield Geom, or you'll be sorry! - - /* - terminate called after throwing an instance of 'std::bad_alloc' - what(): std::bad_alloc - Stacktrace: - - at (wrapper managed-to-native) Ode.NET.d.Collide (intptr,intptr,int,Ode.NET.d/ContactGeom[],int) <0x00004> - at (wrapper managed-to-native) Ode.NET.d.Collide (intptr,intptr,int,Ode.NET.d/ContactGeom[],int) <0xffffffff> - at OpenSim.Region.Physics.OdePlugin.ODERayCastRequestManager.near (intptr,intptr,intptr) <0x00280> - at (wrapper native-to-managed) OpenSim.Region.Physics.OdePlugin.ODERayCastRequestManager.near (intptr,intptr,intptr) <0xfff - fffff> - at (wrapper managed-to-native) Ode.NET.d.SpaceCollide2 (intptr,intptr,intptr,Ode.NET.d/NearCallback) <0x00004> - at (wrapper managed-to-native) Ode.NET.d.SpaceCollide2 (intptr,intptr,intptr,Ode.NET.d/NearCallback) <0xffffffff> - at OpenSim.Region.Physics.OdePlugin.ODERayCastRequestManager.RayCast (OpenSim.Region.Physics.OdePlugin.ODERayCastRequest) < - 0x00114> - at OpenSim.Region.Physics.OdePlugin.ODERayCastRequestManager.ProcessQueuedRequests () <0x000eb> - at OpenSim.Region.Physics.OdePlugin.OdeScene.Simulate (single) <0x017e6> - at OpenSim.Region.Framework.Scenes.SceneGraph.UpdatePhysics (double) <0x00042> - at OpenSim.Region.Framework.Scenes.Scene.Update () <0x0039e> - at OpenSim.Region.Framework.Scenes.Scene.Heartbeat (object) <0x00019> - at (wrapper runtime-invoke) object.runtime_invoke_void__this___object (object,intptr,intptr,intptr) <0xffffffff> - - Native stacktrace: - - mono [0x80d2a42] - [0xb7f5840c] - /lib/i686/cmov/libc.so.6(abort+0x188) [0xb7d1a018] - /usr/lib/libstdc++.so.6(_ZN9__gnu_cxx27__verbose_terminate_handlerEv+0x158) [0xb45fc988] - /usr/lib/libstdc++.so.6 [0xb45fa865] - /usr/lib/libstdc++.so.6 [0xb45fa8a2] - /usr/lib/libstdc++.so.6 [0xb45fa9da] - /usr/lib/libstdc++.so.6(_Znwj+0x83) [0xb45fb033] - /usr/lib/libstdc++.so.6(_Znaj+0x1d) [0xb45fb11d] - libode.so(_ZN13dxHeightfield23dCollideHeightfieldZoneEiiiiP6dxGeomiiP12dContactGeomi+0xd04) [0xb46678e4] - libode.so(_Z19dCollideHeightfieldP6dxGeomS0_iP12dContactGeomi+0x54b) [0xb466832b] - libode.so(dCollide+0x102) [0xb46571b2] - [0x95cfdec9] - [0x8ea07fe1] - [0xab260146] - libode.so [0xb465a5c4] - libode.so(_ZN11dxHashSpace8collide2EPvP6dxGeomPFvS0_S2_S2_E+0x75) [0xb465bcf5] - libode.so(dSpaceCollide2+0x177) [0xb465ac67] - [0x95cf978e] - [0x8ea07945] - [0x95cf2bbc] - [0xab2787e7] - [0xab419fb3] - [0xab416657] - [0xab415bda] - [0xb609b08e] - mono(mono_runtime_delegate_invoke+0x34) [0x8192534] - mono [0x81a2f0f] - mono [0x81d28b6] - mono [0x81ea2c6] - /lib/i686/cmov/libpthread.so.0 [0xb7e744c0] - /lib/i686/cmov/libc.so.6(clone+0x5e) [0xb7dcd6de] - */ - - // Exclude heightfield geom - if (g1 == IntPtr.Zero || g2 == IntPtr.Zero) return; - if (d.GeomGetClass(g1) == d.GeomClassID.HeightfieldClass || d.GeomGetClass(g2) == d.GeomClassID.HeightfieldClass) - return; +// if (d.GeomGetClass(g1) == d.GeomClassID.HeightfieldClass || d.GeomGetClass(g2) == d.GeomClassID.HeightfieldClass) +// return; // Raytest against AABBs of spaces first, then dig into the spaces it hits for actual geoms. if (d.GeomIsSpace(g1) || d.GeomIsSpace(g2)) { if (g1 == IntPtr.Zero || g2 == IntPtr.Zero) return; - + // Separating static prim geometry spaces. // We'll be calling near recursivly if one // of them is a space to find all of the @@ -347,13 +290,13 @@ namespace OpenSim.Region.PhysicsModule.ODE int count = 0; try { - + if (g1 == g2) return; // Can't collide with yourself lock (contacts) { - count = d.Collide(g1, g2, contacts.GetLength(0), contacts, d.ContactGeom.SizeOf); + count = d.Collide(g1, g2, contacts.GetLength(0), contacts, d.ContactGeom.unmanagedSizeOf); } } catch (SEHException) @@ -383,7 +326,7 @@ namespace OpenSim.Region.PhysicsModule.ODE if (p1 is OdePrim) { ContactResult collisionresult = new ContactResult(); - + collisionresult.ConsumerID = p1.LocalID; collisionresult.Pos = new Vector3(contacts[i].pos.X, contacts[i].pos.Y, contacts[i].pos.Z); collisionresult.Depth = contacts[i].depth; @@ -438,4 +381,4 @@ namespace OpenSim.Region.PhysicsModule.ODE public float length; public RayCallback callbackMethod; } -} \ No newline at end of file +} -- cgit v1.1