Changing the shape of polygons, and very big polygons

Official forum for the Chipmunk2D Physics Library.
Post Reply
bzz
Posts: 2
Joined: Wed Oct 31, 2012 3:33 am
Contact:

Changing the shape of polygons, and very big polygons

Post by bzz »

Hello,

I'm making a 2d game in which the user has a fleet of vehicles. The fundamental feature will be digging into the ground and otherwise damaging it with explosions. I'd like to as if Chipmunk supports that.

How big can shapes in Chipmunk be, without requiring a supercomputer to run the simulation? Can I have a surface with a million vertexes?
User avatar
slembcke
Site Admin
Posts: 4166
Joined: Tue Aug 14, 2007 7:13 pm
Contact:

Re: Changing the shape of polygons, and very big polygons

Post by slembcke »

The best example of that I have is this demo for iOS:
https://github.com/slembcke/SpacePatrol
http://www.youtube.com/watch?v=rb49mke8K2k

It uses the autogeometry functionality of Chipmunk Pro to do the terrain geometry deformation based on a large density bitmap. The rest is all regular Chipmunk though. If you know how you want to do the geometry generation yourself you can. Chipmunk Pro's autogeometry is a good choice if you don't though, I've already spent a lot of time tuning its performance and it's cross platform. /me end shameless plug here

As far as performance, I fairly often have spaces with thousands of static line segment shapes in them and I've yet to run into a performance problem. Because static shapes aren't updated each frame they are relatively cheap. The default spatial index is a tree, so the performance will be O(log(n))-ish. A million vertexes would make for either an extremely large surface (big enough you might run into precision issues) or an extremely detailed surface. Realistically you only need the geometry to be accurate to within a couple of pixels of the graphics, and you can vastly reduce your geometric detail that way. Given the expected O(log(n)) performance, a million segments would be about twice as slow as a thousand. This is all conjecture though. The actual data structure is a bit more complicated, and as a spatial query you can end up in multiple tree leaves.
Can't sleep... Chipmunks will eat me...
Check out our latest projects! -> http://howlingmoonsoftware.com/wordpress/
bzz
Posts: 2
Joined: Wed Oct 31, 2012 3:33 am
Contact:

Re: Changing the shape of polygons, and very big polygons

Post by bzz »

This is exactly what I was looking for, thanks!
Post Reply

Who is online

Users browsing this forum: No registered users and 6 guests