Skip to content

EntityIndexInQuery for systems (multithreaded more importantly) #2189

Description

@Lasovar

Describe the problem you are trying to solve.
I've been trying for a while to write data from a multithreaded system into a vector.
With other ecs systems (mainly unity) I can simply grab the EntityIndexInQuery and use that with a ParallelWriter or directly into a NativeArray sized to match the query which works great and avoids locks.
Initially I thought the index in the system provided with the flecs::iter was that but I noticed race conditions and empty fields, after looking into it found that the index isn't the entity index in the query which prevents me from writing into a vector without locks.

Describe the solution you'd like
I would love if there was a simple way to get an index that you can use for writing data without a lock, like it.entity_index_in_query(i). Or anything similar to this.

And if there is actually a way to do this or a different approach I can try I would love to try it

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions