Fix visibility check for rect and sprite