Separate API vs. internal versions of clearAvatarEntity()

This commit is contained in:
David Rowe 2021-03-22 15:36:57 +13:00
parent b0fee2699c
commit 71b025f7f0
8 changed files with 25 additions and 9 deletions

View file

@ -298,7 +298,7 @@ void AvatarMixerClientData::processSetTraitsMessage(ReceivedMessage& message,
void AvatarMixerClientData::emulateDeleteEntitiesTraitsMessage(const QList<QUuid>& 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<QUuid
// to track a deleted instance but keep version information
// the avatar mixer uses the negative value of the sent version
// Because there is no originating message from an avatar we enlarge the magnitude by 1.
// If a user subsequently has canRezAvatarEntities permission granted, they will have to relog in order for their
// avatar entities to be visible to others.
instanceVersionRef = -instanceVersionRef - 1;
}

View file

@ -398,7 +398,7 @@ void ScriptableAvatar::setAvatarEntityData(const AvatarEntityMap& avatarEntityDa
// clear deleted traits
for (const auto& id : idsToClear) {
clearAvatarEntity(id);
clearAvatarEntityInternal(id);
}
}
@ -408,7 +408,7 @@ void ScriptableAvatar::updateAvatarEntity(const QUuid& entityID, const QByteArra
std::map<QUuid, EntityItemPointer>::iterator itr = _entities.find(entityID);
if (itr != _entities.end()) {
_entities.erase(itr);
clearAvatarEntity(entityID);
clearAvatarEntityInternal(entityID);
}
return;
}

View file

@ -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());
}
}
}

View file

@ -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<NodeList>()->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);
}
}
}

View file

@ -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);

View file

@ -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);
}
}

View file

@ -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<QUuid> getAvatarEntityIDs() const;

View file

@ -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());
}
}
}