These past two weeks I've been fixing and creating the saving functionality and adding trees to the game, as I began to add trees to the game, I noticed how much data I have to store and process.
Currently I only store chunks that have been modified by anyone in the game and I'm looking at storing the noisemap, heightmap, treemap and biomemap, currently the problem is storing the treemap, it's easy to store if a certain location in a 2D plane has a tree but if I want to store multiple trees into a certain location, I have to store the height and the type of the tree, of course I could store this data in chunks like.. the chunks, but I could save quite a bit of space if I don't store the type of a tree but just the height but even then it's quite much.
I'm planning on creating a map of a size of 131072 * 131072 * 512 which is quite large (I don't plan on creating an infinite map because there is no point in that), the treemap for multiple trees in a certain spot would be a short type which is 16 bits which in turn is 16 trees upwards, this means that the treemap would be 274877906944 bits which is 34 gigabytes, sure I could compress this to make it smaller but I don't see the point because I plan to have the data ready to be used in the game and compressing and decompressing takes time (Because I plan to have multiple save slots I will compress the whole save to save space), but just as I wrote earlier I will be storing these things in chunks so the game won't eat the whole 34 gigabytes from beginning.
As I don't know how much of the world a player will actually discover I can't really estimate how much space a single game would take, so I'm just trying to plan ahead and try to minimize how much space a save will take.
The cube chunk is stored directly in bytes, int index, float x, float y, float z and then all of the 2048 cubes but only the cube type which is a short, so in total a chunk is 4112 bytes which is around 4 kilobytes.
If you're interested in what I've already done, check the older post to view the list of tasks.
No comments:
Post a Comment