public MyIntersectionResultLineTriangleEx?GetIntersectionInNearSpace(MyEntity entity, ref MyLine worldLine, bool convertLine) { if (!entity.IsVisible()) { return(null); } MyLine line = worldLine; if (convertLine) { ConvertLineToNearWorldCoordinates(ref line); } Matrix drawMatrix = entity.GetWorldMatrixForDraw(); drawMatrix.Translation += MyCamera.Position; Matrix worldInv = Matrix.Invert(drawMatrix); MyIntersectionResultLineTriangleEx?ret = entity.ModelLod0.GetTrianglePruningStructure().GetIntersectionWithLine(entity, ref line, ref worldInv, IntersectionFlags.ALL_TRIANGLES); if (ret == null) { foreach (MyEntity child in entity.Children) { if (!child.IsVisible()) { continue; } drawMatrix = child.GetWorldMatrixForDraw(); drawMatrix.Translation += MyCamera.Position; worldInv = Matrix.Invert(drawMatrix); System.Diagnostics.Debug.Assert(!float.IsNaN(worldInv.M11)); ret = child.ModelLod0.GetTrianglePruningStructure().GetIntersectionWithLine(child, ref line, ref worldInv, IntersectionFlags.ALL_TRIANGLES); if (ret != null) { return(ret); } } } return(ret); }