Stop the camera from moving through a mesh?

I know this, but is there a way to detect if I am about to hit a mesh? so that I can move the camera?