bcthund / Project_Parsec

1 stars 0 forks source link

Chunk Manager #19

Closed bcthund closed 3 years ago

bcthund commented 3 years ago

The map should use a chunk like system (according to my own made up definition of such a thing of course) where every chunk is a section of map of a certain size and includes 3D objects, 2D objects, Events, NPCs and anything else required.

Previously the map was loading in a grid of odd size (3x3, 5x5, 7x7, etc) so there was always a primary center chunk. But loading new maps and shifting maps around in the 2D array was very problematic and a n over complicated way of handling the map.

Instead use either a VectorMap or UMap so we can dynamically add and remove chunks. Each chunk will load/unload depending on a simple distance to center of chunk. If the distance is within the defined view range then load the chunk, if outside then remove. When drawing we simply need to iterate through all chunks and draw them one at a time. Sorting could be used to sort the chunks by distance so furthest are drawn first.

bcthund commented 3 years ago