• Advertisement
Sign in to follow this  

Structure generation in infinite sandbox world

This topic is 1445 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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

Share this post


Link to post
Share on other sites
Advertisement

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.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement