Why do some games have multiple spatial partitions?
Sophisticated games often have multiple spatial partitions for different kinds of content. The basic requirements for this pattern are that you have a set of objects that each have some kind of position and that you are doing enough queries to find objects by location that your performance is suffering.
How are units stored in a spatial partition?
Now, superimpose a grid of fixed-size squares onto it like a sheet of graph paper. Instead of storing our units in a single array, we put them in the cells of this grid. Each cell stores the list of units whose positions are within that cell’s boundary.
When do you update the spatial data structure?
When an object’s position changes, update the spatial data structure so that it can continue to find the object. This is a common pattern for storing both live, moving game objects and also the static art and geometry of the game world.
How are units partitioned in a war game?
Opposing armies with hundreds of units will clash together on the field of battle. Warriors need to know which nearby enemy to swing their blades at. The naïve way to handle this is by looking at every pair of units and seeing how close they are to each other:
What does space partitioning do to a space?
In other words, space partitioning divides a space into non-overlapping regions. Any point in the space can then be identified to lie in exactly one of the regions.
How is space partitioning used in scanline algorithms?
Space partitioning is also often used in scanline algorithms to eliminate the polygons out of the camera’s viewing frustum, limiting the number of polygons processed by the pipeline. There is also a usage in collision detection: determining whether two objects are close to each other can be much faster using space partitioning.