So what I am trying to achieve is voxel greedy mesh generation in C# Job System with Burst on.
Mesh itself contains bunch of submeshes (for different materials).
So I am passing NativeList for vertices, indices, uvs, etc. It works just fine for IJob, but… it’s too slow.
And I can’t use IJobParallelFor because it is forbidden to add to list in parallel. My idea was to create NativeList<NativeList> for every submesh but it’s also impossible.
What I am doing wrong? Maybe you have any ideas how I can generate my meshes suuuuper fast correctly?
You c a n not nest containers ith jobs, for safety resins.
You could execute each mesh however, on own thread.
So you could run either parallel for, or foreach per mesh.
You can actually use Mesh.MeshData and the new mesh API to simplify things a bit. So you can do something along the following lines:
var meshDataArray = Mesh.AllocateWritableMeshData(_targetEntities.CalculateEntityCount());
// Update the meshData in a job here
Mesh.ApplyAndDisposeWritableMeshData(meshDataArray, meshes);