public Hexagon PickHex(Ray ray) { if (Meshes.All(m => ray.Intersects(m.BoundingBox) == null)) { return(null); } var d = float.MaxValue; Hexagon ret = null; foreach (var mesh in Meshes) { if (ray.Intersects(mesh.BoundingBox) == null) { continue; } foreach (var hex in mesh.Hexes) { var td = hex.Geometry.IntersectedBy(ray); if (td == null || !(td < d)) { continue; } d = td.Value; ret = hex; } } return(ret); }