is there a limit to the size of a cpSpace / ChipmunkSpace ?

Discuss new features and future development.

is there a limit to the size of a cpSpace / ChipmunkSpace ?

Postby horseshoe7 » Wed Jan 26, 2011 4:04 pm

I think the subject says it all.

I want to make a game where an object is tracked to be at the centre of the screen, but can 'fall' indefinitely.

Should I make a 'wrap around' and some boundaries to my space? I suppose it has to have some limit - the limit of the float type...
Posts: 36
Joined: Fri Feb 19, 2010 11:58 am

Re: is there a limit to the size of a cpSpace / ChipmunkSpace ?

Postby slembcke » Wed Jan 26, 2011 5:48 pm

It's only limited by the precision of the floating point type used. If you let an object accelerate constantly for a few minutes, you just might end up running into problems with 32bit floats though. Try it first, you might find that there really aren't any problems. Chipmunk is normally configured to use 64 bit doubles, but uses 32 bit floats on the iPhone. If you are on the iPhone, try changing the type in chipmunk_types.h before trying what I describe below. While 64 bit math is (usually) slightly faster on desktop machines, it's quite a bit slower on the iPhone.

I threw together a simple car racing game over infinite terrain a couple years ago called Byte Racer ( What I did for that to avoid precision issues was to create a somewhat wraparound world like you suggested earlier. Basically when the car would get further than a certain distance away from the origin, I would subtract it's position from every rigid body (the chassis, the wheels, and the static bodies the ground segments were attached to). The ground was created using perlin noise generated in screen sized chunks. The segments for each chunk shared a rigid body that I would move when the car's position was reset back to the origin. I of course would have to rehash the static hash each time this happened.

For any reasonable human attention span it probably would have worked fine without the wrapping, but it seemed like a fun experiment to try out.
Can't sleep... Chipmunks will eat me...
Check out our latest projects! ->
User avatar
Site Admin
Posts: 4164
Joined: Tue Aug 14, 2007 7:13 pm

Return to Features/Development

Who is online

Users browsing this forum: No registered users and 1 guest