I have a system where the user can carve into a 2D mesh. Thing is, I don’t use RenderMesh because of unrelated reasons.
Since I can’t access UnityEngine mesh data outside of the main thread, I’d at least like to build the lists of vertices and triangles for all the chunks in a job, and then rebuild the meshes from that data on the main thread.
How do I return that data and bind it to its respective chunk? Nested native containers aren’t currently supported I’ve read.
I’d like to do something like that :
protected override JobHandle OnUpdate(JobHandle inputDependencies)
{
NativeHashMap<int, NativeList<float3>> vertices = new NativeHashMap<int, NativeList<float3>>(480, Allocator.Temp);
NativeHashMap<int, NativeList<int>> triangles = new NativeHashMap<int, NativeList<int>>(480, Allocator.Temp);
MapMeshDataJob mapMeshDataJob = new MapMeshDataJob
{
MapBuffer = GetBufferFromEntity<IntBufferElement>(true),
Vertices = vertices
Triangles = triangles
};
JobHandle jobHandle = mapMeshDataJob.Schedule(inputDependencies);
jobHandle.Complete();
RebuildMeshes(vertices, triangles);
vertices.Dispose();
triangles.Dispose();
return inputDependencies;
}
I’m trying to make sense of the DOTS and feeling pretty dense right now. If there’s anything wrong with the implementation as well, please let me know.