MCPcopy Create free account
hub / github.com/SakuraEngine/SakuraEngine / query_groups

Method query_groups

modules/engine/runtime/src/ecs/query.cpp:659–712  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

657}
658
659void sugoi_storage_t::query_groups(const sugoi_query_t* q, sugoi_group_callback_t callback, void* u)
660{
661 using namespace sugoi;
662 bool mainThread = true;
663 if (scheduler)
664 {
665 mainThread = scheduler->is_main_thread(this);
666 }
667 if (mainThread)
668 {
669 build_queries();
670 }
671 else
672 SKR_ASSERT(queriesBuilt);
673
674 fixed_stack_scope_t _(localStack);
675 bool filterShared = (q->filter.all_shared.length + q->filter.none_shared.length) != 0;
676 sugoi_meta_filter_t* validatedMeta = nullptr;
677 if (q->meta.all_meta.length > 0 || q->meta.any_meta.length > 0 || q->meta.none_meta.length > 0)
678 {
679 validatedMeta = localStack.allocate<sugoi_meta_filter_t>();
680 auto data = (char*)localStack.allocate(data_size(q->meta));
681 *validatedMeta = sugoi::clone(q->meta, data);
682 validate(validatedMeta->all_meta);
683 validate(validatedMeta->any_meta);
684 validate(validatedMeta->none_meta);
685 }
686 else
687 {
688 validatedMeta = (sugoi_meta_filter_t*)&q->meta;
689 }
690 bool filterMeta = (validatedMeta->all_meta.length + validatedMeta->any_meta.length + validatedMeta->none_meta.length) != 0;
691 for (auto& group : q->groups)
692 {
693 if (filterShared)
694 {
695 fixed_stack_scope_t _(localStack);
696 sugoi_type_set_t shared;
697 shared.length = 0;
698 // todo: is 256 enough?
699 shared.data = localStack.allocate<sugoi_type_index_t>(256);
700 group->get_shared_type(shared, localStack.allocate<sugoi_type_index_t>(256));
701 // check(shared.length < 256);
702 if (!match_group_shared(shared, q->filter))
703 continue;
704 }
705 if (filterMeta)
706 {
707 if (!match_group_meta(group->type, *validatedMeta))
708 continue;
709 }
710 callback(u, group);
711 }
712}
713
714void sugoi_storage_t::query_groups(const sugoi_filter_t& filter, const sugoi_meta_filter_t& meta, sugoi_group_callback_t callback, void* u)
715{

Callers 6

sugoiS_queryFunction · 0.80
sugoiQ_get_groupsFunction · 0.80
sugoiQ_get_countFunction · 0.80
sync_queryMethod · 0.80
schedule_ecs_jobMethod · 0.80
update_dependenciesMethod · 0.80

Calls 8

data_sizeFunction · 0.85
match_group_sharedFunction · 0.85
match_group_metaFunction · 0.85
match_group_typeFunction · 0.85
is_main_threadMethod · 0.80
get_shared_typeMethod · 0.80
cloneFunction · 0.70
allocateMethod · 0.45

Tested by

no test coverage detected