mirror of
https://github.com/lubosz/overte.git
synced 2025-04-26 15:55:26 +02:00
always add to detached, flag update on full replace
This commit is contained in:
parent
99f532a20e
commit
4875738a05
2 changed files with 17 additions and 13 deletions
libraries
|
@ -355,21 +355,21 @@ void Avatar::updateAvatarEntities() {
|
|||
stateItr.value().success = success;
|
||||
}
|
||||
|
||||
AvatarEntityIDs recentlyDettachedAvatarEntities = getAndClearRecentlyDetachedIDs();
|
||||
if (!recentlyDettachedAvatarEntities.empty()) {
|
||||
AvatarEntityIDs recentlyDetachedAvatarEntities = getAndClearRecentlyDetachedIDs();
|
||||
if (!recentlyDetachedAvatarEntities.empty()) {
|
||||
// only lock this thread when absolutely necessary
|
||||
AvatarEntityMap avatarEntityData;
|
||||
_avatarEntitiesLock.withReadLock([&] {
|
||||
avatarEntityData = _avatarEntityData;
|
||||
});
|
||||
foreach (auto entityID, recentlyDettachedAvatarEntities) {
|
||||
foreach (auto entityID, recentlyDetachedAvatarEntities) {
|
||||
if (!avatarEntityData.contains(entityID)) {
|
||||
entityTree->deleteEntity(entityID, true, true);
|
||||
}
|
||||
}
|
||||
|
||||
// remove stale data hashes
|
||||
foreach (auto entityID, recentlyDettachedAvatarEntities) {
|
||||
foreach (auto entityID, recentlyDetachedAvatarEntities) {
|
||||
MapOfAvatarEntityDataHashes::iterator stateItr = _avatarEntityDataHashes.find(entityID);
|
||||
if (stateItr != _avatarEntityDataHashes.end()) {
|
||||
_avatarEntityDataHashes.erase(stateItr);
|
||||
|
|
|
@ -2721,16 +2721,12 @@ void AvatarData::clearAvatarEntity(const QUuid& entityID, bool requiresRemovalFr
|
|||
removedEntity = _avatarEntityData.remove(entityID);
|
||||
});
|
||||
|
||||
if (removedEntity) {
|
||||
if (requiresRemovalFromTree) {
|
||||
insertDetachedEntityID(entityID);
|
||||
}
|
||||
insertDetachedEntityID(entityID);
|
||||
|
||||
if (_clientTraitsHandler) {
|
||||
// we have a client traits handler, so we need to mark this removed instance trait as deleted
|
||||
// so that changes are sent next frame
|
||||
_clientTraitsHandler->markInstancedTraitDeleted(AvatarTraits::AvatarEntity, entityID);
|
||||
}
|
||||
if (removedEntity && _clientTraitsHandler) {
|
||||
// we have a client traits handler, so we need to mark this removed instance trait as deleted
|
||||
// so that changes are sent next frame
|
||||
_clientTraitsHandler->markInstancedTraitDeleted(AvatarTraits::AvatarEntity, entityID);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2775,6 +2771,14 @@ void AvatarData::setAvatarEntityData(const AvatarEntityMap& avatarEntityData) {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (_clientTraitsHandler) {
|
||||
// if we have a client traits handler, flag any updated or created entities
|
||||
// so that we send changes for them next frame
|
||||
foreach (auto entityID, _avatarEntityData) {
|
||||
_clientTraitsHandler->markInstancedTraitUpdated(AvatarTraits::AvatarEntity, entityID);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue