Efficient solution for locating player position in world

I'm thinking about an efficient way to load world objects from the server to the client in an MMOG.

I've come up with two ideas and would like everyone's input, if I may.


  1. The most natural would be to use a large sphere around the player ship on the server that continually checks if objects in that area (coordinate-delimited) are inside the sphere. This means we'll have to continually do calculations of what coords are inside the sphere and all objects that are attached to the area's node will have to be checked.


  2. Using a number of smaller boxes (each with its own node) set up around the player ship all objects attached to the node in each such box would be visible to the player. When the player moves into another center box a new "row" of boxes would be loaded from the server in the direction the player travelled. Only those boxes need to be checked and loaded and using an extended array of boxes around the inner one would allow for easy caching of already seen objects. This would not give the exact same view distance in each direction.



    Using fog could of course fix the uneven view distance for the boxes setup, but a hacker could still see outside it and get an advantage (granted not a big one in this particular game).



    What option would you think would work best?

    Is there another option I have overlooked?



    Thanks in advance!

Hi!



I advise you to use a system of spatial subdivision that fits into your need and then you have to find in which spatial subdivision your ship is when he has just moved. Your spatial subdivision can use a bounding volume to accelerate the computations but take care at overlapping, some distinct spatial subdivisions that are not overlapping might have their respective bounding volumes that overlap  :expressionless:



You spoke about ships, I assume your game takes place in the space. You should at least sort the ships to avoid to perform naively collision tests on all ships.

EDIT:

Same idea hereā€¦



Devide your map in fields.

Every field has list of objects which are in the field.



Calculate the players current field.

Set this field, and all neighbors visible.

Hide fields that are no neighbors.

Update.





Good luck.

Schifty said:

EDIT:
Same idea here...

Devide your map in fields.
Every field has list of objects which are in the field.

Calculate the players current field.
Set this field, and all neighbors visible.
Hide fields that are no neighbors.
Update.


Good luck.

Ok you suggest to use a regular grid composed of fixed-size voxels, it might be enough.

Thank you for the replies!



Option 2) is a spatial subdivision system, but in 3d, since it is indeed space the game is set in, so I'm using cubes rather than squares. Do you think such a system (with say 1,000,000,000 cubes in one part of the universe and 179 cubes for checking what "server cubes" each player can see - giving a min. view distance of about 5.83 and a max. view distance of about 8.7 cubes from edge to edge - 5x5x5 cube plus 3x3x1 extension on each side.) would be much faster than the circle (within a larger subdivision cube) checking objects to be within its volume?



I'm not concerned with collisions at this time as they aren't very important in the game at this stage.

What I'm trying to find is just how to get the objects that the player can see from where they are in space, from the server to the client as efficiently as possible.

I spoke about voxels (volumetric pixels) because squares are not enough. The drawback is that voxels require a lot of memory for huge space. Maybe look at the octrees.

I didn't pay much attention to what other people said because I've got a bad case of ADD and a lot to do, but my suggestion to you is to take a look at Radakan's WorldTool and the concept behind it.



Basically you divide your world up into tons of tiny-ish tiles. This allows you to only keep a few tiles loaded at a time. In addition, store all of your object information broken up into tiles and just load all of the objects on the tile.



In terms of dynamic objects like players, I would recommend using a separate message server (if you're using JGN) to manage the location of players, basically you're P2P networked to all other players in a certain area.