diff --git a/src/entt/entity/registry.hpp b/src/entt/entity/registry.hpp index f8cf72270..beee2e1d5 100644 --- a/src/entt/entity/registry.hpp +++ b/src/entt/entity/registry.hpp @@ -259,7 +259,7 @@ class basic_registry { template static void maybe_valid_if(group_handler &handler, basic_registry &owner, const Entity entt) { - [[maybe_unused]] const auto cpools = std::forward_as_tuple(owner.storage(), owner.storage()...); + const auto cpools = std::forward_as_tuple(owner.storage(), owner.storage()...); const auto is_valid = ((std::is_same_v || std::get &>(cpools).contains(entt)) && ... && (std::is_same_v || std::get &>(cpools).contains(entt))) && ((std::is_same_v || owner.storage().contains(entt)) && ...) @@ -272,7 +272,7 @@ class basic_registry { } } - static void discard_if(group_handler &handler, [[maybe_unused]] basic_registry &owner, const Entity entt) { + static void discard_if(group_handler &handler, basic_registry &owner, const Entity entt) { if(const auto cpools = std::forward_as_tuple(owner.storage(), owner.storage()...); std::get<0>(cpools).contains(entt) && (std::get<0>(cpools).index(entt) < handler.current)) { const auto pos = --handler.current; std::get &>(cpools).swap_elements(std::get &>(cpools).data()[pos], entt); @@ -290,17 +290,16 @@ class basic_registry { : current{std::forward(args)...} {} template - static void maybe_valid_if(group_handler &handler, basic_registry &owner, const Entity entt) { - const auto is_valid = ((std::is_same_v || owner.storage().contains(entt)) && ... && (std::is_same_v || owner.storage().contains(entt))) - && ((std::is_same_v || !owner.storage().contains(entt)) && ...); - - if(is_valid && !handler.current.contains(entt)) { - handler.current.push(entt); + static void maybe_valid_if(basic_common_type &set, basic_registry &owner, const Entity entt) { + if(!set.contains(entt)) { + if(((std::is_same_v || owner.storage().contains(entt)) && ... && (std::is_same_v || owner.storage().contains(entt))) && ((std::is_same_v || !owner.storage().contains(entt)) && ...)) { + set.push(entt); + } } } - static void discard_if(group_handler &handler, [[maybe_unused]] basic_registry &owner, const Entity entt) { - handler.current.remove(entt); + static void discard_if(basic_common_type &set, [[maybe_unused]] basic_registry &owner, const Entity entt) { + set.remove(entt); } }; @@ -1375,13 +1374,13 @@ public: groups.push_back(std::move(candidate)); - on_construct>().template connect<&handler_type::template maybe_valid_if>>(*handler); - (on_construct>().template connect<&handler_type::template maybe_valid_if>>(*handler), ...); - (on_destroy>().template connect<&handler_type::template maybe_valid_if>>(*handler), ...); + on_construct>().template connect<&handler_type::template maybe_valid_if>>(handler->current); + (on_construct>().template connect<&handler_type::template maybe_valid_if>>(handler->current), ...); + (on_destroy>().template connect<&handler_type::template maybe_valid_if>>(handler->current), ...); - on_destroy>().template connect<&handler_type::discard_if>(*handler); - (on_destroy>().template connect<&handler_type::discard_if>(*handler), ...); - (on_construct>().template connect<&handler_type::discard_if>(*handler), ...); + on_destroy>().template connect<&handler_type::discard_if>(handler->current); + (on_destroy>().template connect<&handler_type::discard_if>(handler->current), ...); + (on_construct>().template connect<&handler_type::discard_if>(handler->current), ...); for(const auto entity: view(exclude)) { handler->current.push(entity);