Merging polygon2Ds for procedurally generated terrain

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By Afely

I’m currently making a procedurally generated 2D landscape. I’ve already done all the generation, the problem is that I need to optimize it. At first I was just giving every tile its own Polygon2D node, but obviously I can’t do that because it causes major performance issues. So I looked into a way to merge all my polygons into one, and I found this reddit post. This was very useful and got really close to what I wanted, but unfortunately I can’t get it to work. No matter what I do, it always either doesn’t work right or just crashes. Any help, workarounds or alternatives are appreciated.

:bust_in_silhouette: Reply From: matterda

May I ask you why you need a Polygon2D around every tile (or a merged version of it)? Maybe what you want to accomplish can be done in another, simpler way.

I’m using the marching squares algorithm to smooth out my terrain. If I wasn’t I would just use a tilemap. But now that I think about it, it wouldn’t be that hard to modify my code to work with one. If I don’t get a good answer, then I’ll just do that.

Afely | 2021-02-08 10:19