BEPUphysics.CollisionShapes.MobileMeshShape.IsLocalRayOriginInMesh C# (CSharp) Method

IsLocalRayOriginInMesh() public method

Tests to see if a ray's origin is contained within the mesh. If it is, the hit location is found. If it isn't, the hit location is still valid if a hit occurred. If the origin isn't inside and there was no hit, the hit has a T value of float.MaxValue.
public IsLocalRayOriginInMesh ( Ray &ray, RayHit &hit ) : bool
ray Ray Ray in the local space of the shape to test.
hit BEPUutilities.RayHit The first hit against the mesh, if any.
return bool
        public bool IsLocalRayOriginInMesh(ref Ray ray, out RayHit hit)
        {
            var overlapList = CommonResources.GetIntList();
            hit = new RayHit();
            hit.T = float.MaxValue;
            if (triangleMesh.Tree.GetOverlaps(ray, overlapList))
            {
                bool minimumClockwise = false;
                for (int i = 0; i < overlapList.Count; i++)
                {
                    Vector3 vA, vB, vC;
                    triangleMesh.Data.GetTriangle(overlapList[i], out vA, out vB, out vC);
                    bool hitClockwise;
                    RayHit tempHit;
                    if (Toolbox.FindRayTriangleIntersection(ref ray, float.MaxValue, ref vA, ref vB, ref vC, out hitClockwise, out tempHit) &&
                        tempHit.T < hit.T)
                    {
                        hit = tempHit;
                        minimumClockwise = hitClockwise;
                    }
                }
                CommonResources.GiveBack(overlapList);

                //If the mesh is hit from behind by the ray on the first hit, then the ray is inside.
                return hit.T < float.MaxValue && ((solidSidedness == TriangleSidedness.Clockwise && !minimumClockwise) || (solidSidedness == TriangleSidedness.Counterclockwise && minimumClockwise));
            }
            CommonResources.GiveBack(overlapList);
            return false;

        }