Search Unity

Confusion About Creating Temporary Collections Inside A Job

Discussion in 'Entity Component System' started by Fobri, Apr 11, 2019.

  1. Fobri

    Fobri

    Joined:
    Jan 28, 2014
    Posts:
    22
    Hey
    I’m trying to generate a terrainchunk inside a job. I need to create an array of vertices, normals etc. but I don’t know the amount of them before calculating them since I’m going for the same blocky style as minecraft.

    I can only think about two options right now. Either largely overestimate the amount for each of them and allocate a large NativeArray or keep resizing a NativeList as I get more elements. Neither of these seem like a solid way to me. Are there any better options?

    Also, when calculating noise values, can I take advantage of burst’s SIMD compilation? I can’t figure out if it’s possible or not...

    Thanks
     
  2. ilih

    ilih

    Joined:
    Aug 6, 2013
    Posts:
    1,413
    Should be possible with Unity.Mathematics.noise class.
     
  3. DreamingImLatios

    DreamingImLatios

    Joined:
    Jun 3, 2017
    Posts:
    4,266
    If you don't want to use NativeList (you can pre-allocate a capacity to avoid most of the resizings), then you may want to check out Unity.Physics BlockStream container. I haven't fully figured out how to use it yet, but it might be what you want.