From ea614a0f3f4c75d71ba5d9dcb0a3be21487e83ff Mon Sep 17 00:00:00 2001 From: Michele Caini Date: Tue, 25 May 2021 12:45:51 +0200 Subject: [PATCH] entity: review of entt_traits::to_type --- src/entt/entity/entity.hpp | 2 +- test/entt/entity/entity.cpp | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/src/entt/entity/entity.hpp b/src/entt/entity/entity.hpp index 45978247f..9a71268b6 100644 --- a/src/entt/entity/entity.hpp +++ b/src/entt/entity/entity.hpp @@ -120,7 +120,7 @@ public: * @return A properly constructed identifier. */ [[nodiscard]] static constexpr auto to_type(const entity_type entity, const version_type version = {}) { - return Type{entity | (version << traits_type::entity_shift)}; + return Type{(entity & traits_type::entity_mask) | (version << traits_type::entity_shift)}; } }; diff --git a/test/entt/entity/entity.cpp b/test/entt/entity/entity.cpp index b1e077772..6443bf99d 100644 --- a/test/entt/entity/entity.cpp +++ b/test/entt/entity/entity.cpp @@ -23,6 +23,7 @@ TEST(Entity, Traits) { ASSERT_EQ(traits_type::to_type(traits_type::to_entity(entity), traits_type::to_version(entity)), entity); ASSERT_EQ(traits_type::to_type(traits_type::to_entity(other), traits_type::to_version(other)), other); + ASSERT_NE(traits_type::to_type(traits_type::to_integral(entity)), entity); } TEST(Entity, Null) {