It's been a while since I've posted about this because my first prototype demonstrated the idea but was very awkward to actually use. It turns out the best way to use a data-oriented approach that I found is an Entity-Component-System approach. So, after much work, I now have a minimal numpy based ECS for y'all. See the README of my repo for more information about what data oriented programing and ECS are.
Repo: https://github.com/Permafacture/data-oriented-pyglet I could not figure a way to integrate this approach with the current pyglet batches and groups. Thus, this is an alternative to pyglet batches and groups. It provides a way to do all computationally expensive operations on batches, such as rendering, translation, changing animation frames, updating position based on velocity, updating acceleration based on forces, collisions, etc in a batched manner using vectorized operations on numpy arrays. An interesting side-effect of this organization is that it makes multiprocessing much easier. If I have physics running that results in updated positions and angles, and rendering which takes those positions and angles and translates polygons to render, the position and angle numpy arrays can sit in shared memory. The physics and rendering processes can run independently in separate CPU threads. My personal project using pymunk and pyglet went from 50 FPS on my low end laptop to 180 space steps per second for physics and 600 FPS for rendering using this model. This is an extraordinary improvement and other situations are not improved by as much. In single threaded examples, I find that the translation and other batched computations take an insignificant amount of time and rendering is the bottle neck. Also, the shared memory is not yet implemented in the public repo. The only requirements for the examples are pyglet and numpy. Try it out and let me know what you think. This is very alpha. Thanks for reading, Elliot -- You received this message because you are subscribed to the Google Groups "pyglet-users" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. Visit this group at https://groups.google.com/group/pyglet-users. For more options, visit https://groups.google.com/d/optout.
