/// <summary> /// Method that actually initiates the raycast /// </summary> /// <param name="req"></param> 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 = SafeNativeMethods.CreateRay(m_scene.space, len); SafeNativeMethods.GeomRaySet(ray, req.Origin.X, req.Origin.Y, req.Origin.Z, req.Normal.X, req.Normal.Y, req.Normal.Z); // Collide test SafeNativeMethods.SpaceCollide2(m_scene.space, ray, IntPtr.Zero, nearCallback); // Remove Ray SafeNativeMethods.GeomDestroy(ray); // Find closest contact and object. lock (m_contactResults) { // Return results if (req.callbackMethod != null) { req.callbackMethod(m_contactResults); } } }
/// <summary> /// Queues a raycast /// </summary> /// <param name="position">Origin of Ray</param> /// <param name="direction">Ray normal</param> /// <param name="length">Ray length</param> /// <param name="count"></param> /// <param name="retMethod">Return method to send the results</param> public void QueueRequest(Vector3 position, Vector3 direction, float length, int count, RayCallback retMethod) { lock (m_PendingRequests) { ODERayRequest req = new ODERayRequest(); req.callbackMethod = retMethod; req.length = length; req.Normal = direction; req.Origin = position; req.Count = count; m_PendingRayRequests.Add(req); } }
/// <summary> /// Method that actually initiates the raycast /// </summary> /// <param name="req"></param> private void RayCast(ODERayRequest req) { // Create the ray IntPtr ray = d.CreateRay(m_scene.space, req.length); d.GeomRaySet(ray, req.Origin.X, req.Origin.Y, req.Origin.Z, req.Normal.X, req.Normal.Y, req.Normal.Z); // Collide test d.SpaceCollide2(m_scene.space, ray, IntPtr.Zero, nearCallback); // Remove Ray d.GeomDestroy(ray); // Find closest contact and object. lock (m_contactResults) { // Return results if (req.callbackMethod != null) { req.callbackMethod(m_contactResults); } } }
/// <summary> /// Method that actually initiates the raycast /// </summary> /// <param name="req"></param> private void RayCast(ODERayRequest req) { // Create the ray IntPtr ray = d.CreateRay(m_scene.space, req.length); d.GeomRaySet(ray, req.Origin.X, req.Origin.Y, req.Origin.Z, req.Normal.X, req.Normal.Y, req.Normal.Z); // Collide test d.SpaceCollide2(m_scene.space, ray, IntPtr.Zero, nearCallback); // Remove Ray d.GeomDestroy(ray); // Find closest contact and object. lock (m_contactResults) { // Return results if (req.callbackMethod != null) req.callbackMethod(m_contactResults); } }
/// <summary> /// Method that actually initiates the raycast /// </summary> /// <param name="req"></param> 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, len); d.GeomRaySet(ray, req.Origin.X, req.Origin.Y, req.Origin.Z, req.Normal.X, req.Normal.Y, req.Normal.Z); // Collide test d.SpaceCollide2(m_scene.space, ray, IntPtr.Zero, nearCallback); // Remove Ray d.GeomDestroy(ray); // Find closest contact and object. lock (m_contactResults) { // Return results if (req.callbackMethod != null) req.callbackMethod(m_contactResults); } }