From: Simon Cross Date: Fri, 9 Sep 2016 21:48:20 +0000 (+0200) Subject: Add back light radius checks. X-Git-Tag: tabakrolletjie-v1.0.0~142 X-Git-Url: https://git.ctpug.org.za/?a=commitdiff_plain;h=314608904d58bd77b0c76c24c0a5135c8117a479;p=tabakrolletjie.git Add back light radius checks. --- 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