Does it make sense to use MeshData when the vertex count is unknown?

The benefit of using MeshData is no memcopy when the job is complete, the mesh is populated by pointer magic.
The drawback is that you need to set the vertex and triangle count before you schedule the job.

Although my poly count is defined within the job I still use MeshData, setting the tri and vertex count at its maximum possible number, internally I use NativeList which is then converted to the triangle and vertex nativearrays of the MeshData output.

I’m wondering if that makes sense or if I’m producing some garbage mesh with all these empty indices and vertices?

You could run mesh.Optimize() and check if that lowers the vertex count. Though Optimize() can easily take longer than your carefully bursted mesh gen job.

Alternative that I have been using: run a job that only determines the number of vertices/triangles. This can be extremely fast and at the same time you perform the MeshData setup (up to where you need the counts) and maybe any other stuff that you can throw in between counting and generating.

1 Like