Notifications
Clear all

[Closed] Calculate distance from camera to point on mesh

I feel like this must have been ask before but I am really struggling to find a way to calculate the distance from a camera to the closest point of a mesh that the camera is looking towards. I’m basically trying to write a customizable Auto-Focus type script for Vray Cameras and am totally stuck and not getting anywhere with Google and Forum searches. If anyone can point me in the right direction, I’d be very gratefull

2 Replies

So I ended up just looping through all the vertices in my target object and testing the distance of each of those against the camera. The lowest one gets used as the focus distance. I was concerned about it taking too long on a dense mesh but the initial test was almost instant on a 20,000 poly mesh.