From 55b3b5034a0dad81c70dc499033ac478fc3d6a4a Mon Sep 17 00:00:00 2001 From: Andrew Meadows Date: Fri, 22 Mar 2019 15:47:13 -0700 Subject: [PATCH 1/2] always update OwingAvatarID of AvatarEntities --- interface/src/avatar/MyAvatar.cpp | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/interface/src/avatar/MyAvatar.cpp b/interface/src/avatar/MyAvatar.cpp index 298e661f24..4ea0d37710 100644 --- a/interface/src/avatar/MyAvatar.cpp +++ b/interface/src/avatar/MyAvatar.cpp @@ -3454,11 +3454,6 @@ void MyAvatar::setSessionUUID(const QUuid& sessionUUID) { QUuid oldSessionID = getSessionUUID(); Avatar::setSessionUUID(sessionUUID); QUuid newSessionID = getSessionUUID(); - if (DependencyManager::get()->getSessionUUID().isNull()) { - // we don't actually have a connection to a domain right now - // so there is no need to queue AvatarEntity messages --> bail early - return; - } if (newSessionID != oldSessionID) { auto treeRenderer = DependencyManager::get(); EntityTreePointer entityTree = treeRenderer ? treeRenderer->getTree() : nullptr; @@ -3467,6 +3462,7 @@ void MyAvatar::setSessionUUID(const QUuid& sessionUUID) { _avatarEntitiesLock.withReadLock([&] { avatarEntityIDs = _packedAvatarEntityData.keys(); }); + bool sendPackets = DependencyManager::get()->getSessionUUID().isNull(); EntityEditPacketSender* packetSender = qApp->getEntityEditPacketSender(); entityTree->withWriteLock([&] { for (const auto& entityID : avatarEntityIDs) { @@ -3474,12 +3470,14 @@ void MyAvatar::setSessionUUID(const QUuid& sessionUUID) { if (!entity) { continue; } + // update OwningAvatarID so entity can be identified as "ours" later entity->setOwningAvatarID(newSessionID); - // NOTE: each attached AvatarEntity should already have the correct updated parentID - // via magic in SpatiallyNestable, but when an AvatarEntity IS parented to MyAvatar - // we need to update the "packedAvatarEntityData" we send to the avatar-mixer - // so that others will get the updated state. - if (entity->getParentID() == newSessionID) { + // NOTE: each attached AvatarEntity already have the correct updated parentID + // via magic in SpatiallyNestable, hence we check agains newSessionID + if (sendPackets && entity->getParentID() == newSessionID) { + // but when we have a real session and the AvatarEntity is parented to MyAvatar + // we need to update the "packedAvatarEntityData" sent to the avatar-mixer + // because it contains a stale parentID somewhere deep inside packetSender->queueEditAvatarEntityMessage(entityTree, entityID); } } From cd2dbbb955012431b92886756ca11d0d6d6e91d4 Mon Sep 17 00:00:00 2001 From: Andrew Meadows Date: Mon, 25 Mar 2019 11:52:52 -0700 Subject: [PATCH 2/2] fix logic typo --- interface/src/avatar/MyAvatar.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/interface/src/avatar/MyAvatar.cpp b/interface/src/avatar/MyAvatar.cpp index 4ea0d37710..b204588774 100644 --- a/interface/src/avatar/MyAvatar.cpp +++ b/interface/src/avatar/MyAvatar.cpp @@ -3462,7 +3462,7 @@ void MyAvatar::setSessionUUID(const QUuid& sessionUUID) { _avatarEntitiesLock.withReadLock([&] { avatarEntityIDs = _packedAvatarEntityData.keys(); }); - bool sendPackets = DependencyManager::get()->getSessionUUID().isNull(); + bool sendPackets = !DependencyManager::get()->getSessionUUID().isNull(); EntityEditPacketSender* packetSender = qApp->getEntityEditPacketSender(); entityTree->withWriteLock([&] { for (const auto& entityID : avatarEntityIDs) { @@ -3473,7 +3473,7 @@ void MyAvatar::setSessionUUID(const QUuid& sessionUUID) { // update OwningAvatarID so entity can be identified as "ours" later entity->setOwningAvatarID(newSessionID); // NOTE: each attached AvatarEntity already have the correct updated parentID - // via magic in SpatiallyNestable, hence we check agains newSessionID + // via magic in SpatiallyNestable, hence we check against newSessionID if (sendPackets && entity->getParentID() == newSessionID) { // but when we have a real session and the AvatarEntity is parented to MyAvatar // we need to update the "packedAvatarEntityData" sent to the avatar-mixer