Large space with too many segments performance

Official forum for the Chipmunk2D Physics Library.
Post Reply
yilone
Posts: 1
Joined: Mon May 16, 2011 9:40 pm
Contact:

Large space with too many segments performance

Post by yilone »

Hi slembcke,

I'm now using chipmunks for a medium large world. There are a lot of segments in space. The frame rates drop to around 30fps - 40fps. As diagnosed with profiling tool. top second time consuming, which covers 3.3% of all time, goes to this calling graph, cpHashSetEach-->cpSpaceHashRehash-->cpSpaceRehashStatic-->[SpaceManager step:]-->... Want to improve this performance. I did two tunings, one is to decrease the iteration counter to smaller number, the other is to not to do cpSpaceHashEach for static shapes every tick. but still not much improvements for frame rates. and the whole ticking seems to be slow, like kinda of slow motion, not too slow, but still not acceptable.

Question is,

1). what other major tuning do I need to try?
2). Is it do-able to add logic to dynamically add segments or remove segments, say, if they are around the screen, add them to space, if they goes out of screens and adjacent left and right screen, remove then by calling cpRemoveStaticShape
3). Will chipmunks' 6.x version, with AABB tree, improve this tremendously ?
4). How is the "auto geometry" going, as mentioned in http://www.cocos2d-iphone.org/forum/topic/11730

Thanks slembcke in advance.
User avatar
slembcke
Site Admin
Posts: 4166
Joined: Tue Aug 14, 2007 7:13 pm
Contact:

Re: Large space with too many segments performance

Post by slembcke »

Is SpaceManager calling cpSpaceRehashStatic() for some reason? I have no idea why it would be doing that and it really shouldn't. The whole point of static shapes is that they don't move and done need to be rehashed. This sounds like a bug in SpaceManager.

You should be able to have thousands of static line segments in the space before you really notice any performance differences. Though you might need to tune the spatial hash to get better performance. http://files.slembcke.net/chipmunk/rele ... s/#cpSpace

Chipmunk 6's AABB tree tends to be faster, yes, but not in all cases. It's hard to say how much better or worse it would be without actually trying it.

We are just finishing up with a large contracting project in the next couple weeks so I'll be able to work on Chipmunk full time for a few weeks. The auto-geometry is definitely on the list of things to finish.
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 25 guests