made nearest_object_intersecting_ray agnostic to the object types