X-Git-Url: https://git.ctpug.org.za/?a=blobdiff_plain;f=tabakrolletjie%2Flights.py;h=7620c480915c1e8b5bc2226ba1ec64028a7631f9;hb=64eb98f7a836957edacbc8346802c7d91dc0b962;hp=6f2c6e7a1082a5eba81d57e636fd9f1c42f34ff9;hpb=5e5685068049bfe0c06508bd4c71437b3c1675fd;p=tabakrolletjie.git diff --git a/tabakrolletjie/lights.py b/tabakrolletjie/lights.py index 6f2c6e7..7620c48 100644 --- a/tabakrolletjie/lights.py +++ b/tabakrolletjie/lights.py @@ -1,13 +1,12 @@ """ May it be a light for you in dark places, when all other lights go out. """ -import time - import pymunk import pymunk.pygame_util import pygame.draw -from .constants import SCREEN_SIZE, LIGHT_CATEGORY, DEBUG +from .constants import SCREEN_SIZE, LIGHT_CATEGORY +from .utils import debug_timer LIGHT_FILTER = pymunk.ShapeFilter( mask=pymunk.ShapeFilter.ALL_MASKS ^ LIGHT_CATEGORY, @@ -32,8 +31,8 @@ def screen_rays(pos): yield pymunk.Vec2d(x, bottom) +@debug_timer("lights.calculate_ray_polys") def calculate_ray_polys(space, body, position): - start_time = time.time() position = pymunk.Vec2d(position) vertices = [position] ray_polys = [] @@ -54,11 +53,6 @@ def calculate_ray_polys(space, body, position): vertices = trial_poly.get_vertices() + [point] if len(vertices) > 2: ray_polys.append(pymunk.Poly(body, vertices)) - end_time = time.time() - if DEBUG: - print( - "calculate_ray_polys: %d polys, %g seconds" % - (len(ray_polys), end_time - start_time)) return ray_polys