File tree 1 file changed +25
-2
lines changed
1 file changed +25
-2
lines changed Original file line number Diff line number Diff line change @@ -801,8 +801,31 @@ class basic_registry {
801
801
*/
802
802
template <typename It>
803
803
void destroy (It first, It last) {
804
- for (; first != last; ++first) {
805
- destroy (*first);
804
+ if constexpr (std::is_same_v<It, typename basic_common_type::iterator>) {
805
+ basic_common_type *owner = nullptr ;
806
+
807
+ for (size_type pos = pools.size (); pos; --pos) {
808
+ if (pools.begin ()[pos - 1u ].second ->data () == first.data ()) {
809
+ owner = pools.begin ()[pos - 1u ].second .get ();
810
+ } else {
811
+ pools.begin ()[pos - 1u ].second ->remove (first, last);
812
+ }
813
+ }
814
+
815
+ if (owner) {
816
+ // waiting to further/completely optimize this with the entity storage
817
+ for (; first != last; ++first) {
818
+ const auto entt = *first;
819
+ owner->remove (entt);
820
+ release (entt);
821
+ }
822
+ } else {
823
+ release (std::move (first), std::move (last));
824
+ }
825
+ } else {
826
+ for (; first != last; ++first) {
827
+ destroy (*first);
828
+ }
806
829
}
807
830
}
808
831
You can’t perform that action at this time.
0 commit comments