I’m creating a voxel based game, and have planned to gain some performance by not spawning the blocks that don’t have a block of air next to them, and therefore having tens, of not thousands of int’s for each block, so it stores what block is in that slot, and spawns that block accordingly.
What would be the performance gains of this approach, and would they be demolished by the massive number of variables? (I would probably write a program to write the program, as it will be hundreds of thousands of lines of code, just declaring variables that I could easily auto-name…).
You’re planning to write a program that writes code that represents the voxel field? I wouldn’t go down that route, it wont scale and it wont allow you the freedom to have arbitrary level data. Instead generate a file representing the data to load for your voxel levels. At runtime when you load the file, you can use a memory efficient structure to store the voxel data read from the file. I would recommend googling Sparse Voxel Octree. Alternatively, you could use a Spatial Hash, and just have uniform grid of sectors of some standard size, like 128^3 voxels. Then with either of those options you can eliminate needing to store in memory whole sectors of data with no blocks in them.