Stop simulating offscreen bodies

Official forum for the Chipmunk2D Physics Library.
Post Reply
uketernity
Posts: 1
Joined: Fri Aug 05, 2011 2:35 am
Contact:

Stop simulating offscreen bodies

Post 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
User avatar
slembcke
Site Admin
Posts: 4166
Joined: Tue Aug 14, 2007 7:13 pm
Contact:

Re: Stop simulating offscreen bodies

Post 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.
Can't sleep... Chipmunks will eat me...
Check out our latest projects! -> http://howlingmoonsoftware.com/wordpress/
Post Reply

Who is online

Users browsing this forum: No registered users and 10 guests