projects
/
tabakrolletjie.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Use debug_timer on lights.
[tabakrolletjie.git]
/
tabakrolletjie
/
lights.py
diff --git
a/tabakrolletjie/lights.py
b/tabakrolletjie/lights.py
index 6f2c6e7a1082a5eba81d57e636fd9f1c42f34ff9..7620c480915c1e8b5bc2226ba1ec64028a7631f9 100644
(file)
--- 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.
"""
""" 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
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,
LIGHT_FILTER = pymunk.ShapeFilter(
mask=pymunk.ShapeFilter.ALL_MASKS ^ LIGHT_CATEGORY,
@@
-32,8
+31,8
@@
def screen_rays(pos):
yield pymunk.Vec2d(x, bottom)
yield pymunk.Vec2d(x, bottom)
+@debug_timer("lights.calculate_ray_polys")
def calculate_ray_polys(space, body, position):
def calculate_ray_polys(space, body, position):
- start_time = time.time()
position = pymunk.Vec2d(position)
vertices = [position]
ray_polys = []
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))
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
return ray_polys