diff --git a/interface/src/Application.cpp b/interface/src/Application.cpp index d22ab8655d..166903c26c 100644 --- a/interface/src/Application.cpp +++ b/interface/src/Application.cpp @@ -4003,6 +4003,7 @@ bool Application::exportEntities(const QString& filename, auto entityTree = getEntities()->getTree(); auto exportTree = std::make_shared(); + exportTree->setMyAvatar(getMyAvatar()); exportTree->createRootElement(); glm::vec3 root(TREE_SCALE, TREE_SCALE, TREE_SCALE); bool success = true; diff --git a/libraries/entities/src/EntityTree.cpp b/libraries/entities/src/EntityTree.cpp index 0957bb8444..229269ad21 100644 --- a/libraries/entities/src/EntityTree.cpp +++ b/libraries/entities/src/EntityTree.cpp @@ -2254,7 +2254,8 @@ bool EntityTree::writeToMap(QVariantMap& entityDescription, OctreeElementPointer entityDescription["Entities"] = QVariantList(); } QScriptEngine scriptEngine; - RecurseOctreeToMapOperator theOperator(entityDescription, element, &scriptEngine, skipDefaultValues, skipThoseWithBadParents); + RecurseOctreeToMapOperator theOperator(entityDescription, element, &scriptEngine, skipDefaultValues, + skipThoseWithBadParents, _myAvatar); recurseTreeWithOperator(&theOperator); return true; } diff --git a/libraries/entities/src/RecurseOctreeToMapOperator.cpp b/libraries/entities/src/RecurseOctreeToMapOperator.cpp index 217dc0db12..5be921112f 100644 --- a/libraries/entities/src/RecurseOctreeToMapOperator.cpp +++ b/libraries/entities/src/RecurseOctreeToMapOperator.cpp @@ -17,13 +17,15 @@ RecurseOctreeToMapOperator::RecurseOctreeToMapOperator(QVariantMap& map, const OctreeElementPointer& top, QScriptEngine* engine, bool skipDefaultValues, - bool skipThoseWithBadParents) : + bool skipThoseWithBadParents, + std::shared_ptr myAvatar) : RecurseOctreeOperator(), _map(map), _top(top), _engine(engine), _skipDefaultValues(skipDefaultValues), - _skipThoseWithBadParents(skipThoseWithBadParents) + _skipThoseWithBadParents(skipThoseWithBadParents), + _myAvatar(myAvatar) { // if some element "top" was given, only save information for that element and its children. if (_top) { @@ -60,6 +62,18 @@ bool RecurseOctreeToMapOperator::postRecursion(const OctreeElementPointer& eleme } else { qScriptValues = EntityItemPropertiesToScriptValue(_engine, properties); } + + // handle parentJointName for wearables + if (_myAvatar && entityItem->getParentID() == AVATAR_SELF_ID && + entityItem->getParentJointIndex() != INVALID_JOINT_INDEX) { + + auto jointNames = _myAvatar->getJointNames(); + auto parentJointIndex = entityItem->getParentJointIndex(); + if (parentJointIndex < jointNames.count()) { + qScriptValues.setProperty("parentJointName", jointNames.at(parentJointIndex)); + } + } + entitiesQList << qScriptValues.toVariant(); }); diff --git a/libraries/entities/src/RecurseOctreeToMapOperator.h b/libraries/entities/src/RecurseOctreeToMapOperator.h index c661badd88..985ec9de35 100644 --- a/libraries/entities/src/RecurseOctreeToMapOperator.h +++ b/libraries/entities/src/RecurseOctreeToMapOperator.h @@ -14,7 +14,7 @@ class RecurseOctreeToMapOperator : public RecurseOctreeOperator { public: RecurseOctreeToMapOperator(QVariantMap& map, const OctreeElementPointer& top, QScriptEngine* engine, bool skipDefaultValues, - bool skipThoseWithBadParents); + bool skipThoseWithBadParents, std::shared_ptr myAvatar); bool preRecursion(const OctreeElementPointer& element) override; bool postRecursion(const OctreeElementPointer& element) override; private: @@ -24,4 +24,5 @@ public: bool _withinTop; bool _skipDefaultValues; bool _skipThoseWithBadParents; + std::shared_ptr _myAvatar; };