Przeglądaj źródła

review: registry::loader

Michele Caini 7 lat temu
rodzic
commit
a5f48f8af8
3 zmienionych plików z 15 dodań i 12 usunięć
  1. 0 1
      TODO
  2. 14 10
      src/entt/entity/registry.hpp
  3. 1 1
      src/entt/entity/snapshot.hpp

+ 0 - 1
TODO

@@ -23,7 +23,6 @@
 * add entity function to views/groups (component -> owner, see sparse sets)
 * add opaque input iterators to views and groups that return tuples <entity, T &...> (proxy), multi-pass guaranteed
 * add fast lane for raw iterations, extend mt doc to describe allowed add/remove with pre-allocations on fast lanes
-* verify why registry::snapshot does a *this = {} instead of a safer reset that would trigger signals
 * review sparse set to allow customization (mix pack in the spec, base is position only)
   - non-owning groups can iterate pages and skip empty ones, this should mitigate the lack of the packed array
 * review 64 bit id: user defined area + dedicated member on the registry to set it

+ 14 - 10
src/entt/entity/registry.hpp

@@ -366,6 +366,15 @@ public:
         return entities.capacity();
     }
 
+    /**
+     * @brief Requests the removal of unused capacity for a given component.
+     * @tparam Component Type of component for which to reclaim unused capacity.
+     */
+    template<typename Component>
+    void shrink_to_fit() {
+        assure<Component>()->shrink_to_fit();
+    }
+
     /**
      * @brief Checks whether the pool of a given component is empty.
      * @tparam Component Type of component in which one is interested.
@@ -378,15 +387,6 @@ public:
         return cpool ? cpool->empty() : true;
     }
 
-    /**
-     * @brief Requests the removal of unused capacity for a given component.
-     * @tparam Component Type of component for which to reclaim unused capacity.
-     */
-    template<typename Component>
-    void shrink_to_fit() {
-        assure<Component>()->shrink_to_fit();
-    }
-
     /**
      * @brief Checks if there exists at least an entity still in use.
      * @return True if at least an entity is still in use, false otherwise.
@@ -1548,7 +1548,11 @@ public:
             }
         };
 
-        return { (*this = {}), force };
+        reset();
+        entities.clear();
+        available = {};
+
+        return { *this, force };
     }
 
     /**

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

@@ -197,7 +197,7 @@ class basic_snapshot_loader {
           force{fn}
     {
         // to restore a snapshot as a whole requires a clean registry
-        ENTT_ASSERT(!reg.capacity());
+        ENTT_ASSERT(reg.empty());
     }
 
     template<typename Archive>