mirror of
https://github.com/HifiExperiments/overte.git
synced 2025-08-05 01:11:24 +02:00
clear avatarEntity data for entities that are deleted
This commit is contained in:
parent
e4e0be8fa3
commit
872f1b0c64
5 changed files with 21 additions and 2 deletions
|
@ -229,7 +229,10 @@ void Avatar::updateAvatarEntities() {
|
|||
EntityItemPointer entity = entityTree->findEntityByEntityItemID(EntityItemID(entityID));
|
||||
|
||||
if (entity) {
|
||||
if (!entityTree->updateEntity(entityID, properties)) {
|
||||
if (entityTree->updateEntity(entityID, properties)) {
|
||||
entity->markAsChangedOnServer();
|
||||
entity->updateLastEditedFromRemote();
|
||||
} else {
|
||||
qDebug() << "AVATAR-ENTITES -- updateEntity failed: " << properties.getType();
|
||||
success = false;
|
||||
}
|
||||
|
|
|
@ -828,6 +828,7 @@ void MyAvatar::loadData() {
|
|||
for (int i = 0; i < avatarEntityCount; i++) {
|
||||
settings.setArrayIndex(i);
|
||||
QUuid entityID = settings.value("id").toUuid();
|
||||
// QUuid entityID = QUuid::createUuid(); // generate a new ID
|
||||
QByteArray properties = settings.value("properties").toByteArray();
|
||||
updateAvatarEntity(entityID, properties);
|
||||
}
|
||||
|
|
|
@ -81,6 +81,8 @@ void EntityEditPacketSender::queueEditAvatarEntityMessage(PacketType type,
|
|||
|
||||
QByteArray binaryProperties = jsonProperties.toBinaryData();
|
||||
_myAvatar->updateAvatarEntity(entityItemID, binaryProperties);
|
||||
|
||||
entity->setLastBroadcast(usecTimestampNow());
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -115,6 +117,10 @@ void EntityEditPacketSender::queueEraseEntityMessage(const EntityItemID& entityI
|
|||
return; // bail early
|
||||
}
|
||||
|
||||
// in case this was a clientOnly entity:
|
||||
assert(_myAvatar);
|
||||
_myAvatar->clearAvatarEntity(entityItemID);
|
||||
|
||||
QByteArray bufferOut(NLPacket::maxPayloadSize(PacketType::EntityErase), 0);
|
||||
|
||||
if (EntityItemProperties::encodeEraseEntityMessage(entityItemID, bufferOut)) {
|
||||
|
|
|
@ -375,6 +375,7 @@ public:
|
|||
glm::vec3 entityToWorld(const glm::vec3& point) const;
|
||||
|
||||
quint64 getLastEditedFromRemote() const { return _lastEditedFromRemote; }
|
||||
void updateLastEditedFromRemote() { _lastEditedFromRemote = usecTimestampNow(); }
|
||||
|
||||
void getAllTerseUpdateProperties(EntityItemProperties& properties) const;
|
||||
|
||||
|
|
|
@ -401,6 +401,14 @@ void EntityScriptingInterface::deleteEntity(QUuid id) {
|
|||
EntityItemPointer entity = _entityTree->findEntityByEntityItemID(entityID);
|
||||
if (entity) {
|
||||
|
||||
auto nodeList = DependencyManager::get<NodeList>();
|
||||
const QUuid myNodeID = nodeList->getSessionUUID();
|
||||
if (entity->getClientOnly() && entity->getOwningAvatarID() != myNodeID) {
|
||||
// don't delete other avatar's avatarEntities
|
||||
shouldDelete = false;
|
||||
return;
|
||||
}
|
||||
|
||||
auto dimensions = entity->getDimensions();
|
||||
float volume = dimensions.x * dimensions.y * dimensions.z;
|
||||
auto density = entity->getDensity();
|
||||
|
@ -806,7 +814,7 @@ bool EntityScriptingInterface::actionWorker(const QUuid& entityID,
|
|||
return;
|
||||
}
|
||||
|
||||
if (entity->getClientOnly() && entity->getOwningAvatarID() != nodeList->getSessionUUID()) {
|
||||
if (entity->getClientOnly() && entity->getOwningAvatarID() != myNodeID) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue