29 "all sparse_query components must have the dont_fragment trait and "
30 "must not declare the on_instantiate::inherit policy");
42 template <
typename Func>
43 void each(Func&& func)
const {
44 each_impl(std::index_sequence_for<Components...>{}, func);
50 each([&](Components&...) { result ++; });
58 template <
size_t ... Is,
typename Func>
59 void each_impl(std::index_sequence<Is...>,
const Func& func)
const {
60 constexpr size_t n =
sizeof...(Components);
62 ecs_sparse_t *
sparse[n] = { storage(ids_[Is])... };
63 for (
size_t f = 0; f < n; f ++) {
70 for (
size_t f = 1; f < n; f ++) {
76 const uint64_t *entities = flecs_sparse_ids(sparse[lead]);
77 int32_t
count = sparse[lead]->count - 1;
79 for (int32_t i = 0; i <
count; i ++) {
80 uint64_t e = entities[i];
82 if (!(... && (ptrs[Is] = flecs_sparse_get_w_check(
83 sparse[Is], ECS_SIZEOF(remove_reference_t<Components>), e,
90 if (flecs_table_flags(r->table) &
91 (EcsTableNotQueryable|EcsTableIsPrefab|EcsTableIsDisabled))
96 if constexpr (std::is_invocable<
100 (*
static_cast<remove_reference_t<Components>*
>(
103 func((*
static_cast<remove_reference_t<Components>*
>(
111 return cr ? flecs_component_get_sparse(cr) : nullptr;
114 void assert_policies()
const {
119 "sparse_query component has the OnInstantiate Inherit trait, "
120 "which sparse queries cannot match; add the on_instantiate "
121 "trait at compile time instead");
ecs_entity_t ecs_get_target(const ecs_world_t *world, ecs_entity_t entity, ecs_entity_t rel, int32_t index)
Get the target of a relationship.