From 25876bca6397ed1b9036ef5a444beee08e78c02f Mon Sep 17 00:00:00 2001 From: Stephen Birarda Date: Mon, 20 Aug 2018 14:55:07 -0700 Subject: [PATCH] send attachment clears through setAvatarEntityData --- interface/src/AvatarBookmarks.cpp | 15 ++------------- interface/src/avatar/MyAvatar.cpp | 19 +++---------------- interface/src/avatar/MyAvatar.h | 2 +- 3 files changed, 6 insertions(+), 30 deletions(-) diff --git a/interface/src/AvatarBookmarks.cpp b/interface/src/AvatarBookmarks.cpp index 6afab71c90..c7c87aee3e 100644 --- a/interface/src/AvatarBookmarks.cpp +++ b/interface/src/AvatarBookmarks.cpp @@ -151,13 +151,7 @@ bool isWearableEntity(const EntityItemPointer& entity) { void AvatarBookmarks::updateAvatarEntities(const QVariantList &avatarEntities) { auto myAvatar = DependencyManager::get()->getMyAvatar(); - auto treeRenderer = DependencyManager::get(); - EntityTreePointer entityTree = treeRenderer ? treeRenderer->getTree() : nullptr; - myAvatar->removeAvatarEntities([&](const QUuid& entityID) { - auto entity = entityTree->findEntityByID(entityID); - return entity && isWearableEntity(entity); - }); - + myAvatar->clearAvatarEntities(); addAvatarEntities(avatarEntities); } @@ -180,12 +174,7 @@ void AvatarBookmarks::loadBookmark(const QString& bookmarkName) { if (!bookmark.empty()) { auto myAvatar = DependencyManager::get()->getMyAvatar(); - auto treeRenderer = DependencyManager::get(); - EntityTreePointer entityTree = treeRenderer ? treeRenderer->getTree() : nullptr; - myAvatar->removeAvatarEntities([&](const QUuid& entityID) { - auto entity = entityTree->findEntityByID(entityID); - return entity && isWearableEntity(entity); - }); + myAvatar->clearAvatarEntities(); const QString& avatarUrl = bookmark.value(ENTRY_AVATAR_URL, "").toString(); myAvatar->useFullAvatarURL(avatarUrl); qCDebug(interfaceapp) << "Avatar On " << avatarUrl; diff --git a/interface/src/avatar/MyAvatar.cpp b/interface/src/avatar/MyAvatar.cpp index deef69d980..709ddfd17a 100755 --- a/interface/src/avatar/MyAvatar.cpp +++ b/interface/src/avatar/MyAvatar.cpp @@ -1703,21 +1703,6 @@ void MyAvatar::setSkeletonModelURL(const QUrl& skeletonModelURL) { emit skeletonChanged(); } -void MyAvatar::removeAvatarEntities(const std::function& condition) { - auto treeRenderer = DependencyManager::get(); - EntityTreePointer entityTree = treeRenderer ? treeRenderer->getTree() : nullptr; - if (entityTree) { - entityTree->withWriteLock([&] { - AvatarEntityMap avatarEntities = getAvatarEntityData(); - for (auto entityID : avatarEntities.keys()) { - if (!condition || condition(entityID)) { - entityTree->deleteEntity(entityID, true, true); - } - } - }); - } -} - QVariantList MyAvatar::getAvatarEntitiesVariant() { QVariantList avatarEntitiesData; QScriptEngine scriptEngine; @@ -2114,7 +2099,9 @@ void MyAvatar::setAttachmentData(const QVector& attachmentData) attachmentDataToEntityProperties(data, properties); newEntitiesProperties.push_back(properties); } - removeAvatarEntities(); + + clearAvatarEntities(); + for (auto& properties : newEntitiesProperties) { DependencyManager::get()->addEntity(properties, true); } diff --git a/interface/src/avatar/MyAvatar.h b/interface/src/avatar/MyAvatar.h index ba6348cc22..247a0c79c8 100644 --- a/interface/src/avatar/MyAvatar.h +++ b/interface/src/avatar/MyAvatar.h @@ -931,7 +931,7 @@ public: * @returns {object[]} */ Q_INVOKABLE QVariantList getAvatarEntitiesVariant(); - void removeAvatarEntities(const std::function& condition = {}); + void clearAvatarEntities() { setAvatarEntityData(AvatarEntityMap()); } /**jsdoc * @function MyAvatar.isFlying