Fix ecs::entity_container::batch_apply for empty component types

This commit is contained in:
Nikita Lisitsa 2023-08-26 22:00:41 +03:00
parent bc63d98d51
commit 7183a441e5
2 changed files with 7 additions and 4 deletions

View file

@ -43,19 +43,19 @@ namespace psemek::ecs::detail
if constexpr (std::invocable<Function, entity_container &, util::span<entity_handle const>, util::span<Components> ...>)
{
function(parent, handles_span, util::span<Components>{components, count} ...);
function(parent, handles_span, util::span<Components>{components, is_empty_v<Components> ? 1 : count} ...);
}
else if constexpr (std::invocable<Function, util::span<entity_handle const>, util::span<Components> ...>)
{
function(handles_span, util::span<Components>{components, count} ...);
function(handles_span, util::span<Components>{components, is_empty_v<Components> ? 1 : count} ...);
}
else if constexpr (std::invocable<Function, entity_container &, util::span<Components> ...>)
{
function(parent, util::span<Components>{components, count} ...);
function(parent, util::span<Components>{components, is_empty_v<Components> ? 1 : count} ...);
}
else
{
function(util::span<Components>{components, count} ...);
function(util::span<Components>{components, is_empty_v<Components> ? 1 : count} ...);
}
}

View file

@ -126,6 +126,9 @@ namespace psemek::ecs
* void(span<entity_handle const>, span<components>...)
* void(entity_container, span<components>...)
* void(entity_container, span<entity_handle const>, span<components>...)
* The size of all spans within a single function call are the same,
* except for empty component types (i.e. std::is_empty_v<Component> is true),
* each having an unspecified non-zero size.
* An optional query cache can be supplied to speed up iteration.
* If the query cache wasn't created with the exact sequence of component
* types, the behavior is undefined.