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"""
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:
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