Eldemarkki / Marching-Cubes-Terrain

Marching Cubes terrain implementation in Unity using the Job System and the Burst compiler
MIT License
562 stars 80 forks source link

Include NativeArray in custom VoxelDataGenerator #60

Closed ZeroByter closed 2 years ago

ZeroByter commented 2 years ago

Hello, I am currently writing my own data generator which will generate the marching cubes data based off a pre-made model.

I am planning to accomplish this by first scanning the model in a seperate Unity scene, writing all the float data values to a file, and then at a seperate time, loading the values from the asset file and passing the floats data to the generator.

I am passing the float data as a NativeArray<float>.

So finally, my question: how to dispose of the NativeArray I created after the job is completed?

PS. Yes, I realize I am sort of creating an unnecessary step here by loading the float data to a multi-threaded job, only to return that same data, but at the moment I don't see another way of generating the marching cubes from a model.

ZeroByter commented 2 years ago

Nevermind, I looked at the heightmap data generator and used that as inspiration for how to properly create/dispose a NativeArray.