Page 1 of 1

Stop simulating offscreen bodies

Posted: Sun Sep 04, 2011 6:30 am
by uketernity
Hi All


Im having a real problem with the FPS in my game dropping to about 15fps when running on a device.

I think the problem is that chipmunk is calculating all the physics/collisions etc for bodies that are outside of the viewable area. My game world is 13000 pixels wide and populated with lots of objects.

What I need to do is tell chipmunk not to do ANY physics calculations for objects that are offscreen (say 3 screen widths, so viewable screen + 1 screen size either side). I guess I would update the bodies to active in my tick function, but what Im struggling with is finding out how to tell chipmunk to not simulate them at all.

Any one got any suggestions?

Thanks

Oli

Re: Stop simulating offscreen bodies

Posted: Mon Sep 05, 2011 1:43 am
by slembcke
It's possible, but Chipmunk doesn't really have anything built in to help you do that. The design of how that would work would have to be very game engine centric anyway.

What you can do is enable the object sleeping feature in Chipmunk. At least objects that aren't moving should fall asleep and reduce your CPU usage a lot.