Moon Buggy - shapes freak out after falling for a long time

Discuss any Chipmunk bugs here.

Moon Buggy - shapes freak out after falling for a long time

Postby mildm8nnered » Thu Oct 30, 2008 8:01 am

I'm using Chipmunk on the iPhone, and have some code based on the Moon Buggy tutorial running, with configurable vehicles and spaces.

Both in my code, and the original desktop app, if I roll the buggy off the edge of the line, so that it's falling freely, and then wait a few minutes (10-20 say), after a while, the shapes get more and more distorted, so that in the end its just a bundle of lines.

It's not clear to me what's happening here (maybe the position co-ordinates are overflowing or something), but if anyone's got any insight, that would be great.

cheers,
Martin
mildm8nnered
 
Posts: 6
Joined: Thu Oct 30, 2008 7:56 am

Re: Moon Buggy - shapes freak out after falling for a long time

Postby slembcke » Thu Oct 30, 2008 12:09 pm

That's the limited precision of floating point numbers that you are seeing. This is not a bug, but a limitation of computer hardware. If you looked at the coordinates of the bodies they would probably be into the millions or tens of millions. You have to remember that it's accelerating the whole time, going faster and faster.

IIRC, half of the precision of floating point numbers is distributed between 0 and 1. This is one reason why using pixel sized coordinates can be a bad idea. With objects that tend to size in at hundreds of pixels or more, you've wasted a lot of your precision. Using double precision floating point numbers, you have a lot to waste, but even their precision will run out.
Can't sleep... Chipmunks will eat me...
Check out our latest projects! -> http://howlingmoonsoftware.com/wordpress/
User avatar
slembcke
Site Admin
 
Posts: 4164
Joined: Tue Aug 14, 2007 7:13 pm

Re: Moon Buggy - shapes freak out after falling for a long time

Postby mildm8nnered » Thu Oct 30, 2008 11:00 pm

oh yes. No terminal velocity here. I should have thought of that.

I guess I can just blow them up when they exceed a reasonable velocity (mach-1 perhaps).

I've noticed another difference between my iPhone port and the default moon-buggy demo.

I ported the latest library distribution, and then the demo specific code from moon buggy.

I noticed from both the source, and various moon-buggy comments on the forums, that the library code in moon-buggy is slightly different.

I've also observed that on the desktop, the chassis tends to sit a bit lower between the wheels, and the vehicle behaviour is also slightly different. On the desktop, when I'm in the first big dip, I need to rock back and forth, and accelerate to get out over the hump. On the iPhone port, accelerating on the uphill slope tips the vehicle over on its back.

This could be due to either

a) an error in my port (by far the most likely explanation)

b) differences in the library code

If there's any chance that it's b), that would be good to know, so that I can focus on a). I was hoping that the library code differences were pretty trivial ...
mildm8nnered
 
Posts: 6
Joined: Thu Oct 30, 2008 7:56 am

Re: Moon Buggy - shapes freak out after falling for a long time

Postby mildm8nnered » Sun Nov 02, 2008 9:08 pm

Looks like those differences were due to errors on my part - I've now got the iPhone version behaving exactly like the desktop one ...
mildm8nnered
 
Posts: 6
Joined: Thu Oct 30, 2008 7:56 am

Re: Moon Buggy - shapes freak out after falling for a long time

Postby slembcke » Sun Nov 02, 2008 10:33 pm

Oh, I missed that in your last post. Yes, they should be the same in both places as you found out. Sorry. :(
Can't sleep... Chipmunks will eat me...
Check out our latest projects! -> http://howlingmoonsoftware.com/wordpress/
User avatar
slembcke
Site Admin
 
Posts: 4164
Joined: Tue Aug 14, 2007 7:13 pm


Return to Bugs

Who is online

Users browsing this forum: No registered users and 0 guests

cron