| 243 | } |
| 244 | |
| 245 | EntityHandleGenerator::ThreadState::Entry* EntityHandleGenerator::ThreadState::Add() |
| 246 | { |
| 247 | if (NumFreeSlots < Entries.bucket_size() / 2) { |
| 248 | auto oldCapacity = Entries.capacity(); |
| 249 | if (Entries.capacity() < Entries.size() + Entries.bucket_size()) { |
| 250 | Entries.resize(Entries.capacity() + Entries.bucket_size()); |
| 251 | } |
| 252 | |
| 253 | auto growSize = Entries.capacity() - oldCapacity; |
| 254 | for (uint32_t i = 0; i < growSize; i++) { |
| 255 | auto index = Entries.size(); |
| 256 | auto entry = Entries.add(); |
| 257 | *entry = Entry{ |
| 258 | .Index = index, |
| 259 | .Salt = 1 |
| 260 | }; |
| 261 | if (NumFreeSlots > 0) { |
| 262 | Entries[LastFreeSlotIndex].Index = index; |
| 263 | } else { |
| 264 | NextFreeSlotIndex = index; |
| 265 | } |
| 266 | |
| 267 | LastFreeSlotIndex = index; |
| 268 | NumFreeSlots++; |
| 269 | } |
| 270 | } |
| 271 | |
| 272 | auto index = NextFreeSlotIndex; |
| 273 | NumFreeSlots--; |
| 274 | auto entry = &Entries[index]; |
| 275 | NextFreeSlotIndex = entry->Index; |
| 276 | entry->Index = index; |
| 277 | return entry; |
| 278 | } |
| 279 | |
| 280 | void* EntityStorageData::GetComponent(EntityHandle entityHandle, ComponentTypeIndex type, std::size_t componentSize, bool isProxy) const |
| 281 | { |
no test coverage detected