Confusion About Creating Temporary Collections Inside A Job

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

Should be possible with Unity.Mathematics.noise class.

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.