Question

I am working on a java LWJGL game based on minecraft. I am working on the terrain management which is hard because the world can expand as you explore. How would you manage the terrain if it is stored in chunk objects and you needed to know which chunk to remove from the render list, which to add, and which to generate based on player's xyz position?

Was it helpful?

Solution

I work with high resolution medical voxel data and use an octree to store it in an efficient way.

You cannot really use an octree because you want dynamically expanding terrain (an octree is extremly fast when it comes to lookups, but very slow on building/extending).

I suggest you try to use a HashMap, if you provide a good hash function for Vector3 the lookup time will be nearly the same for any amount of chunks (theoretically O(1), but that's just the best case ... ).

You can then remove all map entries that are out of sight by iterating through the map keys.(this could be done on a secondary thread that handles all loading/unloading).

Hope this helps,

~ Loki

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top