9
\$\begingroup\$

When creating a game space in which to move, draw and collide objects, is it better to have the (0,0) point, or the (0,0,0) point, be in the very center of your space, such that the bounds of the worlds are (-halfSize, halfSize), or is it better to have it be at the far corner of your space, so the bounds are (0, size)?

What are the pros and cons of each, and what sort of problems do they each entail? Or does it really just not matter?

It seems like a minor detail, but I wanted to see if there were perhaps major issues I might be overlooking.

\$\endgroup\$
15
\$\begingroup\$

It seems to me that having the center of your space be (0, 0, 0) is better. Assuming you are using a signed format to represent positions in space, a center of (0, 0, 0) allows you to use both the negative and positive parts of your format, which can do wonders for precision for floats and range for signed integers. This may not matter for small scales, but for large scales it can make all the difference, that is, before you have to come up with a new system entirely.

Just to clarify: Given that you are creating a game world, which I assume you're rendering, the ultimate format you will convert to will be float, which is as you know, a signed format. In that case, you may get to a situation where (0, Size) cannot be represented, whereas (-HalfSize, HalfSize) can be. If you are not planning to render and can choose an arbitrary format then use either style, though I would still personally prefer the aforementioned style.

| improve this answer | |
\$\endgroup\$
5
\$\begingroup\$

It doesn't particularly matter. As long as you're consistent throughout your game.

I believe the more common approach is to have the world bounds centered around (0,0), meaning you'd have your bounds go from -halfSize, halfSize. Since most data structures that represent position (Vector2 or Vector3) default to zeros, you know that the default placement for objects is in the center of the world (instead of in the bottom corner).

| improve this answer | |
\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.