As a Roblox developer, it is currently too hard to have performant dynamic EditableMeshes.
Currently, when you set a position of one vertex, it seems to reupload the entire mesh to the gpu (or performs another very slow task) unless the mesh is parented to nil. This process is incredibly slow ( > 5 ms) and you are unable to reparent the mesh without an even longer delay of up to 10 ms. This delay is simply unacceptable in a game. You only have 16 ms per frame and less that you can actually use without lag.
If Roblox is able to address this issue, it would improve my development experience because I will be able to create new things like real-time cloth simulation with a sub 0.2 ms response time. This would also help developers create performant oceans without the use of bones. I believe that this change, would allow the EditableMesh which is still in beta to reach its full potential upon release. Giving us developers a solution to this would allow greater creativity on the platform.
A proposed solution to this would be to have a function which takes a dictionary that specifies vertex ids and positions, similar to :BulkMoveTo.
There’s still the overhead of the function call itself having to cross through to the engine, as well as it still being extremely wasteful if it’s true that
Suddenly, the 5 ms is multiplied by whatever huge number of triangles you are trying to batch-update at once. Deferring the calls on the Luau-side won’t really solve anything because I doubt there is any code run in-between the calls OP script makes (or would make) anyway.
OP is trying to set the vertex position of multiple vertices at once and uploading the mesh to the gpu for every vertex you modify is wasteful when you are going to change them right after.
Huh? That’s what I’m saying though? Ideally, there would be a function to update a bunch of verticies at once, then upload the mesh, instead of the mesh being uploaded to the GPU for every single change to a single vertex.
This is what the proposed function similar to :BulkMoveTo introduces.
However, I think Roblox has made progress in solving this issue. I noticed a 10x speed increase in :SetPosition, going from 3-4 ms to set the positions of all vertices of my mesh, to 0.1-0.3 ms. This may even beat the previous performance of setting positions while parents are nil. Thanks Roblox.