Perlin worms with chunks

Hi there,

I’ve, as usual, stumbled into another problem for my game.
So let’s say we have made a perlin worm algorithm. This is what it would look like:

This is just a drawing of course. You would have to add code for splitting worms.
But in my game all of the blocks aren’t in just one global table. If it were it would be super easy to generate these worms. My game uses chunks so i can’t do that.

Here’s the problem:
If you were to generate these worms on a per-chunk basis, you would have worms cut off and not continue into other chunks.

The blue lines are the dividors between the chunks. As you can see all of the worms that go into other chunks get cut off there. Now people have already tackled this situation before but here’s the kicker:
It needs to be relatively performant. I can’t for example check every chunk and continue the worms coming from those chunks.

Ideally I would not have to use an outside script (one that for example manages all chunks) to generate the worms on the ““outside””. This would be hacky and would not work with my future planned terrain generation system. Chunk objects can’t influence eachother.

I appreciate any help!!

1 Like

Hi! Similar case here. I ended up avoiding the problem entirely by making all my perlin worm caves go down steeply so that they wouldnt break out of terrain, but the only thing I can think of is:

  • Have a table where you keep all active worms as objects
  • Each active worm object has the x,z of the chunk that it is going into
  • When a new chunk is generated, it checks over the table of worms, and if there are any worms stopped at the chunk, resumes them until they reach the other end.

Hope this helps someone who encounters this topic in the future, or you if you are still working on that project.