mirror of
https://github.com/overte-org/overte.git
synced 2025-04-19 13:43:49 +02:00
Merge pull request #11845 from thoys/feat/parentJointName
Import JSON parentJointName value
This commit is contained in:
commit
5dadec0b93
5 changed files with 40 additions and 4 deletions
|
@ -1185,6 +1185,10 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer, bo
|
|||
_entityEditSender.setServerJurisdictions(&_entityServerJurisdictions);
|
||||
_entityEditSender.setMyAvatar(myAvatar.get());
|
||||
|
||||
// The entity octree will have to know about MyAvatar for the parentJointName import
|
||||
getEntities()->getTree()->setMyAvatar(myAvatar);
|
||||
_entityClipboard->setMyAvatar(myAvatar);
|
||||
|
||||
// For now we're going to set the PPS for outbound packets to be super high, this is
|
||||
// probably not the right long term solution. But for now, we're going to do this to
|
||||
// allow you to move an entity around in your hand
|
||||
|
@ -3999,6 +4003,7 @@ bool Application::exportEntities(const QString& filename,
|
|||
|
||||
auto entityTree = getEntities()->getTree();
|
||||
auto exportTree = std::make_shared<EntityTree>();
|
||||
exportTree->setMyAvatar(getMyAvatar());
|
||||
exportTree->createRootElement();
|
||||
glm::vec3 root(TREE_SCALE, TREE_SCALE, TREE_SCALE);
|
||||
bool success = true;
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
@ -2276,6 +2277,17 @@ bool EntityTree::readFromMap(QVariantMap& map) {
|
|||
foreach (QVariant entityVariant, entitiesQList) {
|
||||
// QVariantMap --> QScriptValue --> EntityItemProperties --> Entity
|
||||
QVariantMap entityMap = entityVariant.toMap();
|
||||
|
||||
// handle parentJointName for wearables
|
||||
if (_myAvatar && entityMap.contains("parentJointName") && entityMap.contains("parentID") &&
|
||||
QUuid(entityMap["parentID"].toString()) == AVATAR_SELF_ID) {
|
||||
|
||||
entityMap["parentJointIndex"] = _myAvatar->getJointIndex(entityMap["parentJointName"].toString());
|
||||
|
||||
qCDebug(entities) << "Found parentJointName " << entityMap["parentJointName"].toString() <<
|
||||
" mapped it to parentJointIndex " << entityMap["parentJointIndex"].toInt();
|
||||
}
|
||||
|
||||
QScriptValue entityScriptValue = variantMapToScriptValue(entityMap, scriptEngine);
|
||||
EntityItemProperties properties;
|
||||
EntityItemPropertiesFromScriptValueIgnoreReadOnly(entityScriptValue, properties);
|
||||
|
|
|
@ -278,6 +278,8 @@ public:
|
|||
QByteArray computeEncryptedNonce(const QString& certID, const QString ownerKey);
|
||||
bool verifyDecryptedNonce(const QString& certID, const QString& decryptedNonce, EntityItemID& id);
|
||||
|
||||
void setMyAvatar(std::shared_ptr<AvatarData> myAvatar) { _myAvatar = myAvatar; }
|
||||
|
||||
signals:
|
||||
void deletingEntity(const EntityItemID& entityID);
|
||||
void deletingEntityPointer(EntityItem* entityID);
|
||||
|
@ -383,6 +385,8 @@ private:
|
|||
void sendChallengeOwnershipPacket(const QString& certID, const QString& ownerKey, const EntityItemID& entityItemID, const SharedNodePointer& senderNode);
|
||||
void sendChallengeOwnershipRequestPacket(const QByteArray& certID, const QByteArray& encryptedText, const QByteArray& nodeToChallenge, const SharedNodePointer& senderNode);
|
||||
void validatePop(const QString& certID, const EntityItemID& entityItemID, const SharedNodePointer& senderNode, bool isRetryingValidation);
|
||||
|
||||
std::shared_ptr<AvatarData> _myAvatar{ nullptr };
|
||||
};
|
||||
|
||||
#endif // hifi_EntityTree_h
|
||||
|
|
|
@ -17,13 +17,15 @@ RecurseOctreeToMapOperator::RecurseOctreeToMapOperator(QVariantMap& map,
|
|||
const OctreeElementPointer& top,
|
||||
QScriptEngine* engine,
|
||||
bool skipDefaultValues,
|
||||
bool skipThoseWithBadParents) :
|
||||
bool skipThoseWithBadParents,
|
||||
std::shared_ptr<AvatarData> 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();
|
||||
});
|
||||
|
||||
|
|
|
@ -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<AvatarData> 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<AvatarData> _myAvatar;
|
||||
};
|
||||
|
|
Loading…
Reference in a new issue