diff --git a/src/entt/entity/runtime_view.hpp b/src/entt/entity/runtime_view.hpp index 54a2f4120..95e9a1b2d 100644 --- a/src/entt/entity/runtime_view.hpp +++ b/src/entt/entity/runtime_view.hpp @@ -23,7 +23,8 @@ namespace internal { template class runtime_view_iterator final { [[nodiscard]] bool valid() const { - return std::all_of(pools->begin(), pools->end(), [entt = *it](const auto *curr) { return curr->contains(entt); }) + return (!tombstone_check || *it != tombstone) + && std::all_of(++pools->begin(), pools->end(), [entt = *it](const auto *curr) { return curr->contains(entt); }) && std::none_of(filter->cbegin(), filter->cend(), [entt = *it](const auto *curr) { return curr && curr->contains(entt); }); } @@ -40,7 +41,8 @@ public: runtime_view_iterator(const std::vector &cpools, const std::vector &ignore, iterator_type curr) ENTT_NOEXCEPT : pools{&cpools}, filter{&ignore}, - it{curr} { + it{curr}, + tombstone_check{pools->size() == 1u && (*pools)[0u]->policy() == deletion_policy::in_place} { if(it != (*pools)[0]->end() && !valid()) { ++(*this); } @@ -86,6 +88,7 @@ private: const std::vector *pools; const std::vector *filter; iterator_type it; + bool tombstone_check; }; } // namespace internal