This makes sure that the lights are counted correctly.

This makes sure that the lights are counted correctly based on their visibility. This fixes #4439.