Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Can you help me paralellize this procedural mesh generator using the C# Job System

Discussion in 'C# Job System' started by Brainshack, Apr 4, 2021.

  1. Brainshack

    Brainshack

    Joined:
    Mar 1, 2013
    Posts:
    24
    Hi everyone,

    I am currently trying myself in procedural generation and am currently trying to make it run multi-threaded using unity Jobs. But I am currently struggeling to layout my data, since you cannot nest native arrays and also structs which have any sort of collections don't seem to be supported.

    Basically what I have is a list Poly, defined by a list of 2d coords. For each of these poly's I would like to generate a list of vertices, uvs, and triangles.

    So for each index in my IJobParallelFor I would have to generate a new NativeArray for all 3 elements, which basically means I would have to use a nested NativeArray which is not supported. I also tried a custom "Mesh" struct which has NativeArray elements. Not supported. NativeHashMap<int, NativeArray>. Nope.

    Does anybody have any suggestion on how one might tackle this?