When using edit mode with a mesh, if you have the retopology overlay active,
the selection of vertices, edges, or faces is occluded by the other objects.
However, if local view is on or collections with objects are hidden,
these non-visible objects can occlude the selection.
This patch discards objects that are not visible in the viewport so they
do not occlude selection.