Просмотр исходного кода

entity: review of entt_traits<T>::to_type

Michele Caini 4 лет назад
Родитель
Сommit
ea614a0f3f
2 измененных файлов с 2 добавлено и 1 удалено
  1. 1 1
      src/entt/entity/entity.hpp
  2. 1 0
      test/entt/entity/entity.cpp

+ 1 - 1
src/entt/entity/entity.hpp

@@ -120,7 +120,7 @@ public:
      * @return A properly constructed identifier.
      * @return A properly constructed identifier.
      */
      */
     [[nodiscard]] static constexpr auto to_type(const entity_type entity, const version_type version = {}) {
     [[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)};
     }
     }
 };
 };
 
 

+ 1 - 0
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(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_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) {
 TEST(Entity, Null) {