Преглед изворни кода

registry: avoid bumping version on destroy if not requested

Michele Caini пре 3 година
родитељ
комит
17f5b0a330
1 измењених фајлова са 8 додато и 1 уклоњено
  1. 8 1
      src/entt/entity/registry.hpp

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

@@ -655,7 +655,14 @@ public:
      * @return The version of the recycled entity.
      */
     version_type destroy(const entity_type entt) {
-        return destroy(entt, traits_type::to_version(traits_type::next(entt)));
+        ENTT_ASSERT(!pools.empty() && (pools.begin()->second.get() == shortcut), "Misplaced entity pool");
+        ENTT_ASSERT(shortcut->contains(entt), "Invalid entity");
+
+        for(size_type pos = pools.size(); pos; --pos) {
+            pools.begin()[pos - 1u].second->remove(entt);
+        }
+
+        return shortcut->current(entt);
     }
 
     /**