remove not necessary EntityTreeRenderer from removeAvatarEntities's condition

This commit is contained in:
Alexander Ivash 2018-07-20 19:32:58 +03:00
parent fb8640de47
commit 849c91d8f6
3 changed files with 9 additions and 5 deletions

View file

@ -150,7 +150,9 @@ bool isWearableEntity(const EntityItemPointer& entity) {
void AvatarBookmarks::updateAvatarEntities(const QVariantList &avatarEntities) {
auto myAvatar = DependencyManager::get<AvatarManager>()->getMyAvatar();
myAvatar->removeAvatarEntities([&](const EntityTreePointer& entityTree, const QUuid& entityID) {
auto treeRenderer = DependencyManager::get<EntityTreeRenderer>();
EntityTreePointer entityTree = treeRenderer ? treeRenderer->getTree() : nullptr;
myAvatar->removeAvatarEntities([&](const QUuid& entityID) {
auto entity = entityTree->findEntityByID(entityID);
return entity && isWearableEntity(entity);
});
@ -170,7 +172,9 @@ void AvatarBookmarks::loadBookmark(const QString& bookmarkName) {
QVariantMap bookmark = bookmarkEntry.value().toMap();
if (!bookmark.empty()) {
auto myAvatar = DependencyManager::get<AvatarManager>()->getMyAvatar();
myAvatar->removeAvatarEntities([&](const EntityTreePointer& entityTree, const QUuid& entityID) {
auto treeRenderer = DependencyManager::get<EntityTreeRenderer>();
EntityTreePointer entityTree = treeRenderer ? treeRenderer->getTree() : nullptr;
myAvatar->removeAvatarEntities([&](const QUuid& entityID) {
auto entity = entityTree->findEntityByID(entityID);
return entity && isWearableEntity(entity);
});

View file

@ -1607,14 +1607,14 @@ void MyAvatar::setSkeletonModelURL(const QUrl& skeletonModelURL) {
emit skeletonModelURLChanged();
}
void MyAvatar::removeAvatarEntities(const std::function<bool(const EntityTreePointer& entityTree, const QUuid& entityID)>& condition) {
void MyAvatar::removeAvatarEntities(const std::function<bool(const QUuid& entityID)>& condition) {
auto treeRenderer = DependencyManager::get<EntityTreeRenderer>();
EntityTreePointer entityTree = treeRenderer ? treeRenderer->getTree() : nullptr;
if (entityTree) {
entityTree->withWriteLock([&] {
AvatarEntityMap avatarEntities = getAvatarEntityData();
for (auto entityID : avatarEntities.keys()) {
if(!condition || condition(entityTree, entityID)) {
if(!condition || condition(entityID)) {
entityTree->deleteEntity(entityID, true, true);
}
}

View file

@ -927,7 +927,7 @@ public:
* @returns {object[]}
*/
Q_INVOKABLE QVariantList getAvatarEntitiesVariant();
void removeAvatarEntities(const std::function<bool(const EntityTreePointer& entityTree, const QUuid& entityID)>& condition = {});
void removeAvatarEntities(const std::function<bool(const QUuid& entityID)>& condition = {});
/**jsdoc
* @function MyAvatar.isFlying