First do visibilty check to reduce branching