Make avatar mixer remove clients' unremoved avatar entities

This commit is contained in:
David Rowe 2021-03-12 22:15:26 +13:00
parent fa77441fda
commit 1b33339995
5 changed files with 37 additions and 1 deletions

View file

@ -297,6 +297,27 @@ void AvatarMixerClientData::processSetTraitsMessage(ReceivedMessage& message,
}
}
void AvatarMixerClientData::emulateDeleteEntitiesTraitsMessage(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.
for (const auto& entityID : avatarEntityIDs) {
auto traitType = AvatarTraits::AvatarEntity;
auto& instanceVersionRef = _lastReceivedTraitVersions.getInstanceValueRef(traitType, entityID);
_avatar->processDeletedTraitInstance(traitType, entityID);
// Mixer doesn't need deleted IDs.
_avatar->getAndClearRecentlyRemovedIDs();
// 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.
instanceVersionRef = -instanceVersionRef - 1;
}
_lastReceivedTraitsChange = std::chrono::steady_clock::now();
}
void AvatarMixerClientData::processBulkAvatarTraitsAckMessage(ReceivedMessage& message) {
// Avatar Traits flow control marks each outgoing avatar traits packet with a
// sequence number. The mixer caches the traits sent in the traits packet.

View file

@ -132,6 +132,7 @@ public:
int processPackets(const SlaveSharedData& slaveSharedData); // returns number of packets processed
void processSetTraitsMessage(ReceivedMessage& message, const SlaveSharedData& slaveSharedData, Node& sendingNode);
void emulateDeleteEntitiesTraitsMessage(QList<QUuid>& avatarEntityIDs);
void processBulkAvatarTraitsAckMessage(ReceivedMessage& message);
void checkSkeletonURLAgainstWhitelist(const SlaveSharedData& slaveSharedData, Node& sendingNode,
AvatarTraits::TraitVersion traitVersion);

View file

@ -432,10 +432,14 @@ void AvatarMixerSlave::broadcastAvatarDataToAgent(const SharedNodePointer& node)
}
}
// The source avatar should be removing its avatar entities. However, provide a back-up.
if (sendAvatar) {
if (!sourceAvatarNode->getCanRezAvatarEntities()) {
auto sourceAvatarNodeData = reinterpret_cast<AvatarMixerClientData*>(sourceAvatarNode->getLinkedData());
sourceAvatarNodeData->getAvatar().clearAvatarEntities();
auto avatarEntityIDs = sourceAvatarNodeData->getAvatar().getAvatarEntityIDs();
if (avatarEntityIDs.count() > 0) {
sourceAvatarNodeData->emulateDeleteEntitiesTraitsMessage(avatarEntityIDs);
}
}
}

View file

@ -3056,6 +3056,14 @@ void AvatarData::clearAvatarEntities() {
}
}
QList<QUuid> AvatarData::getAvatarEntityIDs() const {
QList<QUuid> avatarEntityIDs;
_avatarEntitiesLock.withReadLock([&] {
avatarEntityIDs = _packedAvatarEntityData.keys();
});
return avatarEntityIDs;
}
AvatarEntityMap AvatarData::getAvatarEntityData() const {
// overridden where needed
// NOTE: the return value is expected to be a map of unfortunately-formatted-binary-blobs

View file

@ -1189,6 +1189,8 @@ public:
void clearAvatarEntities();
QList<QUuid> getAvatarEntityIDs() const;
/**jsdoc
* Enables blend shapes set using {@link Avatar.setBlendshape} or {@link MyAvatar.setBlendshape} to be transmitted to other
* users so that they can see the animation of your avatar's face.