mirror of
https://github.com/overte-org/overte.git
synced 2025-08-08 21:17:01 +02:00
Process multiple avatars in an AvatarIdentity message
This commit is contained in:
parent
7a0043c010
commit
18c1371321
4 changed files with 50 additions and 45 deletions
|
@ -565,7 +565,7 @@ void AvatarMixer::handleAvatarIdentityPacket(QSharedPointer<ReceivedMessage> mes
|
||||||
// parse the identity packet and update the change timestamp if appropriate
|
// parse the identity packet and update the change timestamp if appropriate
|
||||||
bool identityChanged = false;
|
bool identityChanged = false;
|
||||||
bool displayNameChanged = false;
|
bool displayNameChanged = false;
|
||||||
avatar.processAvatarIdentity(message->getMessage(), identityChanged, displayNameChanged);
|
avatar.processAvatarIdentity(QDataStream(message->getMessage()), identityChanged, displayNameChanged);
|
||||||
|
|
||||||
if (identityChanged) {
|
if (identityChanged) {
|
||||||
QMutexLocker nodeDataLocker(&nodeData->getMutex());
|
QMutexLocker nodeDataLocker(&nodeData->getMutex());
|
||||||
|
|
|
@ -1767,11 +1767,9 @@ glm::quat AvatarData::getOrientationOutbound() const {
|
||||||
return (getLocalOrientation());
|
return (getLocalOrientation());
|
||||||
}
|
}
|
||||||
|
|
||||||
void AvatarData::processAvatarIdentity(const QByteArray& identityData, bool& identityChanged,
|
void AvatarData::processAvatarIdentity(QDataStream& packetStream, bool& identityChanged,
|
||||||
bool& displayNameChanged) {
|
bool& displayNameChanged) {
|
||||||
|
|
||||||
QDataStream packetStream(identityData);
|
|
||||||
|
|
||||||
QUuid avatarSessionID;
|
QUuid avatarSessionID;
|
||||||
|
|
||||||
// peek the sequence number, this will tell us if we should be processing this identity packet at all
|
// peek the sequence number, this will tell us if we should be processing this identity packet at all
|
||||||
|
@ -1786,17 +1784,18 @@ void AvatarData::processAvatarIdentity(const QByteArray& identityData, bool& ide
|
||||||
<< (udt::SequenceNumber::Type) incomingSequenceNumber;
|
<< (udt::SequenceNumber::Type) incomingSequenceNumber;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (incomingSequenceNumber > _identitySequenceNumber) {
|
Identity identity;
|
||||||
Identity identity;
|
|
||||||
|
|
||||||
packetStream
|
packetStream
|
||||||
>> identity.attachmentData
|
>> identity.attachmentData
|
||||||
>> identity.displayName
|
>> identity.displayName
|
||||||
>> identity.sessionDisplayName
|
>> identity.sessionDisplayName
|
||||||
>> identity.isReplicated
|
>> identity.isReplicated
|
||||||
>> identity.lookAtSnappingEnabled
|
>> identity.lookAtSnappingEnabled
|
||||||
;
|
;
|
||||||
|
|
||||||
|
if (incomingSequenceNumber > _identitySequenceNumber) {
|
||||||
|
|
||||||
// set the store identity sequence number to match the incoming identity
|
// set the store identity sequence number to match the incoming identity
|
||||||
_identitySequenceNumber = incomingSequenceNumber;
|
_identitySequenceNumber = incomingSequenceNumber;
|
||||||
|
|
||||||
|
|
|
@ -967,7 +967,7 @@ public:
|
||||||
|
|
||||||
// identityChanged returns true if identity has changed, false otherwise.
|
// identityChanged returns true if identity has changed, false otherwise.
|
||||||
// identityChanged returns true if identity has changed, false otherwise. Similarly for displayNameChanged and skeletonModelUrlChange.
|
// identityChanged returns true if identity has changed, false otherwise. Similarly for displayNameChanged and skeletonModelUrlChange.
|
||||||
void processAvatarIdentity(const QByteArray& identityData, bool& identityChanged, bool& displayNameChanged);
|
void processAvatarIdentity(QDataStream& packetStream, bool& identityChanged, bool& displayNameChanged);
|
||||||
|
|
||||||
qint64 packTrait(AvatarTraits::TraitType traitType, ExtendedIODevice& destination,
|
qint64 packTrait(AvatarTraits::TraitType traitType, ExtendedIODevice& destination,
|
||||||
AvatarTraits::TraitVersion traitVersion = AvatarTraits::NULL_TRAIT_VERSION);
|
AvatarTraits::TraitVersion traitVersion = AvatarTraits::NULL_TRAIT_VERSION);
|
||||||
|
|
|
@ -70,7 +70,7 @@ void AvatarReplicas::processAvatarIdentity(const QUuid& parentID, const QByteArr
|
||||||
if (_replicasMap.find(parentID) != _replicasMap.end()) {
|
if (_replicasMap.find(parentID) != _replicasMap.end()) {
|
||||||
auto &replicas = _replicasMap[parentID];
|
auto &replicas = _replicasMap[parentID];
|
||||||
for (auto avatar : replicas) {
|
for (auto avatar : replicas) {
|
||||||
avatar->processAvatarIdentity(identityData, identityChanged, displayNameChanged);
|
avatar->processAvatarIdentity(QDataStream(identityData), identityChanged, displayNameChanged);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -266,41 +266,47 @@ AvatarSharedPointer AvatarHashMap::parseAvatarData(QSharedPointer<ReceivedMessag
|
||||||
}
|
}
|
||||||
|
|
||||||
void AvatarHashMap::processAvatarIdentityPacket(QSharedPointer<ReceivedMessage> message, SharedNodePointer sendingNode) {
|
void AvatarHashMap::processAvatarIdentityPacket(QSharedPointer<ReceivedMessage> message, SharedNodePointer sendingNode) {
|
||||||
|
QDataStream avatarIdentityStream(message->getMessage());
|
||||||
|
|
||||||
// peek the avatar UUID from the incoming packet
|
while (!avatarIdentityStream.atEnd()) {
|
||||||
QUuid identityUUID = QUuid::fromRfc4122(message->peek(NUM_BYTES_RFC4122_UUID));
|
// peek the avatar UUID from the incoming packet
|
||||||
|
avatarIdentityStream.startTransaction();
|
||||||
|
QUuid identityUUID;
|
||||||
|
avatarIdentityStream >> identityUUID;
|
||||||
|
avatarIdentityStream.rollbackTransaction();
|
||||||
|
|
||||||
if (identityUUID.isNull()) {
|
if (identityUUID.isNull()) {
|
||||||
qCDebug(avatars) << "Refusing to process identity packet for null avatar ID";
|
qCDebug(avatars) << "Refusing to process identity packet for null avatar ID";
|
||||||
return;
|
return;
|
||||||
}
|
|
||||||
|
|
||||||
// make sure this isn't for an ignored avatar
|
|
||||||
auto nodeList = DependencyManager::get<NodeList>();
|
|
||||||
static auto EMPTY = QUuid();
|
|
||||||
|
|
||||||
{
|
|
||||||
QReadLocker locker(&_hashLock);
|
|
||||||
_pendingAvatars.remove(identityUUID);
|
|
||||||
auto me = _avatarHash.find(EMPTY);
|
|
||||||
if ((me != _avatarHash.end()) && (identityUUID == me.value()->getSessionUUID())) {
|
|
||||||
// We add MyAvatar to _avatarHash with an empty UUID. Code relies on this. In order to correctly handle an
|
|
||||||
// identity packet for ourself (such as when we are assigned a sessionDisplayName by the mixer upon joining),
|
|
||||||
// we make things match here.
|
|
||||||
identityUUID = EMPTY;
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if (!nodeList->isIgnoringNode(identityUUID) || nodeList->getRequestsDomainListData()) {
|
|
||||||
// mesh URL for a UUID, find avatar in our list
|
|
||||||
bool isNewAvatar;
|
|
||||||
auto avatar = newOrExistingAvatar(identityUUID, sendingNode, isNewAvatar);
|
|
||||||
bool identityChanged = false;
|
|
||||||
bool displayNameChanged = false;
|
|
||||||
// In this case, the "sendingNode" is the Avatar Mixer.
|
|
||||||
avatar->processAvatarIdentity(message->getMessage(), identityChanged, displayNameChanged);
|
|
||||||
_replicas.processAvatarIdentity(identityUUID, message->getMessage(), identityChanged, displayNameChanged);
|
|
||||||
|
|
||||||
|
// make sure this isn't for an ignored avatar
|
||||||
|
auto nodeList = DependencyManager::get<NodeList>();
|
||||||
|
static auto EMPTY = QUuid();
|
||||||
|
|
||||||
|
{
|
||||||
|
QReadLocker locker(&_hashLock);
|
||||||
|
_pendingAvatars.remove(identityUUID);
|
||||||
|
auto me = _avatarHash.find(EMPTY);
|
||||||
|
if ((me != _avatarHash.end()) && (identityUUID == me.value()->getSessionUUID())) {
|
||||||
|
// We add MyAvatar to _avatarHash with an empty UUID. Code relies on this. In order to correctly handle an
|
||||||
|
// identity packet for ourself (such as when we are assigned a sessionDisplayName by the mixer upon joining),
|
||||||
|
// we make things match here.
|
||||||
|
identityUUID = EMPTY;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!nodeList->isIgnoringNode(identityUUID) || nodeList->getRequestsDomainListData()) {
|
||||||
|
// mesh URL for a UUID, find avatar in our list
|
||||||
|
bool isNewAvatar;
|
||||||
|
auto avatar = newOrExistingAvatar(identityUUID, sendingNode, isNewAvatar);
|
||||||
|
bool identityChanged = false;
|
||||||
|
bool displayNameChanged = false;
|
||||||
|
// In this case, the "sendingNode" is the Avatar Mixer.
|
||||||
|
avatar->processAvatarIdentity(avatarIdentityStream, identityChanged, displayNameChanged);
|
||||||
|
_replicas.processAvatarIdentity(identityUUID, message->getMessage(), identityChanged, displayNameChanged);
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue