Introduction
I have a block system just like minecraft and I want to add sand blocks which, depending on their nearest neighbours, will either turn into a wedge or stay as a cube. Basically what I want to achieve is smooth terrain only using wedges and cubes.
Here’s an example of it could look:
The issues
The algoritm seems obvious at first but the more you think about it the harder it gets.
What’s stopping the current figuration from turning out like this:
Or turning into an infinity loop like this:
Restrictions
You can not create new blocks (you may only modify the blocks that exist)
You can only use single wedges or single blocks
Anyone have any good reads or links on this topic?
Or straight up a solution/suggestion?
A neightbour is only counted if it’s a block (wedges counts as empty).
It only checks 2, 4, 6, 8, the rest is irrelevant.
Problem is, look at the second block from the left in the gif!
It’s switching between being a wedge and a block because the block to the left is switching.
They are co-dependent, causing the cyclic behaviour which I dont know how to solve…
Maybe make the blocks independent from your terrain state, so instead of looking at what the neighbours are, you could check from a table and not modify it.
So what I’m guessing what you do right now is check the state of a block’s neighbours, what I’m saying is that the state should be stored somewhere else like in a table and not mutated (modified).