Hello,
I wrote the first part of a tutorial on integrating pyglet, pymunk, Numpy and OpenCV. Any feedback would be appreciated.
-videos-
In case you don't end up reading it but have some insight, the bottleneck in my code right now is translating the dynamic vertices and updating batches. I have 300+ polygons that are updated every frame, having their vertices rotated and translated. This runs at 60 fps on my not so great laptop. Am I doing the best I can?
The update function is only this:
def translate(self):
px,py = self.body.position
theta = self.body.angle
initiald = self.initial_data
cost, sint = cos(theta), sin(theta)
#Just a bunch of multiplication and addition, optimized
pts = [(px+x+r*(xhelper*(cost-1)-sint*yhelper),py+y+r*(yhelper*(cost-1)+sint*xhelper)) for x,y,r,xhelper,yhelper in initiald]
#flatten and assign as tuple to batch vertices
self.vertlist.vertices = tuple(map(int,[val for subl in pts for val in subl]))
ncalls tottime percall cumtime percall filename:lineno(function)
1 0.019 0.019 49.193 49.193 poly_demo.py:1(<module>)
...
1911 0.035 0.000 44.047 0.023 poly_demo.py:122(on_draw)
1911 3.940 0.002 42.308 0.022 entities.py:12(step)
620979 2.838 0.000 37.946 0.000 entities.py:268(update)
So this function takes up 86% of my run time. The second to last line takes up 2/3 of that, and the last line 1/3.
Thanks everyone,
Elliot