"safe range" of world size

Official forum for the Chipmunk2D Physics Library.
Post Reply
Beta Carotene
Posts: 123
Joined: Sat Aug 04, 2012 6:34 pm
Contact:

"safe range" of world size

Post by Beta Carotene »

so here's a more general comp-sci question for you. Basically, what I'm looking to understand is how large I can make the world im building without precision problems. This isnt just about chipmunk, its about all subsystems. Albeit, chipmunk probably requires significantly more precision that say, graphics (where double precision is not an option).

What I need to know is, practically speaking, what is a "safe range" to stay in with respect to floating point precision. I dont know that much about quantization, but I would *suspect* that you lose another bit of precision with every power of 2 (512, 1024, 2048, 4096, ect)

I *think* my world will need to be roughly 8192 width x 4096 height.

What do you think scott? Will this range be ok for stuff like graphics, and should I enable double precision in chipmunk?

PS: How do you enable double precision? ?? :oops: ??

PPS: ah, it looks like double is enabled by default... looks like I'm all set to go anyway =P
User avatar
slembcke
Site Admin
Posts: 4166
Joined: Tue Aug 14, 2007 7:13 pm
Contact:

Re: "safe range" of world size

Post by slembcke »

Yup. Double precision is used by default in Chipmunk. On modern desktop CPUs it tends to be either slightly faster or barely slower. Not really true of ARM though.

We sort of abandoned a space shooter game we were working on where the world was 200k x 200k in size. Never had any issues. It wasn't using Chipmunk, but was using 32 bit floats. You are correct that each time you lose precision each time you double a number. There is a nice series about this exact thing on AltDevBlog. http://www.altdevblogaday.com/tag/floating-point/ You should find a lot of those articles relevant, and much more detailed than I can tell you.

As for rendering, I wouldn't worry about 32 bit floats at that size either unless you need to zoom way in. You can always render the world in chunks to keep the range of values used in each chunk low. I wouldn't worry about it too much until it's a problem though.
Can't sleep... Chipmunks will eat me...
Check out our latest projects! -> http://howlingmoonsoftware.com/wordpress/
Beta Carotene
Posts: 123
Joined: Sat Aug 04, 2012 6:34 pm
Contact:

Re: "safe range" of world size

Post by Beta Carotene »

alright, good to know. Thanks.
Post Reply

Who is online

Users browsing this forum: No registered users and 13 guests