Browse Source

group: sort/respect -> sort_as (also decoupled from group types)

Michele Caini 3 years ago
parent
commit
3e13e0b59b
2 changed files with 6 additions and 15 deletions
  1. 5 14
      src/entt/entity/group.hpp
  2. 1 1
      test/entt/entity/group.cpp

+ 5 - 14
src/entt/entity/group.hpp

@@ -636,25 +636,16 @@ public:
     }
 
     /**
-     * @brief Sort the shared pool of entities according to the given component.
+     * @brief Sort the shared pool of entities according to a given storage.
      *
-     * Non-owning groups of the same type share with the registry a pool of
-     * entities with its own order that doesn't depend on the order of any pool
-     * of components. Users can order the underlying data structure so that it
-     * respects the order of the pool of the given component.
-     *
-     * @note
      * The shared pool of entities and thus its order is affected by the changes
-     * to each and every pool that it tracks. Therefore changes to those pools
-     * can quickly ruin the order imposed to the pool of entities shared between
-     * the non-owning groups.
+     * to each and every pool that it tracks.
      *
-     * @tparam Type Type of component to use to impose the order.
+     * @param other The storage to use to impose the order.
      */
-    template<typename Type>
-    void sort() const {
+    void sort_as(const base_type &other) const {
         if(*this) {
-            descriptor->group().respect(storage<index_of<Type>>());
+            descriptor->group().respect(other);
         }
     }
 

+ 1 - 1
test/entt/entity/group.cpp

@@ -326,7 +326,7 @@ TEST(NonOwningGroup, SortAsAPool) {
     }
 
     registry.sort<unsigned int>(std::less<unsigned int>{});
-    group.sort<unsigned int>();
+    group.sort_as(group.storage<unsigned int>());
 
     ASSERT_EQ((group.get<const int, unsigned int>(e0)), (std::make_tuple(0, 0u)));
     ASSERT_EQ((group.get<0, 1>(e1)), (std::make_tuple(1, 1u)));