Captain-Chaos / WorldPainter

WorldPainter is an interactive graphical map generator for the indie game Minecraft.
http://www.worldpainter.net/
GNU General Public License v3.0
341 stars 58 forks source link

Feature request: Set minimum distance between objects #335

Open Fornad95 opened 10 months ago

Fornad95 commented 10 months ago

More or less as in the title - even at relatively low densities I sometimes get trees spawning one block away from one another, which nearly always looks bad. I'd like to be able to define a minimum distance between where they spawn so this doesn't happen.

Fornad95 commented 5 months ago

Just thought I'd add to this with your idea from our conversation back in September:

"One thing I have considered is to add a grid option, so objects are placed on a greater than 1x1 grid, possibly with a random deviation from the grid point. That might help with this."

After a bit of thought I think this could work well. Here's a concept of how it could be implemented:

100density

In this case, each tree has been set to spawn randomly within a 2x2 square. The overall grid has a checkerboard pattern (helps to keep the distribution looking more natural), and they are forbidden from spawning within the orange squares. This would be the result of a brush at 100% intensity, so at lower intensities you'd get some empty white areas. For trees with bigger canopies, you could obviously make these squares bigger (3x3, 4x4, etc.).

You would get some trees spawning diagonally across from one another, but I think that this looks less bad than right next to one another. If you wanted to prevent this, you could have another grid option:

100density2

(this is still at 100% density, but the pattern tessellates)

In fact, you could allow users to create their own grid patterns (similar to the custom annotation creation tool). This would make for the highest level of customisability and I think is probably the best solution to this problem.

I think this solution keeps the distribution of trees feeling natural, but means the user has more control over their density and spawning behaviour.

I hope this all makes sense!

Captain-Chaos commented 5 months ago

I would definitely start with a simple square grid, which would not be exactly the same as your first example, but would get you pretty close (basically it's that but rotated 45 degrees). We can see about custom grid patterns later, that would be significantly more advanced and more work.