Add back light radius checks.
[tabakrolletjie.git] / tabakrolletjie / lights.py
index 2952da5c86680eada28d63130e425bf017179e87..34160f006de713ce58163cf54307f0995047cc12 100644 (file)
@@ -65,7 +65,10 @@ class LightManager(object):
         point_info_list = self._space.point_query(
             pos, max_distance, pymunk.ShapeFilter(mask=LIGHT_CATEGORY))
         lights = [p.shape.body.light for p in point_info_list]
-        return [light for light in lights if light.on]
+        return [
+            light for light in lights
+            if light.on and light.ray_manager.reaches(pos)
+        ]
 
     def light_query(self, shape):
         """Query the lights by shape"""
@@ -75,7 +78,10 @@ class LightManager(object):
         shape_info_list = self._space.shape_query(shape)
         shape.filter = old_filter
         lights = [p.shape.body.light for p in shape_info_list]
-        return [light for light in lights if light.on]
+        return [
+            light for light in lights
+            if light.on and light.ray_manager.reaches(shape.body.position)
+        ]
 
     def render_light(self, surface):
         for light in self._lights: