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 | 4030 | bool Application::exportEntities(const QString& filename, const QVector<EntityItemID>& entityIDs, const glm::vec3* givenOffset) { |
| 4031 | 4031 | QHash<EntityItemID, EntityItemPointer> entities; |
| 4032 | 4032 | |
| 4033 | + auto accountManager = DependencyManager::get<AccountManager>(); | |
| 4034 | + auto mySessionID = accountManager->getSessionID(); | |
| 4035 | + | |
| 4033 | 4036 | auto entityTree = getEntities()->getTree(); |
| 4034 | 4037 | auto exportTree = std::make_shared<EntityTree>(); |
| 4035 | 4038 | exportTree->createRootElement(); |
| @@ -4045,8 +4048,12 @@ bool Application::exportEntities(const QString& filename, const QVector<EntityIt · 9 unmodified lines | ||
| 4045 | 4048 | |
| 4046 | 4049 | if (!givenOffset) { |
| 4047 | 4050 | 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(); | |
| 4050 | 4057 | root.x = glm::min(root.x, position.x); |
| 4051 | 4058 | root.y = glm::min(root.y, position.y); |
| 4052 | 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 | 4073 | for (EntityItemPointer& entityDatum : entities) { |
| 4067 | 4074 | auto properties = entityDatum->getProperties(); |
| 4068 | 4075 | 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 | |
| 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 | 4086 | exportTree->addEntity(entityDatum->getEntityItemID(), properties); |
| 4076 | 4087 | } |
| 4077 | 4088 | }); |