|
|
@@ -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, typename Component>
|
|
|
typename Registry::entity_type to_entity(const Registry ®, const Component &instance) {
|
|
|
const auto &storage = reg.template storage<Component>();
|
|
|
+ static constexpr auto page_size = storage_for_t<Component>::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<Component>::page_size) {
|
|
|
- if(const auto dist = (addr - std::addressof(storage.get(*it))); dist >= 0 && dist < static_cast<decltype(dist)>(component_traits<Component>::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<decltype(dist)>(page_size)) {
|
|
|
return *(it + dist);
|
|
|
}
|
|
|
}
|