Revert "Revert "Fix clipping through corners""

This reverts commit 6d040ae7683484618f316cb6fc87c8941dc07ab7.