Triangle terrain generator optimizations

Hello. I’ve been working on a triangle terrain generator, and the terrain generation part of it is mostly complete (It only generates the terrain / landscape. No trees, or anything else). But there is a big problem. It’s slow. After doing some extensive tests, I’ve concluded that most of these problems with speed has to do with setting the size, and cframe of the wedgeparts. Pretty much everything that involves changing the properties of a basepart. I’ve implemented a couple of optimizations, one of them is instance pooling, where instead of creating new wedgeparts every time it makes a new chunk, and deleting the wedgeparts that are too far away, it will instead move the position of the far away wedgeparts to Vector3.yAxis * math.huge, and then insert them into a table, and then when it generates new chunks, it just re-uses these far away wedgeparts, so that way it doesn’t have to constantly create, and delete wedgeparts, and this does help with performance. The other “optimization” that I am doing is that if it’s taking too long to generate new chunks, the code will take a break, and wait .1 seconds before continuing to generate the rest of the chunks. This did help quite a bit, but now I am a bit… lost. I don’t know what other optimizations I could do that could help performance. It would be nice if I could change properties of baseparts in parallel, rather than serial, but roblox doesn’t support this yet. And I could use the editable mesh, but then this means that my terrain won’t have any propper collision, but I guess I could make a function that could calculate the height of the terrain at any given x, z coordinate, and implement custom collision, but I don’t know how practical, this is. I can’t use greedy meshing because the game isn’t like minecraft. And since it’s triangle terrain, this also means that it’s already been culled to hide faces that you are never going to see. In its current state, the “game” is playable, and I could probably script the gameplay parts of the game without adding any more optimizations, and the game will probably be playable, but the second optimization that I added is a tradeoff, because now the chunk generation is distributed over a larger amount of time, which means that the chunks don’t actually generate any faster, they just don’t make any lag spikes, and the framerate doesn’t drop as much when they generate.

I can’t show much code because I want to use this in a game, and I don’t want people stealing my ideas, or my code.

Tldr; What are some optimizations that I can implement to speed up scripts that change properties of large amounts of baseparts?

Editable mesh is probably your best bet. You could try to make WedgePart triangles right under the player for collision. This is assuming your triangle terrain is just a heightmap.

Anything part related usually can’t be optimized any further. BulkMoveTo works well but setting Size is a problem as it cant be done in bulk. It also does some collision related things in the background if you set it.