Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.Sign up
Performance: Object sleep API #191
Following discussion on the forum, it sounds like a good idea to implement an object sleep mechanism to save CPU cycles for objects that have nothing to do.
The way I imagine it is having two pools for game objects; the
A sleeping object will never be iterated in the update or draw loops, saving precious CPU time.
Further, we can enable a flag like
I didn't really had the time to check the forum since yesterday since I was travelling, but this seems to be a good idea !
Not sure though however about the automatic feature, as both putting them to sleep or awake automatically would effectively could be quite CPU consuming .
Reminder: Implementing auto-sleep through callbacks is the right way to do this. A "viewport leave" callback is very easy, as we know. With the new collision detection in #103, we will have a spatial grid that already contains objects... Seems like this can be reused for auto-wakeup, too! When a new spatial grid cell enters the viewport, fire the "wakeup" callback on all objects in that cell.
Wow ... that seems almost too easy to be true!
This was referenced
Feb 11, 2014
something interesting i just spotted in the chipmunk API :
it's also possible to disable object collision check for idle object, and specify a