From 314608904d58bd77b0c76c24c0a5135c8117a479 Mon Sep 17 00:00:00 2001 From: Simon Cross Date: Fri, 9 Sep 2016 23:48:20 +0200 Subject: [PATCH] Add back light radius checks. --- tabakrolletjie/lights.py | 10 ++++++++-- tabakrolletjie/rays.py | 4 ++++ 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/tabakrolletjie/lights.py b/tabakrolletjie/lights.py index 2952da5..34160f0 100644 --- a/tabakrolletjie/lights.py +++ b/tabakrolletjie/lights.py @@ -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: diff --git a/tabakrolletjie/rays.py b/tabakrolletjie/rays.py index 9e5a1bf..6ff8a6e 100644 --- a/tabakrolletjie/rays.py +++ b/tabakrolletjie/rays.py @@ -125,6 +125,10 @@ class RayPolyManager(object): def min_radius_setter(self, value): self._min_radius = value or 0.0 + def reaches(self, position): + distance = self.position.get_distance(self.position) + return (self._min_radius <= distance <= self._max_radius) + def _set_radius_limits(self, radius_limits): if radius_limits is None or not radius_limits[0]: self._min_radius = 0 -- 2.34.1