I've been playing around the Job system mesh generating. One big performance bottleneck I found is native array coping. Using a for loop is just not ideal. I found this article there explaining how to copy a float3 native array to mesh.vertices with MemCpy https://gist.github.com/LotteMakesStuff/c2f9b764b15f74d14c00ceb4214356b4 However, I want to take it to the next level, I want to modify a certain section of the native array in one Job based on the index. Is there a way for me to offset the pointer based on the index?
Tho I'm not familiar with Jobs, presumably you can still use pointer arithmetic? Code (CSharp): var pointer = (byte*)NativeArrayUnsafeUtility.GetUnsafeBufferPointerWithoutChecks(NativeArray); var offset = pointer + index * stride;
Ok it worked, in the article the pointer type is void and I can't apply '+' to it, all I need to do is change pointer type to Vector3. Thank you!