minor changes

This commit is contained in:
Michele Caini
2019-06-18 23:23:42 +02:00
parent 04dd1447ee
commit eb252321a7
2 changed files with 5 additions and 3 deletions

View File

@@ -176,7 +176,8 @@ class basic_observer {
template<std::size_t Index>
static void maybe_valid_if(basic_observer *obs, const basic_registry<Entity> &reg, const Entity entt) {
if(reg.template has<Require...>(entt) && !(reg.template has<Reject>(entt) || ...)) {
(obs->view.has(entt) ? obs->view.get(entt) : obs->view.construct(entt)) |= (1 << Index);
auto *comp = obs->view.try_get(entt);
(comp ? *comp : obs->view.construct(entt)) |= (1 << Index);
}
}
@@ -210,7 +211,8 @@ class basic_observer {
if(reg.template has<AllOf...>(entt) && !(reg.template has<NoneOf>(entt) || ...)
&& reg.template has<Require...>(entt) && !(reg.template has<Reject>(entt) || ...))
{
(obs->view.has(entt) ? obs->view.get(entt) : obs->view.construct(entt)) |= (1 << Index);
auto *comp = obs->view.try_get(entt);
(comp ? *comp : obs->view.construct(entt)) |= (1 << Index);
}
}

View File

@@ -47,7 +47,7 @@ class sparse_set {
using traits_type = entt_traits<Entity>;
static_assert(ENTT_PAGE_SIZE && ((ENTT_PAGE_SIZE & (ENTT_PAGE_SIZE - 1)) == 0));
static constexpr auto entt_per_page = ENTT_PAGE_SIZE / sizeof(typename entt_traits<Entity>::entity_type);
static constexpr auto entt_per_page = ENTT_PAGE_SIZE / sizeof(typename traits_type::entity_type);
class iterator {
friend class sparse_set<Entity>;