Jump to content

  • Log In with Google      Sign In   
  • Create Account

Structure generation in infinite sandbox world


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
1 reply to this topic

#1 Kiel368   Members   -  Reputation: 215

Like
0Likes
Like

Posted 06 February 2014 - 04:54 PM

Hey!

 

I'm working on a sanbox game project. I use voxel terrain and my world is infinite. It is divided into 16x16x16 chunks. Generating the heightmap is quite easy, but generating structures like trees or ponds is a problem and here's why:

 

Each of these structures can reach outside the given chunk and my generator works like this:

 

generator.generateDataForChunk(Vector3 offset).

 

The easiest solution would be to just create a map full of chunks and then run the generator over the whole map using world.setVoxel that would work out the proper chunk and set the block, but my world generates also as the player moves so the problem is that if eg. I generate a big tree and its trunk resides on the chunk, which just has been created by player motion, an already existing chunk could be altered eg. by the leaves which generate along with a tree and this is really bad:

 

consider a tunnel starting on a chunk created due to the player's motion. This chunk gets generated and it changes half of the world player can see because it is carved so that it changes the existing chunks!

 

I don't know how to resolve that problem and setting sth like MAX_SPREAD to each component is not also good because then a lot more chunks would have to be generated. Doing everything only based on noise (like heightmap) is not an option either, because I'll want also to generate from some pre-loaded structures like villages or castles.

 

Please help me and thanks in advance.

Kiel368



Sponsor:

#2 phil_t   Crossbones+   -  Reputation: 3915

Like
0Likes
Like

Posted 06 February 2014 - 05:35 PM

Fundamentally you have to know which adjacent structures (in chunks that haven't been created) could possibly affect any currently existing chunks, correct? Like, there's no getting around this, assuming you want your existing world not to suddenly change when new chunks are created.

 

So you'll need to have some kind of "max spread" notion, and search any adjacent areas for structures which might impact any chunks you're creating. There's no reason other chunks impacted by that structure (but not "in view") need to be created/allocated at this time though.






Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS