Showing the changes to interface/src/Application.cpp (1 of 1 file). Show all
Unified · Split
| @@ -4030,6 +4030,9 @@ void Application::calibrateEyeTracker5Points() { · 4029 unmodified lines | |||
| 4030 | bool Application::exportEntities(const QString& filename, const QVector<EntityItemID>& entityIDs, const glm::vec3* givenOffset) { | 4030 | bool Application::exportEntities(const QString& filename, const QVector<EntityItemID>& entityIDs, const glm::vec3* givenOffset) { |
| 4031 | QHash<EntityItemID, EntityItemPointer> entities; | 4031 | QHash<EntityItemID, EntityItemPointer> entities; |
| 4032 | 4032 | ||
| 4033 | auto accountManager = DependencyManager::get<AccountManager>(); | ||
| 4034 | auto mySessionID = accountManager->getSessionID(); | ||
| 4035 | |||
| 4033 | auto entityTree = getEntities()->getTree(); | 4036 | auto entityTree = getEntities()->getTree(); |
| 4034 | auto exportTree = std::make_shared<EntityTree>(); | 4037 | auto exportTree = std::make_shared<EntityTree>(); |
| 4035 | exportTree->createRootElement(); | 4038 | exportTree->createRootElement(); |
| @@ -4045,8 +4048,12 @@ bool Application::exportEntities(const QString& filename, const QVector<EntityIt · 9 unmodified lines | |||
| 4045 | 4048 | ||
| 4046 | if (!givenOffset) { | 4049 | if (!givenOffset) { |
| 4047 | EntityItemID parentID = entityItem->getParentID(); | 4050 | EntityItemID parentID = entityItem->getParentID(); |
| 4048 | if (parentID.isInvalidID() || !entityIDs.contains(parentID) || !entityTree->findEntityByEntityItemID(parentID)) { | 4051 | bool parentIsAvatar = (parentID == AVATAR_SELF_ID || parentID == mySessionID); |
| 4049 | auto position = entityItem->getPosition(); // If parent wasn't selected, we want absolute position, which isn't in properties. | 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(); | ||
| 4050 | root.x = glm::min(root.x, position.x); | 4057 | root.x = glm::min(root.x, position.x); |
| 4051 | root.y = glm::min(root.y, position.y); | 4058 | root.y = glm::min(root.y, position.y); |
| 4052 | root.z = glm::min(root.z, position.z); | 4059 | root.z = glm::min(root.z, position.z); |
| @@ -4066,12 +4073,16 @@ bool Application::exportEntities(const QString& filename, const QVector<EntityIt · 13 unmodified lines | |||
| 4066 | for (EntityItemPointer& entityDatum : entities) { | 4073 | for (EntityItemPointer& entityDatum : entities) { |
| 4067 | auto properties = entityDatum->getProperties(); | 4074 | auto properties = entityDatum->getProperties(); |
| 4068 | EntityItemID parentID = properties.getParentID(); | 4075 | EntityItemID parentID = properties.getParentID(); |
| 4069 | if (parentID.isInvalidID()) { | 4076 | bool parentIsAvatar = (parentID == AVATAR_SELF_ID || parentID == mySessionID); |
| 4070 | properties.setPosition(properties.getPosition() - root); | 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 | ||
| 4071 | } | 4085 | } |
| 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 | ||
| 4075 | exportTree->addEntity(entityDatum->getEntityItemID(), properties); | 4086 | exportTree->addEntity(entityDatum->getEntityItemID(), properties); |
| 4076 | } | 4087 | } |
| 4077 | }); | 4088 | }); |