diff --git a/src/entt/entity/registry.hpp b/src/entt/entity/registry.hpp index 1f2632326..228b863ed 100644 --- a/src/entt/entity/registry.hpp +++ b/src/entt/entity/registry.hpp @@ -263,7 +263,7 @@ class basic_registry { : current{std::forward(args)...} {} template - void maybe_valid_if(basic_registry &owner, const Entity entt) { + 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()...); const auto is_valid = ((std::is_same_v || std::get &>(cpools).contains(entt)) && ...) @@ -271,23 +271,23 @@ class basic_registry { && ((std::is_same_v || !owner.storage().contains(entt)) && ...); if constexpr(sizeof...(Owned) == 0) { - if(is_valid && !current.contains(entt)) { - current.push(entt); + if(is_valid && !handler.current.contains(entt)) { + handler.current.push(entt); } } else { - if(is_valid && !(std::get<0>(cpools).index(entt) < current)) { - const auto pos = current++; + if(is_valid && !(std::get<0>(cpools).index(entt) < handler.current)) { + const auto pos = handler.current++; (std::get &>(cpools).swap_elements(std::get &>(cpools).data()[pos], entt), ...); } } } - void discard_if([[maybe_unused]] basic_registry &owner, const Entity entt) { + static void discard_if(group_handler &handler, [[maybe_unused]] basic_registry &owner, const Entity entt) { if constexpr(sizeof...(Owned) == 0) { - current.remove(entt); + handler.current.remove(entt); } else { - if(const auto cpools = std::forward_as_tuple(owner.storage()...); std::get<0>(cpools).contains(entt) && (std::get<0>(cpools).index(entt) < current)) { - const auto pos = --current; + if(const auto cpools = std::forward_as_tuple(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), ...); } } @@ -1316,7 +1316,7 @@ public: // we cannot iterate backwards because we want to leave behind valid entities in case of owned types for(auto *first = std::get<0>(cpools).data(), *last = first + std::get<0>(cpools).size(); first != last; ++first) { - handler->template maybe_valid_if(*this, *first); + handler->template maybe_valid_if(*handler, *this, *first); } }