| 354 | } |
| 355 | |
| 356 | void DescriptionEditService::reconnectCells(DataDescription& data, float maxDistance) |
| 357 | { |
| 358 | std::unordered_map<int, std::unordered_map<int, std::vector<int>>> cellIndicesBySlot; |
| 359 | |
| 360 | int index = 0; |
| 361 | for (auto& cell : data.cells) { |
| 362 | cell.connections.clear(); |
| 363 | cellIndicesBySlot[toInt(cell.pos.x)][toInt(cell.pos.y)].emplace_back(toInt(index)); |
| 364 | ++index; |
| 365 | } |
| 366 | |
| 367 | std::unordered_map<uint64_t, int> cache; |
| 368 | for (auto const& [index, cell] : data.cells | boost::adaptors::indexed(0)) { |
| 369 | cache.emplace(cell.id, static_cast<int>(index)); |
| 370 | } |
| 371 | for (auto& cell : data.cells) { |
| 372 | auto nearbyCellIndices = getCellIndicesWithinRadius(data, cellIndicesBySlot, cell.pos, maxDistance); |
| 373 | for (auto const& nearbyCellIndex : nearbyCellIndices) { |
| 374 | auto const& nearbyCell = data.cells.at(nearbyCellIndex); |
| 375 | if (cell.id != nearbyCell.id && cell.connections.size() < cell.maxConnections && nearbyCell.connections.size() < nearbyCell.maxConnections |
| 376 | && !cell.isConnectedTo(nearbyCell.id)) { |
| 377 | data.addConnection(cell.id, nearbyCell.id, &cache); |
| 378 | } |
| 379 | } |
| 380 | } |
| 381 | } |
| 382 | |
| 383 | void DescriptionEditService::removeStickiness(DataDescription& data) |
| 384 | { |
no test coverage detected