From 50cc68c63eec993e9a30ce43e3770c589c2f8a05 Mon Sep 17 00:00:00 2001 From: luiscuenca Date: Sun, 19 Aug 2018 12:43:06 -0700 Subject: [PATCH 01/16] Recording app doesn't record old attachments --- libraries/avatars/src/AvatarData.cpp | 28 ---------------------------- 1 file changed, 28 deletions(-) diff --git a/libraries/avatars/src/AvatarData.cpp b/libraries/avatars/src/AvatarData.cpp index 62c7a7053f..bc504b4496 100644 --- a/libraries/avatars/src/AvatarData.cpp +++ b/libraries/avatars/src/AvatarData.cpp @@ -2255,7 +2255,6 @@ static const QString JSON_AVATAR_HEAD_MODEL = QStringLiteral("headModel"); static const QString JSON_AVATAR_BODY_MODEL = QStringLiteral("bodyModel"); static const QString JSON_AVATAR_DISPLAY_NAME = QStringLiteral("displayName"); // It isn't meaningful to persist sessionDisplayName. -static const QString JSON_AVATAR_ATTACHMENTS = QStringLiteral("attachments"); static const QString JSON_AVATAR_ENTITIES = QStringLiteral("attachedEntities"); static const QString JSON_AVATAR_SCALE = QStringLiteral("scale"); static const QString JSON_AVATAR_VERSION = QStringLiteral("version"); @@ -2303,13 +2302,6 @@ QJsonObject AvatarData::toJson() const { if (!getDisplayName().isEmpty()) { root[JSON_AVATAR_DISPLAY_NAME] = getDisplayName(); } - if (!getAttachmentData().isEmpty()) { - QJsonArray attachmentsJson; - for (auto attachment : getAttachmentData()) { - attachmentsJson.push_back(attachment.toJson()); - } - root[JSON_AVATAR_ATTACHMENTS] = attachmentsJson; - } _avatarEntitiesLock.withReadLock([&] { if (!_avatarEntityData.empty()) { @@ -2426,26 +2418,6 @@ void AvatarData::fromJson(const QJsonObject& json, bool useFrameSkeleton) { setTargetScale((float)json[JSON_AVATAR_SCALE].toDouble()); } - QVector attachments; - if (json.contains(JSON_AVATAR_ATTACHMENTS) && json[JSON_AVATAR_ATTACHMENTS].isArray()) { - QJsonArray attachmentsJson = json[JSON_AVATAR_ATTACHMENTS].toArray(); - for (auto attachmentJson : attachmentsJson) { - AttachmentData attachment; - attachment.fromJson(attachmentJson.toObject()); - attachments.push_back(attachment); - } - } - if (attachments != getAttachmentData()) { - setAttachmentData(attachments); - } - - // if (json.contains(JSON_AVATAR_ENTITIES) && json[JSON_AVATAR_ENTITIES].isArray()) { - // QJsonArray attachmentsJson = json[JSON_AVATAR_ATTACHMENTS].toArray(); - // for (auto attachmentJson : attachmentsJson) { - // // TODO -- something - // } - // } - if (json.contains(JSON_AVATAR_JOINT_ARRAY)) { if (version == (int)JsonAvatarFrameVersion::JointRotationsInRelativeFrame) { // because we don't have the full joint hierarchy skeleton of the model, From c564119edc03948c5d4c067769e6c7b19bbcec2f Mon Sep 17 00:00:00 2001 From: luiscuenca Date: Mon, 20 Aug 2018 11:58:19 -0700 Subject: [PATCH 02/16] Keep attachments when playing back recordings --- libraries/avatars/src/AvatarData.cpp | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/libraries/avatars/src/AvatarData.cpp b/libraries/avatars/src/AvatarData.cpp index bc504b4496..bfe483e8d7 100644 --- a/libraries/avatars/src/AvatarData.cpp +++ b/libraries/avatars/src/AvatarData.cpp @@ -2255,6 +2255,7 @@ static const QString JSON_AVATAR_HEAD_MODEL = QStringLiteral("headModel"); static const QString JSON_AVATAR_BODY_MODEL = QStringLiteral("bodyModel"); static const QString JSON_AVATAR_DISPLAY_NAME = QStringLiteral("displayName"); // It isn't meaningful to persist sessionDisplayName. +static const QString JSON_AVATAR_ATTACHMENTS = QStringLiteral("attachments"); static const QString JSON_AVATAR_ENTITIES = QStringLiteral("attachedEntities"); static const QString JSON_AVATAR_SCALE = QStringLiteral("scale"); static const QString JSON_AVATAR_VERSION = QStringLiteral("version"); @@ -2302,7 +2303,6 @@ QJsonObject AvatarData::toJson() const { if (!getDisplayName().isEmpty()) { root[JSON_AVATAR_DISPLAY_NAME] = getDisplayName(); } - _avatarEntitiesLock.withReadLock([&] { if (!_avatarEntityData.empty()) { QJsonArray avatarEntityJson; @@ -2418,6 +2418,19 @@ void AvatarData::fromJson(const QJsonObject& json, bool useFrameSkeleton) { setTargetScale((float)json[JSON_AVATAR_SCALE].toDouble()); } + QVector attachments; + if (json.contains(JSON_AVATAR_ATTACHMENTS) && json[JSON_AVATAR_ATTACHMENTS].isArray()) { + QJsonArray attachmentsJson = json[JSON_AVATAR_ATTACHMENTS].toArray(); + for (auto attachmentJson : attachmentsJson) { + AttachmentData attachment; + attachment.fromJson(attachmentJson.toObject()); + attachments.push_back(attachment); + } + } + if (attachments != getAttachmentData()) { + setAttachmentData(attachments); + } + if (json.contains(JSON_AVATAR_JOINT_ARRAY)) { if (version == (int)JsonAvatarFrameVersion::JointRotationsInRelativeFrame) { // because we don't have the full joint hierarchy skeleton of the model, From dc0fbcca59ecc3d671ed4e08177c25a3994d9975 Mon Sep 17 00:00:00 2001 From: luiscuenca Date: Mon, 20 Aug 2018 13:10:36 -0700 Subject: [PATCH 03/16] Include avatar entities on recordings --- libraries/avatars/src/AvatarData.cpp | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/libraries/avatars/src/AvatarData.cpp b/libraries/avatars/src/AvatarData.cpp index bfe483e8d7..58b86db881 100644 --- a/libraries/avatars/src/AvatarData.cpp +++ b/libraries/avatars/src/AvatarData.cpp @@ -2431,6 +2431,18 @@ void AvatarData::fromJson(const QJsonObject& json, bool useFrameSkeleton) { setAttachmentData(attachments); } + if (json.contains(JSON_AVATAR_ENTITIES) && json[JSON_AVATAR_ENTITIES].isArray()) { + QJsonArray attachmentsJson = json[JSON_AVATAR_ATTACHMENTS].toArray(); + for (auto attachmentJson : attachmentsJson) { + if (attachmentJson.isObject()) { + QVariantMap entityData = attachmentJson.toObject().toVariantMap(); + QUuid entityID = entityData.value("id").toUuid(); + QByteArray properties = entityData.value("properties").toByteArray(); + updateAvatarEntity(entityID, properties); + } + } + } + if (json.contains(JSON_AVATAR_JOINT_ARRAY)) { if (version == (int)JsonAvatarFrameVersion::JointRotationsInRelativeFrame) { // because we don't have the full joint hierarchy skeleton of the model, From 8bd9bf39b6abb052e6bcdcb92456ba407298757a Mon Sep 17 00:00:00 2001 From: luiscuenca Date: Mon, 20 Aug 2018 14:31:03 -0700 Subject: [PATCH 04/16] Fix json load --- libraries/avatars/src/AvatarData.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libraries/avatars/src/AvatarData.cpp b/libraries/avatars/src/AvatarData.cpp index 58b86db881..8c72be633f 100644 --- a/libraries/avatars/src/AvatarData.cpp +++ b/libraries/avatars/src/AvatarData.cpp @@ -2432,7 +2432,7 @@ void AvatarData::fromJson(const QJsonObject& json, bool useFrameSkeleton) { } if (json.contains(JSON_AVATAR_ENTITIES) && json[JSON_AVATAR_ENTITIES].isArray()) { - QJsonArray attachmentsJson = json[JSON_AVATAR_ATTACHMENTS].toArray(); + QJsonArray attachmentsJson = json[JSON_AVATAR_ENTITIES].toArray(); for (auto attachmentJson : attachmentsJson) { if (attachmentJson.isObject()) { QVariantMap entityData = attachmentJson.toObject().toVariantMap(); From 5f4903f884a37edb06e6189136e3949afd9c88b3 Mon Sep 17 00:00:00 2001 From: luiscuenca Date: Wed, 22 Aug 2018 08:53:51 -0700 Subject: [PATCH 05/16] Record entities --- interface/src/avatar/MyAvatar.cpp | 1 + .../src/avatars-renderer/Avatar.cpp | 2 ++ libraries/avatars/src/AvatarData.cpp | 20 +++++++++++++++---- libraries/avatars/src/AvatarData.h | 2 ++ 4 files changed, 21 insertions(+), 4 deletions(-) diff --git a/interface/src/avatar/MyAvatar.cpp b/interface/src/avatar/MyAvatar.cpp index 41855e7973..ba9d15159b 100755 --- a/interface/src/avatar/MyAvatar.cpp +++ b/interface/src/avatar/MyAvatar.cpp @@ -184,6 +184,7 @@ MyAvatar::MyAvatar(QThread* thread) : if (recordingInterface->getPlayFromCurrentLocation()) { setRecordingBasis(); } + createRecordingIDs(); _previousCollisionGroup = _characterController.computeCollisionGroup(); _characterController.setCollisionless(true); } else { diff --git a/libraries/avatars-renderer/src/avatars-renderer/Avatar.cpp b/libraries/avatars-renderer/src/avatars-renderer/Avatar.cpp index 0b43fd5433..0f2c936507 100644 --- a/libraries/avatars-renderer/src/avatars-renderer/Avatar.cpp +++ b/libraries/avatars-renderer/src/avatars-renderer/Avatar.cpp @@ -236,6 +236,8 @@ void Avatar::updateAvatarEntities() { return; } + createRecordingIDs(); + if (getID().isNull() || getID() == AVATAR_SELF_ID || DependencyManager::get()->getSessionUUID() == QUuid()) { diff --git a/libraries/avatars/src/AvatarData.cpp b/libraries/avatars/src/AvatarData.cpp index 8c72be633f..40df2fa3aa 100644 --- a/libraries/avatars/src/AvatarData.cpp +++ b/libraries/avatars/src/AvatarData.cpp @@ -2243,6 +2243,15 @@ void AvatarData::setRecordingBasis(std::shared_ptr recordingBasis) { _recordingBasis = recordingBasis; } +void AvatarData::createRecordingIDs() { + _avatarEntitiesLock.withReadLock([&] { + _avatarEntityForRecording.clear(); + for (int i = 0; i < _avatarEntityData.size(); i++) { + _avatarEntityForRecording.insert(QUuid::createUuid()); + } + }); +} + void AvatarData::clearRecordingBasis() { _recordingBasis.reset(); } @@ -2306,10 +2315,12 @@ QJsonObject AvatarData::toJson() const { _avatarEntitiesLock.withReadLock([&] { if (!_avatarEntityData.empty()) { QJsonArray avatarEntityJson; + int entityCount = 0; for (auto entityID : _avatarEntityData.keys()) { QVariantMap entityData; - entityData.insert("id", entityID); - entityData.insert("properties", _avatarEntityData.value(entityID)); + QUuid newId = _avatarEntityForRecording.size() == _avatarEntityData.size() ? _avatarEntityForRecording.values()[entityCount++] : entityID; + entityData.insert("id", newId); + entityData.insert("properties", _avatarEntityData.value(entityID).toBase64()); avatarEntityJson.push_back(QVariant(entityData).toJsonObject()); } root[JSON_AVATAR_ENTITIES] = avatarEntityJson; @@ -2434,10 +2445,11 @@ void AvatarData::fromJson(const QJsonObject& json, bool useFrameSkeleton) { if (json.contains(JSON_AVATAR_ENTITIES) && json[JSON_AVATAR_ENTITIES].isArray()) { QJsonArray attachmentsJson = json[JSON_AVATAR_ENTITIES].toArray(); for (auto attachmentJson : attachmentsJson) { - if (attachmentJson.isObject()) { + if (attachmentJson.isObject()) { QVariantMap entityData = attachmentJson.toObject().toVariantMap(); QUuid entityID = entityData.value("id").toUuid(); - QByteArray properties = entityData.value("properties").toByteArray(); + auto ds = QByteArray::fromBase64(entityData.value("properties").toString().toUtf8()); + QByteArray properties = QByteArray::fromBase64(entityData.value("properties").toByteArray()); updateAvatarEntity(entityID, properties); } } diff --git a/libraries/avatars/src/AvatarData.h b/libraries/avatars/src/AvatarData.h index fcc63fdc98..79d47eb03f 100644 --- a/libraries/avatars/src/AvatarData.h +++ b/libraries/avatars/src/AvatarData.h @@ -1077,6 +1077,7 @@ public: void clearRecordingBasis(); TransformPointer getRecordingBasis() const; void setRecordingBasis(TransformPointer recordingBasis = TransformPointer()); + void createRecordingIDs(); QJsonObject toJson() const; void fromJson(const QJsonObject& json, bool useFrameSkeleton = true); @@ -1410,6 +1411,7 @@ protected: mutable ReadWriteLockable _avatarEntitiesLock; AvatarEntityIDs _avatarEntityDetached; // recently detached from this avatar + AvatarEntityIDs _avatarEntityForRecording; // create new entities id for avatar recording AvatarEntityMap _avatarEntityData; bool _avatarEntityDataLocallyEdited { false }; bool _avatarEntityDataChanged { false }; From 5a5aa2f5b9cc07a66369a28d715302d9ea1af547 Mon Sep 17 00:00:00 2001 From: luiscuenca Date: Wed, 22 Aug 2018 09:13:27 -0700 Subject: [PATCH 06/16] Remove proxy line --- libraries/avatars/src/AvatarData.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/libraries/avatars/src/AvatarData.cpp b/libraries/avatars/src/AvatarData.cpp index 40df2fa3aa..c97051eddf 100644 --- a/libraries/avatars/src/AvatarData.cpp +++ b/libraries/avatars/src/AvatarData.cpp @@ -2448,7 +2448,6 @@ void AvatarData::fromJson(const QJsonObject& json, bool useFrameSkeleton) { if (attachmentJson.isObject()) { QVariantMap entityData = attachmentJson.toObject().toVariantMap(); QUuid entityID = entityData.value("id").toUuid(); - auto ds = QByteArray::fromBase64(entityData.value("properties").toString().toUtf8()); QByteArray properties = QByteArray::fromBase64(entityData.value("properties").toByteArray()); updateAvatarEntity(entityID, properties); } From 579b2435c27c2733dbe3f421dc0b4d66cd81ea31 Mon Sep 17 00:00:00 2001 From: Seth Alves Date: Wed, 22 Aug 2018 11:04:26 -0700 Subject: [PATCH 07/16] don't squash delete events during shutdown so that QWebEngine process gets destroyed --- interface/src/Application.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/interface/src/Application.cpp b/interface/src/Application.cpp index 396c6cbcac..cc24511afd 100644 --- a/interface/src/Application.cpp +++ b/interface/src/Application.cpp @@ -3667,7 +3667,7 @@ bool Application::event(QEvent* event) { bool Application::eventFilter(QObject* object, QEvent* event) { - if (_aboutToQuit) { + if (_aboutToQuit && event->type() != QEvent::DeferredDelete && event->type() != QEvent::Destroy) { return true; } From 3b5ba71163a66f95b20320f0fa5b02d6833f519e Mon Sep 17 00:00:00 2001 From: Stephen Birarda Date: Wed, 22 Aug 2018 12:23:24 -0700 Subject: [PATCH 08/16] fix a crash in ESS from missing dependency --- .../src/scripts/EntityScriptServer.cpp | 24 ++++++++++++------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/assignment-client/src/scripts/EntityScriptServer.cpp b/assignment-client/src/scripts/EntityScriptServer.cpp index 05002828f5..1d46b6040e 100644 --- a/assignment-client/src/scripts/EntityScriptServer.cpp +++ b/assignment-client/src/scripts/EntityScriptServer.cpp @@ -24,6 +24,7 @@ #include #include #include +#include #include #include #include @@ -55,7 +56,8 @@ int EntityScriptServer::_entitiesScriptEngineCount = 0; EntityScriptServer::EntityScriptServer(ReceivedMessage& message) : ThreadedAssignment(message) { qInstallMessageHandler(messageHandler); - DependencyManager::get()->setPacketSender(&_entityEditSender); + DependencyManager::set(false)->setPacketSender(&_entityEditSender); + DependencyManager::set(); DependencyManager::set(); DependencyManager::set(); @@ -559,14 +561,16 @@ void EntityScriptServer::handleOctreePacket(QSharedPointer mess void EntityScriptServer::aboutToFinish() { shutdownScriptEngine(); - auto entityScriptingInterface = DependencyManager::get(); - // our entity tree is going to go away so tell that to the EntityScriptingInterface - entityScriptingInterface->setEntityTree(nullptr); + { + auto entityScriptingInterface = DependencyManager::get(); + // our entity tree is going to go away so tell that to the EntityScriptingInterface + entityScriptingInterface->setEntityTree(nullptr); - // Should always be true as they are singletons. - if (entityScriptingInterface->getPacketSender() == &_entityEditSender) { - // The packet sender is about to go away. - entityScriptingInterface->setPacketSender(nullptr); + // Should always be true as they are singletons. + if (entityScriptingInterface->getPacketSender() == &_entityEditSender) { + // The packet sender is about to go away. + entityScriptingInterface->setPacketSender(nullptr); + } } DependencyManager::destroy(); @@ -575,8 +579,12 @@ void EntityScriptServer::aboutToFinish() { DependencyManager::destroy(); + DependencyManager::destroy(); + DependencyManager::destroy(); + // cleanup the AudioInjectorManager (and any still running injectors) DependencyManager::destroy(); + DependencyManager::destroy(); DependencyManager::destroy(); From 01e8fd66a3afb09e1c685a48e86c7e2c5be926d6 Mon Sep 17 00:00:00 2001 From: Stephen Birarda Date: Wed, 22 Aug 2018 12:41:13 -0700 Subject: [PATCH 09/16] fix script engine(s) cleanup from ESS --- .../src/scripts/EntityScriptServer.cpp | 34 +++++++++++-------- libraries/script-engine/src/ScriptEngine.cpp | 4 +-- libraries/script-engine/src/ScriptEngine.h | 2 -- 3 files changed, 21 insertions(+), 19 deletions(-) diff --git a/assignment-client/src/scripts/EntityScriptServer.cpp b/assignment-client/src/scripts/EntityScriptServer.cpp index 1d46b6040e..586931d403 100644 --- a/assignment-client/src/scripts/EntityScriptServer.cpp +++ b/assignment-client/src/scripts/EntityScriptServer.cpp @@ -457,8 +457,11 @@ void EntityScriptServer::resetEntitiesScriptEngine() { auto newEngineSP = qSharedPointerCast(newEngine); DependencyManager::get()->setEntitiesScriptEngine(newEngineSP); - disconnect(_entitiesScriptEngine.data(), &ScriptEngine::entityScriptDetailsUpdated, - this, &EntityScriptServer::updateEntityPPS); + if (_entitiesScriptEngine) { + disconnect(_entitiesScriptEngine.data(), &ScriptEngine::entityScriptDetailsUpdated, + this, &EntityScriptServer::updateEntityPPS); + } + _entitiesScriptEngine.swap(newEngine); connect(_entitiesScriptEngine.data(), &ScriptEngine::entityScriptDetailsUpdated, this, &EntityScriptServer::updateEntityPPS); @@ -489,6 +492,21 @@ void EntityScriptServer::shutdownScriptEngine() { _shuttingDown = true; clear(); // always clear() on shutdown + + auto scriptEngines = DependencyManager::get(); + scriptEngines->shutdownScripting(); + + _entitiesScriptEngine.clear(); + + auto entityScriptingInterface = DependencyManager::get(); + // our entity tree is going to go away so tell that to the EntityScriptingInterface + entityScriptingInterface->setEntityTree(nullptr); + + // Should always be true as they are singletons. + if (entityScriptingInterface->getPacketSender() == &_entityEditSender) { + // The packet sender is about to go away. + entityScriptingInterface->setPacketSender(nullptr); + } } void EntityScriptServer::addingEntity(const EntityItemID& entityID) { @@ -561,18 +579,6 @@ void EntityScriptServer::handleOctreePacket(QSharedPointer mess void EntityScriptServer::aboutToFinish() { shutdownScriptEngine(); - { - auto entityScriptingInterface = DependencyManager::get(); - // our entity tree is going to go away so tell that to the EntityScriptingInterface - entityScriptingInterface->setEntityTree(nullptr); - - // Should always be true as they are singletons. - if (entityScriptingInterface->getPacketSender() == &_entityEditSender) { - // The packet sender is about to go away. - entityScriptingInterface->setPacketSender(nullptr); - } - } - DependencyManager::destroy(); DependencyManager::get()->cleanup(); diff --git a/libraries/script-engine/src/ScriptEngine.cpp b/libraries/script-engine/src/ScriptEngine.cpp index 105742db35..ce4ec89950 100644 --- a/libraries/script-engine/src/ScriptEngine.cpp +++ b/libraries/script-engine/src/ScriptEngine.cpp @@ -176,9 +176,7 @@ ScriptEngine::ScriptEngine(Context context, const QString& scriptContents, const _timerFunctionMap(), _fileNameString(fileNameString), _arrayBufferClass(new ArrayBufferClass(this)), - _assetScriptingInterface(new AssetScriptingInterface(this)), - // don't delete `ScriptEngines` until all `ScriptEngine`s are gone - _scriptEngines(DependencyManager::get()) + _assetScriptingInterface(new AssetScriptingInterface(this)) { switch (_context) { case Context::CLIENT_SCRIPT: diff --git a/libraries/script-engine/src/ScriptEngine.h b/libraries/script-engine/src/ScriptEngine.h index 1791360a45..94b50bfd2c 100644 --- a/libraries/script-engine/src/ScriptEngine.h +++ b/libraries/script-engine/src/ScriptEngine.h @@ -806,8 +806,6 @@ protected: static const QString _SETTINGS_ENABLE_EXTENDED_EXCEPTIONS; Setting::Handle _enableExtendedJSExceptions { _SETTINGS_ENABLE_EXTENDED_EXCEPTIONS, true }; - - QSharedPointer _scriptEngines; }; ScriptEnginePointer scriptEngineFactory(ScriptEngine::Context context, From b3d127c9531563900998973e850716fb0edbc5a7 Mon Sep 17 00:00:00 2001 From: luiscuenca Date: Wed, 22 Aug 2018 14:31:34 -0700 Subject: [PATCH 10/16] Fix flickering --- interface/src/avatar/MyAvatar.cpp | 2 +- .../src/avatars-renderer/Avatar.cpp | 5 +++-- libraries/avatars/src/AvatarData.cpp | 18 +++++++++--------- 3 files changed, 13 insertions(+), 12 deletions(-) diff --git a/interface/src/avatar/MyAvatar.cpp b/interface/src/avatar/MyAvatar.cpp index ba9d15159b..8b139ee364 100755 --- a/interface/src/avatar/MyAvatar.cpp +++ b/interface/src/avatar/MyAvatar.cpp @@ -184,7 +184,6 @@ MyAvatar::MyAvatar(QThread* thread) : if (recordingInterface->getPlayFromCurrentLocation()) { setRecordingBasis(); } - createRecordingIDs(); _previousCollisionGroup = _characterController.computeCollisionGroup(); _characterController.setCollisionless(true); } else { @@ -203,6 +202,7 @@ MyAvatar::MyAvatar(QThread* thread) : connect(recorder.data(), &Recorder::recordingStateChanged, [=] { if (recorder->isRecording()) { + createRecordingIDs(); setRecordingBasis(); } else { clearRecordingBasis(); diff --git a/libraries/avatars-renderer/src/avatars-renderer/Avatar.cpp b/libraries/avatars-renderer/src/avatars-renderer/Avatar.cpp index 0f2c936507..93de1ab29b 100644 --- a/libraries/avatars-renderer/src/avatars-renderer/Avatar.cpp +++ b/libraries/avatars-renderer/src/avatars-renderer/Avatar.cpp @@ -236,8 +236,6 @@ void Avatar::updateAvatarEntities() { return; } - createRecordingIDs(); - if (getID().isNull() || getID() == AVATAR_SELF_ID || DependencyManager::get()->getSessionUUID() == QUuid()) { @@ -368,6 +366,9 @@ void Avatar::updateAvatarEntities() { } } } + if (avatarEntities.size() != _avatarEntityForRecording.size()) { + createRecordingIDs(); + } }); setAvatarEntityDataChanged(false); diff --git a/libraries/avatars/src/AvatarData.cpp b/libraries/avatars/src/AvatarData.cpp index c97051eddf..6fa5ba2c5b 100644 --- a/libraries/avatars/src/AvatarData.cpp +++ b/libraries/avatars/src/AvatarData.cpp @@ -2443,15 +2443,15 @@ void AvatarData::fromJson(const QJsonObject& json, bool useFrameSkeleton) { } if (json.contains(JSON_AVATAR_ENTITIES) && json[JSON_AVATAR_ENTITIES].isArray()) { - QJsonArray attachmentsJson = json[JSON_AVATAR_ENTITIES].toArray(); - for (auto attachmentJson : attachmentsJson) { - if (attachmentJson.isObject()) { - QVariantMap entityData = attachmentJson.toObject().toVariantMap(); - QUuid entityID = entityData.value("id").toUuid(); - QByteArray properties = QByteArray::fromBase64(entityData.value("properties").toByteArray()); - updateAvatarEntity(entityID, properties); - } - } + QJsonArray attachmentsJson = json[JSON_AVATAR_ENTITIES].toArray(); + for (auto attachmentJson : attachmentsJson) { + if (attachmentJson.isObject()) { + QVariantMap entityData = attachmentJson.toObject().toVariantMap(); + QUuid entityID = entityData.value("id").toUuid(); + QByteArray properties = QByteArray::fromBase64(entityData.value("properties").toByteArray()); + updateAvatarEntity(entityID, properties); + } + } } if (json.contains(JSON_AVATAR_JOINT_ARRAY)) { From dd098f05c2a8e1c3239548989e6c95a9f9b2d36d Mon Sep 17 00:00:00 2001 From: Simon Walton Date: Wed, 22 Aug 2018 14:54:07 -0700 Subject: [PATCH 11/16] Change EntityQueryInitialResultsComplete protocol to use exclusive sequence number --- assignment-client/src/entities/EntityTreeSendThread.cpp | 2 +- interface/src/octree/SafeLanding.cpp | 4 ++-- interface/src/octree/SafeLanding.h | 2 +- libraries/networking/src/udt/PacketHeaders.cpp | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/assignment-client/src/entities/EntityTreeSendThread.cpp b/assignment-client/src/entities/EntityTreeSendThread.cpp index f7ca05fbf2..8b7c8771e8 100644 --- a/assignment-client/src/entities/EntityTreeSendThread.cpp +++ b/assignment-client/src/entities/EntityTreeSendThread.cpp @@ -164,7 +164,7 @@ bool EntityTreeSendThread::traverseTreeAndSendContents(SharedNodePointer node, O // Send EntityQueryInitialResultsComplete reliable packet ... auto initialCompletion = NLPacket::create(PacketType::EntityQueryInitialResultsComplete, sizeof(OCTREE_PACKET_SEQUENCE), true); - initialCompletion->writePrimitive(OCTREE_PACKET_SEQUENCE(nodeData->getSequenceNumber() - 1U)); + initialCompletion->writePrimitive(OCTREE_PACKET_SEQUENCE(nodeData->getSequenceNumber())); DependencyManager::get()->sendPacket(std::move(initialCompletion), *node); } diff --git a/interface/src/octree/SafeLanding.cpp b/interface/src/octree/SafeLanding.cpp index 31106457fb..60b660f66a 100644 --- a/interface/src/octree/SafeLanding.cpp +++ b/interface/src/octree/SafeLanding.cpp @@ -122,11 +122,11 @@ bool SafeLanding::isSequenceNumbersComplete() { int sequenceSize = _initialStart <= _initialEnd ? _initialEnd - _initialStart: _initialEnd + SEQUENCE_MODULO - _initialStart; auto startIter = _sequenceNumbers.find(_initialStart); - auto endIter = _sequenceNumbers.find(_initialEnd); + auto endIter = _sequenceNumbers.find(_initialEnd - 1); if (sequenceSize == 0 || (startIter != _sequenceNumbers.end() && endIter != _sequenceNumbers.end() - && distance(startIter, endIter) == sequenceSize) ) { + && distance(startIter, endIter) == sequenceSize - 1) ) { _trackingEntities = false; // Don't track anything else that comes in. return true; } diff --git a/interface/src/octree/SafeLanding.h b/interface/src/octree/SafeLanding.h index 210dfbac25..9177930d81 100644 --- a/interface/src/octree/SafeLanding.h +++ b/interface/src/octree/SafeLanding.h @@ -26,7 +26,7 @@ class SafeLanding : public QObject { public: void startEntitySequence(QSharedPointer entityTreeRenderer); void stopEntitySequence(); - void setCompletionSequenceNumbers(int first, int last); + void setCompletionSequenceNumbers(int first, int last); // 'last' exclusive. void noteReceivedsequenceNumber(int sequenceNumber); bool isLoadSequenceComplete(); diff --git a/libraries/networking/src/udt/PacketHeaders.cpp b/libraries/networking/src/udt/PacketHeaders.cpp index 8b50e37699..bf455de3e4 100644 --- a/libraries/networking/src/udt/PacketHeaders.cpp +++ b/libraries/networking/src/udt/PacketHeaders.cpp @@ -95,7 +95,7 @@ PacketVersion versionForPacketType(PacketType packetType) { case PacketType::AvatarIdentityRequest: return 22; default: - return 22; + return 23; } } From c32cc1ead298f973e366da23fc3fa4ad748656e9 Mon Sep 17 00:00:00 2001 From: Wayne Chen Date: Wed, 22 Aug 2018 15:42:15 -0700 Subject: [PATCH 12/16] adding implementation --- interface/src/avatar/MyAvatar.cpp | 3 +-- interface/src/ui/PreferencesDialog.cpp | 2 +- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/interface/src/avatar/MyAvatar.cpp b/interface/src/avatar/MyAvatar.cpp index b30f05225e..79c3f969b5 100755 --- a/interface/src/avatar/MyAvatar.cpp +++ b/interface/src/avatar/MyAvatar.cpp @@ -105,8 +105,8 @@ MyAvatar::MyAvatar(QThread* thread) : _eyeContactTarget(LEFT_EYE), _realWorldFieldOfView("realWorldFieldOfView", DEFAULT_REAL_WORLD_FIELD_OF_VIEW_DEGREES), - _useAdvancedMovementControls("advancedMovementForHandControllersIsChecked", false), _smoothOrientationTimer(std::numeric_limits::max()), + _useAdvancedMovementControls("advancedMovementForHandControllersIsChecked", true), _smoothOrientationInitial(), _smoothOrientationTarget(), _hmdSensorMatrix(), @@ -444,7 +444,6 @@ void MyAvatar::reset(bool andRecenter, bool andReload, bool andHead) { } void MyAvatar::update(float deltaTime) { - // update moving average of HMD facing in xz plane. const float HMD_FACING_TIMESCALE = getRotationRecenterFilterLength(); diff --git a/interface/src/ui/PreferencesDialog.cpp b/interface/src/ui/PreferencesDialog.cpp index e2037d54d0..c5cce261ae 100644 --- a/interface/src/ui/PreferencesDialog.cpp +++ b/interface/src/ui/PreferencesDialog.cpp @@ -272,7 +272,7 @@ void setupPreferences() { auto getter = [myAvatar]()->bool { return myAvatar->useAdvancedMovementControls(); }; auto setter = [myAvatar](bool value) { myAvatar->setUseAdvancedMovementControls(value); }; preferences->addPreference(new CheckPreference(VR_MOVEMENT, - QStringLiteral("Advanced movement for hand controllers"), + QStringLiteral("Advanced movement for VR (Teleport movement when unchecked)"), getter, setter)); } { From 9518b8cdafa47a51678df0b6c604515bdab5e807 Mon Sep 17 00:00:00 2001 From: Wayne Chen Date: Wed, 22 Aug 2018 15:46:02 -0700 Subject: [PATCH 13/16] rearrangement --- interface/src/avatar/MyAvatar.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/interface/src/avatar/MyAvatar.cpp b/interface/src/avatar/MyAvatar.cpp index 79c3f969b5..840747003f 100755 --- a/interface/src/avatar/MyAvatar.cpp +++ b/interface/src/avatar/MyAvatar.cpp @@ -105,8 +105,8 @@ MyAvatar::MyAvatar(QThread* thread) : _eyeContactTarget(LEFT_EYE), _realWorldFieldOfView("realWorldFieldOfView", DEFAULT_REAL_WORLD_FIELD_OF_VIEW_DEGREES), - _smoothOrientationTimer(std::numeric_limits::max()), _useAdvancedMovementControls("advancedMovementForHandControllersIsChecked", true), + _smoothOrientationTimer(std::numeric_limits::max()), _smoothOrientationInitial(), _smoothOrientationTarget(), _hmdSensorMatrix(), From 4daa30c1d0c199f306920b344ce266cd0fa6dc4b Mon Sep 17 00:00:00 2001 From: Wayne Chen Date: Wed, 22 Aug 2018 15:58:37 -0700 Subject: [PATCH 14/16] changing text for check preference --- interface/src/ui/PreferencesDialog.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/interface/src/ui/PreferencesDialog.cpp b/interface/src/ui/PreferencesDialog.cpp index c5cce261ae..79ca2063ec 100644 --- a/interface/src/ui/PreferencesDialog.cpp +++ b/interface/src/ui/PreferencesDialog.cpp @@ -272,7 +272,7 @@ void setupPreferences() { auto getter = [myAvatar]()->bool { return myAvatar->useAdvancedMovementControls(); }; auto setter = [myAvatar](bool value) { myAvatar->setUseAdvancedMovementControls(value); }; preferences->addPreference(new CheckPreference(VR_MOVEMENT, - QStringLiteral("Advanced movement for VR (Teleport movement when unchecked)"), + QStringLiteral("Advanced movement in VR (Teleport movement when unchecked)"), getter, setter)); } { From c4b916af62788d62946d59a140ad26ede6f9f81f Mon Sep 17 00:00:00 2001 From: Simon Walton Date: Wed, 22 Aug 2018 16:22:30 -0700 Subject: [PATCH 15/16] Just bump packet version for EntityQueryInitialResultsComplete --- libraries/networking/src/udt/PacketHeaders.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/libraries/networking/src/udt/PacketHeaders.cpp b/libraries/networking/src/udt/PacketHeaders.cpp index bf455de3e4..25503e192f 100644 --- a/libraries/networking/src/udt/PacketHeaders.cpp +++ b/libraries/networking/src/udt/PacketHeaders.cpp @@ -94,8 +94,10 @@ PacketVersion versionForPacketType(PacketType packetType) { return static_cast(AvatarQueryVersion::ConicalFrustums); case PacketType::AvatarIdentityRequest: return 22; - default: + case PacketType::EntityQueryInitialResultsComplete: return 23; + default: + return 22; } } From c0966d738e334a17f94320639accdfa7f1ae2cde Mon Sep 17 00:00:00 2001 From: Simon Walton Date: Wed, 22 Aug 2018 16:40:49 -0700 Subject: [PATCH 16/16] Use EntityVersion for the EntityQueryInitialResultsComplete packet --- libraries/networking/src/udt/PacketHeaders.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libraries/networking/src/udt/PacketHeaders.cpp b/libraries/networking/src/udt/PacketHeaders.cpp index 25503e192f..0f9a49da32 100644 --- a/libraries/networking/src/udt/PacketHeaders.cpp +++ b/libraries/networking/src/udt/PacketHeaders.cpp @@ -95,7 +95,7 @@ PacketVersion versionForPacketType(PacketType packetType) { case PacketType::AvatarIdentityRequest: return 22; case PacketType::EntityQueryInitialResultsComplete: - return 23; + return static_cast(EntityVersion::ParticleSpin); default: return 22; }