mirror of
https://github.com/overte-org/overte.git
synced 2025-08-09 23:14:34 +02:00
use std::vector<> instead of QVector<>
This commit is contained in:
parent
fb090d1388
commit
3546bab19a
6 changed files with 44 additions and 26 deletions
|
@ -1589,14 +1589,15 @@ void MyAvatar::handleChangedAvatarEntityData() {
|
||||||
// move the lists to minimize lock time
|
// move the lists to minimize lock time
|
||||||
std::vector<QUuid> cachedBlobsToDelete;
|
std::vector<QUuid> cachedBlobsToDelete;
|
||||||
std::vector<QUuid> cachedBlobsToUpdate;
|
std::vector<QUuid> cachedBlobsToUpdate;
|
||||||
QSet<EntityItemID> idsToDelete;
|
std::vector<EntityItemID> idsToDelete;
|
||||||
|
idsToDelete.reserve(_entitiesToDelete.size());
|
||||||
std::vector<QUuid> entitiesToAdd;
|
std::vector<QUuid> entitiesToAdd;
|
||||||
std::vector<QUuid> entitiesToUpdate;
|
std::vector<QUuid> entitiesToUpdate;
|
||||||
_avatarEntitiesLock.withWriteLock([&] {
|
_avatarEntitiesLock.withWriteLock([&] {
|
||||||
cachedBlobsToDelete = std::move(_cachedAvatarEntityBlobsToDelete);
|
cachedBlobsToDelete = std::move(_cachedAvatarEntityBlobsToDelete);
|
||||||
cachedBlobsToUpdate = std::move(_cachedAvatarEntityBlobsToAddOrUpdate);
|
cachedBlobsToUpdate = std::move(_cachedAvatarEntityBlobsToAddOrUpdate);
|
||||||
foreach (auto id, _entitiesToDelete) {
|
foreach (auto id, _entitiesToDelete) {
|
||||||
idsToDelete.insert(id);
|
idsToDelete.push_back(id);
|
||||||
}
|
}
|
||||||
_entitiesToDelete.clear();
|
_entitiesToDelete.clear();
|
||||||
entitiesToAdd = std::move(_entitiesToAdd);
|
entitiesToAdd = std::move(_entitiesToAdd);
|
||||||
|
|
|
@ -561,16 +561,19 @@ void OtherAvatar::handleChangedAvatarEntityData() {
|
||||||
_avatarEntitiesLock.withReadLock([&] {
|
_avatarEntitiesLock.withReadLock([&] {
|
||||||
packedAvatarEntityData = _packedAvatarEntityData;
|
packedAvatarEntityData = _packedAvatarEntityData;
|
||||||
});
|
});
|
||||||
QSet<EntityItemID> idsToDelete;
|
if (!recentlyRemovedAvatarEntities.empty()) {
|
||||||
foreach (auto entityID, recentlyRemovedAvatarEntities) {
|
std::vector<EntityItemID> idsToDelete;
|
||||||
if (!packedAvatarEntityData.contains(entityID)) {
|
idsToDelete.reserve(recentlyRemovedAvatarEntities.size());
|
||||||
idsToDelete.insert(entityID);
|
foreach (auto entityID, recentlyRemovedAvatarEntities) {
|
||||||
|
if (!packedAvatarEntityData.contains(entityID)) {
|
||||||
|
idsToDelete.push_back(entityID);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!idsToDelete.empty()) {
|
||||||
|
bool force = true;
|
||||||
|
bool ignoreWarnings = true;
|
||||||
|
entityTree->deleteEntitiesByID(idsToDelete, force, ignoreWarnings);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
if (!idsToDelete.empty()) {
|
|
||||||
bool force = true;
|
|
||||||
bool ignoreWarnings = true;
|
|
||||||
entityTree->deleteEntitiesByID(idsToDelete, force, ignoreWarnings);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: move this outside of tree lock
|
// TODO: move this outside of tree lock
|
||||||
|
|
|
@ -333,6 +333,9 @@ void Avatar::setTargetScale(float targetScale) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void Avatar::removeAvatarEntitiesFromTree() {
|
void Avatar::removeAvatarEntitiesFromTree() {
|
||||||
|
if (_packedAvatarEntityData.empty()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
auto treeRenderer = DependencyManager::get<EntityTreeRenderer>();
|
auto treeRenderer = DependencyManager::get<EntityTreeRenderer>();
|
||||||
EntityTreePointer entityTree = treeRenderer ? treeRenderer->getTree() : nullptr;
|
EntityTreePointer entityTree = treeRenderer ? treeRenderer->getTree() : nullptr;
|
||||||
if (entityTree) {
|
if (entityTree) {
|
||||||
|
@ -340,9 +343,10 @@ void Avatar::removeAvatarEntitiesFromTree() {
|
||||||
_avatarEntitiesLock.withReadLock([&] {
|
_avatarEntitiesLock.withReadLock([&] {
|
||||||
avatarEntityIDs = _packedAvatarEntityData.keys();
|
avatarEntityIDs = _packedAvatarEntityData.keys();
|
||||||
});
|
});
|
||||||
QSet<EntityItemID> ids;
|
std::vector<EntityItemID> ids;
|
||||||
|
ids.reserve(avatarEntityIDs.size());
|
||||||
foreach (auto id, avatarEntityIDs) {
|
foreach (auto id, avatarEntityIDs) {
|
||||||
ids.insert(id);
|
ids.push_back(id);
|
||||||
}
|
}
|
||||||
bool force = true;
|
bool force = true;
|
||||||
bool ignoreWarnings = true;
|
bool ignoreWarnings = true;
|
||||||
|
|
|
@ -609,8 +609,8 @@ void EntityTree::setSimulation(EntitySimulationPointer simulation) {
|
||||||
|
|
||||||
void EntityTree::deleteEntity(const EntityItemID& entityID, bool force, bool ignoreWarnings) {
|
void EntityTree::deleteEntity(const EntityItemID& entityID, bool force, bool ignoreWarnings) {
|
||||||
// NOTE: can be called without lock because deleteEntitiesByID() will lock
|
// NOTE: can be called without lock because deleteEntitiesByID() will lock
|
||||||
QSet<EntityItemID> ids;
|
std::vector<EntityItemID> ids;
|
||||||
ids << entityID;
|
ids.push_back(entityID);
|
||||||
deleteEntitiesByID(ids, force, ignoreWarnings);
|
deleteEntitiesByID(ids, force, ignoreWarnings);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -674,7 +674,7 @@ void EntityTree::recursivelyFilterAndCollectForDelete(const EntityItemPointer& e
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void EntityTree::deleteEntitiesByID(const QSet<EntityItemID>& ids, bool force, bool ignoreWarnings) {
|
void EntityTree::deleteEntitiesByID(const std::vector<EntityItemID>& ids, bool force, bool ignoreWarnings) {
|
||||||
// this method has two paths:
|
// this method has two paths:
|
||||||
// (a) entity-server: applies delete filter
|
// (a) entity-server: applies delete filter
|
||||||
// (b) interface-client: deletes local- and my-avatar-entities immediately, submits domainEntity deletes to the entity-server
|
// (b) interface-client: deletes local- and my-avatar-entities immediately, submits domainEntity deletes to the entity-server
|
||||||
|
@ -2230,11 +2230,19 @@ void EntityTree::fixupNeedsParentFixups() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void EntityTree::deleteDescendantsOfAvatar(QUuid avatarID) {
|
void EntityTree::deleteDescendantsOfAvatar(QUuid avatarID) {
|
||||||
if (_childrenOfAvatars.contains(avatarID)) {
|
QHash<QUuid, QSet<EntityItemID>>::const_iterator itr = _childrenOfAvatars.constFind(avatarID);
|
||||||
bool force = true;
|
if (itr != _childrenOfAvatars.end()) {
|
||||||
bool ignoreWarnings = true;
|
if (!itr.value().empty()) {
|
||||||
deleteEntitiesByID(_childrenOfAvatars[avatarID], force, ignoreWarnings);
|
std::vector<EntityItemID> ids;
|
||||||
_childrenOfAvatars.remove(avatarID);
|
ids.reserve(itr.value().size());
|
||||||
|
for (const auto id : itr.value()) {
|
||||||
|
ids.push_back(id);
|
||||||
|
}
|
||||||
|
bool force = true;
|
||||||
|
bool ignoreWarnings = true;
|
||||||
|
deleteEntitiesByID(ids, force, ignoreWarnings);
|
||||||
|
}
|
||||||
|
_childrenOfAvatars.erase(itr);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2436,7 +2444,8 @@ int EntityTree::processEraseMessageDetails(const QByteArray& dataByteArray, cons
|
||||||
processedBytes += sizeof(numberOfIds);
|
processedBytes += sizeof(numberOfIds);
|
||||||
|
|
||||||
if (numberOfIds > 0) {
|
if (numberOfIds > 0) {
|
||||||
QSet<EntityItemID> ids;
|
std::vector<EntityItemID> ids;
|
||||||
|
ids.reserve(numberOfIds);
|
||||||
|
|
||||||
// extract ids from packet
|
// extract ids from packet
|
||||||
for (size_t i = 0; i < numberOfIds; i++) {
|
for (size_t i = 0; i < numberOfIds; i++) {
|
||||||
|
@ -2454,7 +2463,7 @@ int EntityTree::processEraseMessageDetails(const QByteArray& dataByteArray, cons
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
EntityItemID entityID(id);
|
EntityItemID entityID(id);
|
||||||
ids << entityID;
|
ids.push_back(entityID);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool force = sourceNode->isAllowedEditor();
|
bool force = sourceNode->isAllowedEditor();
|
||||||
|
|
|
@ -127,7 +127,7 @@ public:
|
||||||
void cleanupCloneIDs(const EntityItemID& entityID);
|
void cleanupCloneIDs(const EntityItemID& entityID);
|
||||||
void deleteEntity(const EntityItemID& entityID, bool force = false, bool ignoreWarnings = true);
|
void deleteEntity(const EntityItemID& entityID, bool force = false, bool ignoreWarnings = true);
|
||||||
|
|
||||||
void deleteEntitiesByID(const QSet<EntityItemID>& entityIDs, bool force = false, bool ignoreWarnings = true);
|
void deleteEntitiesByID(const std::vector<EntityItemID>& entityIDs, bool force = false, bool ignoreWarnings = true);
|
||||||
void deleteEntitiesByPointer(const SetOfEntities& entities);
|
void deleteEntitiesByPointer(const SetOfEntities& entities);
|
||||||
|
|
||||||
EntityItemPointer findEntityByID(const QUuid& id) const;
|
EntityItemPointer findEntityByID(const QUuid& id) const;
|
||||||
|
|
|
@ -434,12 +434,13 @@ void EntityTests::entityTreeTests(bool verbose) {
|
||||||
quint64 totalElapsedFind = 0;
|
quint64 totalElapsedFind = 0;
|
||||||
for (int i = 0; i < TEST_ITERATIONS; i++) {
|
for (int i = 0; i < TEST_ITERATIONS; i++) {
|
||||||
|
|
||||||
QSet<EntityItemID> entitiesToDelete;
|
std::vector<EntityItemID> entitiesToDelete;
|
||||||
|
entitiesToDelete.reserve(ENTITIES_PER_ITERATION);
|
||||||
for (int j = 0; j < ENTITIES_PER_ITERATION; j++) {
|
for (int j = 0; j < ENTITIES_PER_ITERATION; j++) {
|
||||||
//uint32_t id = 2 + (i * ENTITIES_PER_ITERATION) + j; // These are the entities we added above
|
//uint32_t id = 2 + (i * ENTITIES_PER_ITERATION) + j; // These are the entities we added above
|
||||||
QUuid id = QUuid::createUuid();// make sure it doesn't collide with previous entity ids
|
QUuid id = QUuid::createUuid();// make sure it doesn't collide with previous entity ids
|
||||||
EntityItemID entityID(id);
|
EntityItemID entityID(id);
|
||||||
entitiesToDelete << entityID;
|
entitiesToDelete.push_back(entityID);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (extraVerbose) {
|
if (extraVerbose) {
|
||||||
|
|
Loading…
Reference in a new issue