I am making a voxel based 3-D game that can be infinitely generated in all directions using procedural terrain generation. I am having a hard time managing the world in a way that it has these requirements:
*It can be updated each frame quickly
*It can remove unused chunks
*It can find out whether or not a chunk is rendered and add it if it isn't
The ideas I have tried aren't very sound, and they will not work with several features. I have a chunk class that stores the block data, and a ChunkManager class that loads and unloads the chunks using arraylist. How would you make them index-able so you can find whether chunk (x, y, z) is loaded? If I went through the arraylist each frame and checked the coordinates of the chunk to figure out which need to be loaded and removed, it would probably run slowly.
I am stumped, and I can't find any code that shows ways to do this in an infinitely expandable world (Yes, its based on exploring). Any help will be appreciated!