Ejemplo n.º 1
0
        public static float?Intersects(this Ray ray, ModelMesh mesh)
        {
            var   verts   = mesh.GetVerts();
            var   inds    = mesh.GetInds();
            float?maxDist = null;

            for (int i = 0; i < inds.Length; i += 3)
            {
                float?result = RayIntersectsTriangle(ref ray,
                                                     ref verts[inds[i + 0]].Position, ref verts[inds[i + 1]].Position, ref verts[inds[i + 2]].Position);
                if ((result ?? float.MaxValue) < (maxDist ?? float.MaxValue))
                {
                    maxDist = result;
                }
            }
            return(maxDist);
        }