Test visibility like cursor selection

Hi. I have a mesh and a group of icospheres added to scene. My issue is, given some transformation of mesh and icospheres, is there a good way to test if each icosphere is still visible to camera or blocked by the mesh?

I have searched many ways, but ray_cast() seems to be unstable and visible_get() returns True for all icospheres.

Here are 2 visualizations. It is the bottom of a bed model and you can see small spheres on some faces. There are more on the other side but being blocked by the bed.

Capture2

visible_get() is indeed not for occlusion tests. How is ray_cast() unstable for you?

It’s an issue I posted several days ago. I created a repo on GitHub that you can try.

Essentially, for some points, ray_cast() returns False even though they are apparently occluded by some faces, while many other points under similar conditions are found True.