iDevGames Forums
Adding lots of static shapes in Chipmunk - performance question - Printable Version

+- iDevGames Forums (http://www.idevgames.com/forums)
+-- Forum: Development Zone (/forum-3.html)
+--- Forum: Game Programming Fundamentals (/forum-7.html)
+--- Thread: Adding lots of static shapes in Chipmunk - performance question (/thread-9155.html)



Adding lots of static shapes in Chipmunk - performance question - TomorrowPlusX - Jul 11, 2011 05:43 AM

Hey everybody,

I'm adding a lot of static shapes (sensors) at level load, and it's showing up as a big performance hit. Now, once loaded, it runs fantastically well. But loading them all is slow.

I'm adding them via cpSpaceAddStaticShape()

I'm wondering if there's a way to tell chipmunk to wait while I add a batch of shapes, and then do its rehashing and other expensive computation once I've finished.

Note: In my profiling I find the hotspot is the function cpSpaceActivateShapesTouchingShape -- which seems spurious since the shapes I'm adding are sensors.


RE: Adding lots of static shapes in Chipmunk - performance question - Skorche - Jul 11, 2011 10:56 AM

I just released Chipmunk 6.0.0 a week ago. You might want to consider upgrading to that. This was one of the problems it fixed. There have been a few small API changes though.

In Chipmunk 5.3.x it would run a shape query when inserting or removing static shapes to see if it needed to wake anything up to deal with the newly inserted static shape. In Chipmunk 6, it actually keeps a contact graph, so it can efficiently (and more accurately) wake objects resting on a static shape. I removed the query for insertions completely as it was ridiculously expensive and a pretty specific border case.

If you want to stick with 5.3.5, it wouldn't be the worst thing to modify the Chipmunk source to get rid of the cpSpaceActivateShapesTouchingShape() call. I don't plan on releasing a Chipmunk 5.3.6, so you'd never have to merge changes or anything.


RE: Adding lots of static shapes in Chipmunk - performance question - TomorrowPlusX - Jul 11, 2011 12:43 PM

Wow, awesome! Is there any transition information, any gotchas about switching from 5.3.whatevs to 6.0?


RE: Adding lots of static shapes in Chipmunk - performance question - Skorche - Jul 11, 2011 01:39 PM

The release notes should be pretty thorough. We just created an updates feed, that's probably the easiest way to get to the release notes other than downloading and looking at the readme:
feed://chipmunk-physics.net/updates.rss