From 29ff47c6fbd613bf196851eda4963194bff910e5 Mon Sep 17 00:00:00 2001 From: Atlante45 Date: Mon, 18 Jun 2018 16:23:54 -0700 Subject: [PATCH 01/29] Ensure audio devices are made on the right thread --- libraries/audio-client/src/AudioClient.cpp | 6 +++++- libraries/script-engine/src/AudioScriptingInterface.cpp | 9 ++++++++- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/libraries/audio-client/src/AudioClient.cpp b/libraries/audio-client/src/AudioClient.cpp index a5f79290cd..39578622c9 100644 --- a/libraries/audio-client/src/AudioClient.cpp +++ b/libraries/audio-client/src/AudioClient.cpp @@ -1463,6 +1463,8 @@ void AudioClient::outputFormatChanged() { } bool AudioClient::switchInputToAudioDevice(const QAudioDeviceInfo inputDeviceInfo, bool isShutdownRequest) { + Q_ASSERT_X(QThread::currentThread() == thread(), Q_FUNC_INFO, "Function invoked on wrong thread"); + qCDebug(audioclient) << __FUNCTION__ << "inputDeviceInfo: [" << inputDeviceInfo.deviceName() << "]"; bool supportedFormat = false; @@ -1663,6 +1665,8 @@ void AudioClient::outputNotify() { } bool AudioClient::switchOutputToAudioDevice(const QAudioDeviceInfo outputDeviceInfo, bool isShutdownRequest) { + Q_ASSERT_X(QThread::currentThread() == thread(), Q_FUNC_INFO, "Function invoked on wrong thread"); + qCDebug(audioclient) << "AudioClient::switchOutputToAudioDevice() outputDeviceInfo: [" << outputDeviceInfo.deviceName() << "]"; bool supportedFormat = false; @@ -2021,7 +2025,7 @@ void AudioClient::setAvatarBoundingBoxParameters(glm::vec3 corner, glm::vec3 sca void AudioClient::startThread() { - moveToNewNamedThread(this, "Audio Thread", [this] { start(); }); + moveToNewNamedThread(this, "Audio Thread", [this] { start(); }, QThread::TimeCriticalPriority); } void AudioClient::setInputVolume(float volume, bool emitSignal) { diff --git a/libraries/script-engine/src/AudioScriptingInterface.cpp b/libraries/script-engine/src/AudioScriptingInterface.cpp index f248c20d41..c06bb2d952 100644 --- a/libraries/script-engine/src/AudioScriptingInterface.cpp +++ b/libraries/script-engine/src/AudioScriptingInterface.cpp @@ -63,8 +63,15 @@ ScriptAudioInjector* AudioScriptingInterface::playSound(SharedSoundPointer sound bool AudioScriptingInterface::setStereoInput(bool stereo) { bool stereoInputChanged = false; if (_localAudioInterface) { - stereoInputChanged = _localAudioInterface->setIsStereoInput(stereo); + if (QThread::currentThread() != _localAudioInterface->thread()) { + // TODO: This can block the main thread which is not ideal, make this function and the UI calling it async + BLOCKING_INVOKE_METHOD(_localAudioInterface, "setIsStereoInput", Q_RETURN_ARG(bool, stereoInputChanged), + Q_ARG(bool, stereo)); + } else { + stereoInputChanged = _localAudioInterface->setIsStereoInput(stereo); + } } + return stereoInputChanged; } From 4a4c0d132ecd489fc541ea575b12e7459112584b Mon Sep 17 00:00:00 2001 From: Atlante45 Date: Mon, 18 Jun 2018 17:25:38 -0700 Subject: [PATCH 02/29] Make stereo interface async --- interface/resources/qml/hifi/audio/Audio.qml | 8 ++---- libraries/audio-client/src/AudioClient.cpp | 2 ++ libraries/audio/src/AbstractAudioInterface.h | 3 ++ .../src/AudioScriptingInterface.cpp | 28 +++++++++++-------- .../src/AudioScriptingInterface.h | 14 ++++++++-- 5 files changed, 36 insertions(+), 19 deletions(-) diff --git a/interface/resources/qml/hifi/audio/Audio.qml b/interface/resources/qml/hifi/audio/Audio.qml index ba50b7f238..cc1ba49984 100644 --- a/interface/resources/qml/hifi/audio/Audio.qml +++ b/interface/resources/qml/hifi/audio/Audio.qml @@ -129,12 +129,10 @@ Rectangle { id: stereoMic spacing: muteMic.spacing; text: qsTr("Enable stereo input"); - checked: AudioScriptingInterface.isStereoInput(); + checked: AudioScriptingInterface.isStereoInput; onClicked: { - var success = AudioScriptingInterface.setStereoInput(checked); - if (!success) { - checked = !checked; - } + AudioScriptingInterface.isStereoInput = checked; + checked = Qt.binding(function() { return AudioScriptingInterface.isStereoInput; }); // restore binding } } } diff --git a/libraries/audio-client/src/AudioClient.cpp b/libraries/audio-client/src/AudioClient.cpp index 39578622c9..a6f0416a30 100644 --- a/libraries/audio-client/src/AudioClient.cpp +++ b/libraries/audio-client/src/AudioClient.cpp @@ -1426,6 +1426,8 @@ bool AudioClient::setIsStereoInput(bool isStereoInput) { // restart the input device switchInputToAudioDevice(_inputDeviceInfo); + + emit isStereoInputChanged(_isStereoInput); } return stereoInputChanged; diff --git a/libraries/audio/src/AbstractAudioInterface.h b/libraries/audio/src/AbstractAudioInterface.h index 30cbceeb0e..bbfd79d0aa 100644 --- a/libraries/audio/src/AbstractAudioInterface.h +++ b/libraries/audio/src/AbstractAudioInterface.h @@ -44,6 +44,9 @@ public slots: virtual bool setIsStereoInput(bool stereo) = 0; virtual bool isStereoInput() = 0; + +signals: + void isStereoInputChanged(bool isStereo); }; Q_DECLARE_METATYPE(AbstractAudioInterface*) diff --git a/libraries/script-engine/src/AudioScriptingInterface.cpp b/libraries/script-engine/src/AudioScriptingInterface.cpp index c06bb2d952..72918e33f6 100644 --- a/libraries/script-engine/src/AudioScriptingInterface.cpp +++ b/libraries/script-engine/src/AudioScriptingInterface.cpp @@ -23,6 +23,21 @@ void registerAudioMetaTypes(QScriptEngine* engine) { qScriptRegisterMetaType(engine, soundSharedPointerToScriptValue, soundSharedPointerFromScriptValue); } + +void AudioScriptingInterface::setLocalAudioInterface(AbstractAudioInterface* audioInterface) { + if (_localAudioInterface) { + disconnect(_localAudioInterface, &AbstractAudioInterface::isStereoInputChanged, + this, &AudioScriptingInterface::isStereoInputChanged); + } + + _localAudioInterface = audioInterface; + + if (_localAudioInterface) { + connect(_localAudioInterface, &AbstractAudioInterface::isStereoInputChanged, + this, &AudioScriptingInterface::isStereoInputChanged); + } +} + ScriptAudioInjector* AudioScriptingInterface::playSystemSound(SharedSoundPointer sound, const QVector3D& position) { AudioInjectorOptions options; options.position = glm::vec3(position.x(), position.y(), position.z()); @@ -60,19 +75,10 @@ ScriptAudioInjector* AudioScriptingInterface::playSound(SharedSoundPointer sound } } -bool AudioScriptingInterface::setStereoInput(bool stereo) { - bool stereoInputChanged = false; +void AudioScriptingInterface::setStereoInput(bool stereo) { if (_localAudioInterface) { - if (QThread::currentThread() != _localAudioInterface->thread()) { - // TODO: This can block the main thread which is not ideal, make this function and the UI calling it async - BLOCKING_INVOKE_METHOD(_localAudioInterface, "setIsStereoInput", Q_RETURN_ARG(bool, stereoInputChanged), - Q_ARG(bool, stereo)); - } else { - stereoInputChanged = _localAudioInterface->setIsStereoInput(stereo); - } + QMetaObject::invokeMethod(_localAudioInterface, "setIsStereoInput", Q_ARG(bool, stereo)); } - - return stereoInputChanged; } bool AudioScriptingInterface::isStereoInput() { diff --git a/libraries/script-engine/src/AudioScriptingInterface.h b/libraries/script-engine/src/AudioScriptingInterface.h index 36fe29243d..20ca977da1 100644 --- a/libraries/script-engine/src/AudioScriptingInterface.h +++ b/libraries/script-engine/src/AudioScriptingInterface.h @@ -23,9 +23,11 @@ class AudioScriptingInterface : public QObject, public Dependency { Q_OBJECT SINGLETON_DEPENDENCY + Q_PROPERTY(bool isStereoInput READ isStereoInput WRITE setStereoInput NOTIFY isStereoInputChanged) + public: virtual ~AudioScriptingInterface() {} - void setLocalAudioInterface(AbstractAudioInterface* audioInterface) { _localAudioInterface = audioInterface; } + void setLocalAudioInterface(AbstractAudioInterface* audioInterface); protected: AudioScriptingInterface() {} @@ -52,9 +54,8 @@ protected: /**jsdoc * @function Audio.setStereoInput * @param {boolean} stereo - * @returns {boolean} */ - Q_INVOKABLE bool setStereoInput(bool stereo); + Q_INVOKABLE void setStereoInput(bool stereo); /**jsdoc * @function Audio.isStereoInput @@ -114,6 +115,13 @@ signals: */ void inputReceived(const QByteArray& inputSamples); + /**jsdoc + * @function Audio.isStereoInputChanged + * @param {boolean} isStereo + * @returns {Signal} + */ + void isStereoInputChanged(bool isStereo); + private: AbstractAudioInterface* _localAudioInterface { nullptr }; }; From 2bf7db6952555dc0f513c5205600badc995ea6a9 Mon Sep 17 00:00:00 2001 From: Clement Date: Tue, 19 Jun 2018 16:36:37 -0700 Subject: [PATCH 03/29] setStereoInput always returns true to not break old scripts --- libraries/script-engine/src/AudioScriptingInterface.cpp | 3 ++- libraries/script-engine/src/AudioScriptingInterface.h | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/libraries/script-engine/src/AudioScriptingInterface.cpp b/libraries/script-engine/src/AudioScriptingInterface.cpp index 72918e33f6..be419e8005 100644 --- a/libraries/script-engine/src/AudioScriptingInterface.cpp +++ b/libraries/script-engine/src/AudioScriptingInterface.cpp @@ -75,10 +75,11 @@ ScriptAudioInjector* AudioScriptingInterface::playSound(SharedSoundPointer sound } } -void AudioScriptingInterface::setStereoInput(bool stereo) { +bool AudioScriptingInterface::setStereoInput(bool stereo) { if (_localAudioInterface) { QMetaObject::invokeMethod(_localAudioInterface, "setIsStereoInput", Q_ARG(bool, stereo)); } + return true; } bool AudioScriptingInterface::isStereoInput() { diff --git a/libraries/script-engine/src/AudioScriptingInterface.h b/libraries/script-engine/src/AudioScriptingInterface.h index 20ca977da1..843fa3e8f0 100644 --- a/libraries/script-engine/src/AudioScriptingInterface.h +++ b/libraries/script-engine/src/AudioScriptingInterface.h @@ -54,8 +54,9 @@ protected: /**jsdoc * @function Audio.setStereoInput * @param {boolean} stereo + * @returns {boolean} */ - Q_INVOKABLE void setStereoInput(bool stereo); + Q_INVOKABLE bool setStereoInput(bool stereo); /**jsdoc * @function Audio.isStereoInput From b8dea4b86955781f6b1a7d641a6513bdd8223be1 Mon Sep 17 00:00:00 2001 From: Angus Antley Date: Tue, 26 Jun 2018 06:27:01 +0100 Subject: [PATCH 04/29] adding changes to add the orb when an avatar is processed by the avatar mixer and when a new model is being loaded for an avatar. The orb is removed when the geometry has loaded. --- interface/src/avatar/AvatarManager.cpp | 8 +++++ .../src/avatars-renderer/Avatar.cpp | 31 +++++++++++++++++++ .../src/avatars-renderer/Avatar.h | 8 ++++- 3 files changed, 46 insertions(+), 1 deletion(-) diff --git a/interface/src/avatar/AvatarManager.cpp b/interface/src/avatar/AvatarManager.cpp index c63095a204..0b03a660bc 100644 --- a/interface/src/avatar/AvatarManager.cpp +++ b/interface/src/avatar/AvatarManager.cpp @@ -193,6 +193,14 @@ void AvatarManager::updateOtherAvatars(float deltaTime) { const SortableAvatar& sortData = sortedAvatars.top(); const auto avatar = std::static_pointer_cast(sortData.getAvatar()); + //if the geometry is loaded then turn off the orb + if (avatar->getSkeletonModel()->isLoaded()) { + //remove the orb if it is there + avatar->removeOrb(); + } else { + avatar->updateOrbPosition(); + } + bool ignoring = DependencyManager::get()->isPersonalMutingNode(avatar->getID()); if (ignoring) { sortedAvatars.pop(); diff --git a/libraries/avatars-renderer/src/avatars-renderer/Avatar.cpp b/libraries/avatars-renderer/src/avatars-renderer/Avatar.cpp index a99838d810..6d23b524d3 100644 --- a/libraries/avatars-renderer/src/avatars-renderer/Avatar.cpp +++ b/libraries/avatars-renderer/src/avatars-renderer/Avatar.cpp @@ -34,6 +34,7 @@ #include #include "ModelEntityItem.h" #include "RenderableModelEntityItem.h" +#include "../../interface/src/Application.h" #include @@ -1338,6 +1339,27 @@ void Avatar::scaleVectorRelativeToPosition(glm::vec3 &positionToScale) const { } void Avatar::setSkeletonModelURL(const QUrl& skeletonModelURL) { + if (!isMyAvatar()) { + if (_purpleOrbMeshPlaceholderID == UNKNOWN_OVERLAY_ID || + !qApp->getOverlays().isAddedOverlay(_purpleOrbMeshPlaceholderID)) { + qCWarning(avatars_renderer) << "change model add the purple orb************************"; + _purpleOrbMeshPlaceholder = std::make_shared(); + _purpleOrbMeshPlaceholder->setAlpha(1.0f); + _purpleOrbMeshPlaceholder->setColor({ 0xFF, 0x00, 0xFF }); + _purpleOrbMeshPlaceholder->setIsSolid(false); + _purpleOrbMeshPlaceholder->setPulseMin(0.5); + _purpleOrbMeshPlaceholder->setPulseMax(1.0); + _purpleOrbMeshPlaceholder->setColorPulse(1.0); + _purpleOrbMeshPlaceholder->setIgnoreRayIntersection(true); + _purpleOrbMeshPlaceholder->setDrawInFront(false); + _purpleOrbMeshPlaceholderID = qApp->getOverlays().addOverlay(_purpleOrbMeshPlaceholder); + // Position focus + _purpleOrbMeshPlaceholder->setWorldOrientation(glm::quat(0.0f, 0.0f, 0.0f, 1.0)); + _purpleOrbMeshPlaceholder->setWorldPosition(getHead()->getPosition()); + _purpleOrbMeshPlaceholder->setDimensions(glm::vec3(0.5f, 0.5f, 0.5f)); + _purpleOrbMeshPlaceholder->setVisible(true); + } + } AvatarData::setSkeletonModelURL(skeletonModelURL); if (QThread::currentThread() == thread()) { _skeletonModel->setURL(_skeletonModelURL); @@ -1869,7 +1891,16 @@ void Avatar::processMaterials() { } } } +void Avatar::removeOrb() { + if (qApp->getOverlays().isAddedOverlay(_purpleOrbMeshPlaceholderID)) { + qApp->getOverlays().deleteOverlay(_purpleOrbMeshPlaceholderID); + qCWarning(avatars_renderer) << "remove the purple orb***************************"; + } +} +void Avatar::updateOrbPosition() { + _purpleOrbMeshPlaceholder->setWorldPosition(getHead()->getPosition()); +} scriptable::ScriptableModelBase Avatar::getScriptableModel() { if (!_skeletonModel || !_skeletonModel->isLoaded()) { return scriptable::ScriptableModelBase(); diff --git a/libraries/avatars-renderer/src/avatars-renderer/Avatar.h b/libraries/avatars-renderer/src/avatars-renderer/Avatar.h index 98246330c4..c480c5905e 100644 --- a/libraries/avatars-renderer/src/avatars-renderer/Avatar.h +++ b/libraries/avatars-renderer/src/avatars-renderer/Avatar.h @@ -27,6 +27,9 @@ #include "Head.h" #include "SkeletonModel.h" #include "Rig.h" +#include "../../interface/src/ui/overlays/Overlays.h" +#include "../../interface/src/ui/overlays/Sphere3DOverlay.h" + #include namespace render { @@ -364,7 +367,10 @@ public: void removeMaterial(graphics::MaterialPointer material, const std::string& parentMaterialName) override; virtual scriptable::ScriptableModelBase getScriptableModel() override; - + void removeOrb(); + void updateOrbPosition(); + std::shared_ptr _purpleOrbMeshPlaceholder{ nullptr }; + OverlayID _purpleOrbMeshPlaceholderID{ UNKNOWN_OVERLAY_ID }; public slots: // FIXME - these should be migrated to use Pose data instead From 232dc21c7b34494490036588d65922eceb4cfd10 Mon Sep 17 00:00:00 2001 From: Angus Antley Date: Tue, 26 Jun 2018 06:38:09 +0100 Subject: [PATCH 05/29] add orb code added to otheravatar.cpp --- .../src/avatars-renderer/OtherAvatar.cpp | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/libraries/avatars-renderer/src/avatars-renderer/OtherAvatar.cpp b/libraries/avatars-renderer/src/avatars-renderer/OtherAvatar.cpp index 7678c03276..11281334eb 100644 --- a/libraries/avatars-renderer/src/avatars-renderer/OtherAvatar.cpp +++ b/libraries/avatars-renderer/src/avatars-renderer/OtherAvatar.cpp @@ -7,6 +7,7 @@ // #include "OtherAvatar.h" +#include "../../interface/src/Application.h" OtherAvatar::OtherAvatar(QThread* thread) : Avatar(thread) { // give the pointer to our head to inherited _headData variable from AvatarData @@ -16,4 +17,23 @@ OtherAvatar::OtherAvatar(QThread* thread) : Avatar(thread) { connect(_skeletonModel.get(), &Model::setURLFinished, this, &Avatar::setModelURLFinished); connect(_skeletonModel.get(), &Model::rigReady, this, &Avatar::rigReady); connect(_skeletonModel.get(), &Model::rigReset, this, &Avatar::rigReset); + + //add the purple orb + if (_purpleOrbMeshPlaceholderID == UNKNOWN_OVERLAY_ID || !qApp->getOverlays().isAddedOverlay(_purpleOrbMeshPlaceholderID)) { + _purpleOrbMeshPlaceholder = std::make_shared(); + _purpleOrbMeshPlaceholder->setAlpha(1.0f); + _purpleOrbMeshPlaceholder->setColor({ 0xFF, 0x00, 0xFF }); + _purpleOrbMeshPlaceholder->setIsSolid(false); + _purpleOrbMeshPlaceholder->setPulseMin(0.5); + _purpleOrbMeshPlaceholder->setPulseMax(1.0); + _purpleOrbMeshPlaceholder->setColorPulse(1.0); + _purpleOrbMeshPlaceholder->setIgnoreRayIntersection(true); + _purpleOrbMeshPlaceholder->setDrawInFront(false); + _purpleOrbMeshPlaceholderID = qApp->getOverlays().addOverlay(_purpleOrbMeshPlaceholder); + // Position focus + _purpleOrbMeshPlaceholder->setWorldOrientation(glm::quat(0.0f, 0.0f, 0.0f, 1.0)); + _purpleOrbMeshPlaceholder->setWorldPosition(glm::vec3(476.0f, 500.0f, 493.0f)); + _purpleOrbMeshPlaceholder->setDimensions(glm::vec3(0.5f, 0.5f, 0.5f)); + _purpleOrbMeshPlaceholder->setVisible(true); + } } From fa1a9d04e07e945cffb35de8685f10f5c49eecb7 Mon Sep 17 00:00:00 2001 From: amantley Date: Tue, 26 Jun 2018 13:18:26 -0700 Subject: [PATCH 06/29] everything working before trying to move otheravatar to interface --- interface/src/avatar/AvatarManager.cpp | 40 ++++++++++++++++++- interface/src/avatar/AvatarManager.h | 2 + .../src/avatars-renderer/Avatar.cpp | 9 +---- .../src/avatars-renderer/Avatar.h | 4 +- .../src/avatars-renderer/OtherAvatar.cpp | 2 + libraries/avatars/src/AvatarData.h | 2 + 6 files changed, 48 insertions(+), 11 deletions(-) diff --git a/interface/src/avatar/AvatarManager.cpp b/interface/src/avatar/AvatarManager.cpp index 0b03a660bc..8866ae68f9 100644 --- a/interface/src/avatar/AvatarManager.cpp +++ b/interface/src/avatar/AvatarManager.cpp @@ -196,7 +196,7 @@ void AvatarManager::updateOtherAvatars(float deltaTime) { //if the geometry is loaded then turn off the orb if (avatar->getSkeletonModel()->isLoaded()) { //remove the orb if it is there - avatar->removeOrb(); + removeOrb(avatar->_purpleOrbMeshPlaceholderID); } else { avatar->updateOrbPosition(); } @@ -325,7 +325,34 @@ void AvatarManager::simulateAvatarFades(float deltaTime) { } AvatarSharedPointer AvatarManager::newSharedAvatar() { - return AvatarSharedPointer(new OtherAvatar(qApp->thread()), [](OtherAvatar* ptr) { ptr->deleteLater(); }); + + auto newOtherAvatar = AvatarSharedPointer(new OtherAvatar(qApp->thread()), [](OtherAvatar* ptr) { ptr->deleteLater(); }); + + //add the purple orb + /* + if (newOtherAvatar->_purpleOrbMeshPlaceholderID == UNKNOWN_OVERLAY_ID || + !qApp->getOverlays().isAddedOverlay(newOtherAvatar->_purpleOrbMeshPlaceholderID)) { + newOtherAvatar->_purpleOrbMeshPlaceholder = std::make_shared(); + newOtherAvatar->_purpleOrbMeshPlaceholder->setAlpha(1.0f); + newOtherAvatar->_purpleOrbMeshPlaceholder->setColor({ 0xFF, 0x00, 0xFF }); + newOtherAvatar->_purpleOrbMeshPlaceholder->setIsSolid(false); + newOtherAvatar->_purpleOrbMeshPlaceholder->setPulseMin(0.5); + newOtherAvatar->_purpleOrbMeshPlaceholder->setPulseMax(1.0); + newOtherAvatar->_purpleOrbMeshPlaceholder->setColorPulse(1.0); + newOtherAvatar->_purpleOrbMeshPlaceholder->setIgnoreRayIntersection(true); + newOtherAvatar->_purpleOrbMeshPlaceholder->setDrawInFront(false); + newOtherAvatar->_purpleOrbMeshPlaceholderID = qApp->getOverlays().addOverlay(newOtherAvatar->_purpleOrbMeshPlaceholder); + // Position focus + newOtherAvatar->_purpleOrbMeshPlaceholder->setWorldOrientation(glm::quat(0.0f, 0.0f, 0.0f, 1.0)); + newOtherAvatar->_purpleOrbMeshPlaceholder->setWorldPosition(glm::vec3(476.0f, 500.0f, 493.0f)); + newOtherAvatar->_purpleOrbMeshPlaceholder->setDimensions(glm::vec3(0.5f, 0.5f, 0.5f)); + newOtherAvatar->_purpleOrbMeshPlaceholder->setVisible(true); + } + */ + + + + return newOtherAvatar; } void AvatarManager::handleRemovedAvatar(const AvatarSharedPointer& removedAvatar, KillAvatarReason removalReason) { @@ -621,3 +648,12 @@ void AvatarManager::setAvatarSortCoefficient(const QString& name, const QScriptV DependencyManager::get()->broadcastToNodes(std::move(packet), NodeSet() << NodeType::AvatarMixer); } } + +void AvatarManager::removeOrb(OverlayID orbID) { + if (qApp->getOverlays().isAddedOverlay(orbID)) { + qApp->getOverlays().deleteOverlay(orbID); + //qCWarning(avatars_renderer) << "remove the purple orb***************************"; + } +} + + diff --git a/interface/src/avatar/AvatarManager.h b/interface/src/avatar/AvatarManager.h index 6a3d0355f6..600da65b85 100644 --- a/interface/src/avatar/AvatarManager.h +++ b/interface/src/avatar/AvatarManager.h @@ -158,6 +158,8 @@ public: float getMyAvatarSendRate() const { return _myAvatarSendRate.rate(); } + void removeOrb(OverlayID orbID); + public slots: /**jsdoc diff --git a/libraries/avatars-renderer/src/avatars-renderer/Avatar.cpp b/libraries/avatars-renderer/src/avatars-renderer/Avatar.cpp index 6d23b524d3..4fc987d6dd 100644 --- a/libraries/avatars-renderer/src/avatars-renderer/Avatar.cpp +++ b/libraries/avatars-renderer/src/avatars-renderer/Avatar.cpp @@ -1891,16 +1891,11 @@ void Avatar::processMaterials() { } } } -void Avatar::removeOrb() { - if (qApp->getOverlays().isAddedOverlay(_purpleOrbMeshPlaceholderID)) { - qApp->getOverlays().deleteOverlay(_purpleOrbMeshPlaceholderID); - qCWarning(avatars_renderer) << "remove the purple orb***************************"; - } -} void Avatar::updateOrbPosition() { _purpleOrbMeshPlaceholder->setWorldPosition(getHead()->getPosition()); -} +} + scriptable::ScriptableModelBase Avatar::getScriptableModel() { if (!_skeletonModel || !_skeletonModel->isLoaded()) { return scriptable::ScriptableModelBase(); diff --git a/libraries/avatars-renderer/src/avatars-renderer/Avatar.h b/libraries/avatars-renderer/src/avatars-renderer/Avatar.h index c480c5905e..e4052865dd 100644 --- a/libraries/avatars-renderer/src/avatars-renderer/Avatar.h +++ b/libraries/avatars-renderer/src/avatars-renderer/Avatar.h @@ -367,10 +367,10 @@ public: void removeMaterial(graphics::MaterialPointer material, const std::string& parentMaterialName) override; virtual scriptable::ScriptableModelBase getScriptableModel() override; - void removeOrb(); + void updateOrbPosition(); std::shared_ptr _purpleOrbMeshPlaceholder{ nullptr }; - OverlayID _purpleOrbMeshPlaceholderID{ UNKNOWN_OVERLAY_ID }; + OverlayID _purpleOrbMeshPlaceholderID{ UNKNOWN_OVERLAY_ID }; public slots: // FIXME - these should be migrated to use Pose data instead diff --git a/libraries/avatars-renderer/src/avatars-renderer/OtherAvatar.cpp b/libraries/avatars-renderer/src/avatars-renderer/OtherAvatar.cpp index 11281334eb..a6c69d24f6 100644 --- a/libraries/avatars-renderer/src/avatars-renderer/OtherAvatar.cpp +++ b/libraries/avatars-renderer/src/avatars-renderer/OtherAvatar.cpp @@ -19,6 +19,7 @@ OtherAvatar::OtherAvatar(QThread* thread) : Avatar(thread) { connect(_skeletonModel.get(), &Model::rigReset, this, &Avatar::rigReset); //add the purple orb + if (_purpleOrbMeshPlaceholderID == UNKNOWN_OVERLAY_ID || !qApp->getOverlays().isAddedOverlay(_purpleOrbMeshPlaceholderID)) { _purpleOrbMeshPlaceholder = std::make_shared(); _purpleOrbMeshPlaceholder->setAlpha(1.0f); @@ -36,4 +37,5 @@ OtherAvatar::OtherAvatar(QThread* thread) : Avatar(thread) { _purpleOrbMeshPlaceholder->setDimensions(glm::vec3(0.5f, 0.5f, 0.5f)); _purpleOrbMeshPlaceholder->setVisible(true); } + } diff --git a/libraries/avatars/src/AvatarData.h b/libraries/avatars/src/AvatarData.h index 51b3257ba2..2d150609d1 100644 --- a/libraries/avatars/src/AvatarData.h +++ b/libraries/avatars/src/AvatarData.h @@ -55,6 +55,8 @@ #include "PathUtils.h" #include +//#include "Overlays.h" +//#include "Sphere3DOverlay.h" using AvatarSharedPointer = std::shared_ptr; using AvatarWeakPointer = std::weak_ptr; From 1fec900ba61baa686c0f72082f434b8a416d1313 Mon Sep 17 00:00:00 2001 From: Dante Ruiz Date: Tue, 26 Jun 2018 13:31:59 -0700 Subject: [PATCH 07/29] disable flying by default --- interface/src/avatar/MyAvatar.cpp | 3 ++- interface/src/avatar/MyAvatar.h | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/interface/src/avatar/MyAvatar.cpp b/interface/src/avatar/MyAvatar.cpp index b0369303e9..7190ac87b9 100755 --- a/interface/src/avatar/MyAvatar.cpp +++ b/interface/src/avatar/MyAvatar.cpp @@ -1070,6 +1070,7 @@ void MyAvatar::saveData() { settings.setValue("useSnapTurn", _useSnapTurn); settings.setValue("clearOverlayWhenMoving", _clearOverlayWhenMoving); settings.setValue("userHeight", getUserHeight()); + settings.setValue("enabledFlying", getFlyingEnabled()); settings.endGroup(); } @@ -1219,7 +1220,7 @@ void MyAvatar::loadData() { settings.remove("avatarEntityData"); } setAvatarEntityDataChanged(true); - + setFlyingEnabled(settings.value("enabledFlying").toBool()); setDisplayName(settings.value("displayName").toString()); setCollisionSoundURL(settings.value("collisionSoundURL", DEFAULT_AVATAR_COLLISION_SOUND_URL).toString()); setSnapTurn(settings.value("useSnapTurn", _useSnapTurn).toBool()); diff --git a/interface/src/avatar/MyAvatar.h b/interface/src/avatar/MyAvatar.h index 1a6feb142a..ad4d849607 100644 --- a/interface/src/avatar/MyAvatar.h +++ b/interface/src/avatar/MyAvatar.h @@ -1433,7 +1433,7 @@ private: std::array _driveKeys; std::bitset _disabledDriveKeys; - bool _enableFlying { true }; + bool _enableFlying { false }; bool _wasPushing { false }; bool _isPushing { false }; bool _isBeingPushed { false }; From 3cf36bed55be192a17d239236d55a0017cb3485d Mon Sep 17 00:00:00 2001 From: Dante Ruiz Date: Tue, 26 Jun 2018 14:57:15 -0700 Subject: [PATCH 08/29] making small adjustments --- interface/src/avatar/MyAvatar.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/interface/src/avatar/MyAvatar.cpp b/interface/src/avatar/MyAvatar.cpp index 7190ac87b9..a7b7c1a20d 100755 --- a/interface/src/avatar/MyAvatar.cpp +++ b/interface/src/avatar/MyAvatar.cpp @@ -685,7 +685,8 @@ void MyAvatar::simulate(float deltaTime) { entityTree->recurseTreeWithOperator(&moveOperator); } }); - _characterController.setFlyingAllowed(zoneAllowsFlying && _enableFlying); + bool isPhysicsEnabled = qApp->isPhysicsEnabled(); + _characterController.setFlyingAllowed(zoneAllowsFlying && (_enableFlying || !isPhysicsEnabled)); _characterController.setCollisionlessAllowed(collisionlessAllowed); } From 46c70d948f054a06dd54adcf2317180bf1ee0a80 Mon Sep 17 00:00:00 2001 From: amantley Date: Tue, 26 Jun 2018 15:11:58 -0700 Subject: [PATCH 09/29] Moved OtherAvatar class to interface project. This allows AvatarManager to create and delete the orb overlay that is drawn when an avatar is present in a domain but for some reason the geometry is not loaded. OtherAvatar has new members orbMeshPlaceholder and orbMeshPlaceholderID for a spherical orb that is drawn --- interface/src/avatar/AvatarManager.cpp | 38 +----- interface/src/avatar/OtherAvatar.cpp | 58 +++++++++ interface/src/avatar/OtherAvatar.h | 28 +++++ .../src/avatars-renderer/Avatar.cpp | 24 +--- .../src/avatars-renderer/Avatar.h | 118 ++++++++++-------- .../src/avatars-renderer/OtherAvatar.cpp | 41 ------ .../src/avatars-renderer/OtherAvatar.h | 20 --- 7 files changed, 157 insertions(+), 170 deletions(-) create mode 100644 interface/src/avatar/OtherAvatar.cpp create mode 100644 interface/src/avatar/OtherAvatar.h delete mode 100644 libraries/avatars-renderer/src/avatars-renderer/OtherAvatar.cpp delete mode 100644 libraries/avatars-renderer/src/avatars-renderer/OtherAvatar.h diff --git a/interface/src/avatar/AvatarManager.cpp b/interface/src/avatar/AvatarManager.cpp index 8866ae68f9..1304fa84a9 100644 --- a/interface/src/avatar/AvatarManager.cpp +++ b/interface/src/avatar/AvatarManager.cpp @@ -36,13 +36,13 @@ #include #include #include -#include #include #include "Application.h" #include "InterfaceLogging.h" #include "Menu.h" #include "MyAvatar.h" +#include "OtherAvatar.h" #include "SceneScriptingInterface.h" // 50 times per second - target is 45hz, but this helps account for any small deviations @@ -192,13 +192,14 @@ void AvatarManager::updateOtherAvatars(float deltaTime) { while (!sortedAvatars.empty()) { const SortableAvatar& sortData = sortedAvatars.top(); const auto avatar = std::static_pointer_cast(sortData.getAvatar()); + const auto otherAvatar = std::static_pointer_cast(sortData.getAvatar()); //if the geometry is loaded then turn off the orb if (avatar->getSkeletonModel()->isLoaded()) { //remove the orb if it is there - removeOrb(avatar->_purpleOrbMeshPlaceholderID); + otherAvatar->removeOrb(); } else { - avatar->updateOrbPosition(); + otherAvatar->updateOrbPosition(); } bool ignoring = DependencyManager::get()->isPersonalMutingNode(avatar->getID()); @@ -327,30 +328,6 @@ void AvatarManager::simulateAvatarFades(float deltaTime) { AvatarSharedPointer AvatarManager::newSharedAvatar() { auto newOtherAvatar = AvatarSharedPointer(new OtherAvatar(qApp->thread()), [](OtherAvatar* ptr) { ptr->deleteLater(); }); - - //add the purple orb - /* - if (newOtherAvatar->_purpleOrbMeshPlaceholderID == UNKNOWN_OVERLAY_ID || - !qApp->getOverlays().isAddedOverlay(newOtherAvatar->_purpleOrbMeshPlaceholderID)) { - newOtherAvatar->_purpleOrbMeshPlaceholder = std::make_shared(); - newOtherAvatar->_purpleOrbMeshPlaceholder->setAlpha(1.0f); - newOtherAvatar->_purpleOrbMeshPlaceholder->setColor({ 0xFF, 0x00, 0xFF }); - newOtherAvatar->_purpleOrbMeshPlaceholder->setIsSolid(false); - newOtherAvatar->_purpleOrbMeshPlaceholder->setPulseMin(0.5); - newOtherAvatar->_purpleOrbMeshPlaceholder->setPulseMax(1.0); - newOtherAvatar->_purpleOrbMeshPlaceholder->setColorPulse(1.0); - newOtherAvatar->_purpleOrbMeshPlaceholder->setIgnoreRayIntersection(true); - newOtherAvatar->_purpleOrbMeshPlaceholder->setDrawInFront(false); - newOtherAvatar->_purpleOrbMeshPlaceholderID = qApp->getOverlays().addOverlay(newOtherAvatar->_purpleOrbMeshPlaceholder); - // Position focus - newOtherAvatar->_purpleOrbMeshPlaceholder->setWorldOrientation(glm::quat(0.0f, 0.0f, 0.0f, 1.0)); - newOtherAvatar->_purpleOrbMeshPlaceholder->setWorldPosition(glm::vec3(476.0f, 500.0f, 493.0f)); - newOtherAvatar->_purpleOrbMeshPlaceholder->setDimensions(glm::vec3(0.5f, 0.5f, 0.5f)); - newOtherAvatar->_purpleOrbMeshPlaceholder->setVisible(true); - } - */ - - return newOtherAvatar; } @@ -649,11 +626,6 @@ void AvatarManager::setAvatarSortCoefficient(const QString& name, const QScriptV } } -void AvatarManager::removeOrb(OverlayID orbID) { - if (qApp->getOverlays().isAddedOverlay(orbID)) { - qApp->getOverlays().deleteOverlay(orbID); - //qCWarning(avatars_renderer) << "remove the purple orb***************************"; - } -} + diff --git a/interface/src/avatar/OtherAvatar.cpp b/interface/src/avatar/OtherAvatar.cpp new file mode 100644 index 0000000000..e6c3553b1e --- /dev/null +++ b/interface/src/avatar/OtherAvatar.cpp @@ -0,0 +1,58 @@ +// +// Created by Bradley Austin Davis on 2017/04/27 +// Copyright 2013-2017 High Fidelity, Inc. +// +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html +// + +#include "OtherAvatar.h" +#include "../../interface/src/Application.h" + +OtherAvatar::OtherAvatar(QThread* thread) : Avatar(thread) { + // give the pointer to our head to inherited _headData variable from AvatarData + _headData = new Head(this); + _skeletonModel = std::make_shared(this, nullptr); + _skeletonModel->setLoadingPriority(OTHERAVATAR_LOADING_PRIORITY); + connect(_skeletonModel.get(), &Model::setURLFinished, this, &Avatar::setModelURLFinished); + connect(_skeletonModel.get(), &Model::rigReady, this, &Avatar::rigReady); + connect(_skeletonModel.get(), &Model::rigReset, this, &Avatar::rigReset); + + //add the purple orb + createOrb(); + + +} + +void OtherAvatar::removeOrb() { + if (qApp->getOverlays().isAddedOverlay(_otherAvatarOrbMeshPlaceholderID)) { + qApp->getOverlays().deleteOverlay(_otherAvatarOrbMeshPlaceholderID); + //qCWarning(avatars_renderer) << "remove the purple orb***************************"; + } +} + +void OtherAvatar::updateOrbPosition() { + _otherAvatarOrbMeshPlaceholder->setWorldPosition(getHead()->getPosition()); +} + +void OtherAvatar::createOrb() { + qCDebug(interfaceapp) << "we are in create orb otherAvatar.h"; + if (_otherAvatarOrbMeshPlaceholderID == UNKNOWN_OVERLAY_ID || + !qApp->getOverlays().isAddedOverlay(_otherAvatarOrbMeshPlaceholderID)) { + _otherAvatarOrbMeshPlaceholder = std::make_shared(); + _otherAvatarOrbMeshPlaceholder->setAlpha(1.0f); + _otherAvatarOrbMeshPlaceholder->setColor({ 0xFF, 0x00, 0xFF }); + _otherAvatarOrbMeshPlaceholder->setIsSolid(false); + _otherAvatarOrbMeshPlaceholder->setPulseMin(0.5); + _otherAvatarOrbMeshPlaceholder->setPulseMax(1.0); + _otherAvatarOrbMeshPlaceholder->setColorPulse(1.0); + _otherAvatarOrbMeshPlaceholder->setIgnoreRayIntersection(true); + _otherAvatarOrbMeshPlaceholder->setDrawInFront(false); + _otherAvatarOrbMeshPlaceholderID = qApp->getOverlays().addOverlay(_otherAvatarOrbMeshPlaceholder); + // Position focus + _otherAvatarOrbMeshPlaceholder->setWorldOrientation(glm::quat(0.0f, 0.0f, 0.0f, 1.0)); + _otherAvatarOrbMeshPlaceholder->setWorldPosition(glm::vec3(476.0f, 500.0f, 493.0f)); + _otherAvatarOrbMeshPlaceholder->setDimensions(glm::vec3(0.5f, 0.5f, 0.5f)); + _otherAvatarOrbMeshPlaceholder->setVisible(true); + } +} diff --git a/interface/src/avatar/OtherAvatar.h b/interface/src/avatar/OtherAvatar.h new file mode 100644 index 0000000000..707dd1fcc8 --- /dev/null +++ b/interface/src/avatar/OtherAvatar.h @@ -0,0 +1,28 @@ +// +// Created by Bradley Austin Davis on 2017/04/27 +// Copyright 2013-2017 High Fidelity, Inc. +// +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html +// + +#ifndef hifi_OtherAvatar_h +#define hifi_OtherAvatar_h + +#include +#include "ui/overlays/Overlays.h" +#include "ui/overlays/Sphere3DOverlay.h" +#include "InterfaceLogging.h" + +class OtherAvatar : public Avatar { +public: + explicit OtherAvatar(QThread* thread); + virtual void instantiableAvatar() override{}; + void createOrb() override; + void updateOrbPosition(); + void removeOrb(); + std::shared_ptr _otherAvatarOrbMeshPlaceholder{ nullptr }; + OverlayID _otherAvatarOrbMeshPlaceholderID{ UNKNOWN_OVERLAY_ID }; +}; + +#endif // hifi_OtherAvatar_h diff --git a/libraries/avatars-renderer/src/avatars-renderer/Avatar.cpp b/libraries/avatars-renderer/src/avatars-renderer/Avatar.cpp index 4fc987d6dd..64545f326d 100644 --- a/libraries/avatars-renderer/src/avatars-renderer/Avatar.cpp +++ b/libraries/avatars-renderer/src/avatars-renderer/Avatar.cpp @@ -1340,25 +1340,7 @@ void Avatar::scaleVectorRelativeToPosition(glm::vec3 &positionToScale) const { void Avatar::setSkeletonModelURL(const QUrl& skeletonModelURL) { if (!isMyAvatar()) { - if (_purpleOrbMeshPlaceholderID == UNKNOWN_OVERLAY_ID || - !qApp->getOverlays().isAddedOverlay(_purpleOrbMeshPlaceholderID)) { - qCWarning(avatars_renderer) << "change model add the purple orb************************"; - _purpleOrbMeshPlaceholder = std::make_shared(); - _purpleOrbMeshPlaceholder->setAlpha(1.0f); - _purpleOrbMeshPlaceholder->setColor({ 0xFF, 0x00, 0xFF }); - _purpleOrbMeshPlaceholder->setIsSolid(false); - _purpleOrbMeshPlaceholder->setPulseMin(0.5); - _purpleOrbMeshPlaceholder->setPulseMax(1.0); - _purpleOrbMeshPlaceholder->setColorPulse(1.0); - _purpleOrbMeshPlaceholder->setIgnoreRayIntersection(true); - _purpleOrbMeshPlaceholder->setDrawInFront(false); - _purpleOrbMeshPlaceholderID = qApp->getOverlays().addOverlay(_purpleOrbMeshPlaceholder); - // Position focus - _purpleOrbMeshPlaceholder->setWorldOrientation(glm::quat(0.0f, 0.0f, 0.0f, 1.0)); - _purpleOrbMeshPlaceholder->setWorldPosition(getHead()->getPosition()); - _purpleOrbMeshPlaceholder->setDimensions(glm::vec3(0.5f, 0.5f, 0.5f)); - _purpleOrbMeshPlaceholder->setVisible(true); - } + createOrb(); } AvatarData::setSkeletonModelURL(skeletonModelURL); if (QThread::currentThread() == thread()) { @@ -1892,9 +1874,7 @@ void Avatar::processMaterials() { } } -void Avatar::updateOrbPosition() { - _purpleOrbMeshPlaceholder->setWorldPosition(getHead()->getPosition()); -} + scriptable::ScriptableModelBase Avatar::getScriptableModel() { if (!_skeletonModel || !_skeletonModel->isLoaded()) { diff --git a/libraries/avatars-renderer/src/avatars-renderer/Avatar.h b/libraries/avatars-renderer/src/avatars-renderer/Avatar.h index e4052865dd..964ce91a30 100644 --- a/libraries/avatars-renderer/src/avatars-renderer/Avatar.h +++ b/libraries/avatars-renderer/src/avatars-renderer/Avatar.h @@ -23,29 +23,34 @@ #include #include - #include "Head.h" #include "SkeletonModel.h" #include "Rig.h" #include "../../interface/src/ui/overlays/Overlays.h" #include "../../interface/src/ui/overlays/Sphere3DOverlay.h" +#include "Logging.h" + #include namespace render { - template <> const ItemKey payloadGetKey(const AvatarSharedPointer& avatar); - template <> const Item::Bound payloadGetBound(const AvatarSharedPointer& avatar); - template <> void payloadRender(const AvatarSharedPointer& avatar, RenderArgs* args); - template <> uint32_t metaFetchMetaSubItems(const AvatarSharedPointer& avatar, ItemIDs& subItems); -} +template <> +const ItemKey payloadGetKey(const AvatarSharedPointer& avatar); +template <> +const Item::Bound payloadGetBound(const AvatarSharedPointer& avatar); +template <> +void payloadRender(const AvatarSharedPointer& avatar, RenderArgs* args); +template <> +uint32_t metaFetchMetaSubItems(const AvatarSharedPointer& avatar, ItemIDs& subItems); +} // namespace render static const float SCALING_RATIO = .05f; extern const float CHAT_MESSAGE_SCALE; extern const float CHAT_MESSAGE_HEIGHT; - -enum ScreenTintLayer { +enum ScreenTintLayer +{ SCREEN_TINT_BEFORE_LANDSCAPE = 0, SCREEN_TINT_BEFORE_AVATARS, SCREEN_TINT_BEFORE_MY_AVATAR, @@ -85,11 +90,9 @@ public: virtual void render(RenderArgs* renderArgs); - void addToScene(AvatarSharedPointer self, const render::ScenePointer& scene, - render::Transaction& transaction); + void addToScene(AvatarSharedPointer self, const render::ScenePointer& scene, render::Transaction& transaction); - void removeFromScene(AvatarSharedPointer self, const render::ScenePointer& scene, - render::Transaction& transaction); + void removeFromScene(AvatarSharedPointer self, const render::ScenePointer& scene, render::Transaction& transaction); void updateRenderItem(render::Transaction& transaction); @@ -112,6 +115,7 @@ public: float getLODDistance() const; virtual bool isMyAvatar() const override { return false; } + virtual void createOrb() { qCDebug(avatars_renderer) << "we are in create orb avatar.h"; } virtual QVector getJointRotations() const override; using AvatarData::getJointRotation; @@ -166,14 +170,18 @@ public: virtual void setAttachmentData(const QVector& attachmentData) override; void updateDisplayNameAlpha(bool showDisplayName); - virtual void setSessionDisplayName(const QString& sessionDisplayName) override { }; // no-op + virtual void setSessionDisplayName(const QString& sessionDisplayName) override{}; // no-op virtual int parseDataFromBuffer(const QByteArray& buffer) override; - static void renderJointConnectingCone( gpu::Batch& batch, glm::vec3 position1, glm::vec3 position2, - float radius1, float radius2, const glm::vec4& color); + static void renderJointConnectingCone(gpu::Batch& batch, + glm::vec3 position1, + glm::vec3 position2, + float radius1, + float radius2, + const glm::vec4& color); - virtual void applyCollision(const glm::vec3& contactPoint, const glm::vec3& penetration) { } + virtual void applyCollision(const glm::vec3& contactPoint, const glm::vec3& penetration) {} /**jsdoc * Set the offset applied to the current avatar. The offset adjusts the position that the avatar is rendered. For example, @@ -238,7 +246,7 @@ public: /// Scales a world space position vector relative to the avatar position and scale /// \param vector position to be scaled. Will store the result - void scaleVectorRelativeToPosition(glm::vec3 &positionToScale) const; + void scaleVectorRelativeToPosition(glm::vec3& positionToScale) const; void slamPosition(const glm::vec3& position); virtual void updateAttitude(const glm::quat& orientation) override; @@ -257,7 +265,6 @@ public: void setPositionViaScript(const glm::vec3& position) override; void setOrientationViaScript(const glm::quat& orientation) override; - /**jsdoc * @function MyAvatar.getParentID * @returns {Uuid} @@ -286,7 +293,6 @@ public: // This calls through to the SpatiallyNestable versions, but is here to expose these to JavaScript. Q_INVOKABLE virtual void setParentJointIndex(quint16 parentJointIndex) override; - /**jsdoc * Returns an array of joints, where each joint is an object containing name, index, and parentIndex fields. * @function MyAvatar.getSkeleton @@ -324,7 +330,8 @@ public: bool hasNewJointData() const { return _hasNewJointData; } float getBoundingRadius() const; - AABox getRenderBounds() const; // THis call is accessible from rendering thread only to report the bounding box of the avatar during the frame. + AABox getRenderBounds() + const; // THis call is accessible from rendering thread only to report the bounding box of the avatar during the frame. void addToScene(AvatarSharedPointer self, const render::ScenePointer& scene); void ensureInScene(AvatarSharedPointer self, const render::ScenePointer& scene); @@ -352,7 +359,6 @@ public: // not all subclasses of AvatarData have access to this data. virtual bool canMeasureEyeHeight() const override { return true; } - virtual float getModelScale() const { return _modelScale; } virtual void setModelScale(float scale) { _modelScale = scale; } virtual glm::vec3 scaleForChildren() const override { return glm::vec3(getModelScale()); } @@ -367,10 +373,10 @@ public: void removeMaterial(graphics::MaterialPointer material, const std::string& parentMaterialName) override; virtual scriptable::ScriptableModelBase getScriptableModel() override; - - void updateOrbPosition(); - std::shared_ptr _purpleOrbMeshPlaceholder{ nullptr }; - OverlayID _purpleOrbMeshPlaceholderID{ UNKNOWN_OVERLAY_ID }; + + //void updateOrbPosition(); + //std::shared_ptr _purpleOrbMeshPlaceholder{ nullptr }; + //OverlayID _purpleOrbMeshPlaceholderID{ UNKNOWN_OVERLAY_ID }; public slots: // FIXME - these should be migrated to use Pose data instead @@ -432,9 +438,13 @@ protected: float getUnscaledEyeHeightFromSkeleton() const; void buildUnscaledEyeHeightCache(); void clearUnscaledEyeHeightCache(); - virtual const QString& getSessionDisplayNameForTransport() const override { return _empty; } // Save a tiny bit of bandwidth. Mixer won't look at what we send. + virtual const QString& getSessionDisplayNameForTransport() const override { + return _empty; + } // Save a tiny bit of bandwidth. Mixer won't look at what we send. QString _empty{}; - virtual void maybeUpdateSessionDisplayNameFromTransport(const QString& sessionDisplayName) override { _sessionDisplayName = sessionDisplayName; } // don't use no-op setter! + virtual void maybeUpdateSessionDisplayNameFromTransport(const QString& sessionDisplayName) override { + _sessionDisplayName = sessionDisplayName; + } // don't use no-op setter! SkeletonModelPointer _skeletonModel; @@ -442,7 +452,7 @@ protected: void withValidJointIndicesCache(std::function const& worker) const; mutable QHash _modelJointIndicesCache; mutable QReadWriteLock _modelJointIndicesCacheLock; - mutable bool _modelJointsCached { false }; + mutable bool _modelJointsCached{ false }; glm::vec3 _skeletonOffset; std::vector> _attachmentModels; @@ -450,7 +460,7 @@ protected: std::vector> _attachmentsToRemove; std::vector> _attachmentsToDelete; - float _bodyYawDelta { 0.0f }; // degrees/sec + float _bodyYawDelta{ 0.0f }; // degrees/sec // These position histories and derivatives are in the world-frame. // The derivatives are the MEASURED results of all external and internal forces @@ -466,8 +476,8 @@ protected: glm::vec3 _angularAcceleration; glm::quat _lastOrientation; - glm::vec3 _worldUpDirection { Vectors::UP }; - bool _moving { false }; ///< set when position is changing + glm::vec3 _worldUpDirection{ Vectors::UP }; + bool _moving{ false }; ///< set when position is changing // protected methods... bool isLookingAtMe(AvatarSharedPointer avatar) const; @@ -493,10 +503,10 @@ protected: render::ItemID _renderItemID{ render::Item::INVALID_ITEM_ID }; - ThreadSafeValueCache _leftPalmPositionCache { glm::vec3() }; - ThreadSafeValueCache _leftPalmRotationCache { glm::quat() }; - ThreadSafeValueCache _rightPalmPositionCache { glm::vec3() }; - ThreadSafeValueCache _rightPalmRotationCache { glm::quat() }; + ThreadSafeValueCache _leftPalmPositionCache{ glm::vec3() }; + ThreadSafeValueCache _leftPalmRotationCache{ glm::quat() }; + ThreadSafeValueCache _rightPalmPositionCache{ glm::vec3() }; + ThreadSafeValueCache _rightPalmRotationCache{ glm::quat() }; // Some rate tracking support RateCounter<> _simulationRate; @@ -507,36 +517,36 @@ protected: protected: class AvatarEntityDataHash { public: - AvatarEntityDataHash(uint32_t h) : hash(h) {}; - uint32_t hash { 0 }; - bool success { false }; + AvatarEntityDataHash(uint32_t h) : hash(h){}; + uint32_t hash{ 0 }; + bool success{ false }; }; using MapOfAvatarEntityDataHashes = QMap; MapOfAvatarEntityDataHashes _avatarEntityDataHashes; - uint64_t _lastRenderUpdateTime { 0 }; - int _leftPointerGeometryID { 0 }; - int _rightPointerGeometryID { 0 }; - int _nameRectGeometryID { 0 }; - bool _initialized { false }; - bool _isLookAtTarget { false }; - bool _isAnimatingScale { false }; - bool _mustFadeIn { false }; - bool _isFading { false }; - bool _reconstructSoftEntitiesJointMap { false }; - float _modelScale { 1.0f }; + uint64_t _lastRenderUpdateTime{ 0 }; + int _leftPointerGeometryID{ 0 }; + int _rightPointerGeometryID{ 0 }; + int _nameRectGeometryID{ 0 }; + bool _initialized{ false }; + bool _isLookAtTarget{ false }; + bool _isAnimatingScale{ false }; + bool _mustFadeIn{ false }; + bool _isFading{ false }; + bool _reconstructSoftEntitiesJointMap{ false }; + float _modelScale{ 1.0f }; static int _jointConesID; int _voiceSphereID; - AvatarPhysicsCallback _physicsCallback { nullptr }; + AvatarPhysicsCallback _physicsCallback{ nullptr }; - float _displayNameTargetAlpha { 1.0f }; - float _displayNameAlpha { 1.0f }; + float _displayNameTargetAlpha{ 1.0f }; + float _displayNameAlpha{ 1.0f }; - ThreadSafeValueCache _unscaledEyeHeightCache { DEFAULT_AVATAR_EYE_HEIGHT }; + ThreadSafeValueCache _unscaledEyeHeightCache{ DEFAULT_AVATAR_EYE_HEIGHT }; std::unordered_map _materials; std::mutex _materialsLock; @@ -552,4 +562,4 @@ protected: static const float ATTACHMENT_LOADING_PRIORITY; }; -#endif // hifi_Avatar_h +#endif // hifi_Avatar_h diff --git a/libraries/avatars-renderer/src/avatars-renderer/OtherAvatar.cpp b/libraries/avatars-renderer/src/avatars-renderer/OtherAvatar.cpp deleted file mode 100644 index a6c69d24f6..0000000000 --- a/libraries/avatars-renderer/src/avatars-renderer/OtherAvatar.cpp +++ /dev/null @@ -1,41 +0,0 @@ -// -// Created by Bradley Austin Davis on 2017/04/27 -// Copyright 2013-2017 High Fidelity, Inc. -// -// Distributed under the Apache License, Version 2.0. -// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html -// - -#include "OtherAvatar.h" -#include "../../interface/src/Application.h" - -OtherAvatar::OtherAvatar(QThread* thread) : Avatar(thread) { - // give the pointer to our head to inherited _headData variable from AvatarData - _headData = new Head(this); - _skeletonModel = std::make_shared(this, nullptr); - _skeletonModel->setLoadingPriority(OTHERAVATAR_LOADING_PRIORITY); - connect(_skeletonModel.get(), &Model::setURLFinished, this, &Avatar::setModelURLFinished); - connect(_skeletonModel.get(), &Model::rigReady, this, &Avatar::rigReady); - connect(_skeletonModel.get(), &Model::rigReset, this, &Avatar::rigReset); - - //add the purple orb - - if (_purpleOrbMeshPlaceholderID == UNKNOWN_OVERLAY_ID || !qApp->getOverlays().isAddedOverlay(_purpleOrbMeshPlaceholderID)) { - _purpleOrbMeshPlaceholder = std::make_shared(); - _purpleOrbMeshPlaceholder->setAlpha(1.0f); - _purpleOrbMeshPlaceholder->setColor({ 0xFF, 0x00, 0xFF }); - _purpleOrbMeshPlaceholder->setIsSolid(false); - _purpleOrbMeshPlaceholder->setPulseMin(0.5); - _purpleOrbMeshPlaceholder->setPulseMax(1.0); - _purpleOrbMeshPlaceholder->setColorPulse(1.0); - _purpleOrbMeshPlaceholder->setIgnoreRayIntersection(true); - _purpleOrbMeshPlaceholder->setDrawInFront(false); - _purpleOrbMeshPlaceholderID = qApp->getOverlays().addOverlay(_purpleOrbMeshPlaceholder); - // Position focus - _purpleOrbMeshPlaceholder->setWorldOrientation(glm::quat(0.0f, 0.0f, 0.0f, 1.0)); - _purpleOrbMeshPlaceholder->setWorldPosition(glm::vec3(476.0f, 500.0f, 493.0f)); - _purpleOrbMeshPlaceholder->setDimensions(glm::vec3(0.5f, 0.5f, 0.5f)); - _purpleOrbMeshPlaceholder->setVisible(true); - } - -} diff --git a/libraries/avatars-renderer/src/avatars-renderer/OtherAvatar.h b/libraries/avatars-renderer/src/avatars-renderer/OtherAvatar.h deleted file mode 100644 index df09d7fd99..0000000000 --- a/libraries/avatars-renderer/src/avatars-renderer/OtherAvatar.h +++ /dev/null @@ -1,20 +0,0 @@ -// -// Created by Bradley Austin Davis on 2017/04/27 -// Copyright 2013-2017 High Fidelity, Inc. -// -// Distributed under the Apache License, Version 2.0. -// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html -// - -#ifndef hifi_OtherAvatar_h -#define hifi_OtherAvatar_h - -#include "Avatar.h" - -class OtherAvatar : public Avatar { -public: - explicit OtherAvatar(QThread* thread); - virtual void instantiableAvatar() override {}; -}; - -#endif // hifi_OtherAvatar_h From a89c2ea734867763a692cb6abd6004ddb4c063ce Mon Sep 17 00:00:00 2001 From: amantley Date: Tue, 26 Jun 2018 16:40:51 -0700 Subject: [PATCH 10/29] removed crust --- interface/src/avatar/AvatarManager.cpp | 12 ++----- interface/src/avatar/AvatarManager.h | 2 -- interface/src/avatar/OtherAvatar.cpp | 4 +-- .../src/avatars-renderer/Avatar.cpp | 7 ++-- .../src/avatars-renderer/Avatar.h | 35 +++++++++---------- 5 files changed, 23 insertions(+), 37 deletions(-) diff --git a/interface/src/avatar/AvatarManager.cpp b/interface/src/avatar/AvatarManager.cpp index 1304fa84a9..d1fcfc7d4b 100644 --- a/interface/src/avatar/AvatarManager.cpp +++ b/interface/src/avatar/AvatarManager.cpp @@ -201,7 +201,7 @@ void AvatarManager::updateOtherAvatars(float deltaTime) { } else { otherAvatar->updateOrbPosition(); } - + bool ignoring = DependencyManager::get()->isPersonalMutingNode(avatar->getID()); if (ignoring) { sortedAvatars.pop(); @@ -326,10 +326,8 @@ void AvatarManager::simulateAvatarFades(float deltaTime) { } AvatarSharedPointer AvatarManager::newSharedAvatar() { - - auto newOtherAvatar = AvatarSharedPointer(new OtherAvatar(qApp->thread()), [](OtherAvatar* ptr) { ptr->deleteLater(); }); - return newOtherAvatar; + return AvatarSharedPointer(new OtherAvatar(qApp->thread()), [](OtherAvatar* ptr) { ptr->deleteLater(); }); } void AvatarManager::handleRemovedAvatar(const AvatarSharedPointer& removedAvatar, KillAvatarReason removalReason) { @@ -624,8 +622,4 @@ void AvatarManager::setAvatarSortCoefficient(const QString& name, const QScriptV packet->writePrimitive(AvatarData::_avatarSortCoefficientAge); DependencyManager::get()->broadcastToNodes(std::move(packet), NodeSet() << NodeType::AvatarMixer); } -} - - - - +} \ No newline at end of file diff --git a/interface/src/avatar/AvatarManager.h b/interface/src/avatar/AvatarManager.h index 600da65b85..6a3d0355f6 100644 --- a/interface/src/avatar/AvatarManager.h +++ b/interface/src/avatar/AvatarManager.h @@ -158,8 +158,6 @@ public: float getMyAvatarSendRate() const { return _myAvatarSendRate.rate(); } - void removeOrb(OverlayID orbID); - public slots: /**jsdoc diff --git a/interface/src/avatar/OtherAvatar.cpp b/interface/src/avatar/OtherAvatar.cpp index e6c3553b1e..035708b71d 100644 --- a/interface/src/avatar/OtherAvatar.cpp +++ b/interface/src/avatar/OtherAvatar.cpp @@ -7,7 +7,7 @@ // #include "OtherAvatar.h" -#include "../../interface/src/Application.h" +#include "Application.h" OtherAvatar::OtherAvatar(QThread* thread) : Avatar(thread) { // give the pointer to our head to inherited _headData variable from AvatarData @@ -20,8 +20,6 @@ OtherAvatar::OtherAvatar(QThread* thread) : Avatar(thread) { //add the purple orb createOrb(); - - } void OtherAvatar::removeOrb() { diff --git a/libraries/avatars-renderer/src/avatars-renderer/Avatar.cpp b/libraries/avatars-renderer/src/avatars-renderer/Avatar.cpp index 64545f326d..0381168407 100644 --- a/libraries/avatars-renderer/src/avatars-renderer/Avatar.cpp +++ b/libraries/avatars-renderer/src/avatars-renderer/Avatar.cpp @@ -33,8 +33,7 @@ #include #include #include "ModelEntityItem.h" -#include "RenderableModelEntityItem.h" -#include "../../interface/src/Application.h" +#include "RenderableModelEntityItem.h" #include @@ -1339,9 +1338,9 @@ void Avatar::scaleVectorRelativeToPosition(glm::vec3 &positionToScale) const { } void Avatar::setSkeletonModelURL(const QUrl& skeletonModelURL) { - if (!isMyAvatar()) { + if (!isMyAvatar()) { createOrb(); - } + } AvatarData::setSkeletonModelURL(skeletonModelURL); if (QThread::currentThread() == thread()) { _skeletonModel->setURL(_skeletonModelURL); diff --git a/libraries/avatars-renderer/src/avatars-renderer/Avatar.h b/libraries/avatars-renderer/src/avatars-renderer/Avatar.h index 964ce91a30..d3f4e7d327 100644 --- a/libraries/avatars-renderer/src/avatars-renderer/Avatar.h +++ b/libraries/avatars-renderer/src/avatars-renderer/Avatar.h @@ -29,28 +29,24 @@ #include "../../interface/src/ui/overlays/Overlays.h" #include "../../interface/src/ui/overlays/Sphere3DOverlay.h" -#include "Logging.h" #include namespace render { -template <> -const ItemKey payloadGetKey(const AvatarSharedPointer& avatar); -template <> -const Item::Bound payloadGetBound(const AvatarSharedPointer& avatar); -template <> -void payloadRender(const AvatarSharedPointer& avatar, RenderArgs* args); -template <> -uint32_t metaFetchMetaSubItems(const AvatarSharedPointer& avatar, ItemIDs& subItems); -} // namespace render + template <> const ItemKey payloadGetKey(const AvatarSharedPointer& avatar); + template <> const Item::Bound payloadGetBound(const AvatarSharedPointer& avatar); + template <> void payloadRender(const AvatarSharedPointer& avatar, RenderArgs* args); + template <> uint32_t metaFetchMetaSubItems(const AvatarSharedPointer& avatar, ItemIDs& subItems); +} + +// namespace render static const float SCALING_RATIO = .05f; extern const float CHAT_MESSAGE_SCALE; extern const float CHAT_MESSAGE_HEIGHT; -enum ScreenTintLayer -{ +enum ScreenTintLayer { SCREEN_TINT_BEFORE_LANDSCAPE = 0, SCREEN_TINT_BEFORE_AVATARS, SCREEN_TINT_BEFORE_MY_AVATAR, @@ -90,9 +86,11 @@ public: virtual void render(RenderArgs* renderArgs); - void addToScene(AvatarSharedPointer self, const render::ScenePointer& scene, render::Transaction& transaction); + void addToScene(AvatarSharedPointer self, const render::ScenePointer& scene, + render::Transaction& transaction); - void removeFromScene(AvatarSharedPointer self, const render::ScenePointer& scene, render::Transaction& transaction); + void removeFromScene(AvatarSharedPointer self, const render::ScenePointer& scene, + render::Transaction& transaction); void updateRenderItem(render::Transaction& transaction); @@ -115,7 +113,7 @@ public: float getLODDistance() const; virtual bool isMyAvatar() const override { return false; } - virtual void createOrb() { qCDebug(avatars_renderer) << "we are in create orb avatar.h"; } + virtual void createOrb() {} virtual QVector getJointRotations() const override; using AvatarData::getJointRotation; @@ -170,7 +168,7 @@ public: virtual void setAttachmentData(const QVector& attachmentData) override; void updateDisplayNameAlpha(bool showDisplayName); - virtual void setSessionDisplayName(const QString& sessionDisplayName) override{}; // no-op + virtual void setSessionDisplayName(const QString& sessionDisplayName) override { }; // no-op virtual int parseDataFromBuffer(const QByteArray& buffer) override; @@ -181,7 +179,7 @@ public: float radius2, const glm::vec4& color); - virtual void applyCollision(const glm::vec3& contactPoint, const glm::vec3& penetration) {} + virtual void applyCollision(const glm::vec3& contactPoint, const glm::vec3& penetration) { } /**jsdoc * Set the offset applied to the current avatar. The offset adjusts the position that the avatar is rendered. For example, @@ -330,8 +328,7 @@ public: bool hasNewJointData() const { return _hasNewJointData; } float getBoundingRadius() const; - AABox getRenderBounds() - const; // THis call is accessible from rendering thread only to report the bounding box of the avatar during the frame. + AABox getRenderBounds() const; // THis call is accessible from rendering thread only to report the bounding box of the avatar during the frame. void addToScene(AvatarSharedPointer self, const render::ScenePointer& scene); void ensureInScene(AvatarSharedPointer self, const render::ScenePointer& scene); From 1fcaf16b0c31c85971ff3de91c003862ab66b1be Mon Sep 17 00:00:00 2001 From: amantley Date: Tue, 26 Jun 2018 17:07:55 -0700 Subject: [PATCH 11/29] removed editor auto format errors --- .../src/avatars-renderer/Avatar.cpp | 4 +- .../src/avatars-renderer/Avatar.h | 88 ++++++++----------- libraries/avatars/src/AvatarData.h | 2 - 3 files changed, 38 insertions(+), 56 deletions(-) diff --git a/libraries/avatars-renderer/src/avatars-renderer/Avatar.cpp b/libraries/avatars-renderer/src/avatars-renderer/Avatar.cpp index 0381168407..843235c0e1 100644 --- a/libraries/avatars-renderer/src/avatars-renderer/Avatar.cpp +++ b/libraries/avatars-renderer/src/avatars-renderer/Avatar.cpp @@ -33,7 +33,7 @@ #include #include #include "ModelEntityItem.h" -#include "RenderableModelEntityItem.h" +#include "RenderableModelEntityItem.h" #include @@ -1873,8 +1873,6 @@ void Avatar::processMaterials() { } } - - scriptable::ScriptableModelBase Avatar::getScriptableModel() { if (!_skeletonModel || !_skeletonModel->isLoaded()) { return scriptable::ScriptableModelBase(); diff --git a/libraries/avatars-renderer/src/avatars-renderer/Avatar.h b/libraries/avatars-renderer/src/avatars-renderer/Avatar.h index d3f4e7d327..1e80e3d2cf 100644 --- a/libraries/avatars-renderer/src/avatars-renderer/Avatar.h +++ b/libraries/avatars-renderer/src/avatars-renderer/Avatar.h @@ -26,10 +26,6 @@ #include "Head.h" #include "SkeletonModel.h" #include "Rig.h" -#include "../../interface/src/ui/overlays/Overlays.h" -#include "../../interface/src/ui/overlays/Sphere3DOverlay.h" - - #include namespace render { @@ -37,9 +33,7 @@ namespace render { template <> const Item::Bound payloadGetBound(const AvatarSharedPointer& avatar); template <> void payloadRender(const AvatarSharedPointer& avatar, RenderArgs* args); template <> uint32_t metaFetchMetaSubItems(const AvatarSharedPointer& avatar, ItemIDs& subItems); -} - -// namespace render +} static const float SCALING_RATIO = .05f; @@ -90,7 +84,7 @@ public: render::Transaction& transaction); void removeFromScene(AvatarSharedPointer self, const render::ScenePointer& scene, - render::Transaction& transaction); + render::Transaction& transaction); void updateRenderItem(render::Transaction& transaction); @@ -113,7 +107,7 @@ public: float getLODDistance() const; virtual bool isMyAvatar() const override { return false; } - virtual void createOrb() {} + virtual void createOrb() { } virtual QVector getJointRotations() const override; using AvatarData::getJointRotation; @@ -168,16 +162,12 @@ public: virtual void setAttachmentData(const QVector& attachmentData) override; void updateDisplayNameAlpha(bool showDisplayName); - virtual void setSessionDisplayName(const QString& sessionDisplayName) override { }; // no-op + virtual void setSessionDisplayName(const QString& sessionDisplayName) override { }; // no-op virtual int parseDataFromBuffer(const QByteArray& buffer) override; - static void renderJointConnectingCone(gpu::Batch& batch, - glm::vec3 position1, - glm::vec3 position2, - float radius1, - float radius2, - const glm::vec4& color); + static void renderJointConnectingCone(gpu::Batch& batch, glm::vec3 position1, glm::vec3 position2, + float radius1, float radius2, const glm::vec4& color); virtual void applyCollision(const glm::vec3& contactPoint, const glm::vec3& penetration) { } @@ -246,7 +236,7 @@ public: /// \param vector position to be scaled. Will store the result void scaleVectorRelativeToPosition(glm::vec3& positionToScale) const; - void slamPosition(const glm::vec3& position); + void slamPosition(const glm::vec3 &position); virtual void updateAttitude(const glm::quat& orientation) override; // Call this when updating Avatar position with a delta. This will allow us to @@ -328,7 +318,7 @@ public: bool hasNewJointData() const { return _hasNewJointData; } float getBoundingRadius() const; - AABox getRenderBounds() const; // THis call is accessible from rendering thread only to report the bounding box of the avatar during the frame. + AABox getRenderBounds() const; // THis call is accessible from rendering thread only to report the bounding box of the avatar during the frame. void addToScene(AvatarSharedPointer self, const render::ScenePointer& scene); void ensureInScene(AvatarSharedPointer self, const render::ScenePointer& scene); @@ -435,13 +425,9 @@ protected: float getUnscaledEyeHeightFromSkeleton() const; void buildUnscaledEyeHeightCache(); void clearUnscaledEyeHeightCache(); - virtual const QString& getSessionDisplayNameForTransport() const override { - return _empty; - } // Save a tiny bit of bandwidth. Mixer won't look at what we send. + virtual const QString& getSessionDisplayNameForTransport() const override { return _empty; } // Save a tiny bit of bandwidth. Mixer won't look at what we send. QString _empty{}; - virtual void maybeUpdateSessionDisplayNameFromTransport(const QString& sessionDisplayName) override { - _sessionDisplayName = sessionDisplayName; - } // don't use no-op setter! + virtual void maybeUpdateSessionDisplayNameFromTransport(const QString& sessionDisplayName) override { _sessionDisplayName = sessionDisplayName; } // don't use no-op setter! SkeletonModelPointer _skeletonModel; @@ -449,7 +435,7 @@ protected: void withValidJointIndicesCache(std::function const& worker) const; mutable QHash _modelJointIndicesCache; mutable QReadWriteLock _modelJointIndicesCacheLock; - mutable bool _modelJointsCached{ false }; + mutable bool _modelJointsCached { false }; glm::vec3 _skeletonOffset; std::vector> _attachmentModels; @@ -457,7 +443,7 @@ protected: std::vector> _attachmentsToRemove; std::vector> _attachmentsToDelete; - float _bodyYawDelta{ 0.0f }; // degrees/sec + float _bodyYawDelta { 0.0f }; // degrees/sec // These position histories and derivatives are in the world-frame. // The derivatives are the MEASURED results of all external and internal forces @@ -473,8 +459,8 @@ protected: glm::vec3 _angularAcceleration; glm::quat _lastOrientation; - glm::vec3 _worldUpDirection{ Vectors::UP }; - bool _moving{ false }; ///< set when position is changing + glm::vec3 _worldUpDirection { Vectors::UP }; + bool _moving { false }; ///< set when position is changing // protected methods... bool isLookingAtMe(AvatarSharedPointer avatar) const; @@ -500,10 +486,10 @@ protected: render::ItemID _renderItemID{ render::Item::INVALID_ITEM_ID }; - ThreadSafeValueCache _leftPalmPositionCache{ glm::vec3() }; - ThreadSafeValueCache _leftPalmRotationCache{ glm::quat() }; - ThreadSafeValueCache _rightPalmPositionCache{ glm::vec3() }; - ThreadSafeValueCache _rightPalmRotationCache{ glm::quat() }; + ThreadSafeValueCache _leftPalmPositionCache { glm::vec3() }; + ThreadSafeValueCache _leftPalmRotationCache { glm::quat() }; + ThreadSafeValueCache _rightPalmPositionCache { glm::vec3() }; + ThreadSafeValueCache _rightPalmRotationCache { glm::quat() }; // Some rate tracking support RateCounter<> _simulationRate; @@ -514,36 +500,36 @@ protected: protected: class AvatarEntityDataHash { public: - AvatarEntityDataHash(uint32_t h) : hash(h){}; - uint32_t hash{ 0 }; - bool success{ false }; + AvatarEntityDataHash(uint32_t h) : hash(h) {}; + uint32_t hash { 0 }; + bool success { false }; }; using MapOfAvatarEntityDataHashes = QMap; MapOfAvatarEntityDataHashes _avatarEntityDataHashes; - uint64_t _lastRenderUpdateTime{ 0 }; - int _leftPointerGeometryID{ 0 }; - int _rightPointerGeometryID{ 0 }; - int _nameRectGeometryID{ 0 }; - bool _initialized{ false }; - bool _isLookAtTarget{ false }; - bool _isAnimatingScale{ false }; - bool _mustFadeIn{ false }; - bool _isFading{ false }; - bool _reconstructSoftEntitiesJointMap{ false }; - float _modelScale{ 1.0f }; + uint64_t _lastRenderUpdateTime { 0 }; + int _leftPointerGeometryID { 0 }; + int _rightPointerGeometryID { 0 }; + int _nameRectGeometryID { 0 }; + bool _initialized { false }; + bool _isLookAtTarget { false }; + bool _isAnimatingScale { false }; + bool _mustFadeIn { false }; + bool _isFading { false }; + bool _reconstructSoftEntitiesJointMap { false }; + float _modelScale { 1.0f }; static int _jointConesID; int _voiceSphereID; - AvatarPhysicsCallback _physicsCallback{ nullptr }; + AvatarPhysicsCallback _physicsCallback { nullptr }; - float _displayNameTargetAlpha{ 1.0f }; - float _displayNameAlpha{ 1.0f }; + float _displayNameTargetAlpha { 1.0f }; + float _displayNameAlpha { 1.0f }; - ThreadSafeValueCache _unscaledEyeHeightCache{ DEFAULT_AVATAR_EYE_HEIGHT }; + ThreadSafeValueCache _unscaledEyeHeightCache { DEFAULT_AVATAR_EYE_HEIGHT }; std::unordered_map _materials; std::mutex _materialsLock; @@ -559,4 +545,4 @@ protected: static const float ATTACHMENT_LOADING_PRIORITY; }; -#endif // hifi_Avatar_h +#endif // hifi_Avatar_h diff --git a/libraries/avatars/src/AvatarData.h b/libraries/avatars/src/AvatarData.h index 2d150609d1..51b3257ba2 100644 --- a/libraries/avatars/src/AvatarData.h +++ b/libraries/avatars/src/AvatarData.h @@ -55,8 +55,6 @@ #include "PathUtils.h" #include -//#include "Overlays.h" -//#include "Sphere3DOverlay.h" using AvatarSharedPointer = std::shared_ptr; using AvatarWeakPointer = std::weak_ptr; From ea76def2b58ce03c8564cefb016d7cf01ad0fd31 Mon Sep 17 00:00:00 2001 From: amantley Date: Tue, 26 Jun 2018 17:18:35 -0700 Subject: [PATCH 12/29] more white space errors --- .../avatars-renderer/src/avatars-renderer/Avatar.h | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/libraries/avatars-renderer/src/avatars-renderer/Avatar.h b/libraries/avatars-renderer/src/avatars-renderer/Avatar.h index 1e80e3d2cf..abe7e4b620 100644 --- a/libraries/avatars-renderer/src/avatars-renderer/Avatar.h +++ b/libraries/avatars-renderer/src/avatars-renderer/Avatar.h @@ -166,7 +166,7 @@ public: virtual int parseDataFromBuffer(const QByteArray& buffer) override; - static void renderJointConnectingCone(gpu::Batch& batch, glm::vec3 position1, glm::vec3 position2, + static void renderJointConnectingCone(gpu::Batch& batch, glm::vec3 position1, glm::vec3 position2, float radius1, float radius2, const glm::vec4& color); virtual void applyCollision(const glm::vec3& contactPoint, const glm::vec3& penetration) { } @@ -234,9 +234,9 @@ public: /// Scales a world space position vector relative to the avatar position and scale /// \param vector position to be scaled. Will store the result - void scaleVectorRelativeToPosition(glm::vec3& positionToScale) const; + void scaleVectorRelativeToPosition(glm::vec3 &positionToScale) const; - void slamPosition(const glm::vec3 &position); + void slamPosition(const glm::vec3& position); virtual void updateAttitude(const glm::quat& orientation) override; // Call this when updating Avatar position with a delta. This will allow us to @@ -427,7 +427,7 @@ protected: void clearUnscaledEyeHeightCache(); virtual const QString& getSessionDisplayNameForTransport() const override { return _empty; } // Save a tiny bit of bandwidth. Mixer won't look at what we send. QString _empty{}; - virtual void maybeUpdateSessionDisplayNameFromTransport(const QString& sessionDisplayName) override { _sessionDisplayName = sessionDisplayName; } // don't use no-op setter! + virtual void maybeUpdateSessionDisplayNameFromTransport(const QString& sessionDisplayName) override { _sessionDisplayName = sessionDisplayName; } // don't use no-op setter! SkeletonModelPointer _skeletonModel; @@ -460,7 +460,7 @@ protected: glm::quat _lastOrientation; glm::vec3 _worldUpDirection { Vectors::UP }; - bool _moving { false }; ///< set when position is changing + bool _moving { false }; ///< set when position is changing // protected methods... bool isLookingAtMe(AvatarSharedPointer avatar) const; From 8b13905d6c158ca743fd86f3c2b30ce9bf5dc9ba Mon Sep 17 00:00:00 2001 From: amantley Date: Tue, 26 Jun 2018 17:43:45 -0700 Subject: [PATCH 13/29] final final final coding standards --- interface/src/avatar/AvatarManager.cpp | 3 +-- interface/src/avatar/OtherAvatar.cpp | 6 ++---- interface/src/avatar/OtherAvatar.h | 8 +++++--- libraries/avatars-renderer/src/avatars-renderer/Avatar.h | 5 +---- 4 files changed, 9 insertions(+), 13 deletions(-) diff --git a/interface/src/avatar/AvatarManager.cpp b/interface/src/avatar/AvatarManager.cpp index d1fcfc7d4b..094a49fd44 100644 --- a/interface/src/avatar/AvatarManager.cpp +++ b/interface/src/avatar/AvatarManager.cpp @@ -194,7 +194,7 @@ void AvatarManager::updateOtherAvatars(float deltaTime) { const auto avatar = std::static_pointer_cast(sortData.getAvatar()); const auto otherAvatar = std::static_pointer_cast(sortData.getAvatar()); - //if the geometry is loaded then turn off the orb + //if the geometry is loaded then turn off the orb if (avatar->getSkeletonModel()->isLoaded()) { //remove the orb if it is there otherAvatar->removeOrb(); @@ -326,7 +326,6 @@ void AvatarManager::simulateAvatarFades(float deltaTime) { } AvatarSharedPointer AvatarManager::newSharedAvatar() { - return AvatarSharedPointer(new OtherAvatar(qApp->thread()), [](OtherAvatar* ptr) { ptr->deleteLater(); }); } diff --git a/interface/src/avatar/OtherAvatar.cpp b/interface/src/avatar/OtherAvatar.cpp index 035708b71d..7ef4269b96 100644 --- a/interface/src/avatar/OtherAvatar.cpp +++ b/interface/src/avatar/OtherAvatar.cpp @@ -18,14 +18,13 @@ OtherAvatar::OtherAvatar(QThread* thread) : Avatar(thread) { connect(_skeletonModel.get(), &Model::rigReady, this, &Avatar::rigReady); connect(_skeletonModel.get(), &Model::rigReset, this, &Avatar::rigReset); - //add the purple orb + // add the purple orb createOrb(); } void OtherAvatar::removeOrb() { if (qApp->getOverlays().isAddedOverlay(_otherAvatarOrbMeshPlaceholderID)) { qApp->getOverlays().deleteOverlay(_otherAvatarOrbMeshPlaceholderID); - //qCWarning(avatars_renderer) << "remove the purple orb***************************"; } } @@ -34,7 +33,6 @@ void OtherAvatar::updateOrbPosition() { } void OtherAvatar::createOrb() { - qCDebug(interfaceapp) << "we are in create orb otherAvatar.h"; if (_otherAvatarOrbMeshPlaceholderID == UNKNOWN_OVERLAY_ID || !qApp->getOverlays().isAddedOverlay(_otherAvatarOrbMeshPlaceholderID)) { _otherAvatarOrbMeshPlaceholder = std::make_shared(); @@ -49,7 +47,7 @@ void OtherAvatar::createOrb() { _otherAvatarOrbMeshPlaceholderID = qApp->getOverlays().addOverlay(_otherAvatarOrbMeshPlaceholder); // Position focus _otherAvatarOrbMeshPlaceholder->setWorldOrientation(glm::quat(0.0f, 0.0f, 0.0f, 1.0)); - _otherAvatarOrbMeshPlaceholder->setWorldPosition(glm::vec3(476.0f, 500.0f, 493.0f)); + _otherAvatarOrbMeshPlaceholder->setWorldPosition(getHead()->getPosition()); _otherAvatarOrbMeshPlaceholder->setDimensions(glm::vec3(0.5f, 0.5f, 0.5f)); _otherAvatarOrbMeshPlaceholder->setVisible(true); } diff --git a/interface/src/avatar/OtherAvatar.h b/interface/src/avatar/OtherAvatar.h index 707dd1fcc8..483f400bed 100644 --- a/interface/src/avatar/OtherAvatar.h +++ b/interface/src/avatar/OtherAvatar.h @@ -17,12 +17,14 @@ class OtherAvatar : public Avatar { public: explicit OtherAvatar(QThread* thread); - virtual void instantiableAvatar() override{}; + virtual void instantiableAvatar() override { }; void createOrb() override; void updateOrbPosition(); void removeOrb(); - std::shared_ptr _otherAvatarOrbMeshPlaceholder{ nullptr }; - OverlayID _otherAvatarOrbMeshPlaceholderID{ UNKNOWN_OVERLAY_ID }; + +protected: + std::shared_ptr _otherAvatarOrbMeshPlaceholder { nullptr }; + OverlayID _otherAvatarOrbMeshPlaceholderID { UNKNOWN_OVERLAY_ID }; }; #endif // hifi_OtherAvatar_h diff --git a/libraries/avatars-renderer/src/avatars-renderer/Avatar.h b/libraries/avatars-renderer/src/avatars-renderer/Avatar.h index abe7e4b620..8a0957075d 100644 --- a/libraries/avatars-renderer/src/avatars-renderer/Avatar.h +++ b/libraries/avatars-renderer/src/avatars-renderer/Avatar.h @@ -234,7 +234,7 @@ public: /// Scales a world space position vector relative to the avatar position and scale /// \param vector position to be scaled. Will store the result - void scaleVectorRelativeToPosition(glm::vec3 &positionToScale) const; + void scaleVectorRelativeToPosition(glm::vec3& positionToScale) const; void slamPosition(const glm::vec3& position); virtual void updateAttitude(const glm::quat& orientation) override; @@ -361,9 +361,6 @@ public: virtual scriptable::ScriptableModelBase getScriptableModel() override; - //void updateOrbPosition(); - //std::shared_ptr _purpleOrbMeshPlaceholder{ nullptr }; - //OverlayID _purpleOrbMeshPlaceholderID{ UNKNOWN_OVERLAY_ID }; public slots: // FIXME - these should be migrated to use Pose data instead From 39edc21423259709e63c163a6b2e1a75128e6aad Mon Sep 17 00:00:00 2001 From: amantley Date: Tue, 26 Jun 2018 17:47:36 -0700 Subject: [PATCH 14/29] spaced comment fixed --- interface/src/avatar/AvatarManager.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/interface/src/avatar/AvatarManager.cpp b/interface/src/avatar/AvatarManager.cpp index 094a49fd44..e924f291b8 100644 --- a/interface/src/avatar/AvatarManager.cpp +++ b/interface/src/avatar/AvatarManager.cpp @@ -194,9 +194,9 @@ void AvatarManager::updateOtherAvatars(float deltaTime) { const auto avatar = std::static_pointer_cast(sortData.getAvatar()); const auto otherAvatar = std::static_pointer_cast(sortData.getAvatar()); - //if the geometry is loaded then turn off the orb + // if the geometry is loaded then turn off the orb if (avatar->getSkeletonModel()->isLoaded()) { - //remove the orb if it is there + // remove the orb if it is there otherAvatar->removeOrb(); } else { otherAvatar->updateOrbPosition(); From eba4a273296ed78082af2af1a5cc9b978e0bbfe7 Mon Sep 17 00:00:00 2001 From: Angus Antley Date: Wed, 27 Jun 2018 05:59:53 +0100 Subject: [PATCH 15/29] added newline to the end of AvatarManager.cpp --- interface/src/avatar/AvatarManager.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/interface/src/avatar/AvatarManager.cpp b/interface/src/avatar/AvatarManager.cpp index e924f291b8..8a25c21946 100644 --- a/interface/src/avatar/AvatarManager.cpp +++ b/interface/src/avatar/AvatarManager.cpp @@ -621,4 +621,4 @@ void AvatarManager::setAvatarSortCoefficient(const QString& name, const QScriptV packet->writePrimitive(AvatarData::_avatarSortCoefficientAge); DependencyManager::get()->broadcastToNodes(std::move(packet), NodeSet() << NodeType::AvatarMixer); } -} \ No newline at end of file +} From 1804422df0d2d622374006818d3d66356e146ff2 Mon Sep 17 00:00:00 2001 From: amantley Date: Wed, 27 Jun 2018 11:15:33 -0700 Subject: [PATCH 16/29] remove orb in the otherAvatar destructor, and check _otherAvatarOrbMeshPlaceholder pointer before updating the position --- interface/src/avatar/OtherAvatar.cpp | 8 +++++++- interface/src/avatar/OtherAvatar.h | 2 ++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/interface/src/avatar/OtherAvatar.cpp b/interface/src/avatar/OtherAvatar.cpp index 7ef4269b96..5e51658128 100644 --- a/interface/src/avatar/OtherAvatar.cpp +++ b/interface/src/avatar/OtherAvatar.cpp @@ -22,6 +22,10 @@ OtherAvatar::OtherAvatar(QThread* thread) : Avatar(thread) { createOrb(); } +OtherAvatar::~OtherAvatar() { + removeOrb(); +} + void OtherAvatar::removeOrb() { if (qApp->getOverlays().isAddedOverlay(_otherAvatarOrbMeshPlaceholderID)) { qApp->getOverlays().deleteOverlay(_otherAvatarOrbMeshPlaceholderID); @@ -29,7 +33,9 @@ void OtherAvatar::removeOrb() { } void OtherAvatar::updateOrbPosition() { - _otherAvatarOrbMeshPlaceholder->setWorldPosition(getHead()->getPosition()); + if (_otherAvatarOrbMeshPlaceholder != nullptr) { + _otherAvatarOrbMeshPlaceholder->setWorldPosition(getHead()->getPosition()); + } } void OtherAvatar::createOrb() { diff --git a/interface/src/avatar/OtherAvatar.h b/interface/src/avatar/OtherAvatar.h index 483f400bed..e6f5b9c433 100644 --- a/interface/src/avatar/OtherAvatar.h +++ b/interface/src/avatar/OtherAvatar.h @@ -17,6 +17,8 @@ class OtherAvatar : public Avatar { public: explicit OtherAvatar(QThread* thread); + ~OtherAvatar(); + virtual void instantiableAvatar() override { }; void createOrb() override; void updateOrbPosition(); From 99ff5f9140ae8b562567c2a55ea8296ac523c066 Mon Sep 17 00:00:00 2001 From: amantley Date: Wed, 27 Jun 2018 11:59:53 -0700 Subject: [PATCH 17/29] made the Avatar destructor virtual to ensure that MyAvatar and OtherAvatar cleanup correctly --- interface/src/avatar/MyAvatar.h | 2 +- interface/src/avatar/OtherAvatar.h | 2 +- libraries/avatars-renderer/src/avatars-renderer/Avatar.h | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/interface/src/avatar/MyAvatar.h b/interface/src/avatar/MyAvatar.h index 1a6feb142a..212abd6bde 100644 --- a/interface/src/avatar/MyAvatar.h +++ b/interface/src/avatar/MyAvatar.h @@ -250,7 +250,7 @@ public: Q_ENUM(DriveKeys) explicit MyAvatar(QThread* thread); - ~MyAvatar(); + ~MyAvatar() override; void instantiableAvatar() override {}; void registerMetaTypes(ScriptEnginePointer engine); diff --git a/interface/src/avatar/OtherAvatar.h b/interface/src/avatar/OtherAvatar.h index e6f5b9c433..f7ad0ed669 100644 --- a/interface/src/avatar/OtherAvatar.h +++ b/interface/src/avatar/OtherAvatar.h @@ -17,7 +17,7 @@ class OtherAvatar : public Avatar { public: explicit OtherAvatar(QThread* thread); - ~OtherAvatar(); + ~OtherAvatar() override; virtual void instantiableAvatar() override { }; void createOrb() override; diff --git a/libraries/avatars-renderer/src/avatars-renderer/Avatar.h b/libraries/avatars-renderer/src/avatars-renderer/Avatar.h index 8a0957075d..bb9d6d8cc9 100644 --- a/libraries/avatars-renderer/src/avatars-renderer/Avatar.h +++ b/libraries/avatars-renderer/src/avatars-renderer/Avatar.h @@ -67,7 +67,7 @@ public: static void setShowNamesAboveHeads(bool show); explicit Avatar(QThread* thread); - ~Avatar(); + virtual ~Avatar(); virtual void instantiableAvatar() = 0; From cfc8c0fb099edd2d7eb76e56fbdaa92a5e71c7e0 Mon Sep 17 00:00:00 2001 From: Zach Fox Date: Wed, 27 Jun 2018 14:07:04 -0700 Subject: [PATCH 18/29] Implement MS16257: Remove 'clear overlay when moving' setting and code --- interface/src/avatar/MyAvatar.cpp | 2 -- interface/src/avatar/MyAvatar.h | 11 ----------- interface/src/ui/OverlayConductor.cpp | 11 ----------- interface/src/ui/PreferencesDialog.cpp | 6 ------ scripts/system/snapshot.js | 12 ------------ 5 files changed, 42 deletions(-) diff --git a/interface/src/avatar/MyAvatar.cpp b/interface/src/avatar/MyAvatar.cpp index b0369303e9..4c78c88d8d 100755 --- a/interface/src/avatar/MyAvatar.cpp +++ b/interface/src/avatar/MyAvatar.cpp @@ -1068,7 +1068,6 @@ void MyAvatar::saveData() { settings.setValue("displayName", _displayName); settings.setValue("collisionSoundURL", _collisionSoundURL); settings.setValue("useSnapTurn", _useSnapTurn); - settings.setValue("clearOverlayWhenMoving", _clearOverlayWhenMoving); settings.setValue("userHeight", getUserHeight()); settings.endGroup(); @@ -1223,7 +1222,6 @@ void MyAvatar::loadData() { setDisplayName(settings.value("displayName").toString()); setCollisionSoundURL(settings.value("collisionSoundURL", DEFAULT_AVATAR_COLLISION_SOUND_URL).toString()); setSnapTurn(settings.value("useSnapTurn", _useSnapTurn).toBool()); - setClearOverlayWhenMoving(settings.value("clearOverlayWhenMoving", _clearOverlayWhenMoving).toBool()); setDominantHand(settings.value("dominantHand", _dominantHand).toString().toLower()); setUserHeight(settings.value("userHeight", DEFAULT_AVATAR_HEIGHT).toDouble()); settings.endGroup(); diff --git a/interface/src/avatar/MyAvatar.h b/interface/src/avatar/MyAvatar.h index 1a6feb142a..356f734564 100644 --- a/interface/src/avatar/MyAvatar.h +++ b/interface/src/avatar/MyAvatar.h @@ -469,16 +469,6 @@ public: * @param {boolean} on */ Q_INVOKABLE void setSnapTurn(bool on) { _useSnapTurn = on; } - /**jsdoc - * @function MyAvatar.getClearOverlayWhenMoving - * @returns {boolean} - */ - Q_INVOKABLE bool getClearOverlayWhenMoving() const { return _clearOverlayWhenMoving; } - /**jsdoc - * @function MyAvatar.setClearOverlayWhenMoving - * @param {boolean} on - */ - Q_INVOKABLE void setClearOverlayWhenMoving(bool on) { _clearOverlayWhenMoving = on; } /**jsdoc @@ -1495,7 +1485,6 @@ private: ThreadSafeValueCache _prefOverrideAnimGraphUrl; QUrl _fstAnimGraphOverrideUrl; bool _useSnapTurn { true }; - bool _clearOverlayWhenMoving { true }; QString _dominantHand { DOMINANT_RIGHT_HAND }; const float ROLL_CONTROL_DEAD_ZONE_DEFAULT = 8.0f; // degrees diff --git a/interface/src/ui/OverlayConductor.cpp b/interface/src/ui/OverlayConductor.cpp index d131bb3467..551a5adb2e 100644 --- a/interface/src/ui/OverlayConductor.cpp +++ b/interface/src/ui/OverlayConductor.cpp @@ -93,17 +93,6 @@ void OverlayConductor::update(float dt) { bool shouldRecenter = false; - if (_flags & SuppressedByMove) { - if (!isMoving) { - _flags &= ~SuppressedByMove; - shouldRecenter = true; - } - } else { - if (myAvatar->getClearOverlayWhenMoving() && isMoving) { - _flags |= SuppressedByMove; - } - } - if (_flags & SuppressedByHead) { if (isAtRest) { _flags &= ~SuppressedByHead; diff --git a/interface/src/ui/PreferencesDialog.cpp b/interface/src/ui/PreferencesDialog.cpp index 3d3c432e92..e7c010fc31 100644 --- a/interface/src/ui/PreferencesDialog.cpp +++ b/interface/src/ui/PreferencesDialog.cpp @@ -161,12 +161,6 @@ void setupPreferences() { preferences->addPreference(new CheckPreference(UI_CATEGORY, "Use reticle cursor instead of arrow", getter, setter)); } - { - auto getter = [=]()->bool { return myAvatar->getClearOverlayWhenMoving(); }; - auto setter = [=](bool value) { myAvatar->setClearOverlayWhenMoving(value); }; - preferences->addPreference(new CheckPreference(UI_CATEGORY, "Clear overlays when moving", getter, setter)); - } - static const QString VIEW_CATEGORY{ "View" }; { auto getter = [=]()->float { return myAvatar->getRealWorldFieldOfView(); }; diff --git a/scripts/system/snapshot.js b/scripts/system/snapshot.js index 9b540aefc8..f16dd04715 100644 --- a/scripts/system/snapshot.js +++ b/scripts/system/snapshot.js @@ -17,7 +17,6 @@ var SNAPSHOT_DELAY = 500; // 500ms var FINISH_SOUND_DELAY = 350; var resetOverlays; var reticleVisible; -var clearOverlayWhenMoving; var buttonName = "SNAP"; var buttonConnected = false; @@ -438,11 +437,6 @@ function takeSnapshot() { isUploadingPrintableStill = true; updatePrintPermissions(); - // Raising the desktop for the share dialog at end will interact badly with clearOverlayWhenMoving. - // Turn it off now, before we start futzing with things (and possibly moving). - clearOverlayWhenMoving = MyAvatar.getClearOverlayWhenMoving(); // Do not use Settings. MyAvatar keeps a separate copy. - MyAvatar.setClearOverlayWhenMoving(false); - // We will record snapshots based on the starting location. That could change, e.g., when recording a .gif. // Even the domainID could change (e.g., if the user falls into a teleporter while recording). href = location.href; @@ -544,9 +538,6 @@ function stillSnapshotTaken(pathStillSnapshot, notify) { // last element in data array tells dialog whether we can share or not Settings.setValue("previousStillSnapPath", pathStillSnapshot); - if (clearOverlayWhenMoving) { - MyAvatar.setClearOverlayWhenMoving(true); // not until after the share dialog - } HMD.openTablet(); isDomainOpen(domainID, function (canShare) { @@ -590,9 +581,6 @@ function processingGifStarted(pathStillSnapshot) { } Settings.setValue("previousStillSnapPath", pathStillSnapshot); - if (clearOverlayWhenMoving) { - MyAvatar.setClearOverlayWhenMoving(true); // not until after the share dialog - } HMD.openTablet(); isDomainOpen(domainID, function (canShare) { From 2347634d7230ea548e7d5ec1586abc6251034bfc Mon Sep 17 00:00:00 2001 From: Zach Fox Date: Wed, 27 Jun 2018 14:27:09 -0700 Subject: [PATCH 19/29] Fixed View Overlays checkbox (thanks Dante) --- interface/src/ui/OverlayConductor.cpp | 2 +- interface/src/ui/OverlayConductor.h | 6 ++---- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/interface/src/ui/OverlayConductor.cpp b/interface/src/ui/OverlayConductor.cpp index 551a5adb2e..a779ef8d1e 100644 --- a/interface/src/ui/OverlayConductor.cpp +++ b/interface/src/ui/OverlayConductor.cpp @@ -104,7 +104,7 @@ void OverlayConductor::update(float dt) { } } - bool targetVisible = Menu::getInstance()->isOptionChecked(MenuOption::Overlays) && (0 == (_flags & SuppressMask)); + bool targetVisible = Menu::getInstance()->isOptionChecked(MenuOption::Overlays) && (0 == (_flags & SuppressedByHead)); if (targetVisible != currentVisible) { offscreenUi->setPinned(!targetVisible); } diff --git a/interface/src/ui/OverlayConductor.h b/interface/src/ui/OverlayConductor.h index cf69c32fc5..60809bcf33 100644 --- a/interface/src/ui/OverlayConductor.h +++ b/interface/src/ui/OverlayConductor.h @@ -26,12 +26,10 @@ private: bool updateAvatarIsAtRest(); enum SupressionFlags { - SuppressedByMove = 0x01, - SuppressedByHead = 0x02, - SuppressMask = 0x03, + SuppressedByHead = 0x01 }; - uint8_t _flags { SuppressedByMove }; + uint8_t _flags { SuppressedByHead }; bool _hmdMode { false }; // used by updateAvatarIsAtRest From 205cd44a49b7d9b36dfed661b384e7982656bd94 Mon Sep 17 00:00:00 2001 From: amantley Date: Wed, 27 Jun 2018 14:31:33 -0700 Subject: [PATCH 20/29] removed override keyword from OtherAvatar and MyAvatar destructors, also added the virtual keyword to the createOrb virtual method in OtherAvatar --- interface/src/avatar/MyAvatar.h | 2 +- interface/src/avatar/OtherAvatar.h | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/interface/src/avatar/MyAvatar.h b/interface/src/avatar/MyAvatar.h index 212abd6bde..0a2f6f8354 100644 --- a/interface/src/avatar/MyAvatar.h +++ b/interface/src/avatar/MyAvatar.h @@ -250,7 +250,7 @@ public: Q_ENUM(DriveKeys) explicit MyAvatar(QThread* thread); - ~MyAvatar() override; + virtual ~MyAvatar(); void instantiableAvatar() override {}; void registerMetaTypes(ScriptEnginePointer engine); diff --git a/interface/src/avatar/OtherAvatar.h b/interface/src/avatar/OtherAvatar.h index f7ad0ed669..f33952b78b 100644 --- a/interface/src/avatar/OtherAvatar.h +++ b/interface/src/avatar/OtherAvatar.h @@ -17,10 +17,10 @@ class OtherAvatar : public Avatar { public: explicit OtherAvatar(QThread* thread); - ~OtherAvatar() override; + virtual ~OtherAvatar(); virtual void instantiableAvatar() override { }; - void createOrb() override; + virtual void createOrb() override; void updateOrbPosition(); void removeOrb(); From 8ba184db6a0cd3aea41c9a19c90a063a122c556d Mon Sep 17 00:00:00 2001 From: Zach Fox Date: Wed, 27 Jun 2018 14:59:46 -0700 Subject: [PATCH 21/29] Don't use flags; use a bool --- interface/src/ui/OverlayConductor.cpp | 10 +++++----- interface/src/ui/OverlayConductor.h | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/interface/src/ui/OverlayConductor.cpp b/interface/src/ui/OverlayConductor.cpp index a779ef8d1e..06f60ec6ed 100644 --- a/interface/src/ui/OverlayConductor.cpp +++ b/interface/src/ui/OverlayConductor.cpp @@ -93,22 +93,22 @@ void OverlayConductor::update(float dt) { bool shouldRecenter = false; - if (_flags & SuppressedByHead) { + if (_suppressedByHead) { if (isAtRest) { - _flags &= ~SuppressedByHead; + _suppressedByHead = false; shouldRecenter = true; } } else { if (_hmdMode && headOutsideOverlay()) { - _flags |= SuppressedByHead; + _suppressedByHead = true; } } - bool targetVisible = Menu::getInstance()->isOptionChecked(MenuOption::Overlays) && (0 == (_flags & SuppressedByHead)); + bool targetVisible = Menu::getInstance()->isOptionChecked(MenuOption::Overlays) && !_suppressedByHead; if (targetVisible != currentVisible) { offscreenUi->setPinned(!targetVisible); } - if (shouldRecenter && !_flags) { + if (shouldRecenter && !_suppressedByHead) { centerUI(); } } diff --git a/interface/src/ui/OverlayConductor.h b/interface/src/ui/OverlayConductor.h index 60809bcf33..ffbb2da431 100644 --- a/interface/src/ui/OverlayConductor.h +++ b/interface/src/ui/OverlayConductor.h @@ -29,7 +29,7 @@ private: SuppressedByHead = 0x01 }; - uint8_t _flags { SuppressedByHead }; + bool _suppressedByHead { false }; bool _hmdMode { false }; // used by updateAvatarIsAtRest From e15fc787d3bc7e716a69db63d7a86c3198012b9f Mon Sep 17 00:00:00 2001 From: Gabriel Calero Date: Wed, 27 Jun 2018 19:04:27 -0300 Subject: [PATCH 22/29] Remove the duplicated AccountManager used for android --- android/app/src/main/cpp/native.cpp | 8 ++++---- interface/src/AndroidHelper.cpp | 20 -------------------- interface/src/AndroidHelper.h | 6 ------ interface/src/Application.cpp | 1 - 4 files changed, 4 insertions(+), 31 deletions(-) diff --git a/android/app/src/main/cpp/native.cpp b/android/app/src/main/cpp/native.cpp index 437505be3f..9b5e5f2543 100644 --- a/android/app/src/main/cpp/native.cpp +++ b/android/app/src/main/cpp/native.cpp @@ -228,7 +228,7 @@ Java_io_highfidelity_hifiinterface_fragment_LoginFragment_nativeLogin(JNIEnv *en env->ReleaseStringUTFChars(username_, c_username); env->ReleaseStringUTFChars(password_, c_password); - auto accountManager = AndroidHelper::instance().getAccountManager(); + auto accountManager = DependencyManager::get(); __loginCompletedListener = QAndroidJniObject(instance); __usernameChangedListener = QAndroidJniObject(usernameChangedListener); @@ -270,18 +270,18 @@ Java_io_highfidelity_hifiinterface_SplashActivity_registerLoadCompleteListener(J } JNIEXPORT jboolean JNICALL Java_io_highfidelity_hifiinterface_MainActivity_nativeIsLoggedIn(JNIEnv *env, jobject instance) { - return AndroidHelper::instance().getAccountManager()->isLoggedIn(); + return DependencyManager::get()->isLoggedIn(); } JNIEXPORT void JNICALL Java_io_highfidelity_hifiinterface_MainActivity_nativeLogout(JNIEnv *env, jobject instance) { - AndroidHelper::instance().getAccountManager()->logout(); + DependencyManager::get()->logout(); } JNIEXPORT jstring JNICALL Java_io_highfidelity_hifiinterface_MainActivity_nativeGetDisplayName(JNIEnv *env, jobject instance) { - QString username = AndroidHelper::instance().getAccountManager()->getAccountInfo().getUsername(); + QString username = DependencyManager::get()->getAccountInfo().getUsername(); return env->NewStringUTF(username.toLatin1().data()); } diff --git a/interface/src/AndroidHelper.cpp b/interface/src/AndroidHelper.cpp index ef7319e63f..be41d434df 100644 --- a/interface/src/AndroidHelper.cpp +++ b/interface/src/AndroidHelper.cpp @@ -10,31 +10,11 @@ // #include "AndroidHelper.h" #include -#include AndroidHelper::AndroidHelper() { } AndroidHelper::~AndroidHelper() { - workerThread.quit(); - workerThread.wait(); -} - -void AndroidHelper::init() { - workerThread.start(); - _accountManager = QSharedPointer(new AccountManager, &QObject::deleteLater); - _accountManager->setIsAgent(true); - _accountManager->setAuthURL(NetworkingConstants::METAVERSE_SERVER_URL()); - _accountManager->setSessionID(DependencyManager::get()->getSessionID()); - connect(_accountManager.data(), &AccountManager::loginComplete, [](const QUrl& authURL) { - DependencyManager::get()->setAccountInfo(AndroidHelper::instance().getAccountManager()->getAccountInfo()); - DependencyManager::get()->setAuthURL(authURL); - }); - - connect(_accountManager.data(), &AccountManager::logoutComplete, [] () { - DependencyManager::get()->logout(); - }); - _accountManager->moveToThread(&workerThread); } void AndroidHelper::requestActivity(const QString &activityName, const bool backToScene) { diff --git a/interface/src/AndroidHelper.h b/interface/src/AndroidHelper.h index 007c0db4a5..cecae4a79e 100644 --- a/interface/src/AndroidHelper.h +++ b/interface/src/AndroidHelper.h @@ -13,8 +13,6 @@ #define hifi_Android_Helper_h #include -#include -#include class AndroidHelper : public QObject { Q_OBJECT @@ -23,7 +21,6 @@ public: static AndroidHelper instance; return instance; } - void init(); void requestActivity(const QString &activityName, const bool backToScene); void notifyLoadComplete(); void notifyEnterForeground(); @@ -31,7 +28,6 @@ public: void performHapticFeedback(int duration); - QSharedPointer getAccountManager() { return _accountManager; } AndroidHelper(AndroidHelper const&) = delete; void operator=(AndroidHelper const&) = delete; @@ -49,8 +45,6 @@ signals: private: AndroidHelper(); ~AndroidHelper(); - QSharedPointer _accountManager; - QThread workerThread; }; #endif diff --git a/interface/src/Application.cpp b/interface/src/Application.cpp index 6f95a1afe8..2ddf5c2a10 100644 --- a/interface/src/Application.cpp +++ b/interface/src/Application.cpp @@ -2256,7 +2256,6 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer, bo qCDebug(interfaceapp) << "Metaverse session ID is" << uuidStringWithoutCurlyBraces(accountManager->getSessionID()); #if defined(Q_OS_ANDROID) - AndroidHelper::instance().init(); connect(&AndroidHelper::instance(), &AndroidHelper::enterBackground, this, &Application::enterBackground); connect(&AndroidHelper::instance(), &AndroidHelper::enterForeground, this, &Application::enterForeground); AndroidHelper::instance().notifyLoadComplete(); From 1b414fbbfec1caad858454708d8706f8784fdd80 Mon Sep 17 00:00:00 2001 From: Zach Fox Date: Wed, 27 Jun 2018 15:11:59 -0700 Subject: [PATCH 23/29] Quick CR comments --- interface/src/ui/OverlayConductor.cpp | 5 +---- interface/src/ui/OverlayConductor.h | 4 ---- 2 files changed, 1 insertion(+), 8 deletions(-) diff --git a/interface/src/ui/OverlayConductor.cpp b/interface/src/ui/OverlayConductor.cpp index 06f60ec6ed..e27001567f 100644 --- a/interface/src/ui/OverlayConductor.cpp +++ b/interface/src/ui/OverlayConductor.cpp @@ -88,13 +88,10 @@ void OverlayConductor::update(float dt) { _hmdMode = false; } - bool isAtRest = updateAvatarIsAtRest(); - bool isMoving = !isAtRest; - bool shouldRecenter = false; if (_suppressedByHead) { - if (isAtRest) { + if (updateAvatarIsAtRest()) { _suppressedByHead = false; shouldRecenter = true; } diff --git a/interface/src/ui/OverlayConductor.h b/interface/src/ui/OverlayConductor.h index ffbb2da431..b47e23d28a 100644 --- a/interface/src/ui/OverlayConductor.h +++ b/interface/src/ui/OverlayConductor.h @@ -25,10 +25,6 @@ private: bool headOutsideOverlay() const; bool updateAvatarIsAtRest(); - enum SupressionFlags { - SuppressedByHead = 0x01 - }; - bool _suppressedByHead { false }; bool _hmdMode { false }; From 70a3c9ce3c40ae2fb288b6dfc9d6fd66d623c1ba Mon Sep 17 00:00:00 2001 From: "Anthony J. Thibault" Date: Wed, 27 Jun 2018 16:06:23 -0700 Subject: [PATCH 24/29] Fix for heap-corruption in Settings::saveAll due to implicitly shared QStrings Using gflags on windows and enabling full page heap verification, I was able to detect this as a source of memory corruption. https://docs.microsoft.com/en-us/windows-hardware/drivers/debugger/enable-page-heap Running interface with pageheap before and after, this change leads me to believe that this is a source of some of our heap-corruption crashes on backtrace. Specifically these 19 crashes in the last month, and possibly more. https://highfidelity.sp.backtrace.io/dashboard/highfidelity/project/Interface/query-builder?qb=%7B%22mode%22%3A%22aggregate%22%2C%22sorting%22%3A%7B%22aggFactor%22%3A%22count%22%2C%22aggSortOrder%22%3A%22descending%22%2C%22selectFactor%22%3A%22timestamp%22%2C%22selectSortOrder%22%3A%22descending%22%2C%22sortedColumnNames%22%3A%5B%5D%7D%2C%22dateTimePicker%22%3A%7B%22granularity%22%3A%221M%22%2C%22start%22%3A%222018-05-27T07%3A00%3A00.000Z%22%2C%22end%22%3A%222018-06-27T23%3A05%3A29.399Z%22%7D%7D&qn=&query=%7B%22filter%22%3A%5B%7B%22callstack%22%3A%5B%5B%22contains%22%2C%22saveAll%22%5D%5D%2C%22timestamp%22%3A%5B%5B%22at-least%22%2C1527404400%5D%2C%5B%22at-most%22%2C1530140729%5D%5D%7D%5D%2C%22fold%22%3A%7B%22timestamp%22%3A%5B%5B%22range%22%5D%2C%5B%22bin%22%2C32%2C1527404400%2C1530140729%5D%5D%7D%2C%22group%22%3A%5B%22classifiers%22%5D%2C%22select%22%3A%5B%22timestamp%22%2C%22fingerprint%22%2C%22_deleted%22%2C%22callstack%22%2C%22object%22%5D%7D --- interface/src/scripting/SettingsScriptingInterface.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/interface/src/scripting/SettingsScriptingInterface.cpp b/interface/src/scripting/SettingsScriptingInterface.cpp index 2f14c33dc7..afafe1a350 100644 --- a/interface/src/scripting/SettingsScriptingInterface.cpp +++ b/interface/src/scripting/SettingsScriptingInterface.cpp @@ -35,5 +35,8 @@ QVariant SettingsScriptingInterface::getValue(const QString& setting, const QVar } void SettingsScriptingInterface::setValue(const QString& setting, const QVariant& value) { - Setting::Handle(setting).set(value); + // Make a deep-copy of the string. + // Dangling pointers can occur with QStrings that are implicitly shared from a QScriptEngine. + QString deepCopy = QString::fromUtf16(setting.utf16()); + Setting::Handle(deepCopy).set(value); } From c80ab0d23730d27f45a463a7ba9c32726498441c Mon Sep 17 00:00:00 2001 From: r3tk0n Date: Wed, 27 Jun 2018 16:10:07 -0700 Subject: [PATCH 25/29] Re-added mouse sensitivity settings to General Preferences dialog. --- .../resources/qml/hifi/dialogs/GeneralPreferencesDialog.qml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/interface/resources/qml/hifi/dialogs/GeneralPreferencesDialog.qml b/interface/resources/qml/hifi/dialogs/GeneralPreferencesDialog.qml index cb4913f999..861de001d8 100644 --- a/interface/resources/qml/hifi/dialogs/GeneralPreferencesDialog.qml +++ b/interface/resources/qml/hifi/dialogs/GeneralPreferencesDialog.qml @@ -17,7 +17,7 @@ PreferencesDialog { id: root objectName: "GeneralPreferencesDialog" title: "General Settings" - showCategories: ["User Interface", "HMD", "Snapshots", "Privacy"] + showCategories: ["User Interface", "Mouse Sensitivity", "HMD", "Snapshots", "Privacy"] property var settings: Settings { category: root.objectName property alias x: root.x From d6684e5ef7975df531fb649d4edba069b33b1bc8 Mon Sep 17 00:00:00 2001 From: r3tk0n Date: Wed, 27 Jun 2018 16:23:40 -0700 Subject: [PATCH 26/29] Re-add mouse sensitivity option to tablet. --- .../resources/qml/hifi/tablet/TabletGeneralPreferences.qml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/interface/resources/qml/hifi/tablet/TabletGeneralPreferences.qml b/interface/resources/qml/hifi/tablet/TabletGeneralPreferences.qml index 63801019b9..8925b2f3fd 100644 --- a/interface/resources/qml/hifi/tablet/TabletGeneralPreferences.qml +++ b/interface/resources/qml/hifi/tablet/TabletGeneralPreferences.qml @@ -32,6 +32,6 @@ StackView { TabletPreferencesDialog { id: root objectName: "TabletGeneralPreferences" - showCategories: ["User Interface", "HMD", "Snapshots", "Privacy"] + showCategories: ["User Interface", "Mouse Settings", "HMD", "Snapshots", "Privacy"] } } From f36ba49fbd4d6ef215565c9b7d347ec287d4abb0 Mon Sep 17 00:00:00 2001 From: r3tk0n <39922250+r3tk0n@users.noreply.github.com> Date: Wed, 27 Jun 2018 16:30:38 -0700 Subject: [PATCH 27/29] Update TabletGeneralPreferences.qml Fixed a typo --- .../resources/qml/hifi/tablet/TabletGeneralPreferences.qml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/interface/resources/qml/hifi/tablet/TabletGeneralPreferences.qml b/interface/resources/qml/hifi/tablet/TabletGeneralPreferences.qml index 8925b2f3fd..4f1100f20b 100644 --- a/interface/resources/qml/hifi/tablet/TabletGeneralPreferences.qml +++ b/interface/resources/qml/hifi/tablet/TabletGeneralPreferences.qml @@ -32,6 +32,6 @@ StackView { TabletPreferencesDialog { id: root objectName: "TabletGeneralPreferences" - showCategories: ["User Interface", "Mouse Settings", "HMD", "Snapshots", "Privacy"] + showCategories: ["User Interface", "Mouse Sensitivity", "HMD", "Snapshots", "Privacy"] } } From ac6fcf092c52ab42d50c4d054bbaf512f305063d Mon Sep 17 00:00:00 2001 From: "Anthony J. Thibault" Date: Wed, 27 Jun 2018 16:57:57 -0700 Subject: [PATCH 28/29] Fix memory corruption via lambdas that capture local variables by reference. The lambdas in ScriptEngine::fetchModuleSource() were referencing local stack variables by reference. This could lead to un-expected results including memory corruption. To workaround this issue the QTimer and QEventLoop variables are allocated on the heap and held onto by a shared_ptr. This shared_ptr is passed to the lambda. This will not result in cycles and should result in the QTimer and QEventLoop being destroyed when the BatchLoader object they are connected to is deleted. --- libraries/script-engine/src/ScriptEngine.cpp | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/libraries/script-engine/src/ScriptEngine.cpp b/libraries/script-engine/src/ScriptEngine.cpp index f8c99b192f..99c02ba1f6 100644 --- a/libraries/script-engine/src/ScriptEngine.cpp +++ b/libraries/script-engine/src/ScriptEngine.cpp @@ -1639,22 +1639,24 @@ QVariantMap ScriptEngine::fetchModuleSource(const QString& modulePath, const boo loader->start(MAX_RETRIES); if (!loader->isFinished()) { - QTimer monitor; - QEventLoop loop; - QObject::connect(loader, &BatchLoader::finished, this, [&monitor, &loop]{ - monitor.stop(); - loop.quit(); + // This lambda can get called AFTER this local scope has completed. + // This is why we pass smart ptrs to the lambda instead of references to local variables. + auto monitor = std::make_shared(); + auto loop = std::make_shared(); + QObject::connect(loader, &BatchLoader::finished, this, [monitor, loop] { + monitor->stop(); + loop->quit(); }); // this helps detect the case where stop() is invoked during the download // but not seen in time to abort processing in onload()... - connect(&monitor, &QTimer::timeout, this, [this, &loop]{ + connect(monitor.get(), &QTimer::timeout, this, [this, loop] { if (isStopping()) { - loop.exit(-1); + loop->exit(-1); } }); - monitor.start(500); - loop.exec(); + monitor->start(500); + loop->exec(); } loader->deleteLater(); return req; From 2d27de12bd906344244994fa686561a294035216 Mon Sep 17 00:00:00 2001 From: Zach Fox Date: Thu, 28 Jun 2018 12:06:31 -0700 Subject: [PATCH 29/29] Fix MS14743: Change SNAP prints such that they don't fall through the floor --- scripts/system/snapshot.js | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/scripts/system/snapshot.js b/scripts/system/snapshot.js index f16dd04715..e265ddb621 100644 --- a/scripts/system/snapshot.js +++ b/scripts/system/snapshot.js @@ -285,6 +285,7 @@ function printToPolaroid(image_url) { var polaroid_url = image_url; var model_pos = Vec3.sum(MyAvatar.position, Vec3.multiply(1.25, Quat.getForward(MyAvatar.orientation))); + model_pos.y += 0.2; // Print a bit closer to the head var model_q1 = MyAvatar.orientation; var model_q2 = Quat.angleAxis(90, Quat.getRight(model_q1)); @@ -294,11 +295,11 @@ function printToPolaroid(image_url) { "type": 'Model', "shapeType": 'box', - "name": "New Snapshot", - "description": "Printed from Snaps", + "name": "Snapshot by " + MyAvatar.sessionDisplayName, + "description": "Printed from SNAP app", "modelURL": POLAROID_MODEL_URL, - "dimensions": { "x": 0.5667, "y": 0.0212, "z": 0.4176 }, + "dimensions": { "x": 0.5667, "y": 0.042, "z": 0.4176 }, "position": model_pos, "rotation": model_rot, @@ -306,9 +307,9 @@ function printToPolaroid(image_url) { "density": 200, "restitution": 0.15, - "gravity": { "x": 0, "y": -4.5, "z": 0 }, + "gravity": { "x": 0, "y": -2.5, "z": 0 }, - "velocity": { "x": 0, "y": 3.5, "z": 0 }, + "velocity": { "x": 0, "y": 1.95, "z": 0 }, "angularVelocity": { "x": -1.0, "y": 0, "z": -1.3 }, "dynamic": true,