From 50dd865bdc763aeaafb9d68fc4e268c2f804c193 Mon Sep 17 00:00:00 2001 From: danteruiz Date: Mon, 11 Feb 2019 16:48:34 -0800 Subject: [PATCH 1/2] fix spatially nestable parent overwrite --- interface/src/avatar/OtherAvatar.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/interface/src/avatar/OtherAvatar.cpp b/interface/src/avatar/OtherAvatar.cpp index a3950c8e96..8ad9c6b121 100755 --- a/interface/src/avatar/OtherAvatar.cpp +++ b/interface/src/avatar/OtherAvatar.cpp @@ -489,6 +489,9 @@ void OtherAvatar::handleChangedAvatarEntityData() { bool success = true; if (entity) { QUuid oldParentID = entity->getParentID(); + const QUuid NULL_ID = QUuid("{00000000-0000-0000-0000-000000000005}"); + entity->setParentID(NULL_ID); + entity->setParentID(oldParentID); if (entityTree->updateEntity(entityID, properties)) { entity->updateLastEditedFromRemote(); } else { From fdfb9196d351a7811e71b463850a627b64035fe9 Mon Sep 17 00:00:00 2001 From: danteruiz Date: Tue, 12 Feb 2019 11:45:08 -0800 Subject: [PATCH 2/2] comments explaining horrible code --- interface/src/avatar/OtherAvatar.cpp | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/interface/src/avatar/OtherAvatar.cpp b/interface/src/avatar/OtherAvatar.cpp index 8ad9c6b121..9496336ae1 100755 --- a/interface/src/avatar/OtherAvatar.cpp +++ b/interface/src/avatar/OtherAvatar.cpp @@ -447,6 +447,10 @@ void OtherAvatar::handleChangedAvatarEntityData() { EntityItemProperties properties; int32_t bytesLeftToRead = data.size(); unsigned char* dataAt = (unsigned char*)(data.data()); + // FIXME: This function will cause unintented changes in SpaillyNestable + // E.g overriding the ID index of an exisiting entity to temporary entity + // in the following map QHash _children; + // Andrew Meadows will address this issue if (!properties.constructFromBuffer(dataAt, bytesLeftToRead)) { // properties are corrupt continue; @@ -489,6 +493,14 @@ void OtherAvatar::handleChangedAvatarEntityData() { bool success = true; if (entity) { QUuid oldParentID = entity->getParentID(); + + // Since has overwrtiiten the back pointer + // from the parent children map (see comment for function call above), + // we need to for reset the back pointer in the map correctly by setting the parentID, but + // since the parentID of the entity has not changed we first need to set it some ither ID, + // then set the the original ID for the changes to take effect + // TODO: This is a horrible hack and once properties.constructFromBuffer no longer causes + // side effects...remove the following three lines const QUuid NULL_ID = QUuid("{00000000-0000-0000-0000-000000000005}"); entity->setParentID(NULL_ID); entity->setParentID(oldParentID);