Efficient way of matching entities to systems in an entity component system

后端 未结 6 538
再見小時候
再見小時候 2021-01-31 04:53

I\'m working on a data-oriented entity component system where component types and system signatures are known at compile-time.


An entity

6条回答
  •  醉酒成梦
    2021-01-31 05:15

    Having a sparse integer set per signature type is the theoretically best solution (in terms of time complexity).

    The sparse integer set data structure allows efficient contiguous O(N) iteration over the stored integers, O(1) insertion/removal of integers, and O(1) querying for a specific integer.

    The per-signature sparse integer set would store all entity IDs associated with that specific signature.

    Example: Diana, an open-source C and C++ ECS library, makes use of sparse integer set to keep track of entities in systems. Every system has its own sparse integer set instance.

提交回复
热议问题