#How can I do nested iteration of entities in jobs?

1 messages · Page 1 of 1 (latest)

novel shadow
#

Basically, I want to do a job that iterates over all entities with X components, and for each iteration, iterate over all entities with Y components? (I know this is quadratic complexity btw).
But I'm not sure how to model that with IJobEntity.

oblique bay
#

run additional job before which will store all entities in a suitable way

#

and then use that collection in your main job

novel shadow
oblique bay
#

_query.CalculateEntityCount()

novel shadow
#

Oh, thanks!

chilly island
#

This may not be directly relevant here, but if you have a case where Job1 is generating a variable-size list of elements and Job2 is going to iterate over that list of elements, and you want to avoid the sync between after Job1 where you compute how many elements it wrote and pass that count to Job2, you may want to look into IJobParallelForDefer

#

(or NativeList.AsDeferredJobArray())