Minor nit:  `limit` is declared twice in `computeBorderVisibilityIndex()`.