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

snapshot: use start_from with entity storage

Michele Caini 1 год назад
Родитель
Сommit
7e0e3a2196
1 измененных файлов с 3 добавлено и 0 удалено
  1. 3 0
      src/entt/entity/snapshot.hpp

+ 3 - 0
src/entt/entity/snapshot.hpp

@@ -231,6 +231,7 @@ public:
 
         if constexpr(std::is_same_v<Type, entity_type>) {
             typename traits_type::entity_type count{};
+            entity_type placeholder{};
 
             storage.reserve(length);
             archive(count);
@@ -238,8 +239,10 @@ public:
             for(entity_type entity = null; length; --length) {
                 archive(entity);
                 storage.generate(entity);
+                placeholder = (entity > placeholder) ? entity : placeholder;
             }
 
+            storage.start_from(traits_type::next(placeholder));
             storage.free_list(count);
         } else {
             auto &other = reg->template storage<entity_type>();