0

For a project I'm remaking Minecraft's voxel blocky terran.

Currently im using a 3 key array(new Block[,,]) and then i can reference a block using its cords like BlockList[x,y,z].BlockID and stuff like that.

But i want infinite terrain which isn't possible with a array. So would a List be better for this?

Keep in mind there are ~200k blocks loaded at any given time - I am afraid of looping through each block in the list to find the block requested would be heavy on CPU.

Chandan Kumar
  • 4,570
  • 4
  • 42
  • 62
  • 4
    This is too broad to explain in a single answer, and belongs on the [Game Dev site](http://gamedev.stackexchange.com/) anyway. You can't hold an infinite terrain in neither a list nor an array. You need to implement some kind of "streaming" algorithm, where the edges of your terrain are streamed in once they become (nearly) visible. How to do so has been discussed in various places on the web, so please share your research. – CodeCaster Aug 12 '16 at 06:29
  • 2
    Possible duplicate of [Which is better to use array or List<>?](http://stackoverflow.com/questions/2975426/which-is-better-to-use-array-or-list) – Ehsan Akbar Aug 12 '16 at 06:30
  • @EhsanAkbar really? Read the question. – EvilTak Aug 12 '16 at 06:30
  • @EvilTak maybe yes – Ehsan Akbar Aug 12 '16 at 06:32
  • Nothing is ever infinite. Your computer will not be able to handle it – monstertjie_za Aug 12 '16 at 06:33
  • @CodeCaster Didnt even think of doing that. If you post as a answer ill accept it. – michael becker Aug 12 '16 at 06:37
  • The thing is to add something new when you're near the end so the user experience a never ending terrain. – jegtugado Aug 12 '16 at 06:45
  • Better use a Hashset this is the fastest data structure in .NET https://msdn.microsoft.com/en-us/library/bb359438.aspx – Anonymous Duck Aug 12 '16 at 10:11
  • @Sherlock this might be the best answer. Performance data shows it outperforms both List and Array in speed when thousands of elements are involved. There is still the major problem where I would have to loop through each element in the Hashset to find the one I'm looking for. I cant imagine this would ever be easy on a CPU – michael becker Aug 12 '16 at 18:41

0 Answers0