1
\$\begingroup\$

The most common practice that I read about for overcoming floating point precision in video games with large worlds is by dividing the world into cells and load it with player's position and shift origin of objects with respect to player.

However this seems to be only valid for single-player games. As soon as you change to multiplayer with authoritative server scenario a lot of anomalies arises.

Since a authoritative server has to keep track of all of the world its not possible to base the origin off a single player

For a object that is halfway through two or more cell's co-ordinate system. which cell's part should it be ? and how should it react to it?

There seems to be extremely little to no information about supporting such worlds for multiplayer which are larger than what a common origin can support with enough precision.

Can anyone shed some light on the topic ?

\$\endgroup\$
3
\$\begingroup\$

It can work just as well in multiplayer games.

You can partition the world up into cells with integer coordinates and consider the center of each cell the origin for the floating point coordinates of the objects contained in that cell.

Ideally you choose a cell size that allows you to express the cellspace coordinates within a range of floating point values that won't exhibit too much question (due to accuracy away from zero) about when the object leaves one cell and enters another. But even if even if you have that problem you can solve it by choosing a suitable border size and essentially overlapping the cells slightly, so an object is reported in two cells while it's on the border.

Naturally you will want some form of uniquely identifying the object in this case, so even though there are two records for the objects in two different cells you don't double-process it in certain cases.

\$\endgroup\$
  • \$\begingroup\$ Could you kindly elaborate on the second paragraph? \$\endgroup\$ – Allahjane Oct 20 '16 at 20:51
  • \$\begingroup\$ @Allahjane Which part of it in particular? \$\endgroup\$ – Josh Oct 20 '16 at 21:02
  • \$\begingroup\$ " Ideally you choose a cell size that allows you to express the cellspace coordinates within a range of floating point values that won't exhibit too much question (due to accuracy away from zero) about when the object leaves one cell and enters another. " \$\endgroup\$ – Allahjane Oct 20 '16 at 21:37
  • \$\begingroup\$ Oh, by that I just mean you decide that each cell goes from, say, -5500 to +5500 (as floats) on each axis. Some reasonable range of values so you aren't pushing up against the upper limits of what is expressible in a float (and thus, running into huge accuracy problems). \$\endgroup\$ – Josh Oct 20 '16 at 21:39
  • 1
    \$\begingroup\$ @Allahjane I don't understand what you mean then, can you clarify? My answer is to put that object in both cells and keep track of that. One cell has the object in its origin, the other cell has the object in its origin. \$\endgroup\$ – Josh Oct 20 '16 at 22:02

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.