Michele Caini 7 лет назад
Родитель
Сommit
355c7b59aa
3 измененных файлов с 1 добавлено и 38 удалено
  1. 1 1
      TODO
  2. 0 12
      src/entt/entity/sparse_set.hpp
  3. 0 25
      test/entt/entity/sparse_set.cpp

+ 1 - 1
TODO

@@ -19,5 +19,5 @@
 * 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
-* remove entity function from sparse sets (no longer required)
 * reactive systems
+* optimize groups access in case there are no named types (use family for direct access)

+ 0 - 12
src/entt/entity/sparse_set.hpp

@@ -860,18 +860,6 @@ public:
         return const_cast<object_type *>(std::as_const(*this).raw());
     }
 
-    /**
-     * @brief Returns the entity to which a given component is assigned.
-     * @param instance A valid reference to an object.
-     * @return A valid entity identifier if the instance belongs to the sparse
-     * set, the null entity otherwise.
-     */
-    inline entity_type entity(const object_type &instance) {
-        const auto address = std::addressof(instance);
-        const bool valid = !(instances.data() > address) && (address < (instances.data() + instances.size()));
-        return valid ? sparse_set<entity_type>::data()[address - instances.data()] : null;
-    }
-
     /**
      * @brief Returns an iterator to the beginning.
      *

+ 0 - 25
test/entt/entity/sparse_set.cpp

@@ -486,31 +486,6 @@ TEST(SparseSetWithType, Functionalities) {
     other = std::move(set);
 }
 
-TEST(SparseSetWithType, EntityFromComponent) {
-    entt::sparse_set<std::uint64_t, int> set;
-    typename entt::sparse_set<std::uint64_t, int>::entity_type invalid = entt::null;
-
-    set.reserve(3);
-
-    const auto &first = set.construct(42, 3);
-    const auto &second = set.construct(3, 9);
-    const auto &third = set.construct(99, 7);
-
-    ASSERT_NE(set.entity(first), invalid);
-    ASSERT_EQ(set.get(set.entity(first)), first);
-    ASSERT_EQ(&set.get(set.entity(first)), &first);
-
-    ASSERT_NE(set.entity(second), invalid);
-    ASSERT_EQ(set.get(set.entity(second)), second);
-    ASSERT_EQ(&set.get(set.entity(second)), &second);
-
-    ASSERT_NE(set.entity(third), invalid);
-    ASSERT_EQ(set.get(set.entity(third)), third);
-    ASSERT_EQ(&set.get(set.entity(third)), &third);
-
-    ASSERT_EQ(set.entity(0), invalid);
-}
-
 TEST(SparseSetWithType, EmptyType) {
     entt::sparse_set<std::uint64_t, empty_type> set;