History

don't export avatar-parent sessions IDs into json

Seth Alves committed 9 years ago

Commit d1d2b8a1 parent 13da20e1 file · +18 −7Browse files

Showing the changes to interface/src/Application.cpp (1 of 1 file). Show all

Unified · Split

interface/src/Application.cpp+18−7
@@ -4030,6 +4030,9 @@ void Application::calibrateEyeTracker5Points() { · 4029 unmodified lines
40304030 bool Application::exportEntities(const QString& filename, const QVector<EntityItemID>& entityIDs, const glm::vec3* givenOffset) {
40314031 QHash<EntityItemID, EntityItemPointer> entities;
40324032
4033+ auto accountManager = DependencyManager::get<AccountManager>();
4034+ auto mySessionID = accountManager->getSessionID();
4035+
40334036 auto entityTree = getEntities()->getTree();
40344037 auto exportTree = std::make_shared<EntityTree>();
40354038 exportTree->createRootElement();
@@ -4045,8 +4048,12 @@ bool Application::exportEntities(const QString& filename, const QVector<EntityIt · 9 unmodified lines
40454048
40464049 if (!givenOffset) {
40474050 EntityItemID parentID = entityItem->getParentID();
4048− if (parentID.isInvalidID() || !entityIDs.contains(parentID) || !entityTree->findEntityByEntityItemID(parentID)) {
4049− auto position = entityItem->getPosition(); // If parent wasn't selected, we want absolute position, which isn't in properties.
4051+ bool parentIsAvatar = (parentID == AVATAR_SELF_ID || parentID == mySessionID);
4052+ if (!parentIsAvatar && (parentID.isInvalidID() ||
4053+ !entityIDs.contains(parentID) ||
4054+ !entityTree->findEntityByEntityItemID(parentID))) {
4055+ // If parent wasn't selected, we want absolute position, which isn't in properties.
4056+ auto position = entityItem->getPosition();
40504057 root.x = glm::min(root.x, position.x);
40514058 root.y = glm::min(root.y, position.y);
40524059 root.z = glm::min(root.z, position.z);
@@ -4066,12 +4073,16 @@ bool Application::exportEntities(const QString& filename, const QVector<EntityIt · 13 unmodified lines
40664073 for (EntityItemPointer& entityDatum : entities) {
40674074 auto properties = entityDatum->getProperties();
40684075 EntityItemID parentID = properties.getParentID();
4069− if (parentID.isInvalidID()) {
4070− properties.setPosition(properties.getPosition() - root);
4076+ bool parentIsAvatar = (parentID == AVATAR_SELF_ID || parentID == mySessionID);
4077+ if (parentIsAvatar) {
4078+ properties.setParentID(AVATAR_SELF_ID);
4079+ } else {
4080+ if (parentID.isInvalidID()) {
4081+ properties.setPosition(properties.getPosition() - root);
4082+ } else if (!entities.contains(parentID)) {
4083+ entityDatum->globalizeProperties(properties, "Parent %3 of %2 %1 is not selected for export.", -root);
4084+ } // else valid parent -- don't offset
40714085 }
4072− else if (!entities.contains(parentID)) {
4073− entityDatum->globalizeProperties(properties, "Parent %3 of %2 %1 is not selected for export.", -root);
4074− } // else valid parent -- don't offset
40754086 exportTree->addEntity(entityDatum->getEntityItemID(), properties);
40764087 }
40774088 });