mirror of
https://github.com/overte-org/overte.git
synced 2025-08-10 01:24:36 +02:00
Merge pull request #15255 from AndrewMeadows/fix-owningAvataID
Case 21897: fix bug where AvatarEntities vanish after going to serverless and back
This commit is contained in:
commit
d464415e0b
1 changed files with 8 additions and 10 deletions
|
@ -3466,11 +3466,6 @@ void MyAvatar::setSessionUUID(const QUuid& sessionUUID) {
|
||||||
QUuid oldSessionID = getSessionUUID();
|
QUuid oldSessionID = getSessionUUID();
|
||||||
Avatar::setSessionUUID(sessionUUID);
|
Avatar::setSessionUUID(sessionUUID);
|
||||||
QUuid newSessionID = getSessionUUID();
|
QUuid newSessionID = getSessionUUID();
|
||||||
if (DependencyManager::get<NodeList>()->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) {
|
if (newSessionID != oldSessionID) {
|
||||||
auto treeRenderer = DependencyManager::get<EntityTreeRenderer>();
|
auto treeRenderer = DependencyManager::get<EntityTreeRenderer>();
|
||||||
EntityTreePointer entityTree = treeRenderer ? treeRenderer->getTree() : nullptr;
|
EntityTreePointer entityTree = treeRenderer ? treeRenderer->getTree() : nullptr;
|
||||||
|
@ -3479,6 +3474,7 @@ void MyAvatar::setSessionUUID(const QUuid& sessionUUID) {
|
||||||
_avatarEntitiesLock.withReadLock([&] {
|
_avatarEntitiesLock.withReadLock([&] {
|
||||||
avatarEntityIDs = _packedAvatarEntityData.keys();
|
avatarEntityIDs = _packedAvatarEntityData.keys();
|
||||||
});
|
});
|
||||||
|
bool sendPackets = !DependencyManager::get<NodeList>()->getSessionUUID().isNull();
|
||||||
EntityEditPacketSender* packetSender = qApp->getEntityEditPacketSender();
|
EntityEditPacketSender* packetSender = qApp->getEntityEditPacketSender();
|
||||||
entityTree->withWriteLock([&] {
|
entityTree->withWriteLock([&] {
|
||||||
for (const auto& entityID : avatarEntityIDs) {
|
for (const auto& entityID : avatarEntityIDs) {
|
||||||
|
@ -3486,12 +3482,14 @@ void MyAvatar::setSessionUUID(const QUuid& sessionUUID) {
|
||||||
if (!entity) {
|
if (!entity) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
// update OwningAvatarID so entity can be identified as "ours" later
|
||||||
entity->setOwningAvatarID(newSessionID);
|
entity->setOwningAvatarID(newSessionID);
|
||||||
// NOTE: each attached AvatarEntity should already have the correct updated parentID
|
// NOTE: each attached AvatarEntity already have the correct updated parentID
|
||||||
// via magic in SpatiallyNestable, but when an AvatarEntity IS parented to MyAvatar
|
// via magic in SpatiallyNestable, hence we check against newSessionID
|
||||||
// we need to update the "packedAvatarEntityData" we send to the avatar-mixer
|
if (sendPackets && entity->getParentID() == newSessionID) {
|
||||||
// so that others will get the updated state.
|
// but when we have a real session and the AvatarEntity is parented to MyAvatar
|
||||||
if (entity->getParentID() == newSessionID) {
|
// we need to update the "packedAvatarEntityData" sent to the avatar-mixer
|
||||||
|
// because it contains a stale parentID somewhere deep inside
|
||||||
packetSender->queueEditAvatarEntityMessage(entityTree, entityID);
|
packetSender->queueEditAvatarEntityMessage(entityTree, entityID);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue