mirror of
https://github.com/JulianGro/overte.git
synced 2025-04-08 19:23:28 +02:00
Merge pull request #15231 from AndrewMeadows/fix-vanishing-avatar-entities
Case 21838: fix vanishing avatar entities for 0.82.0
This commit is contained in:
commit
212f02598c
6 changed files with 26 additions and 23 deletions
|
@ -1570,7 +1570,7 @@ void MyAvatar::handleChangedAvatarEntityData() {
|
|||
entityTree->withWriteLock([&] {
|
||||
EntityItemPointer entity = entityTree->addEntity(id, properties);
|
||||
if (entity) {
|
||||
packetSender->queueEditEntityMessage(PacketType::EntityAdd, entityTree, id, properties);
|
||||
packetSender->queueEditAvatarEntityMessage(entityTree, id);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
@ -3451,10 +3451,15 @@ float MyAvatar::getGravity() {
|
|||
}
|
||||
|
||||
void MyAvatar::setSessionUUID(const QUuid& sessionUUID) {
|
||||
QUuid oldID = getSessionUUID();
|
||||
QUuid oldSessionID = getSessionUUID();
|
||||
Avatar::setSessionUUID(sessionUUID);
|
||||
QUuid id = getSessionUUID();
|
||||
if (id != oldID) {
|
||||
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) {
|
||||
auto treeRenderer = DependencyManager::get<EntityTreeRenderer>();
|
||||
EntityTreePointer entityTree = treeRenderer ? treeRenderer->getTree() : nullptr;
|
||||
if (entityTree) {
|
||||
|
@ -3462,15 +3467,20 @@ void MyAvatar::setSessionUUID(const QUuid& sessionUUID) {
|
|||
_avatarEntitiesLock.withReadLock([&] {
|
||||
avatarEntityIDs = _packedAvatarEntityData.keys();
|
||||
});
|
||||
EntityEditPacketSender* packetSender = qApp->getEntityEditPacketSender();
|
||||
entityTree->withWriteLock([&] {
|
||||
for (const auto& entityID : avatarEntityIDs) {
|
||||
auto entity = entityTree->findEntityByID(entityID);
|
||||
if (!entity) {
|
||||
continue;
|
||||
}
|
||||
entity->setOwningAvatarID(id);
|
||||
if (entity->getParentID() == oldID) {
|
||||
entity->setParentID(id);
|
||||
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) {
|
||||
packetSender->queueEditAvatarEntityMessage(entityTree, entityID);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
@ -5523,14 +5533,14 @@ void MyAvatar::initFlowFromFST() {
|
|||
}
|
||||
}
|
||||
|
||||
void MyAvatar::sendPacket(const QUuid& entityID, const EntityItemProperties& properties) const {
|
||||
void MyAvatar::sendPacket(const QUuid& entityID) const {
|
||||
auto treeRenderer = DependencyManager::get<EntityTreeRenderer>();
|
||||
EntityTreePointer entityTree = treeRenderer ? treeRenderer->getTree() : nullptr;
|
||||
if (entityTree) {
|
||||
entityTree->withWriteLock([&] {
|
||||
// force an update packet
|
||||
EntityEditPacketSender* packetSender = qApp->getEntityEditPacketSender();
|
||||
packetSender->queueEditEntityMessage(PacketType::EntityEdit, entityTree, entityID, properties);
|
||||
packetSender->queueEditAvatarEntityMessage(entityTree, entityID);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1919,7 +1919,7 @@ private:
|
|||
bool didTeleport();
|
||||
bool getIsAway() const { return _isAway; }
|
||||
void setAway(bool value);
|
||||
void sendPacket(const QUuid& entityID, const EntityItemProperties& properties) const override;
|
||||
void sendPacket(const QUuid& entityID) const override;
|
||||
|
||||
std::mutex _pinnedJointsMutex;
|
||||
std::vector<int> _pinnedJoints;
|
||||
|
|
|
@ -376,7 +376,7 @@ bool Avatar::applyGrabChanges() {
|
|||
const EntityItemPointer& entity = std::dynamic_pointer_cast<EntityItem>(target);
|
||||
if (entity && entity->getEntityHostType() == entity::HostType::AVATAR && entity->getSimulationOwner().getID() == getID()) {
|
||||
EntityItemProperties properties = entity->getProperties();
|
||||
sendPacket(entity->getID(), properties);
|
||||
sendPacket(entity->getID());
|
||||
}
|
||||
}
|
||||
} else {
|
||||
|
|
|
@ -605,7 +605,7 @@ protected:
|
|||
|
||||
// protected methods...
|
||||
bool isLookingAtMe(AvatarSharedPointer avatar) const;
|
||||
virtual void sendPacket(const QUuid& entityID, const EntityItemProperties& properties) const { }
|
||||
virtual void sendPacket(const QUuid& entityID) const { }
|
||||
bool applyGrabChanges();
|
||||
void relayJointDataToChildren();
|
||||
|
||||
|
|
|
@ -39,9 +39,7 @@ void EntityEditPacketSender::adjustEditPacketForClockSkew(PacketType type, QByte
|
|||
}
|
||||
}
|
||||
|
||||
void EntityEditPacketSender::queueEditAvatarEntityMessage(EntityTreePointer entityTree,
|
||||
EntityItemID entityItemID,
|
||||
const EntityItemProperties& properties) {
|
||||
void EntityEditPacketSender::queueEditAvatarEntityMessage(EntityTreePointer entityTree, EntityItemID entityItemID) {
|
||||
assert(_myAvatar);
|
||||
if (!entityTree) {
|
||||
qCDebug(entities) << "EntityEditPacketSender::queueEditAvatarEntityMessage null entityTree.";
|
||||
|
@ -54,11 +52,6 @@ void EntityEditPacketSender::queueEditAvatarEntityMessage(EntityTreePointer enti
|
|||
}
|
||||
entity->setLastBroadcast(usecTimestampNow());
|
||||
|
||||
// serialize ALL properties in an "AvatarEntity" packet
|
||||
// rather than just the ones being edited.
|
||||
EntityItemProperties entityProperties = entity->getProperties();
|
||||
entityProperties.merge(properties);
|
||||
|
||||
OctreePacketData packetData(false, AvatarTraits::MAXIMUM_TRAIT_SIZE);
|
||||
EncodeBitstreamParams params;
|
||||
EntityTreeElementExtraEncodeDataPointer extra { nullptr };
|
||||
|
@ -82,7 +75,7 @@ void EntityEditPacketSender::queueEditEntityMessage(PacketType type,
|
|||
qCWarning(entities) << "Suppressing entity edit message: cannot send avatar entity edit with no myAvatar";
|
||||
} else if (properties.getOwningAvatarID() == _myAvatar->getID()) {
|
||||
// this is an avatar-based entity --> update our avatar-data rather than sending to the entity-server
|
||||
queueEditAvatarEntityMessage(entityTree, entityItemID, properties);
|
||||
queueEditAvatarEntityMessage(entityTree, entityItemID);
|
||||
} else {
|
||||
qCWarning(entities) << "Suppressing entity edit message: cannot send avatar entity edit for another avatar";
|
||||
}
|
||||
|
|
|
@ -50,8 +50,8 @@ public slots:
|
|||
void processEntityEditNackPacket(QSharedPointer<ReceivedMessage> message, SharedNodePointer sendingNode);
|
||||
|
||||
private:
|
||||
void queueEditAvatarEntityMessage(EntityTreePointer entityTree,
|
||||
EntityItemID entityItemID, const EntityItemProperties& properties);
|
||||
friend class MyAvatar;
|
||||
void queueEditAvatarEntityMessage(EntityTreePointer entityTree, EntityItemID entityItemID);
|
||||
|
||||
private:
|
||||
std::mutex _mutex;
|
||||
|
|
Loading…
Reference in a new issue