diff --git a/src/entt/entity/helper.hpp b/src/entt/entity/helper.hpp index 608089214..9ced4c28f 100644 --- a/src/entt/entity/helper.hpp +++ b/src/entt/entity/helper.hpp @@ -6,7 +6,6 @@ #include "../core/fwd.hpp" #include "../core/type_traits.hpp" #include "../signal/delegate.hpp" -#include "component.hpp" #include "fwd.hpp" #include "group.hpp" #include "view.hpp" @@ -127,11 +126,12 @@ void invoke(Registry ®, const typename Registry::entity_type entt) { template typename Registry::entity_type to_entity(const Registry ®, const Component &instance) { const auto &storage = reg.template storage(); + static constexpr auto page_size = storage_for_t::traits_type::page_size; const typename Registry::base_type &base = storage; const auto *addr = std::addressof(instance); - for(auto it = base.rbegin(), last = base.rend(); it < last; it += component_traits::page_size) { - if(const auto dist = (addr - std::addressof(storage.get(*it))); dist >= 0 && dist < static_cast(component_traits::page_size)) { + for(auto it = base.rbegin(), last = base.rend(); it < last; it += page_size) { + if(const auto dist = (addr - std::addressof(storage.get(*it))); dist >= 0 && dist < static_cast(page_size)) { return *(it + dist); } }