From 71b025f7f050d141dabb5b8454e591e1a9ab044e Mon Sep 17 00:00:00 2001 From: David Rowe Date: Mon, 22 Mar 2021 15:36:57 +1300 Subject: [PATCH] Separate API vs. internal versions of clearAvatarEntity() --- assignment-client/src/avatars/AvatarMixerClientData.cpp | 4 +++- assignment-client/src/avatars/ScriptableAvatar.cpp | 4 ++-- interface/src/avatar/AvatarManager.cpp | 2 +- interface/src/avatar/MyAvatar.cpp | 8 ++++++-- interface/src/avatar/MyAvatar.h | 3 +++ libraries/avatars/src/AvatarData.cpp | 8 ++++++-- libraries/avatars/src/AvatarData.h | 3 +++ libraries/entities/src/EntityScriptingInterface.cpp | 2 +- 8 files changed, 25 insertions(+), 9 deletions(-) diff --git a/assignment-client/src/avatars/AvatarMixerClientData.cpp b/assignment-client/src/avatars/AvatarMixerClientData.cpp index 7b1fa1ab57..c83b95c464 100644 --- a/assignment-client/src/avatars/AvatarMixerClientData.cpp +++ b/assignment-client/src/avatars/AvatarMixerClientData.cpp @@ -298,7 +298,7 @@ void AvatarMixerClientData::processSetTraitsMessage(ReceivedMessage& message, void AvatarMixerClientData::emulateDeleteEntitiesTraitsMessage(const QList& avatarEntityIDs) { // Emulates processSetTraitsMessage() actions on behalf of an avatar whose canRezAvatarEntities permission has been removed. - // The source avatar should be removing its avatar entities. However, this provides a back-up. + // The source avatar should be removing its avatar entities. However, using this method provides a back-up. auto traitType = AvatarTraits::AvatarEntity; for (const auto& entityID : avatarEntityIDs) { @@ -311,6 +311,8 @@ void AvatarMixerClientData::emulateDeleteEntitiesTraitsMessage(const QList::iterator itr = _entities.find(entityID); if (itr != _entities.end()) { _entities.erase(itr); - clearAvatarEntity(entityID); + clearAvatarEntityInternal(entityID); } return; } diff --git a/interface/src/avatar/AvatarManager.cpp b/interface/src/avatar/AvatarManager.cpp index 91d339a38d..e4b7176a01 100755 --- a/interface/src/avatar/AvatarManager.cpp +++ b/interface/src/avatar/AvatarManager.cpp @@ -544,7 +544,7 @@ void AvatarManager::removeDeadAvatarEntities(const SetOfEntities& deadEntities) QUuid entityOwnerID = entity->getOwningAvatarID(); AvatarSharedPointer avatar = getAvatarBySessionID(entityOwnerID); if (avatar) { - avatar->clearAvatarEntity(entity->getID()); + avatar->clearAvatarEntityInternal(entity->getID()); } } } diff --git a/interface/src/avatar/MyAvatar.cpp b/interface/src/avatar/MyAvatar.cpp index 43f67b46a3..2510f9a111 100644 --- a/interface/src/avatar/MyAvatar.cpp +++ b/interface/src/avatar/MyAvatar.cpp @@ -1542,7 +1542,11 @@ void MyAvatar::clearAvatarEntity(const QUuid& entityID, bool requiresRemovalFrom return; } - AvatarData::clearAvatarEntity(entityID); + clearAvatarEntityInternal(entityID); +} + +void MyAvatar::clearAvatarEntityInternal(const QUuid& entityID) { + AvatarData::clearAvatarEntityInternal(entityID); if (!DependencyManager::get()->getThisNodeCanRezAvatarEntities()) { // Don't delete potentially non-rezzed avatar entities from cache, otherwise they're removed from settings. @@ -2596,7 +2600,7 @@ void MyAvatar::removeWornAvatarEntity(const EntityItemID& entityID) { auto entity = entityTree->findEntityByID(entityID); if (entity && isWearableEntity(entity)) { treeRenderer->deleteEntity(entityID); - clearAvatarEntity(entityID); + clearAvatarEntityInternal(entityID); } } } diff --git a/interface/src/avatar/MyAvatar.h b/interface/src/avatar/MyAvatar.h index ca5ed3b73c..3f0612579b 100644 --- a/interface/src/avatar/MyAvatar.h +++ b/interface/src/avatar/MyAvatar.h @@ -2710,6 +2710,9 @@ private: bool findAvatarEntity(const QString& modelURL, const QString& jointName, QUuid& entityID); void addAvatarEntitiesToTree(); + // FIXME: Rename to clearAvatarEntity() once the API call is removed. + void clearAvatarEntityInternal(const QUuid& entityID) override; + bool cameraInsideHead(const glm::vec3& cameraPosition) const; void updateEyeContactTarget(float deltaTime); diff --git a/libraries/avatars/src/AvatarData.cpp b/libraries/avatars/src/AvatarData.cpp index 234cc67c72..0e18274801 100755 --- a/libraries/avatars/src/AvatarData.cpp +++ b/libraries/avatars/src/AvatarData.cpp @@ -2246,7 +2246,7 @@ void AvatarData::processTraitInstance(AvatarTraits::TraitType traitType, void AvatarData::processDeletedTraitInstance(AvatarTraits::TraitType traitType, AvatarTraits::TraitInstanceID instanceID) { if (traitType == AvatarTraits::AvatarEntity) { - clearAvatarEntity(instanceID); + clearAvatarEntityInternal(instanceID); } else if (traitType == AvatarTraits::Grab) { clearAvatarGrabData(instanceID); } @@ -3034,6 +3034,10 @@ void AvatarData::updateAvatarEntity(const QUuid& entityID, const QByteArray& ent void AvatarData::clearAvatarEntity(const QUuid& entityID, bool requiresRemovalFromTree) { // NOTE: requiresRemovalFromTree is unused + clearAvatarEntityInternal(entityID); +} + +void AvatarData::clearAvatarEntityInternal(const QUuid& entityID) { bool removedEntity = false; _avatarEntitiesLock.withWriteLock([this, &removedEntity, &entityID] { removedEntity = _packedAvatarEntityData.remove(entityID); @@ -3052,7 +3056,7 @@ void AvatarData::clearAvatarEntities() { avatarEntityIDs = _packedAvatarEntityData.keys(); }); for (const auto& entityID : avatarEntityIDs) { - clearAvatarEntity(entityID); + clearAvatarEntityInternal(entityID); } } diff --git a/libraries/avatars/src/AvatarData.h b/libraries/avatars/src/AvatarData.h index fffe8460f1..b25a6938d7 100755 --- a/libraries/avatars/src/AvatarData.h +++ b/libraries/avatars/src/AvatarData.h @@ -1187,6 +1187,9 @@ public: */ Q_INVOKABLE virtual void clearAvatarEntity(const QUuid& entityID, bool requiresRemovalFromTree = true); + // FIXME: Rename to clearAvatarEntity() once the API call is removed. + virtual void clearAvatarEntityInternal(const QUuid& entityID); + void clearAvatarEntities(); QList getAvatarEntityIDs() const; diff --git a/libraries/entities/src/EntityScriptingInterface.cpp b/libraries/entities/src/EntityScriptingInterface.cpp index d87bab97cd..90c521215e 100644 --- a/libraries/entities/src/EntityScriptingInterface.cpp +++ b/libraries/entities/src/EntityScriptingInterface.cpp @@ -1016,7 +1016,7 @@ void EntityScriptingInterface::deleteEntity(const QUuid& id) { for (auto entity : entitiesToDeleteImmediately) { if (entity->isMyAvatarEntity()) { - getEntityPacketSender()->getMyAvatar()->clearAvatarEntity(entity->getID(), false); + getEntityPacketSender()->getMyAvatar()->clearAvatarEntityInternal(entity->getID()); } } }