registry: better support for integral entity identifiers (even if not recommended)

This commit is contained in:
Michele Caini
2020-07-01 18:39:34 +02:00
parent 804cfb7482
commit 556373d331
2 changed files with 4 additions and 2 deletions

View File

@@ -578,7 +578,7 @@ public:
* @param entity A valid entity identifier.
*/
void destroy(const entity_type entity) {
destroy(entity, (to_integral(entity) >> traits_type::entity_shift) + 1);
destroy(entity, version_type((to_integral(entity) >> traits_type::entity_shift) + 1));
}
/**

View File

@@ -464,10 +464,12 @@ TEST(Registry, CreateDestroyCornerCase) {
}
TEST(Registry, VersionOverflow) {
using traits_type = entt::entt_traits<entt::entity>;
entt::registry registry;
const auto entity = registry.create();
registry.destroy(entity, entt::entt_traits<entt::entity>::version_mask);
registry.destroy(entity, typename traits_type::version_type(traits_type::version_mask));
registry.destroy(registry.create());
ASSERT_EQ(registry.current(entity), registry.version(entity));