mirror of
https://github.com/overte-org/overte.git
synced 2025-08-10 21:43:13 +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.setServerJurisdictions(&_entityServerJurisdictions);
|
||||||
_entityEditSender.setMyAvatar(myAvatar.get());
|
_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
|
// 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
|
// 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
|
// 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 entityTree = getEntities()->getTree();
|
||||||
auto exportTree = std::make_shared<EntityTree>();
|
auto exportTree = std::make_shared<EntityTree>();
|
||||||
|
exportTree->setMyAvatar(getMyAvatar());
|
||||||
exportTree->createRootElement();
|
exportTree->createRootElement();
|
||||||
glm::vec3 root(TREE_SCALE, TREE_SCALE, TREE_SCALE);
|
glm::vec3 root(TREE_SCALE, TREE_SCALE, TREE_SCALE);
|
||||||
bool success = true;
|
bool success = true;
|
||||||
|
|
|
@ -2254,7 +2254,8 @@ bool EntityTree::writeToMap(QVariantMap& entityDescription, OctreeElementPointer
|
||||||
entityDescription["Entities"] = QVariantList();
|
entityDescription["Entities"] = QVariantList();
|
||||||
}
|
}
|
||||||
QScriptEngine scriptEngine;
|
QScriptEngine scriptEngine;
|
||||||
RecurseOctreeToMapOperator theOperator(entityDescription, element, &scriptEngine, skipDefaultValues, skipThoseWithBadParents);
|
RecurseOctreeToMapOperator theOperator(entityDescription, element, &scriptEngine, skipDefaultValues,
|
||||||
|
skipThoseWithBadParents, _myAvatar);
|
||||||
recurseTreeWithOperator(&theOperator);
|
recurseTreeWithOperator(&theOperator);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -2276,6 +2277,17 @@ bool EntityTree::readFromMap(QVariantMap& map) {
|
||||||
foreach (QVariant entityVariant, entitiesQList) {
|
foreach (QVariant entityVariant, entitiesQList) {
|
||||||
// QVariantMap --> QScriptValue --> EntityItemProperties --> Entity
|
// QVariantMap --> QScriptValue --> EntityItemProperties --> Entity
|
||||||
QVariantMap entityMap = entityVariant.toMap();
|
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);
|
QScriptValue entityScriptValue = variantMapToScriptValue(entityMap, scriptEngine);
|
||||||
EntityItemProperties properties;
|
EntityItemProperties properties;
|
||||||
EntityItemPropertiesFromScriptValueIgnoreReadOnly(entityScriptValue, properties);
|
EntityItemPropertiesFromScriptValueIgnoreReadOnly(entityScriptValue, properties);
|
||||||
|
|
|
@ -278,6 +278,8 @@ public:
|
||||||
QByteArray computeEncryptedNonce(const QString& certID, const QString ownerKey);
|
QByteArray computeEncryptedNonce(const QString& certID, const QString ownerKey);
|
||||||
bool verifyDecryptedNonce(const QString& certID, const QString& decryptedNonce, EntityItemID& id);
|
bool verifyDecryptedNonce(const QString& certID, const QString& decryptedNonce, EntityItemID& id);
|
||||||
|
|
||||||
|
void setMyAvatar(std::shared_ptr<AvatarData> myAvatar) { _myAvatar = myAvatar; }
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void deletingEntity(const EntityItemID& entityID);
|
void deletingEntity(const EntityItemID& entityID);
|
||||||
void deletingEntityPointer(EntityItem* 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 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 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);
|
void validatePop(const QString& certID, const EntityItemID& entityItemID, const SharedNodePointer& senderNode, bool isRetryingValidation);
|
||||||
|
|
||||||
|
std::shared_ptr<AvatarData> _myAvatar{ nullptr };
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // hifi_EntityTree_h
|
#endif // hifi_EntityTree_h
|
||||||
|
|
|
@ -17,13 +17,15 @@ RecurseOctreeToMapOperator::RecurseOctreeToMapOperator(QVariantMap& map,
|
||||||
const OctreeElementPointer& top,
|
const OctreeElementPointer& top,
|
||||||
QScriptEngine* engine,
|
QScriptEngine* engine,
|
||||||
bool skipDefaultValues,
|
bool skipDefaultValues,
|
||||||
bool skipThoseWithBadParents) :
|
bool skipThoseWithBadParents,
|
||||||
|
std::shared_ptr<AvatarData> myAvatar) :
|
||||||
RecurseOctreeOperator(),
|
RecurseOctreeOperator(),
|
||||||
_map(map),
|
_map(map),
|
||||||
_top(top),
|
_top(top),
|
||||||
_engine(engine),
|
_engine(engine),
|
||||||
_skipDefaultValues(skipDefaultValues),
|
_skipDefaultValues(skipDefaultValues),
|
||||||
_skipThoseWithBadParents(skipThoseWithBadParents)
|
_skipThoseWithBadParents(skipThoseWithBadParents),
|
||||||
|
_myAvatar(myAvatar)
|
||||||
{
|
{
|
||||||
// if some element "top" was given, only save information for that element and its children.
|
// if some element "top" was given, only save information for that element and its children.
|
||||||
if (_top) {
|
if (_top) {
|
||||||
|
@ -60,6 +62,18 @@ bool RecurseOctreeToMapOperator::postRecursion(const OctreeElementPointer& eleme
|
||||||
} else {
|
} else {
|
||||||
qScriptValues = EntityItemPropertiesToScriptValue(_engine, properties);
|
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();
|
entitiesQList << qScriptValues.toVariant();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -14,7 +14,7 @@
|
||||||
class RecurseOctreeToMapOperator : public RecurseOctreeOperator {
|
class RecurseOctreeToMapOperator : public RecurseOctreeOperator {
|
||||||
public:
|
public:
|
||||||
RecurseOctreeToMapOperator(QVariantMap& map, const OctreeElementPointer& top, QScriptEngine* engine, bool skipDefaultValues,
|
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 preRecursion(const OctreeElementPointer& element) override;
|
||||||
bool postRecursion(const OctreeElementPointer& element) override;
|
bool postRecursion(const OctreeElementPointer& element) override;
|
||||||
private:
|
private:
|
||||||
|
@ -24,4 +24,5 @@ public:
|
||||||
bool _withinTop;
|
bool _withinTop;
|
||||||
bool _skipDefaultValues;
|
bool _skipDefaultValues;
|
||||||
bool _skipThoseWithBadParents;
|
bool _skipThoseWithBadParents;
|
||||||
|
std::shared_ptr<AvatarData> _myAvatar;
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in a new issue