delete avatar entity when switching domains

This commit is contained in:
Dante Ruiz 2017-07-17 21:27:55 +01:00
parent 806d9f1436
commit f6208a394c
2 changed files with 5 additions and 0 deletions

View file

@ -615,6 +615,7 @@ public:
Q_INVOKABLE AvatarEntityMap getAvatarEntityData() const;
Q_INVOKABLE void setAvatarEntityData(const AvatarEntityMap& avatarEntityData);
void setAvatarEntityDataChanged(bool value) { _avatarEntityDataChanged = value; }
void insertDetachedEntityID(const QUuid entityID) { _avatarEntityDetached.insert(entityID); }
AvatarEntityIDs getAndClearRecentlyDetachedIDs();
// thread safe

View file

@ -21,6 +21,7 @@
#include <VariantMapToScriptValue.h>
#include <SharedUtil.h>
#include <SpatialParentFinder.h>
#include <AvatarHashMap.h>
#include "EntityItemID.h"
#include "EntitiesLogging.h"
@ -497,8 +498,11 @@ void EntityScriptingInterface::deleteEntity(QUuid id) {
auto nodeList = DependencyManager::get<NodeList>();
const QUuid myNodeID = nodeList->getSessionUUID();
auto avatarHashMap = DependencyManager::get<AvatarHashMap>();
AvatarSharedPointer myAvatar = avatarHashMap->getAvatarBySessionID(myNodeID);
if (entity->getClientOnly() && entity->getOwningAvatarID() != myNodeID) {
// don't delete other avatar's avatarEntities
myAvatar->insertDetachedEntityID(id);
shouldDelete = false;
return;
}