I am trying to populate a large terrain with objects (trees, rocks etc).
At the moment I am using a single Mesh/Material and give it positions/rotations in a IJobParallelFor.
But ideally I would like to use different meshes in the best way so I can just populate the Entities in parallel… or whatever is the fastest.
Any suggestions?
Have you tried IJobEntityBatch?
Thanks! that looks like a good way forward
1 Like
Just in a case, you don’t fall in the same trap I did, I leave this in here
I think you misunderstand what this batch field does.
A value of 1 means each chunk is separated as normal like IJobChunk so now execute is called up to 1 times per chunk
A value of 2 means each chunk is broken into 2 separate batches so now execute is called up to 2 times per chunk
A value of 256 means each chunk is broken into 256 separate batches so now execute is called up to 256 per chunk
Why you might want to use this is if you have a really slow job (i.e. pathfinding).
If you had all your entities in 1 chunk, you would only execute on a single thread and all your other threads would be empty.
If you set a value of 4 this would break the chunk up over 4 separate groups letting it spread over multiple cores.
You don’t want huge values for this.
Because of these extra calls to execute, you have to avoid allocating per execute and instead re-use it.
In short, you want to keep low batch value.
1 Like