From d1d2b8a4da7807087fb9a37d4e79c19551533c56 Mon Sep 17 00:00:00 2001 From: Seth Alves Date: Mon, 9 Oct 2017 14:02:20 -0700 Subject: [PATCH] don't export avatar-parent sessions IDs into json --- interface/src/Application.cpp | 25 ++++++++++++++++++------- 1 file changed, 18 insertions(+), 7 deletions(-) diff --git a/interface/src/Application.cpp b/interface/src/Application.cpp index 0fc8c46cdc..8820b871f9 100644 --- a/interface/src/Application.cpp +++ b/interface/src/Application.cpp @@ -4030,6 +4030,9 @@ void Application::calibrateEyeTracker5Points() { bool Application::exportEntities(const QString& filename, const QVector& entityIDs, const glm::vec3* givenOffset) { QHash entities; + auto accountManager = DependencyManager::get(); + auto mySessionID = accountManager->getSessionID(); + auto entityTree = getEntities()->getTree(); auto exportTree = std::make_shared(); exportTree->createRootElement(); @@ -4045,8 +4048,12 @@ bool Application::exportEntities(const QString& filename, const QVectorgetParentID(); - if (parentID.isInvalidID() || !entityIDs.contains(parentID) || !entityTree->findEntityByEntityItemID(parentID)) { - auto position = entityItem->getPosition(); // If parent wasn't selected, we want absolute position, which isn't in properties. + bool parentIsAvatar = (parentID == AVATAR_SELF_ID || parentID == mySessionID); + if (!parentIsAvatar && (parentID.isInvalidID() || + !entityIDs.contains(parentID) || + !entityTree->findEntityByEntityItemID(parentID))) { + // If parent wasn't selected, we want absolute position, which isn't in properties. + auto position = entityItem->getPosition(); root.x = glm::min(root.x, position.x); root.y = glm::min(root.y, position.y); root.z = glm::min(root.z, position.z); @@ -4066,12 +4073,16 @@ bool Application::exportEntities(const QString& filename, const QVectorgetProperties(); EntityItemID parentID = properties.getParentID(); - if (parentID.isInvalidID()) { - properties.setPosition(properties.getPosition() - root); + bool parentIsAvatar = (parentID == AVATAR_SELF_ID || parentID == mySessionID); + if (parentIsAvatar) { + properties.setParentID(AVATAR_SELF_ID); + } else { + if (parentID.isInvalidID()) { + properties.setPosition(properties.getPosition() - root); + } else if (!entities.contains(parentID)) { + entityDatum->globalizeProperties(properties, "Parent %3 of %2 %1 is not selected for export.", -root); + } // else valid parent -- don't offset } - else if (!entities.contains(parentID)) { - entityDatum->globalizeProperties(properties, "Parent %3 of %2 %1 is not selected for export.", -root); - } // else valid parent -- don't offset exportTree->addEntity(entityDatum->getEntityItemID(), properties); } });