- Home /
3D voxel Planet (dual contouring) Job System or Task Parallel Library?
Hi all,
I working on a 3D voxel planet game, based on octree.
I need some help with the following 2 things:
Now I save my data in a class which name is ChunkProfile but I am thinking about that I change class to struct, but I contain a lots of data in class so I do not know which is better?
And the other question is that I use Unity Job System or .NET Task parallel libarey? Now i use Task base solution because I tried Job System but the Nativequeue does not want to work well and my project build on queues. How I read about job system is not a prefect solution to generate lots of chunks and mesh data.
My codes for the prototype:
Octree.cs https://dotnetfiddle.net/7nqZCU ChunkProfile.cs https://dotnetfiddle.net/fY5F6p
Answer by andrew-lukasik · Mar 20, 2021 at 12:23 AM
I am thinking about that I change class to struct, but I contain a lots of data in class so I do not know which is better?
Structs are better when you need data locality to optimize cacheline use. Your ChunkProfile is rather big being about 100 bytes long (Vector3 is 12 bytes, for comparison).
I suggest you make that decision yourself. How? Think about how much of these 100 bytes your foreach
loops really make use of. Unused struct bytes represent cpu time wasted on reading them.
Note: managed object fields (like List<T>
) breaks data locality in structs.
And the other question is that I use Unity Job System or .NET Task parallel library?
Job system (or Entities) + Burst will be run faster. But rewriting your code will take at least few days up to few weeks (more realistically). Question is - do you even have such time for this and is it worth it?
Your answer
Follow this Question
Related Questions
Starting mesh generation thread before changing chunk transform position 1 Answer
Colored Voxel Meshs 2 Answers
When I place a breakpoint in my code, it crashes Unity Editor 1 Answer
Getting current time from the worker thread 1 Answer
Getting meshes to render properly, and coloring triangles of a mesh 0 Answers