sparse_set: bump doesn't allow to set a tombstone version (yet)

This commit is contained in:
Michele Caini
2022-05-12 15:58:38 +02:00
parent d3609737f5
commit acb6e90158
3 changed files with 6 additions and 0 deletions
+1
View File
@@ -12,6 +12,7 @@ DOC:
WIP:
* add storage getter for filters to views and groups
* exploit the tombstone mechanism to allow enabling/disabling entities (see bump, compact and clear for further details)
* emitter: runtime handlers, allocator support (ready for both already)
* view: no storage_traits dependency -> use storage instead of components for the definition
* basic_storage::bind for cross-registry setups (see and remove todo from entity_copy.cpp)
+1
View File
@@ -671,6 +671,7 @@ public:
* @param entt A valid identifier.
*/
void bump(const entity_type entt) {
ENTT_ASSERT(entity_traits::to_version(entt) != entity_traits::to_version(tombstone), "Cannot set the tombstone version");
auto &entity = sparse_ref(entt);
entity = entity_traits::combine(entity_traits::to_integral(entity), entity_traits::to_integral(entt));
packed[static_cast<size_type>(entity_traits::to_entity(entity))] = entt;
+4
View File
@@ -335,11 +335,15 @@ TEST(SparseSet, Bump) {
}
TEST(SparseSetDeathTest, Bump) {
using traits_type = entt::entt_traits<entt::entity>;
entt::sparse_set set{entt::deletion_policy::in_place};
set.emplace(entt::entity{3});
ASSERT_DEATH(set.bump(entt::null), "");
ASSERT_DEATH(set.bump(entt::tombstone), "");
ASSERT_DEATH(set.bump(entt::entity{42}), "");
ASSERT_DEATH(set.bump(traits_type::construct(traits_type::to_entity(entt::entity{3}), traits_type::to_entity(entt::tombstone))), "");
}
TEST(SparseSet, Insert) {