3D Planning & Optimization for Safe MAV Flight Under Visibility Constraints