This commit is contained in:
Michele Caini
2019-04-10 13:56:19 +02:00
parent 6508cdc823
commit 355c7b59aa
3 changed files with 1 additions and 38 deletions

2
TODO
View File

@@ -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)

View File

@@ -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.
*

View File

@@ -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;