server only deletes and entity if it's still the child of an avatar, not if it has ever been

This commit is contained in:
Seth Alves 2017-09-28 19:56:15 -07:00
parent bd8dbe4aae
commit 72cacc4cef
3 changed files with 14 additions and 2 deletions

View file

@ -1570,13 +1570,17 @@ void EntityItem::updatePosition(const glm::vec3& value) {
}
void EntityItem::updateParentID(const QUuid& value) {
if (getParentID() != value) {
QUuid oldParentID = getParentID();
if (oldParentID != value) {
EntityTreePointer tree = getTree();
if (!oldParentID.isNull()) {
tree->removeFromChildrenOfAvatars(getThisPointer());
}
setParentID(value);
// children are forced to be kinematic
// may need to not collide with own avatar
markDirtyFlags(Simulation::DIRTY_MOTION_TYPE | Simulation::DIRTY_COLLISION_GROUP);
EntityTreePointer tree = getTree();
if (tree) {
tree->addToNeedsParentFixupList(getThisPointer());
}

View file

@ -1326,6 +1326,13 @@ void EntityTree::deleteDescendantsOfAvatar(QUuid avatarID) {
}
}
void EntityTree::removeFromChildrenOfAvatars(EntityItemPointer entity) {
QUuid avatarID = entity->getParentID();
if (_childrenOfAvatars.contains(avatarID)) {
_childrenOfAvatars[avatarID].remove(entity->getID());
}
}
void EntityTree::addToNeedsParentFixupList(EntityItemPointer entity) {
QWriteLocker locker(&_needsParentFixupLock);
_needsParentFixup.append(entity);

View file

@ -254,6 +254,7 @@ public:
void knowAvatarID(QUuid avatarID) { _avatarIDs += avatarID; }
void forgetAvatarID(QUuid avatarID) { _avatarIDs -= avatarID; }
void deleteDescendantsOfAvatar(QUuid avatarID);
void removeFromChildrenOfAvatars(EntityItemPointer entity);
void addToNeedsParentFixupList(EntityItemPointer entity);