void Scene::updateItems(const ItemIDs& ids, UpdateFunctors& functors) { auto updateID = ids.begin(); auto updateFunctor = functors.begin(); for (;updateID != ids.end(); updateID++, updateFunctor++) { _items[(*updateID)].update((*updateFunctor)); } }
void Scene::updateItems(const ItemIDs& ids, UpdateFunctors& functors) { auto updateFunctor = functors.begin(); for (auto updateID : ids) { if (updateID == Item::INVALID_ITEM_ID) { updateFunctor++; continue; } // Access the true item auto& item = _items[updateID]; auto oldCell = item.getCell(); auto oldKey = item.getKey(); // Update the item item.update((*updateFunctor)); auto newKey = item.getKey(); // Update the item's container if (oldKey.isSpatial() == newKey.isSpatial()) { if (newKey.isSpatial()) { auto newCell = _masterSpatialTree.resetItem(oldCell, oldKey, item.getBound(), updateID, newKey); item.resetCell(newCell, newKey.isSmall()); } } else { if (newKey.isSpatial()) { _masterNonspatialSet.erase(updateID); auto newCell = _masterSpatialTree.resetItem(oldCell, oldKey, item.getBound(), updateID, newKey); item.resetCell(newCell, newKey.isSmall()); } else { _masterSpatialTree.removeItem(oldCell, oldKey, updateID); item.resetCell(); _masterNonspatialSet.insert(updateID); } } // next loop updateFunctor++; } }