| 13 | } |
| 14 | |
| 15 | void entity_registry_t::shrink() |
| 16 | { |
| 17 | SMutexLock lock(mutex.mMutex); |
| 18 | if (entries.size() == 0) |
| 19 | return; |
| 20 | EIndex lastValid = (EIndex)(entries.size() - 1); |
| 21 | while (lastValid != 0 && entries[lastValid].chunk == nullptr) |
| 22 | --lastValid; |
| 23 | if (entries[lastValid].indexInChunk == 0) |
| 24 | { |
| 25 | entries.clear(); |
| 26 | return; |
| 27 | } |
| 28 | entries.resize_default(lastValid + 1); |
| 29 | entries.shrink(); |
| 30 | freeEntries.remove_all_if([&](EIndex i) { |
| 31 | return i > lastValid; |
| 32 | }); |
| 33 | } |
| 34 | |
| 35 | void entity_registry_t::new_entities(sugoi_entity_t* dst, EIndex count) |
| 36 | { |