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

added default constructor to actor

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

+ 0 - 1
TODO

@@ -22,6 +22,5 @@
   - standard each, use bitmask to speed up the whole thing and avoid accessing the pools to test for the page
   - iterator based each with a couple of iterators passed from outside (use bitmask + has)
 * stable component handle that isn't affected by reallocations
-* default constructor + init/re-init function to actor
 * multi component registry::remove and some others?
 * built-in support for dual (or N-) buffering

+ 4 - 0
src/entt/entity/actor.hpp

@@ -29,6 +29,10 @@ struct basic_actor {
     /*! @brief Underlying entity identifier. */
     using entity_type = Entity;
 
+    basic_actor() ENTT_NOEXCEPT
+        : reg{nullptr}, entt{entt::null}
+    {}
+
     /**
      * @brief Constructs an actor by using the given registry.
      * @param ref An entity-component system properly initialized.

+ 7 - 2
test/entt/entity/actor.cpp

@@ -42,11 +42,16 @@ TEST(Actor, Component) {
 
 TEST(Actor, EntityLifetime) {
     entt::registry registry;
-    entt::actor actor{registry};
+    entt::actor actor{};
+
+    ASSERT_FALSE(actor);
+
+    actor = entt::actor{registry};
     actor.assign<int>();
 
     ASSERT_TRUE(actor);
-    ASSERT_TRUE(actor);
+    ASSERT_FALSE(registry.empty<int>());
+    ASSERT_FALSE(registry.empty());
 
     registry.destroy(actor.entity());