From 79278f5add3e881af1e4d3811b7c85d6c84f741b Mon Sep 17 00:00:00 2001 From: LaShonda Hopper Date: Fri, 27 Apr 2018 17:23:27 -0400 Subject: [PATCH 01/61] [BugFix] EntityList UncaughtException in that.sendUpdate (details below). * Adds safety checks to properties.renderInfo to prevent invalid access when undefined. * Error trace prior to guards: [04/27 13:16:19] [CRITICAL] [hifi.scriptengine] [defaultScripts.js] [UncaughtException signalHandlerException] Error: Result of expression 'properties.renderInfo' [undefined] is not an object. in .../build/interface/RelWithDebInfo/scripts/system/libraries/entityList.js:93 [04/27 13:16:19] [CRITICAL] [hifi.scriptengine] [Backtrace] [04/27 13:16:19] [CRITICAL] [hifi.scriptengine] () at .../build/interface/RelWithDebInfo/scripts/system/libraries/entityList.js:93 [04/27 13:16:19] [CRITICAL] [hifi.scriptengine] (data = [object Object]) at .../build/interface/RelWithDebInfo/scripts/system/libraries/entityList.js:149 [04/27 13:16:19] [CRITICAL] [hifi.scriptengine] () at -1 Changes Committed: modified: scripts/system/libraries/entityList.js --- scripts/system/libraries/entityList.js | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/scripts/system/libraries/entityList.js b/scripts/system/libraries/entityList.js index d53766ab4e..8cd8decbef 100644 --- a/scripts/system/libraries/entityList.js +++ b/scripts/system/libraries/entityList.js @@ -90,12 +90,17 @@ EntityListTool = function(opts) { url: url, locked: properties.locked, visible: properties.visible, - verticesCount: valueIfDefined(properties.renderInfo.verticesCount), - texturesCount: valueIfDefined(properties.renderInfo.texturesCount), - texturesSize: valueIfDefined(properties.renderInfo.texturesSize), - hasTransparent: valueIfDefined(properties.renderInfo.hasTransparent), + verticesCount: (properties.renderInfo !== undefined ? + valueIfDefined(properties.renderInfo.verticesCount) : ""), + texturesCount: (properties.renderInfo !== undefined ? + valueIfDefined(properties.renderInfo.texturesCount) : ""), + texturesSize: (properties.renderInfo !== undefined ? + valueIfDefined(properties.renderInfo.texturesSize) : ""), + hasTransparent: (properties.renderInfo !== undefined ? + valueIfDefined(properties.renderInfo.hasTransparent) : ""), isBaked: properties.type == "Model" ? url.toLowerCase().endsWith(".baked.fbx") : false, - drawCalls: valueIfDefined(properties.renderInfo.drawCalls), + drawCalls: (properties.renderInfo !== undefined ? + valueIfDefined(properties.renderInfo.drawCalls) : ""), hasScript: properties.script !== "" }); } From 0ac1ea078e75006d29a890c2a6d5fcfd961ff654 Mon Sep 17 00:00:00 2001 From: Marko Kudjerski Date: Fri, 15 Jun 2018 08:20:58 -0700 Subject: [PATCH 02/61] Updated time stamping server for authenticode signatures Symantec's time stamp server seems to be more robust. --- cmake/macros/OptionalWinExecutableSigning.cmake | 2 +- cmake/templates/NSIS.template.in | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/cmake/macros/OptionalWinExecutableSigning.cmake b/cmake/macros/OptionalWinExecutableSigning.cmake index 41ca5762dc..069fc12fc5 100644 --- a/cmake/macros/OptionalWinExecutableSigning.cmake +++ b/cmake/macros/OptionalWinExecutableSigning.cmake @@ -22,7 +22,7 @@ macro(optional_win_executable_signing) # setup a post build command to sign the executable add_custom_command( TARGET ${TARGET_NAME} POST_BUILD - COMMAND ${SIGNTOOL_EXECUTABLE} sign /fd sha256 /f %HF_PFX_FILE% /p %HF_PFX_PASSPHRASE% /tr http://tsa.starfieldtech.com /td SHA256 ${EXECUTABLE_PATH} + COMMAND ${SIGNTOOL_EXECUTABLE} sign /fd sha256 /f %HF_PFX_FILE% /p %HF_PFX_PASSPHRASE% /tr http://sha256timestamp.ws.symantec.com/sha256/timestamp /td SHA256 ${EXECUTABLE_PATH} ) else () message(FATAL_ERROR "HF_PFX_PASSPHRASE must be set for executables to be signed.") diff --git a/cmake/templates/NSIS.template.in b/cmake/templates/NSIS.template.in index fc9b9ab03d..55a46e7326 100644 --- a/cmake/templates/NSIS.template.in +++ b/cmake/templates/NSIS.template.in @@ -130,7 +130,7 @@ ; The Inner invocation has written an uninstaller binary for us. ; We need to sign it if it's a production or PR build. !if @PRODUCTION_BUILD@ == 1 - !system '"@SIGNTOOL_EXECUTABLE@" sign /fd sha256 /f %HF_PFX_FILE% /p %HF_PFX_PASSPHRASE% /tr http://tsa.starfieldtech.com /td SHA256 $%TEMP%\@UNINSTALLER_NAME@' = 0 + !system '"@SIGNTOOL_EXECUTABLE@" sign /fd sha256 /f %HF_PFX_FILE% /p %HF_PFX_PASSPHRASE% /tr http://sha256timestamp.ws.symantec.com/sha256/timestamp /td SHA256 $%TEMP%\@UNINSTALLER_NAME@' = 0 !endif ; Good. Now we can carry on writing the real installer. From 29ff47c6fbd613bf196851eda4963194bff910e5 Mon Sep 17 00:00:00 2001 From: Atlante45 Date: Mon, 18 Jun 2018 16:23:54 -0700 Subject: [PATCH 03/61] 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 04/61] 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 05/61] 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 06/61] 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 07/61] 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 dcebbada28ad436646a17b2eecc0b9241cda6cef Mon Sep 17 00:00:00 2001 From: Seth Alves Date: Tue, 19 Jun 2018 10:13:48 -0700 Subject: [PATCH 08/61] fix various crashes-upon-exits --- interface/src/Application.cpp | 22 +++++++++++-------- interface/src/Application_render.cpp | 5 ++++- interface/src/ui/ApplicationOverlay.cpp | 2 ++ libraries/networking/src/ResourceManager.cpp | 9 ++++++-- .../plugins/src/plugins/PluginManager.cpp | 5 ++--- libraries/plugins/src/plugins/PluginManager.h | 10 +++++++-- 6 files changed, 36 insertions(+), 17 deletions(-) diff --git a/interface/src/Application.cpp b/interface/src/Application.cpp index 2033e8ee8e..54ecaf1201 100644 --- a/interface/src/Application.cpp +++ b/interface/src/Application.cpp @@ -814,6 +814,7 @@ bool setupEssentials(int& argc, char** argv, bool runningMarkerExisted) { } // Tell the plugin manager about our statically linked plugins + DependencyManager::set(); auto pluginManager = PluginManager::getInstance(); pluginManager->setInputPluginProvider([] { return getInputPlugins(); }); pluginManager->setDisplayPluginProvider([] { return getDisplayPlugins(); }); @@ -1375,6 +1376,10 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer, bo initializeRenderEngine(); qCDebug(interfaceapp, "Initialized Render Engine."); + // Overlays need to exist before we set the ContextOverlayInterface dependency + _overlays.init(); // do this before scripts load + DependencyManager::set(); + // Initialize the user interface and menu system // Needs to happen AFTER the render engine initialization to access its configuration initializeUi(); @@ -1511,10 +1516,6 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer, bo // allow you to move an entity around in your hand _entityEditSender.setPacketsPerSecond(3000); // super high!! - // Overlays need to exist before we set the ContextOverlayInterface dependency - _overlays.init(); // do this before scripts load - DependencyManager::set(); - // Make sure we don't time out during slow operations at startup updateHeartbeat(); @@ -2552,12 +2553,18 @@ Application::~Application() { _octreeProcessor.terminate(); _entityEditSender.terminate(); + if (auto steamClient = PluginManager::getInstance()->getSteamClientPlugin()) { + steamClient->shutdown(); + } + DependencyManager::destroy(); + + DependencyManager::destroy(); // must be destroyed before the FramebufferCache + DependencyManager::destroy(); DependencyManager::destroy(); DependencyManager::destroy(); DependencyManager::destroy(); DependencyManager::destroy(); - DependencyManager::destroy(); DependencyManager::destroy(); DependencyManager::destroy(); DependencyManager::destroy(); @@ -2567,10 +2574,6 @@ Application::~Application() { // remove the NodeList from the DependencyManager DependencyManager::destroy(); - if (auto steamClient = PluginManager::getInstance()->getSteamClientPlugin()) { - steamClient->shutdown(); - } - #if 0 ConnexionClient::getInstance().destroy(); #endif @@ -2890,6 +2893,7 @@ void Application::initializeUi() { auto compositorHelper = DependencyManager::get(); connect(compositorHelper.data(), &CompositorHelper::allowMouseCaptureChanged, this, [=] { if (isHMDMode()) { + auto compositorHelper = DependencyManager::get(); // don't capture outer smartpointer showCursor(compositorHelper->getAllowMouseCapture() ? Cursor::Manager::lookupIcon(_preferredCursor.get()) : Cursor::Icon::SYSTEM); diff --git a/interface/src/Application_render.cpp b/interface/src/Application_render.cpp index 2daa49dcf7..6b4840e3e5 100644 --- a/interface/src/Application_render.cpp +++ b/interface/src/Application_render.cpp @@ -139,7 +139,10 @@ void Application::paintGL() { frame->frameIndex = _renderFrameCount; frame->framebuffer = finalFramebuffer; frame->framebufferRecycler = [](const gpu::FramebufferPointer& framebuffer) { - DependencyManager::get()->releaseFramebuffer(framebuffer); + auto frameBufferCache = DependencyManager::get(); + if (frameBufferCache) { + frameBufferCache->releaseFramebuffer(framebuffer); + } }; // deliver final scene rendering commands to the display plugin { diff --git a/interface/src/ui/ApplicationOverlay.cpp b/interface/src/ui/ApplicationOverlay.cpp index ea660fb0e2..7db6a49d1c 100644 --- a/interface/src/ui/ApplicationOverlay.cpp +++ b/interface/src/ui/ApplicationOverlay.cpp @@ -50,6 +50,8 @@ ApplicationOverlay::~ApplicationOverlay() { geometryCache->releaseID(_magnifierBorder); geometryCache->releaseID(_qmlGeometryId); } + + DependencyManager::destroy(); } // Renders the overlays either to a texture or to the screen diff --git a/libraries/networking/src/ResourceManager.cpp b/libraries/networking/src/ResourceManager.cpp index 6df15129a2..46cf43b97d 100644 --- a/libraries/networking/src/ResourceManager.cpp +++ b/libraries/networking/src/ResourceManager.cpp @@ -39,8 +39,13 @@ ResourceManager::ResourceManager(bool atpSupportEnabled) : _atpSupportEnabled(at } ResourceManager::~ResourceManager() { - _thread.terminate(); - _thread.wait(); + if (_thread.isRunning()) { + _thread.quit(); + static const auto MAX_RESOURCE_MANAGER_THREAD_QUITTING_TIME = 0.5 * MSECS_PER_SECOND; + if (!_thread.wait(MAX_RESOURCE_MANAGER_THREAD_QUITTING_TIME)) { + _thread.terminate(); + } + } } void ResourceManager::setUrlPrefixOverride(const QString& prefix, const QString& replacement) { diff --git a/libraries/plugins/src/plugins/PluginManager.cpp b/libraries/plugins/src/plugins/PluginManager.cpp index e9c084e132..40b6ed820a 100644 --- a/libraries/plugins/src/plugins/PluginManager.cpp +++ b/libraries/plugins/src/plugins/PluginManager.cpp @@ -40,9 +40,8 @@ void PluginManager::setInputPluginSettingsPersister(const InputPluginSettingsPer _inputSettingsPersister = persister; } -PluginManager* PluginManager::getInstance() { - static PluginManager _manager; - return &_manager; +PluginManagerPointer PluginManager::getInstance() { + return DependencyManager::get(); } QString getPluginNameFromMetaData(QJsonObject object) { diff --git a/libraries/plugins/src/plugins/PluginManager.h b/libraries/plugins/src/plugins/PluginManager.h index f16ad7d09f..226ccc8060 100644 --- a/libraries/plugins/src/plugins/PluginManager.h +++ b/libraries/plugins/src/plugins/PluginManager.h @@ -9,11 +9,17 @@ #include +#include + #include "Forward.h" -class PluginManager : public QObject { + +class PluginManager; +using PluginManagerPointer = QSharedPointer; + +class PluginManager : public QObject, public Dependency { public: - static PluginManager* getInstance(); + static PluginManagerPointer getInstance(); PluginManager(); const DisplayPluginList& getDisplayPlugins(); From fa1a9d04e07e945cffb35de8685f10f5c49eecb7 Mon Sep 17 00:00:00 2001 From: amantley Date: Tue, 26 Jun 2018 13:18:26 -0700 Subject: [PATCH 09/61] 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 46c70d948f054a06dd54adcf2317180bf1ee0a80 Mon Sep 17 00:00:00 2001 From: amantley Date: Tue, 26 Jun 2018 15:11:58 -0700 Subject: [PATCH 10/61] 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 11/61] 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 12/61] 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 13/61] 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 14/61] 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 15/61] 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 16/61] 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 18219464f191b79d8a6d0254c8c41af000975ccf Mon Sep 17 00:00:00 2001 From: sabrina-shanman Date: Wed, 27 Jun 2018 09:39:19 -0700 Subject: [PATCH 17/61] Fix shutdown crash on Mac in Application::onPresent --- interface/src/Application.cpp | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/interface/src/Application.cpp b/interface/src/Application.cpp index 2033e8ee8e..c2600f9fca 100644 --- a/interface/src/Application.cpp +++ b/interface/src/Application.cpp @@ -269,9 +269,6 @@ public: } _renderContext->doneCurrent(); - // Deleting the object with automatically shutdown the thread - connect(qApp, &QCoreApplication::aboutToQuit, this, &QObject::deleteLater); - // Transfer to a new thread moveToNewNamedThread(this, "RenderThread", [this](QThread* renderThread) { hifi::qt::addBlockingForbiddenThread("Render", renderThread); @@ -2590,6 +2587,8 @@ Application::~Application() { // Can't log to file passed this point, FileLogger about to be deleted qInstallMessageHandler(LogHandler::verboseMessageHandler); + + _renderEventHandler->deleteLater(); } void Application::initializeGL() { From 4afb19e09106f4605a14e7634bca0a071a9cacb2 Mon Sep 17 00:00:00 2001 From: sabrina-shanman Date: Wed, 27 Jun 2018 09:49:51 -0700 Subject: [PATCH 18/61] Remove assert in ~Frame causing shutdown crash on Mac in dev build --- libraries/gpu/src/gpu/Frame.cpp | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/libraries/gpu/src/gpu/Frame.cpp b/libraries/gpu/src/gpu/Frame.cpp index d08a8ab56d..f1001d97d2 100644 --- a/libraries/gpu/src/gpu/Frame.cpp +++ b/libraries/gpu/src/gpu/Frame.cpp @@ -21,10 +21,7 @@ Frame::~Frame() { framebuffer.reset(); } - assert(bufferUpdates.empty()); - if (!bufferUpdates.empty()) { - qFatal("Buffer sync error... frame destroyed without buffer updates being applied"); - } + bufferUpdates.clear(); } void Frame::finish() { From 1804422df0d2d622374006818d3d66356e146ff2 Mon Sep 17 00:00:00 2001 From: amantley Date: Wed, 27 Jun 2018 11:15:33 -0700 Subject: [PATCH 19/61] 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 20/61] 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 2cdda231698a3e31eeeeaed67c8822dd467856af Mon Sep 17 00:00:00 2001 From: David Back Date: Wed, 27 Jun 2018 13:05:39 -0700 Subject: [PATCH 21/61] more robustness for optional properties --- scripts/system/edit.js | 1 - .../particle_explorer/hifi-entity-ui.js | 48 +++------- .../particle_explorer/particleExplorerTool.js | 93 +++++++++++++------ 3 files changed, 80 insertions(+), 62 deletions(-) diff --git a/scripts/system/edit.js b/scripts/system/edit.js index e9c7a49378..08e7a541d5 100644 --- a/scripts/system/edit.js +++ b/scripts/system/edit.js @@ -2373,7 +2373,6 @@ function selectParticleEntity(entityID) { particleExplorerTool.createWebView(); particleExplorerTool.setActiveParticleEntity(entityID); - particleExplorerTool.setActiveParticleProperties(properties); // Switch to particle explorer var tablet = Tablet.getTablet("com.highfidelity.interface.tablet.system"); diff --git a/scripts/system/particle_explorer/hifi-entity-ui.js b/scripts/system/particle_explorer/hifi-entity-ui.js index 36505a0b7f..62a0aadc86 100644 --- a/scripts/system/particle_explorer/hifi-entity-ui.js +++ b/scripts/system/particle_explorer/hifi-entity-ui.js @@ -61,12 +61,18 @@ function HifiEntityUI(parent) { this.parent = parent; var self = this; + this.sendPackage = {}; this.settingsUpdateLock = false; - this.webBridgeSync = _.debounce(function (id, val) { - if (self.EventBridge && !self.settingsUpdateLock) { - var sendPackage = {}; - sendPackage[id] = val; - self.submitChanges(sendPackage); + this.webBridgeSync = function(id, val) { + if (!this.settingsUpdateLock) { + this.sendPackage[id] = val; + this.webBridgeSyncDebounce(); + } + }; + this.webBridgeSyncDebounce = _.debounce(function () { + if (self.EventBridge) { + self.submitChanges(self.sendPackage); + self.sendPackage = {}; } }, DEBOUNCE_TIMEOUT); } @@ -159,7 +165,6 @@ HifiEntityUI.prototype = { var self = this; var fields = document.getElementsByTagName("input"); - self.settingsUpdateLock = true; if (!currentProperties.locked) { for (var i = 0; i < fields.length; i++) { fields[i].removeAttribute("disabled"); @@ -179,7 +184,7 @@ HifiEntityUI.prototype = { for (var e in keys) { if (keys.hasOwnProperty(e)) { var value = keys[e]; - + var property = currentProperties[value]; var field = self.builtRows[value]; if (field) { @@ -235,10 +240,6 @@ HifiEntityUI.prototype = { } } } - // Now unlocking settings Update lock for sending messages on callbacks. - setTimeout(function () { - self.settingsUpdateLock = false; - }, DEBOUNCE_TIMEOUT * 2.5); }, connect: function (EventBridge) { this.EventBridge = EventBridge; @@ -253,28 +254,9 @@ HifiEntityUI.prototype = { data = JSON.parse(data); if (data.messageType === 'particle_settings') { - // Update settings - var currentProperties = data.currentProperties; - // Update uninitialized variables - if (!currentProperties.alphaStart) { - currentProperties.alphaStart = currentProperties.alpha; - } - if (!currentProperties.alphaFinish) { - currentProperties.alphaFinish = currentProperties.alpha; - } - if (!currentProperties.radiusStart) { - currentProperties.radiusStart = currentProperties.particleRadius; - } - if (!currentProperties.radiusFinish) { - currentProperties.radiusFinish = currentProperties.particleRadius; - } - if (!currentProperties.colorStart || !currentProperties.colorStart.red) { - currentProperties.colorStart = currentProperties.color; - } - if (!currentProperties.colorFinish || !currentProperties.colorFinish.red) { - currentProperties.colorFinish = currentProperties.color; - } - self.fillFields(currentProperties); + self.settingsUpdateLock = true; + self.fillFields(data.currentProperties); + self.settingsUpdateLock = false; // Do expected property match with structure; } else if (data.messageType === 'particle_close') { self.disableFields(); diff --git a/scripts/system/particle_explorer/particleExplorerTool.js b/scripts/system/particle_explorer/particleExplorerTool.js index a1f06fda35..0de86fbf2f 100644 --- a/scripts/system/particle_explorer/particleExplorerTool.js +++ b/scripts/system/particle_explorer/particleExplorerTool.js @@ -9,7 +9,8 @@ // Distributed under the Apache License, Version 2.0. // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // -/* global window, alert, ParticleExplorerTool, EventBridge, dat, listenForSettingsUpdates,createVec3Folder,createQuatFolder,writeVec3ToInterface,writeDataToInterface*/ +/* global window, alert, ParticleExplorerTool, EventBridge, dat, listenForSettingsUpdates, createVec3Folder, + createQuatFolder, writeVec3ToInterface, writeDataToInterface */ var PARTICLE_EXPLORER_HTML_URL = Script.resolvePath('particleExplorer.html'); @@ -17,7 +18,7 @@ var PARTICLE_EXPLORER_HTML_URL = Script.resolvePath('particleExplorer.html'); ParticleExplorerTool = function() { var that = {}; that.activeParticleEntity = 0; - that.activeParticleProperties = {}; + that.updatedActiveParticleProperties = {}; that.createWebView = function() { that.webView = Tablet.getTablet("com.highfidelity.interface.tablet.system"); @@ -30,7 +31,7 @@ ParticleExplorerTool = function() { return; } that.activeParticleEntity = 0; - that.activeParticleProperties = {}; + that.updatedActiveParticleProperties = {}; var messageData = { messageType: "particle_close" @@ -38,46 +39,86 @@ ParticleExplorerTool = function() { that.webView.emitScriptEvent(JSON.stringify(messageData)); }; - function sendActiveParticleProperties() { + function sendParticleProperties(properties) { that.webView.emitScriptEvent(JSON.stringify({ messageType: "particle_settings", - currentProperties: that.activeParticleProperties + currentProperties: properties })); } + function sendActiveParticleProperties() { + var properties = Entities.getEntityProperties(that.activeParticleEntity); + if (properties.emitOrientation) { + properties.emitOrientation = Quat.safeEulerAngles(properties.emitOrientation); + } + // Update uninitialized variables + if (isNaN(properties.alphaStart)) { + properties.alphaStart = properties.alpha; + } + if (isNaN(properties.alphaFinish)) { + properties.alphaFinish = properties.alpha; + } + if (isNaN(properties.radiusStart)) { + properties.radiusStart = properties.particleRadius; + } + if (isNaN(properties.radiusFinish)) { + properties.radiusFinish = properties.particleRadius; + } + if (isNaN(properties.colorStart) || isNaN(properties.colorStart.red)) { + properties.colorStart = properties.color; + } + if (isNaN(properties.colorFinish) || isNaN(properties.colorFinish.red)) { + properties.colorFinish = properties.color; + } + sendParticleProperties(properties); + } + + function sendUpdatedActiveParticleProperties() { + sendParticleProperties(that.updatedActiveParticleProperties); + that.updatedActiveParticleProperties = {}; + } + that.webEventReceived = function(message) { var data = JSON.parse(message); if (data.messageType === "settings_update") { - if (data.updatedSettings.emitOrientation) { - data.updatedSettings.emitOrientation = Quat.fromVec3Degrees(data.updatedSettings.emitOrientation); - } - Entities.editEntity(that.activeParticleEntity, data.updatedSettings); - - for (var key in data.updatedSettings) { - if (that.activeParticleProperties.hasOwnProperty(key)) { - that.activeParticleProperties[key] = data.updatedSettings[key]; - } - } + var updatedSettings = data.updatedSettings; var optionalProps = ["alphaStart", "alphaFinish", "radiusStart", "radiusFinish", "colorStart", "colorFinish"]; var fallbackProps = ["alpha", "particleRadius", "color"]; - var entityProps = Entities.getEntityProperties(that.activeParticleProperties, optionalProps); + for (var i = 0; i < optionalProps.length; i++) { + var fallbackProp = fallbackProps[Math.floor(i / 2)]; + var optionalValue = updatedSettings[optionalProps[i]]; + var fallbackValue = updatedSettings[fallbackProp]; + if (optionalValue && fallbackValue) { + delete updatedSettings[optionalProps[i]]; + } + } + + if (updatedSettings.emitOrientation) { + updatedSettings.emitOrientation = Quat.fromVec3Degrees(updatedSettings.emitOrientation); + } + + Entities.editEntity(that.activeParticleEntity, updatedSettings); + + var entityProps = Entities.getEntityProperties(that.activeParticleEntity, optionalProps); + var needsUpdate = false; for (var i = 0; i < optionalProps.length; i++) { - var fallback = fallbackProps[Math.floor(i / 2)]; - if (data.updatedSettings[fallback]) { - var prop = optionalProps[i]; - if (!that.activeParticleProperties[prop] || (fallback === "color" && !that.activeParticleProperties[prop].red)) { - that.activeParticleProperties[prop] = entityProps[fallback]; + var fallbackProp = fallbackProps[Math.floor(i / 2)]; + var fallbackValue = updatedSettings[fallbackProp]; + if (fallbackValue) { + var optionalProp = optionalProps[i]; + if (isNaN(entityProps[optionalProp]) || (fallbackProp === "color" && isNaN(entityProps[optionalProp].red))) { + that.updatedActiveParticleProperties[optionalProp] = fallbackValue; needsUpdate = true; } } } if (needsUpdate) { - sendActiveParticleProperties(); + sendUpdatedActiveParticleProperties(); } - + } else if (data.messageType === "page_loaded") { sendActiveParticleProperties(); } @@ -85,12 +126,8 @@ ParticleExplorerTool = function() { that.setActiveParticleEntity = function(id) { that.activeParticleEntity = id; - }; - - that.setActiveParticleProperties = function(properties) { - that.activeParticleProperties = properties; sendActiveParticleProperties(); }; - + return that; }; From cfc8c0fb099edd2d7eb76e56fbdaa92a5e71c7e0 Mon Sep 17 00:00:00 2001 From: Zach Fox Date: Wed, 27 Jun 2018 14:07:04 -0700 Subject: [PATCH 22/61] 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 23/61] 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 24/61] 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 25/61] 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 1b414fbbfec1caad858454708d8706f8784fdd80 Mon Sep 17 00:00:00 2001 From: Zach Fox Date: Wed, 27 Jun 2018 15:11:59 -0700 Subject: [PATCH 26/61] 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 27/61] 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 28/61] 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 29/61] 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 30/61] 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 8228afb3782c2b11cfd3d7ee72c243e1c7ac86eb Mon Sep 17 00:00:00 2001 From: Alexia Mandeville Date: Wed, 27 Jun 2018 17:15:54 -0700 Subject: [PATCH 31/61] Resolving issue where VR input for movement stops emotes --- scripts/system/emote.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/scripts/system/emote.js b/scripts/system/emote.js index 1c741ba129..d484078b7b 100644 --- a/scripts/system/emote.js +++ b/scripts/system/emote.js @@ -84,7 +84,7 @@ function onWebEventReceived(event) { emoteName = event.data + randSit; // Sit1, Sit2, Sit3 } - if (ANIMATIONS[emoteName].resource.state =+= FINISHED) { + if (ANIMATIONS[emoteName].resource.state === FINISHED) { if (activeTimer !== false) { Script.clearTimeout(activeTimer); @@ -101,6 +101,7 @@ function onWebEventReceived(event) { // If user provides input during a sit, the avatar animation state should be restored Controller.keyPressEvent.connect(restoreAnimation); + Controller.enableMapping(eventMappingName); MyAvatar.overrideAnimation(ANIMATIONS[emoteName].url, FPS, false, 0, frameCount); } else { @@ -132,6 +133,7 @@ function restoreAnimation() { // Make sure the input is disconnected after animations are restored so it doesn't affect any emotes other than sit Controller.keyPressEvent.disconnect(restoreAnimation); + Controller.disableMapping(eventMappingName); } // Note peek() so as to not interfere with other mappings. @@ -151,7 +153,7 @@ eventMapping.from(Controller.Standard.RS).peek().to(restoreAnimation); eventMapping.from(Controller.Standard.RightGrip).peek().to(restoreAnimation); eventMapping.from(Controller.Standard.Back).peek().to(restoreAnimation); eventMapping.from(Controller.Standard.Start).peek().to(restoreAnimation); -Controller.enableMapping(eventMappingName); + button.clicked.connect(onClicked); tablet.screenChanged.connect(onScreenChanged); From e74d30ce22788b41fdb802543cd01d576a0620a8 Mon Sep 17 00:00:00 2001 From: David Back Date: Wed, 27 Jun 2018 17:43:41 -0700 Subject: [PATCH 32/61] fix color fallbacks --- scripts/system/particle_explorer/particleExplorerTool.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/system/particle_explorer/particleExplorerTool.js b/scripts/system/particle_explorer/particleExplorerTool.js index 0de86fbf2f..b675d26ff6 100644 --- a/scripts/system/particle_explorer/particleExplorerTool.js +++ b/scripts/system/particle_explorer/particleExplorerTool.js @@ -108,7 +108,7 @@ ParticleExplorerTool = function() { var fallbackValue = updatedSettings[fallbackProp]; if (fallbackValue) { var optionalProp = optionalProps[i]; - if (isNaN(entityProps[optionalProp]) || (fallbackProp === "color" && isNaN(entityProps[optionalProp].red))) { + if ((fallbackProp !== "color" && isNaN(entityProps[optionalProp])) || (fallbackProp === "color" && isNaN(entityProps[optionalProp].red))) { that.updatedActiveParticleProperties[optionalProp] = fallbackValue; needsUpdate = true; } From 4f5a1bc340c5605bbe4dd02f51c14e03f419a6f5 Mon Sep 17 00:00:00 2001 From: David Back Date: Wed, 27 Jun 2018 19:02:55 -0700 Subject: [PATCH 33/61] zero out spread values for previous versions --- libraries/entities/src/EntityTree.cpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/libraries/entities/src/EntityTree.cpp b/libraries/entities/src/EntityTree.cpp index a58f01a83b..87fcdc4f4d 100644 --- a/libraries/entities/src/EntityTree.cpp +++ b/libraries/entities/src/EntityTree.cpp @@ -2521,6 +2521,13 @@ bool EntityTree::readFromMap(QVariantMap& map) { } } + // Zero out the spread values that were fixed in version ParticleEntityFix so they behave the same as before + if (contentVersion < (int)EntityVersion::ParticleEntityFix) { + properties.setRadiusSpread(0.f); + properties.setAlphaSpread(0.f); + properties.setColorSpread({0, 0, 0}); + } + EntityItemPointer entity = addEntity(entityItemID, properties); if (!entity) { qCDebug(entities) << "adding Entity failed:" << entityItemID << properties.getType(); From ac6fcf092c52ab42d50c4d054bbaf512f305063d Mon Sep 17 00:00:00 2001 From: "Anthony J. Thibault" Date: Wed, 27 Jun 2018 16:57:57 -0700 Subject: [PATCH 34/61] 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 a8e231c5afad7e4a3a2ffcdef9022de6e53299de Mon Sep 17 00:00:00 2001 From: David Back Date: Thu, 28 Jun 2018 11:33:38 -0700 Subject: [PATCH 35/61] floats .0f --- libraries/entities/src/EntityTree.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libraries/entities/src/EntityTree.cpp b/libraries/entities/src/EntityTree.cpp index 87fcdc4f4d..0315ba7186 100644 --- a/libraries/entities/src/EntityTree.cpp +++ b/libraries/entities/src/EntityTree.cpp @@ -2523,8 +2523,8 @@ bool EntityTree::readFromMap(QVariantMap& map) { // Zero out the spread values that were fixed in version ParticleEntityFix so they behave the same as before if (contentVersion < (int)EntityVersion::ParticleEntityFix) { - properties.setRadiusSpread(0.f); - properties.setAlphaSpread(0.f); + properties.setRadiusSpread(0.0f); + properties.setAlphaSpread(0.0f); properties.setColorSpread({0, 0, 0}); } From 2d27de12bd906344244994fa686561a294035216 Mon Sep 17 00:00:00 2001 From: Zach Fox Date: Thu, 28 Jun 2018 12:06:31 -0700 Subject: [PATCH 36/61] 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, From 9772fc4e22c647914444b78e773fa406364ce517 Mon Sep 17 00:00:00 2001 From: "Anthony J. Thibault" Date: Thu, 28 Jun 2018 14:04:59 -0700 Subject: [PATCH 37/61] Guard against memory corruption in Space::processResets() Check the proxyID before reading from the _proxies vector and writing into the _owners vector. --- libraries/workload/src/workload/Space.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/libraries/workload/src/workload/Space.cpp b/libraries/workload/src/workload/Space.cpp index 27a8639f3a..10e61c5661 100644 --- a/libraries/workload/src/workload/Space.cpp +++ b/libraries/workload/src/workload/Space.cpp @@ -44,6 +44,11 @@ void Space::processResets(const Transaction::Resets& transactions) { for (auto& reset : transactions) { // Access the true item auto proxyID = std::get<0>(reset); + + // Guard against proxyID being past the end of the list. + if (proxyID >= _proxies.size() || proxyID >= _owners.size()) { + continue; + } auto& item = _proxies[proxyID]; // Reset the item with a new payload From 17f9a01fa20486eef87ee8c3c91eb8a4465f26e0 Mon Sep 17 00:00:00 2001 From: "Anthony J. Thibault" Date: Thu, 28 Jun 2018 15:29:01 -0700 Subject: [PATCH 38/61] Fix signed unsigned compare warning --- libraries/workload/src/workload/Space.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libraries/workload/src/workload/Space.cpp b/libraries/workload/src/workload/Space.cpp index 10e61c5661..54fad79741 100644 --- a/libraries/workload/src/workload/Space.cpp +++ b/libraries/workload/src/workload/Space.cpp @@ -46,7 +46,7 @@ void Space::processResets(const Transaction::Resets& transactions) { auto proxyID = std::get<0>(reset); // Guard against proxyID being past the end of the list. - if (proxyID >= _proxies.size() || proxyID >= _owners.size()) { + if (proxyID < 0 || proxyID >= (int32_t)_proxies.size() || proxyID >= (int32_t)_owners.size()) { continue; } auto& item = _proxies[proxyID]; From 847cad46ca828f00eab0e2bb1931d15ad934581e Mon Sep 17 00:00:00 2001 From: Dante Ruiz Date: Thu, 28 Jun 2018 16:25:34 -0700 Subject: [PATCH 39/61] fix billboard crash --- libraries/qml/src/qml/OffscreenSurface.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libraries/qml/src/qml/OffscreenSurface.cpp b/libraries/qml/src/qml/OffscreenSurface.cpp index f0c3dfdffd..dfd0a1d3c6 100644 --- a/libraries/qml/src/qml/OffscreenSurface.cpp +++ b/libraries/qml/src/qml/OffscreenSurface.cpp @@ -66,7 +66,7 @@ OffscreenSurface::OffscreenSurface() } OffscreenSurface::~OffscreenSurface() { - delete _sharedObject; + _sharedObject->deleteLater(); } bool OffscreenSurface::fetchTexture(TextureAndFence& textureAndFence) { From d543cd07668dc543ebd4e6ec1b7bb48bd201f74f Mon Sep 17 00:00:00 2001 From: Sam Gateau Date: Fri, 29 Jun 2018 15:42:19 +0200 Subject: [PATCH 40/61] Fixing a bug if the last session display pluginis an invalid name, resolve to default --- interface/src/Application.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/interface/src/Application.cpp b/interface/src/Application.cpp index a60d72073c..9c262c1980 100644 --- a/interface/src/Application.cpp +++ b/interface/src/Application.cpp @@ -2719,7 +2719,7 @@ void Application::initializeDisplayPlugins() { setDisplayPlugin(defaultDisplayPlugin); // Now set the desired plugin if it's not the same as the default plugin - if (targetDisplayPlugin != defaultDisplayPlugin) { + if (!targetDisplayPlugin && (targetDisplayPlugin != defaultDisplayPlugin)) { setDisplayPlugin(targetDisplayPlugin); } From de831ffea970df0981067bd075f10f2e042362e3 Mon Sep 17 00:00:00 2001 From: Olivier Prat Date: Fri, 29 Jun 2018 16:55:33 +0200 Subject: [PATCH 41/61] Switched shadow maps to sampler2DArrayShadow to try to fix on Mac --- .../src/gpu/gl/GLBackendPipeline.cpp | 5 ++-- .../gpu-gl-common/src/gpu/gl/GLTexture.cpp | 16 ++++++++++--- .../gpu-gl/src/gpu/gl41/GL41BackendOutput.cpp | 14 +++++++++-- .../src/gpu/gl41/GL41BackendTexture.cpp | 9 +++++++- .../gpu-gl/src/gpu/gl45/GL45BackendOutput.cpp | 14 ++++++++--- .../src/gpu/gl45/GL45BackendTexture.cpp | 7 +++++- libraries/gpu/src/gpu/Texture.cpp | 8 +++++++ libraries/gpu/src/gpu/Texture.h | 2 ++ libraries/gpu/src/gpu/Texture_ktx.cpp | 2 +- libraries/ktx/src/ktx/KTX.h | 1 + .../render-utils/src/DebugDeferredBuffer.cpp | 13 +++++++---- .../src/DeferredLightingEffect.cpp | 6 ++--- libraries/render-utils/src/LightStage.cpp | 23 +++++++++++++++++-- libraries/render-utils/src/LightStage.h | 3 ++- libraries/render-utils/src/Shadow.slh | 4 ++-- 15 files changed, 101 insertions(+), 26 deletions(-) diff --git a/libraries/gpu-gl-common/src/gpu/gl/GLBackendPipeline.cpp b/libraries/gpu-gl-common/src/gpu/gl/GLBackendPipeline.cpp index 91f1d8bb8c..b75f89f7ae 100644 --- a/libraries/gpu-gl-common/src/gpu/gl/GLBackendPipeline.cpp +++ b/libraries/gpu-gl-common/src/gpu/gl/GLBackendPipeline.cpp @@ -203,10 +203,11 @@ void GLBackend::releaseResourceTexture(uint32_t slot) { } void GLBackend::resetResourceStage() { - for (uint32_t i = 0; i < _resource._buffers.size(); i++) { + uint32_t i; + for (i = 0; i < _resource._buffers.size(); i++) { releaseResourceBuffer(i); } - for (uint32_t i = 0; i < _resource._textures.size(); i++) { + for (i = 0; i < _resource._textures.size(); i++) { releaseResourceTexture(i); } } diff --git a/libraries/gpu-gl-common/src/gpu/gl/GLTexture.cpp b/libraries/gpu-gl-common/src/gpu/gl/GLTexture.cpp index e11f8f01c7..e9494a1271 100644 --- a/libraries/gpu-gl-common/src/gpu/gl/GLTexture.cpp +++ b/libraries/gpu-gl-common/src/gpu/gl/GLTexture.cpp @@ -59,7 +59,11 @@ const size_t GLVariableAllocationSupport::MAX_BUFFER_SIZE = MAX_TRANSFER_SIZE; GLenum GLTexture::getGLTextureType(const Texture& texture) { switch (texture.getType()) { case Texture::TEX_2D: - return GL_TEXTURE_2D; + if (!texture.isArray()) { + return GL_TEXTURE_2D; + } else { + return GL_TEXTURE_2D_ARRAY; + } break; case Texture::TEX_CUBE: @@ -77,6 +81,7 @@ GLenum GLTexture::getGLTextureType(const Texture& texture) { uint8_t GLTexture::getFaceCount(GLenum target) { switch (target) { case GL_TEXTURE_2D: + case GL_TEXTURE_2D_ARRAY: return TEXTURE_2D_NUM_FACES; case GL_TEXTURE_CUBE_MAP: return TEXTURE_CUBE_NUM_FACES; @@ -86,17 +91,22 @@ uint8_t GLTexture::getFaceCount(GLenum target) { } } const std::vector& GLTexture::getFaceTargets(GLenum target) { - static std::vector cubeFaceTargets { + static const std::vector cubeFaceTargets { GL_TEXTURE_CUBE_MAP_POSITIVE_X, GL_TEXTURE_CUBE_MAP_NEGATIVE_X, GL_TEXTURE_CUBE_MAP_POSITIVE_Y, GL_TEXTURE_CUBE_MAP_NEGATIVE_Y, GL_TEXTURE_CUBE_MAP_POSITIVE_Z, GL_TEXTURE_CUBE_MAP_NEGATIVE_Z }; - static std::vector faceTargets { + static const std::vector faceTargets { GL_TEXTURE_2D }; + static const std::vector arrayFaceTargets{ + GL_TEXTURE_2D_ARRAY + }; switch (target) { case GL_TEXTURE_2D: return faceTargets; + case GL_TEXTURE_2D_ARRAY: + return arrayFaceTargets; case GL_TEXTURE_CUBE_MAP: return cubeFaceTargets; default: diff --git a/libraries/gpu-gl/src/gpu/gl41/GL41BackendOutput.cpp b/libraries/gpu-gl/src/gpu/gl41/GL41BackendOutput.cpp index a5ef2d92e1..1d512103bd 100644 --- a/libraries/gpu-gl/src/gpu/gl41/GL41BackendOutput.cpp +++ b/libraries/gpu-gl/src/gpu/gl41/GL41BackendOutput.cpp @@ -64,7 +64,12 @@ public: } if (gltexture) { - glFramebufferTexture2D(GL_FRAMEBUFFER, colorAttachments[unit], GL_TEXTURE_2D, gltexture->_texture, 0); + if (gltexture->_target == GL_TEXTURE_2D) { + glFramebufferTexture2D(GL_FRAMEBUFFER, colorAttachments[unit], GL_TEXTURE_2D, gltexture->_texture, 0); + } else { + glFramebufferTextureLayer(GL_FRAMEBUFFER, colorAttachments[unit], gltexture->_texture, 0, + b._subresource); + } _colorBuffers.push_back(colorAttachments[unit]); } else { glFramebufferTexture2D(GL_FRAMEBUFFER, colorAttachments[unit], GL_TEXTURE_2D, 0, 0); @@ -91,7 +96,12 @@ public: } if (gltexture) { - glFramebufferTexture2D(GL_FRAMEBUFFER, attachement, GL_TEXTURE_2D, gltexture->_texture, 0); + if (gltexture->_target == GL_TEXTURE_2D) { + glFramebufferTexture2D(GL_FRAMEBUFFER, attachement, GL_TEXTURE_2D, gltexture->_texture, 0); + } else { + glFramebufferTextureLayer(GL_FRAMEBUFFER, attachement, gltexture->_texture, 0, + _gpuObject.getDepthStencilBufferSubresource()); + } } else { glFramebufferTexture2D(GL_FRAMEBUFFER, attachement, GL_TEXTURE_2D, 0, 0); } diff --git a/libraries/gpu-gl/src/gpu/gl41/GL41BackendTexture.cpp b/libraries/gpu-gl/src/gpu/gl41/GL41BackendTexture.cpp index a255cc5878..ce9735b37e 100644 --- a/libraries/gpu-gl/src/gpu/gl41/GL41BackendTexture.cpp +++ b/libraries/gpu-gl/src/gpu/gl41/GL41BackendTexture.cpp @@ -215,12 +215,19 @@ GL41FixedAllocationTexture::~GL41FixedAllocationTexture() { void GL41FixedAllocationTexture::allocateStorage() const { const GLTexelFormat texelFormat = GLTexelFormat::evalGLTexelFormat(_gpuObject.getTexelFormat()); const auto numMips = _gpuObject.getNumMips(); + const auto numSlices = _gpuObject.getNumSlices(); // glTextureStorage2D(_id, mips, texelFormat.internalFormat, dimensions.x, dimensions.y); for (GLint level = 0; level < numMips; level++) { Vec3u dimensions = _gpuObject.evalMipDimensions(level); for (GLenum target : getFaceTargets(_target)) { - glTexImage2D(target, level, texelFormat.internalFormat, dimensions.x, dimensions.y, 0, texelFormat.format, texelFormat.type, nullptr); + if (!_gpuObject.isArray()) { + glTexImage2D(target, level, texelFormat.internalFormat, dimensions.x, dimensions.y, 0, texelFormat.format, + texelFormat.type, nullptr); + } else { + glTexImage3D(target, level, texelFormat.internalFormat, dimensions.x, dimensions.y, numSlices, 0, + texelFormat.format, texelFormat.type, nullptr); + } } } diff --git a/libraries/gpu-gl/src/gpu/gl45/GL45BackendOutput.cpp b/libraries/gpu-gl/src/gpu/gl45/GL45BackendOutput.cpp index ca53d6c624..86332558e3 100644 --- a/libraries/gpu-gl/src/gpu/gl45/GL45BackendOutput.cpp +++ b/libraries/gpu-gl/src/gpu/gl45/GL45BackendOutput.cpp @@ -60,7 +60,11 @@ public: } if (gltexture) { - glNamedFramebufferTexture(_id, colorAttachments[unit], gltexture->_texture, 0); + if (gltexture->_target == GL_TEXTURE_2D) { + glNamedFramebufferTexture(_id, colorAttachments[unit], gltexture->_texture, 0); + } else { + glNamedFramebufferTextureLayer(_id, colorAttachments[unit], gltexture->_texture, 0, b._subresource); + } _colorBuffers.push_back(colorAttachments[unit]); } else { glNamedFramebufferTexture(_id, colorAttachments[unit], 0, 0); @@ -87,14 +91,18 @@ public: } if (gltexture) { - glNamedFramebufferTexture(_id, attachement, gltexture->_texture, 0); + if (gltexture->_target == GL_TEXTURE_2D) { + glNamedFramebufferTexture(_id, attachement, gltexture->_texture, 0); + } else { + glNamedFramebufferTextureLayer(_id, attachement, gltexture->_texture, 0, + _gpuObject.getDepthStencilBufferSubresource()); + } } else { glNamedFramebufferTexture(_id, attachement, 0, 0); } _depthStamp = _gpuObject.getDepthStamp(); } - // Last but not least, define where we draw if (!_colorBuffers.empty()) { glNamedFramebufferDrawBuffers(_id, (GLsizei)_colorBuffers.size(), _colorBuffers.data()); diff --git a/libraries/gpu-gl/src/gpu/gl45/GL45BackendTexture.cpp b/libraries/gpu-gl/src/gpu/gl45/GL45BackendTexture.cpp index fda7ac22dd..a00159a7ce 100644 --- a/libraries/gpu-gl/src/gpu/gl45/GL45BackendTexture.cpp +++ b/libraries/gpu-gl/src/gpu/gl45/GL45BackendTexture.cpp @@ -374,8 +374,13 @@ void GL45FixedAllocationTexture::allocateStorage() const { const GLTexelFormat texelFormat = GLTexelFormat::evalGLTexelFormat(_gpuObject.getTexelFormat()); const auto dimensions = _gpuObject.getDimensions(); const auto mips = _gpuObject.getNumMips(); + const auto numSlices = _gpuObject.getNumSlices(); - glTextureStorage2D(_id, mips, texelFormat.internalFormat, dimensions.x, dimensions.y); + if (!_gpuObject.isArray()) { + glTextureStorage2D(_id, mips, texelFormat.internalFormat, dimensions.x, dimensions.y); + } else { + glTextureStorage3D(_id, mips, texelFormat.internalFormat, dimensions.x, dimensions.y, numSlices); + } glTextureParameteri(_id, GL_TEXTURE_BASE_LEVEL, 0); glTextureParameteri(_id, GL_TEXTURE_MAX_LEVEL, mips - 1); diff --git a/libraries/gpu/src/gpu/Texture.cpp b/libraries/gpu/src/gpu/Texture.cpp index a92243f808..34262b0cd9 100755 --- a/libraries/gpu/src/gpu/Texture.cpp +++ b/libraries/gpu/src/gpu/Texture.cpp @@ -184,6 +184,10 @@ TexturePointer Texture::createRenderBuffer(const Element& texelFormat, uint16 wi return create(TextureUsageType::RENDERBUFFER, TEX_2D, texelFormat, width, height, 1, 1, 0, numMips, sampler); } +TexturePointer Texture::createRenderBufferArray(const Element& texelFormat, uint16 width, uint16 height, uint16 numSlices, uint16 numMips, const Sampler& sampler) { + return create(TextureUsageType::RENDERBUFFER, TEX_2D, texelFormat, width, height, 1, 1, numSlices, numMips, sampler); +} + TexturePointer Texture::create1D(const Element& texelFormat, uint16 width, uint16 numMips, const Sampler& sampler) { return create(TextureUsageType::RESOURCE, TEX_1D, texelFormat, width, 1, 1, 1, 0, numMips, sampler); } @@ -192,6 +196,10 @@ TexturePointer Texture::create2D(const Element& texelFormat, uint16 width, uint1 return create(TextureUsageType::RESOURCE, TEX_2D, texelFormat, width, height, 1, 1, 0, numMips, sampler); } +TexturePointer Texture::create2DArray(const Element& texelFormat, uint16 width, uint16 height, uint16 numSlices, uint16 numMips, const Sampler& sampler) { + return create(TextureUsageType::STRICT_RESOURCE, TEX_2D, texelFormat, width, height, 1, 1, numSlices, numMips, sampler); +} + TexturePointer Texture::createStrict(const Element& texelFormat, uint16 width, uint16 height, uint16 numMips, const Sampler& sampler) { return create(TextureUsageType::STRICT_RESOURCE, TEX_2D, texelFormat, width, height, 1, 1, 0, numMips, sampler); } diff --git a/libraries/gpu/src/gpu/Texture.h b/libraries/gpu/src/gpu/Texture.h index 09b2bc9475..9ad5dc0816 100755 --- a/libraries/gpu/src/gpu/Texture.h +++ b/libraries/gpu/src/gpu/Texture.h @@ -374,9 +374,11 @@ public: static const uint16 SINGLE_MIP = 1; static TexturePointer create1D(const Element& texelFormat, uint16 width, uint16 numMips = SINGLE_MIP, const Sampler& sampler = Sampler()); static TexturePointer create2D(const Element& texelFormat, uint16 width, uint16 height, uint16 numMips = SINGLE_MIP, const Sampler& sampler = Sampler()); + static TexturePointer create2DArray(const Element& texelFormat, uint16 width, uint16 height, uint16 numSlices, uint16 numMips = SINGLE_MIP, const Sampler& sampler = Sampler()); static TexturePointer create3D(const Element& texelFormat, uint16 width, uint16 height, uint16 depth, uint16 numMips = SINGLE_MIP, const Sampler& sampler = Sampler()); static TexturePointer createCube(const Element& texelFormat, uint16 width, uint16 numMips = 1, const Sampler& sampler = Sampler()); static TexturePointer createRenderBuffer(const Element& texelFormat, uint16 width, uint16 height, uint16 numMips = SINGLE_MIP, const Sampler& sampler = Sampler()); + static TexturePointer createRenderBufferArray(const Element& texelFormat, uint16 width, uint16 height, uint16 numSlices, uint16 numMips = SINGLE_MIP, const Sampler& sampler = Sampler()); static TexturePointer createStrict(const Element& texelFormat, uint16 width, uint16 height, uint16 numMips = SINGLE_MIP, const Sampler& sampler = Sampler()); static TexturePointer createExternal(const ExternalRecycler& recycler, const Sampler& sampler = Sampler()); diff --git a/libraries/gpu/src/gpu/Texture_ktx.cpp b/libraries/gpu/src/gpu/Texture_ktx.cpp index 0d4abe78d3..1b7b552078 100644 --- a/libraries/gpu/src/gpu/Texture_ktx.cpp +++ b/libraries/gpu/src/gpu/Texture_ktx.cpp @@ -515,7 +515,7 @@ TexturePointer Texture::build(const ktx::KTXDescriptor& descriptor) { header.getPixelHeight(), header.getPixelDepth(), 1, // num Samples - header.getNumberOfSlices(), + header.isArray() ? header.getNumberOfSlices() : 0, header.getNumberOfLevels(), samplerDesc); texture->setUsage(gpuktxKeyValue._usage); diff --git a/libraries/ktx/src/ktx/KTX.h b/libraries/ktx/src/ktx/KTX.h index 54a8188a42..d755a482e3 100644 --- a/libraries/ktx/src/ktx/KTX.h +++ b/libraries/ktx/src/ktx/KTX.h @@ -163,6 +163,7 @@ namespace ktx { uint32_t getPixelDepth() const { return (pixelDepth ? pixelDepth : 1); } uint32_t getNumberOfSlices() const { return (numberOfArrayElements ? numberOfArrayElements : 1); } uint32_t getNumberOfLevels() const { return (numberOfMipmapLevels ? numberOfMipmapLevels : 1); } + bool isArray() const { return numberOfArrayElements > 0; } bool isCompressed() const { return glFormat == COMPRESSED_FORMAT; } uint32_t evalMaxDimension() const; diff --git a/libraries/render-utils/src/DebugDeferredBuffer.cpp b/libraries/render-utils/src/DebugDeferredBuffer.cpp index c17044be6d..7728c1406c 100644 --- a/libraries/render-utils/src/DebugDeferredBuffer.cpp +++ b/libraries/render-utils/src/DebugDeferredBuffer.cpp @@ -140,11 +140,12 @@ static const std::string DEFAULT_LIGHTING_SHADER { }; static const std::string DEFAULT_SHADOW_SHADER{ - "uniform sampler2DShadow shadowMap;" + "uniform sampler2DArrayShadow shadowMaps;" + "uniform int shadowCascadeIndex;" "vec4 getFragmentColor() {" " for (int i = 255; i >= 0; --i) {" " float depth = i / 255.0;" - " if (texture(shadowMap, vec3(uv, depth)) > 0.5) {" + " if (texture(shadowMaps, vec4(uv, shadowCascadeIndex, depth)) > 0.5) {" " return vec4(vec3(depth), 1.0);" " }" " }" @@ -403,7 +404,7 @@ const gpu::PipelinePointer& DebugDeferredBuffer::getPipeline(Mode mode, std::str slotBindings.insert(gpu::Shader::Binding("depthMap", Depth)); slotBindings.insert(gpu::Shader::Binding("obscuranceMap", AmbientOcclusion)); slotBindings.insert(gpu::Shader::Binding("lightingMap", Lighting)); - slotBindings.insert(gpu::Shader::Binding("shadowMap", Shadow)); + slotBindings.insert(gpu::Shader::Binding("shadowMaps", Shadow)); slotBindings.insert(gpu::Shader::Binding("linearDepthMap", LinearDepth)); slotBindings.insert(gpu::Shader::Binding("halfLinearDepthMap", HalfLinearDepth)); slotBindings.insert(gpu::Shader::Binding("halfNormalMap", HalfNormal)); @@ -490,7 +491,11 @@ void DebugDeferredBuffer::run(const RenderContextPointer& renderContext, const I const auto& globalShadow = lightAndShadow.second; if (globalShadow) { const auto cascadeIndex = glm::clamp(_mode - Mode::ShadowCascade0Mode, 0, (int)globalShadow->getCascadeCount() - 1); - batch.setResourceTexture(Shadow, globalShadow->getCascade(cascadeIndex).map); + const auto cascadeIndexLocation = pipeline->getProgram()->getUniforms().findLocation("shadowCascadeIndex"); + batch.setResourceTexture(Shadow, globalShadow->map); + if (cascadeIndexLocation >= 0) { + batch._glUniform1i(cascadeIndexLocation, cascadeIndex); + } batch.setUniformBuffer(ShadowTransform, globalShadow->getBuffer()); batch.setUniformBuffer(DeferredFrameTransform, frameTransform->getFrameTransformBuffer()); } diff --git a/libraries/render-utils/src/DeferredLightingEffect.cpp b/libraries/render-utils/src/DeferredLightingEffect.cpp index 9223e0fa03..452e5b5ccd 100644 --- a/libraries/render-utils/src/DeferredLightingEffect.cpp +++ b/libraries/render-utils/src/DeferredLightingEffect.cpp @@ -68,7 +68,7 @@ enum DeferredShader_MapSlot { SCATTERING_SPECULAR_UNIT = 9, SKYBOX_MAP_UNIT = render::ShapePipeline::Slot::LIGHT_AMBIENT_MAP, // unit = 10 SHADOW_MAP_UNIT = 11, - nextAvailableUnit = SHADOW_MAP_UNIT + SHADOW_CASCADE_MAX_COUNT + nextAvailableUnit = SHADOW_MAP_UNIT }; enum DeferredShader_BufferSlot { DEFERRED_FRAME_TRANSFORM_BUFFER_SLOT = 0, @@ -534,9 +534,7 @@ void RenderDeferredSetup::run(const render::RenderContextPointer& renderContext, // Bind the shadow buffers if (globalShadow) { - for (unsigned int i = 0; i < globalShadow->getCascadeCount(); i++) { - batch.setResourceTexture(SHADOW_MAP_UNIT+i, globalShadow->getCascade(i).map); - } + batch.setResourceTexture(SHADOW_MAP_UNIT, globalShadow->map); } auto program = deferredLightingEffect->_directionalSkyboxLight; diff --git a/libraries/render-utils/src/LightStage.cpp b/libraries/render-utils/src/LightStage.cpp index ceac4ae3c8..369c62c197 100644 --- a/libraries/render-utils/src/LightStage.cpp +++ b/libraries/render-utils/src/LightStage.cpp @@ -74,8 +74,6 @@ LightStage::Shadow::Cascade::Cascade() : _frustum{ std::make_shared() }, _minDistance{ 0.0f }, _maxDistance{ 20.0f } { - framebuffer = gpu::FramebufferPointer(gpu::Framebuffer::createShadowmap(MAP_SIZE)); - map = framebuffer->getDepthStencilBuffer(); } const glm::mat4& LightStage::Shadow::Cascade::getView() const { @@ -127,8 +125,29 @@ LightStage::Shadow::Shadow(graphics::LightPointer light, float maxDistance, unsi Schema schema; schema.cascadeCount = cascadeCount; _schemaBuffer = std::make_shared(sizeof(Schema), (const gpu::Byte*) &schema); + + // Create shadow cascade texture array + auto depthFormat = gpu::Element(gpu::SCALAR, gpu::FLOAT, gpu::DEPTH); // Depth32 texel format + map = gpu::TexturePointer(gpu::Texture::createRenderBufferArray(depthFormat, MAP_SIZE, MAP_SIZE, cascadeCount)); + gpu::Sampler::Desc samplerDesc; + samplerDesc._borderColor = glm::vec4(1.0f); + samplerDesc._wrapModeU = gpu::Sampler::WRAP_BORDER; + samplerDesc._wrapModeV = gpu::Sampler::WRAP_BORDER; + samplerDesc._filter = gpu::Sampler::FILTER_MIN_MAG_LINEAR; + samplerDesc._comparisonFunc = gpu::LESS; + + map->setSampler(gpu::Sampler(samplerDesc)); + _cascades.resize(cascadeCount); + for (uint cascadeIndex=0; cascadeIndex < cascadeCount; cascadeIndex++) { + auto& cascade = _cascades[cascadeIndex]; + std::string name = "Shadowmap Cascade "; + name += '0' + cascadeIndex; + cascade.framebuffer = gpu::FramebufferPointer(gpu::Framebuffer::create(name)); + cascade.framebuffer->setDepthBuffer(map, depthFormat, cascadeIndex); + } + setMaxDistance(maxDistance); } diff --git a/libraries/render-utils/src/LightStage.h b/libraries/render-utils/src/LightStage.h index 9812426fa6..b8a49d81bb 100644 --- a/libraries/render-utils/src/LightStage.h +++ b/libraries/render-utils/src/LightStage.h @@ -53,7 +53,6 @@ public: Cascade(); gpu::FramebufferPointer framebuffer; - gpu::TexturePointer map; const std::shared_ptr& getFrustum() const { return _frustum; } @@ -93,6 +92,8 @@ public: const graphics::LightPointer& getLight() const { return _light; } + gpu::TexturePointer map; + protected: #include "Shadows_shared.slh" diff --git a/libraries/render-utils/src/Shadow.slh b/libraries/render-utils/src/Shadow.slh index 36eb35c757..235ea519ab 100644 --- a/libraries/render-utils/src/Shadow.slh +++ b/libraries/render-utils/src/Shadow.slh @@ -17,11 +17,11 @@ #define SHADOW_SCREEN_SPACE_DITHER 1 // the shadow texture -uniform sampler2DShadow shadowMaps[SHADOW_CASCADE_MAX_COUNT]; +uniform sampler2DArrayShadow shadowMaps; // Sample the shadowMap with PCF (built-in) float fetchShadow(int cascadeIndex, vec3 shadowTexcoord) { - return texture(shadowMaps[cascadeIndex], shadowTexcoord); + return texture(shadowMaps, vec4(shadowTexcoord.xy, cascadeIndex, shadowTexcoord.z)); } vec2 PCFkernel[4] = vec2[4]( From 9dc03f50133a104b3f7c553737e54f1098dca372 Mon Sep 17 00:00:00 2001 From: sabrina-shanman Date: Fri, 29 Jun 2018 10:39:16 -0700 Subject: [PATCH 42/61] Destroy GeometryCache explicitly in Application destructor --- interface/src/Application.cpp | 1 + interface/src/ui/ApplicationOverlay.cpp | 2 -- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/interface/src/Application.cpp b/interface/src/Application.cpp index 4b32783607..63fff2af5b 100644 --- a/interface/src/Application.cpp +++ b/interface/src/Application.cpp @@ -2565,6 +2565,7 @@ Application::~Application() { DependencyManager::destroy(); DependencyManager::destroy(); DependencyManager::destroy(); + DependencyManager::destroy(); DependencyManager::get()->cleanup(); diff --git a/interface/src/ui/ApplicationOverlay.cpp b/interface/src/ui/ApplicationOverlay.cpp index 7db6a49d1c..ea660fb0e2 100644 --- a/interface/src/ui/ApplicationOverlay.cpp +++ b/interface/src/ui/ApplicationOverlay.cpp @@ -50,8 +50,6 @@ ApplicationOverlay::~ApplicationOverlay() { geometryCache->releaseID(_magnifierBorder); geometryCache->releaseID(_qmlGeometryId); } - - DependencyManager::destroy(); } // Renders the overlays either to a texture or to the screen From e4377a6c95b6cd99fb56116f0768d23e7c901b3a Mon Sep 17 00:00:00 2001 From: sabrina-shanman Date: Fri, 29 Jun 2018 10:55:01 -0700 Subject: [PATCH 43/61] Prevent type conversion in ~ResourceManager constant --- libraries/networking/src/ResourceManager.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libraries/networking/src/ResourceManager.cpp b/libraries/networking/src/ResourceManager.cpp index 46cf43b97d..553f0d0a61 100644 --- a/libraries/networking/src/ResourceManager.cpp +++ b/libraries/networking/src/ResourceManager.cpp @@ -41,7 +41,7 @@ ResourceManager::ResourceManager(bool atpSupportEnabled) : _atpSupportEnabled(at ResourceManager::~ResourceManager() { if (_thread.isRunning()) { _thread.quit(); - static const auto MAX_RESOURCE_MANAGER_THREAD_QUITTING_TIME = 0.5 * MSECS_PER_SECOND; + static const auto MAX_RESOURCE_MANAGER_THREAD_QUITTING_TIME = MSECS_PER_SECOND / 2; if (!_thread.wait(MAX_RESOURCE_MANAGER_THREAD_QUITTING_TIME)) { _thread.terminate(); } From 9e3626cca31432e596586b737ea3d949e4e678a7 Mon Sep 17 00:00:00 2001 From: Wayne Chen Date: Fri, 29 Jun 2018 14:42:33 -0700 Subject: [PATCH 44/61] returning false if there is no entity to connect to --- libraries/entities/src/EntityScriptingInterface.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/libraries/entities/src/EntityScriptingInterface.cpp b/libraries/entities/src/EntityScriptingInterface.cpp index 378ce541d7..09d9823728 100644 --- a/libraries/entities/src/EntityScriptingInterface.cpp +++ b/libraries/entities/src/EntityScriptingInterface.cpp @@ -1269,6 +1269,8 @@ bool EntityScriptingInterface::appendPoint(QUuid entityID, const glm::vec3& poin EntityItemPointer entity = static_cast(_entityTree->findEntityByEntityItemID(entityID)); if (!entity) { qCDebug(entities) << "EntityScriptingInterface::setPoints no entity with ID" << entityID; + // There is no entity + return false; } EntityTypes::EntityType entityType = entity->getType(); From 9b59dc5809f551edb6e321122304f25acc405180 Mon Sep 17 00:00:00 2001 From: r3tk0n Date: Fri, 29 Jun 2018 15:22:57 -0700 Subject: [PATCH 45/61] Changed SpinnerSliderPreference.qml to general-case UI element as originally intended, updated PreferencesDialog.cpp's Avatar Scale slider to hard-coded bounds [0.25, 4.0]. --- .../dialogs/preferences/SpinnerSliderPreference.qml | 8 ++++---- interface/src/ui/PreferencesDialog.cpp | 11 +++++++++-- 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/interface/resources/qml/dialogs/preferences/SpinnerSliderPreference.qml b/interface/resources/qml/dialogs/preferences/SpinnerSliderPreference.qml index 731acc7e5b..126e62fc30 100644 --- a/interface/resources/qml/dialogs/preferences/SpinnerSliderPreference.qml +++ b/interface/resources/qml/dialogs/preferences/SpinnerSliderPreference.qml @@ -56,8 +56,8 @@ Preference { id: slider value: preference.value width: 100 - minimumValue: MyAvatar.getDomainMinScale() - maximumValue: MyAvatar.getDomainMaxScale() + minimumValue: preference.min + maximumValue: preference.max stepSize: preference.step onValueChanged: { spinner.realValue = value @@ -74,8 +74,8 @@ Preference { id: spinner decimals: preference.decimals realValue: preference.value - minimumValue: MyAvatar.getDomainMinScale() - maximumValue: MyAvatar.getDomainMaxScale() + minimumValue: preference.min + maximumValue: preference.max width: 100 onValueChanged: { slider.value = realValue; diff --git a/interface/src/ui/PreferencesDialog.cpp b/interface/src/ui/PreferencesDialog.cpp index 3d3c432e92..983dbe44ec 100644 --- a/interface/src/ui/PreferencesDialog.cpp +++ b/interface/src/ui/PreferencesDialog.cpp @@ -233,6 +233,8 @@ void setupPreferences() { auto getter = [=]()->float { return myAvatar->getTargetScale(); }; auto setter = [=](float value) { myAvatar->setTargetScale(value); }; auto preference = new SpinnerSliderPreference(AVATAR_TUNING, "Avatar Scale", getter, setter); + preference->setMin(0.25); + preference->setMax(4); preference->setStep(0.05f); preference->setDecimals(2); preferences->addPreference(preference); @@ -286,6 +288,7 @@ void setupPreferences() { preferences->addPreference(new CheckPreference(MOVEMENT, "Flying & jumping", getter, setter)); } { + auto getter = [=]()->int { return myAvatar->getSnapTurn() ? 0 : 1; }; auto setter = [=](int value) { myAvatar->setSnapTurn(value == 0); }; auto preference = new RadioButtonsPreference(MOVEMENT, "Snap turn / Smooth turn", getter, setter); @@ -309,17 +312,21 @@ void setupPreferences() { { auto getter = [=]()->float { return myAvatar->getPitchSpeed(); }; auto setter = [=](float value) { myAvatar->setPitchSpeed(value); }; - auto preference = new SpinnerPreference(AVATAR_CAMERA, "Pitch speed (degrees/second)", getter, setter); + auto preference = new SpinnerSliderPreference(AVATAR_CAMERA, "Pitch speed (degrees/second)", getter, setter); preference->setMin(1.0f); preference->setMax(360.0f); + preference->setStep(1); + preference->setDecimals(1); preferences->addPreference(preference); } { auto getter = [=]()->float { return myAvatar->getYawSpeed(); }; auto setter = [=](float value) { myAvatar->setYawSpeed(value); }; - auto preference = new SpinnerPreference(AVATAR_CAMERA, "Yaw speed (degrees/second)", getter, setter); + auto preference = new SpinnerSliderPreference(AVATAR_CAMERA, "Yaw speed (degrees/second)", getter, setter); preference->setMin(1.0f); preference->setMax(360.0f); + preference->setStep(1); + preference->setDecimals(1); preferences->addPreference(preference); } From fd4a8fdd833fea9e31a2ec39b28496a2290c7c32 Mon Sep 17 00:00:00 2001 From: David Back Date: Fri, 29 Jun 2018 15:33:55 -0700 Subject: [PATCH 46/61] fix color NaN check --- scripts/system/particle_explorer/particleExplorerTool.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/system/particle_explorer/particleExplorerTool.js b/scripts/system/particle_explorer/particleExplorerTool.js index b675d26ff6..80256a12e3 100644 --- a/scripts/system/particle_explorer/particleExplorerTool.js +++ b/scripts/system/particle_explorer/particleExplorerTool.js @@ -64,10 +64,10 @@ ParticleExplorerTool = function() { if (isNaN(properties.radiusFinish)) { properties.radiusFinish = properties.particleRadius; } - if (isNaN(properties.colorStart) || isNaN(properties.colorStart.red)) { + if (isNaN(properties.colorStart.red)) { properties.colorStart = properties.color; } - if (isNaN(properties.colorFinish) || isNaN(properties.colorFinish.red)) { + if (isNaN(properties.colorFinish.red)) { properties.colorFinish = properties.color; } sendParticleProperties(properties); From dce9cb0404f058a9431f06eae94c4d9da3a02df6 Mon Sep 17 00:00:00 2001 From: Stephen Birarda Date: Thu, 28 Jun 2018 19:17:22 -0700 Subject: [PATCH 47/61] fix case where TCP Vegas would not re-send lost ACK --- libraries/networking/src/udt/Connection.cpp | 41 ++++++++++++--------- 1 file changed, 23 insertions(+), 18 deletions(-) diff --git a/libraries/networking/src/udt/Connection.cpp b/libraries/networking/src/udt/Connection.cpp index c1fe6ccd85..0bc86a28ad 100644 --- a/libraries/networking/src/udt/Connection.cpp +++ b/libraries/networking/src/udt/Connection.cpp @@ -239,7 +239,7 @@ void Connection::sync() { sendACK(); } - if (_lossList.getLength() > 0) { + if (_congestionControl->shouldNAK() && _lossList.getLength() > 0) { // check if we need to re-transmit a loss list // we do this if it has been longer than the current nakInterval since we last sent auto now = p_high_resolution_clock::now(); @@ -271,10 +271,13 @@ void Connection::sendACK(bool wasCausedBySyncTimeout) { SequenceNumber nextACKNumber = nextACK(); Q_ASSERT_X(nextACKNumber >= _lastSentACK, "Connection::sendACK", "Sending lower ACK, something is wrong"); - - if (nextACKNumber == _lastSentACK) { - // We already sent this ACK, but check if we should re-send it. - if (nextACKNumber < _lastReceivedAcknowledgedACK) { + + // if our congestion control doesn't want to send an ACK for every packet received + // check if we already sent this ACK + if (_congestionControl->_ackInterval > 1 && nextACKNumber == _lastSentACK) { + + // if we use ACK2s, check if the receiving side already confirmed receipt of this ACK + if (_congestionControl->shouldACK2() && nextACKNumber < _lastReceivedAcknowledgedACK) { // we already got an ACK2 for this ACK we would be sending, don't bother return; } @@ -287,11 +290,11 @@ void Connection::sendACK(bool wasCausedBySyncTimeout) { } } // we have received new packets since the last sent ACK + // or our congestion control dictates that we always send ACKs // update the last sent ACK _lastSentACK = nextACKNumber; - _ackPacket->reset(); // We need to reset it every time. // pack in the ACK sub-sequence number @@ -448,20 +451,22 @@ bool Connection::processReceivedSequenceNumber(SequenceNumber sequenceNumber, in // mark our last receive time as now (to push the potential expiry farther) _lastReceiveTime = p_high_resolution_clock::now(); - - // check if this is a packet pair we should estimate bandwidth from, or just a regular packet - if (((uint32_t) sequenceNumber & 0xF) == 0) { - _receiveWindow.onProbePair1Arrival(); - } else if (((uint32_t) sequenceNumber & 0xF) == 1) { - // only use this packet for bandwidth estimation if we didn't just receive a control packet in its place - if (!_receivedControlProbeTail) { - _receiveWindow.onProbePair2Arrival(); - } else { - // reset our control probe tail marker so the next probe that comes with data can be used - _receivedControlProbeTail = false; + + if (_congestionControl->shouldProbe()) { + // check if this is a packet pair we should estimate bandwidth from, or just a regular packet + if (((uint32_t) sequenceNumber & 0xF) == 0) { + _receiveWindow.onProbePair1Arrival(); + } else if (((uint32_t) sequenceNumber & 0xF) == 1) { + // only use this packet for bandwidth estimation if we didn't just receive a control packet in its place + if (!_receivedControlProbeTail) { + _receiveWindow.onProbePair2Arrival(); + } else { + // reset our control probe tail marker so the next probe that comes with data can be used + _receivedControlProbeTail = false; + } } - } + _receiveWindow.onPacketArrival(); // If this is not the next sequence number, report loss From 5158a9c4fd35b1d0c374b6a7d13109f2baec842a Mon Sep 17 00:00:00 2001 From: r3tk0n <39922250+r3tk0n@users.noreply.github.com> Date: Fri, 29 Jun 2018 16:11:18 -0700 Subject: [PATCH 48/61] Update Mouse Sensitivity Settings Text Changed text for clarity to new users. --- interface/src/ui/PreferencesDialog.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/interface/src/ui/PreferencesDialog.cpp b/interface/src/ui/PreferencesDialog.cpp index 983dbe44ec..eb65001561 100644 --- a/interface/src/ui/PreferencesDialog.cpp +++ b/interface/src/ui/PreferencesDialog.cpp @@ -312,7 +312,7 @@ void setupPreferences() { { auto getter = [=]()->float { return myAvatar->getPitchSpeed(); }; auto setter = [=](float value) { myAvatar->setPitchSpeed(value); }; - auto preference = new SpinnerSliderPreference(AVATAR_CAMERA, "Pitch speed (degrees/second)", getter, setter); + auto preference = new SpinnerSliderPreference(AVATAR_CAMERA, "Y axis:", getter, setter); preference->setMin(1.0f); preference->setMax(360.0f); preference->setStep(1); @@ -322,7 +322,7 @@ void setupPreferences() { { auto getter = [=]()->float { return myAvatar->getYawSpeed(); }; auto setter = [=](float value) { myAvatar->setYawSpeed(value); }; - auto preference = new SpinnerSliderPreference(AVATAR_CAMERA, "Yaw speed (degrees/second)", getter, setter); + auto preference = new SpinnerSliderPreference(AVATAR_CAMERA, "X axis: ", getter, setter); preference->setMin(1.0f); preference->setMax(360.0f); preference->setStep(1); From 4feba7e66e058d1fe0de2e05d7e1e95b78b03485 Mon Sep 17 00:00:00 2001 From: r3tk0n <39922250+r3tk0n@users.noreply.github.com> Date: Fri, 29 Jun 2018 16:12:31 -0700 Subject: [PATCH 49/61] Correction of string literals Last update to string literals, miscommunication. --- interface/src/ui/PreferencesDialog.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/interface/src/ui/PreferencesDialog.cpp b/interface/src/ui/PreferencesDialog.cpp index eb65001561..deedc74619 100644 --- a/interface/src/ui/PreferencesDialog.cpp +++ b/interface/src/ui/PreferencesDialog.cpp @@ -312,7 +312,7 @@ void setupPreferences() { { auto getter = [=]()->float { return myAvatar->getPitchSpeed(); }; auto setter = [=](float value) { myAvatar->setPitchSpeed(value); }; - auto preference = new SpinnerSliderPreference(AVATAR_CAMERA, "Y axis:", getter, setter); + auto preference = new SpinnerSliderPreference(AVATAR_CAMERA, "Y input:", getter, setter); preference->setMin(1.0f); preference->setMax(360.0f); preference->setStep(1); @@ -322,7 +322,7 @@ void setupPreferences() { { auto getter = [=]()->float { return myAvatar->getYawSpeed(); }; auto setter = [=](float value) { myAvatar->setYawSpeed(value); }; - auto preference = new SpinnerSliderPreference(AVATAR_CAMERA, "X axis: ", getter, setter); + auto preference = new SpinnerSliderPreference(AVATAR_CAMERA, "X input:", getter, setter); preference->setMin(1.0f); preference->setMax(360.0f); preference->setStep(1); From 2c32dc1cf52e817c33cd05ac9712fad5d9ab275d Mon Sep 17 00:00:00 2001 From: Wayne Chen Date: Fri, 29 Jun 2018 16:13:02 -0700 Subject: [PATCH 50/61] adding enter key event for logging in in pw textfield --- .../resources/qml/LoginDialog/+android/LinkAccountBody.qml | 2 ++ interface/resources/qml/LoginDialog/LinkAccountBody.qml | 2 ++ 2 files changed, 4 insertions(+) diff --git a/interface/resources/qml/LoginDialog/+android/LinkAccountBody.qml b/interface/resources/qml/LoginDialog/+android/LinkAccountBody.qml index 38e65af4ca..bf7807c85d 100644 --- a/interface/resources/qml/LoginDialog/+android/LinkAccountBody.qml +++ b/interface/resources/qml/LoginDialog/+android/LinkAccountBody.qml @@ -135,6 +135,8 @@ Item { placeholderText: qsTr("Password") echoMode: TextInput.Password + + Keys.onReturnPressed: linkAccountBody.login() } } diff --git a/interface/resources/qml/LoginDialog/LinkAccountBody.qml b/interface/resources/qml/LoginDialog/LinkAccountBody.qml index 6cbd1c4837..814778a4b1 100644 --- a/interface/resources/qml/LoginDialog/LinkAccountBody.qml +++ b/interface/resources/qml/LoginDialog/LinkAccountBody.qml @@ -177,6 +177,8 @@ Item { root.text = ""; root.isPassword = true; } + + Keys.onReturnPressed: linkAccountBody.login() } CheckBox { From 39f491d9d02e9e88d515c694d788599921d5f551 Mon Sep 17 00:00:00 2001 From: r3tk0n <39922250+r3tk0n@users.noreply.github.com> Date: Fri, 29 Jun 2018 16:17:15 -0700 Subject: [PATCH 51/61] Update PreferencesDialog.cpp Removing errant newline --- interface/src/ui/PreferencesDialog.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/interface/src/ui/PreferencesDialog.cpp b/interface/src/ui/PreferencesDialog.cpp index deedc74619..af11d9c4c8 100644 --- a/interface/src/ui/PreferencesDialog.cpp +++ b/interface/src/ui/PreferencesDialog.cpp @@ -288,7 +288,6 @@ void setupPreferences() { preferences->addPreference(new CheckPreference(MOVEMENT, "Flying & jumping", getter, setter)); } { - auto getter = [=]()->int { return myAvatar->getSnapTurn() ? 0 : 1; }; auto setter = [=](int value) { myAvatar->setSnapTurn(value == 0); }; auto preference = new RadioButtonsPreference(MOVEMENT, "Snap turn / Smooth turn", getter, setter); From 99a64f31d794e67ee9636acaf75a7637f28d4186 Mon Sep 17 00:00:00 2001 From: Wayne Chen Date: Fri, 29 Jun 2018 16:21:03 -0700 Subject: [PATCH 52/61] Adding Enter/Return for sign up dialog in pw field --- interface/resources/qml/LoginDialog/SignUpBody.qml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/interface/resources/qml/LoginDialog/SignUpBody.qml b/interface/resources/qml/LoginDialog/SignUpBody.qml index 5eb99e0ece..bb30696e4c 100644 --- a/interface/resources/qml/LoginDialog/SignUpBody.qml +++ b/interface/resources/qml/LoginDialog/SignUpBody.qml @@ -164,6 +164,8 @@ Item { root.text = ""; root.isPassword = focus } + + Keys.onReturnPressed: signupBody.signup() } Row { From ba53e7add8feb39ab4922938eed0ff3f71972527 Mon Sep 17 00:00:00 2001 From: Clement Date: Fri, 29 Jun 2018 15:51:40 -0700 Subject: [PATCH 53/61] Fix ACs startup crash --- assignment-client/src/Agent.cpp | 3 +++ assignment-client/src/audio/AudioMixer.cpp | 7 ++++++- assignment-client/src/audio/AudioMixer.h | 3 +++ assignment-client/src/scripts/EntityScriptServer.cpp | 3 +++ libraries/plugins/src/plugins/PluginManager.cpp | 3 --- libraries/plugins/src/plugins/PluginManager.h | 5 ++++- 6 files changed, 19 insertions(+), 5 deletions(-) diff --git a/assignment-client/src/Agent.cpp b/assignment-client/src/Agent.cpp index 42924a8487..73444d1198 100644 --- a/assignment-client/src/Agent.cpp +++ b/assignment-client/src/Agent.cpp @@ -64,6 +64,7 @@ Agent::Agent(ReceivedMessage& message) : DependencyManager::get()->setPacketSender(&_entityEditSender); DependencyManager::set(); + DependencyManager::set(); DependencyManager::registerInheritance(); @@ -833,6 +834,8 @@ void Agent::aboutToFinish() { DependencyManager::get()->cleanup(); + DependencyManager::destroy(); + // cleanup the AudioInjectorManager (and any still running injectors) DependencyManager::destroy(); diff --git a/assignment-client/src/audio/AudioMixer.cpp b/assignment-client/src/audio/AudioMixer.cpp index 34eb138697..d56b22466e 100644 --- a/assignment-client/src/audio/AudioMixer.cpp +++ b/assignment-client/src/audio/AudioMixer.cpp @@ -65,7 +65,8 @@ AudioMixer::AudioMixer(ReceivedMessage& message) : // hash the available codecs (on the mixer) _availableCodecs.clear(); // Make sure struct is clean - auto codecPlugins = PluginManager::getInstance()->getCodecPlugins(); + auto pluginManager = DependencyManager::set(); + auto codecPlugins = pluginManager->getCodecPlugins(); std::for_each(codecPlugins.cbegin(), codecPlugins.cend(), [&](const CodecPluginPointer& codec) { _availableCodecs[codec->getName()] = codec; @@ -106,6 +107,10 @@ AudioMixer::AudioMixer(ReceivedMessage& message) : connect(nodeList.data(), &NodeList::nodeKilled, this, &AudioMixer::handleNodeKilled); } +void AudioMixer::aboutToFinish() { + DependencyManager::destroy(); +} + void AudioMixer::queueAudioPacket(QSharedPointer message, SharedNodePointer node) { if (message->getType() == PacketType::SilentAudioFrame) { _numSilentPackets++; diff --git a/assignment-client/src/audio/AudioMixer.h b/assignment-client/src/audio/AudioMixer.h index 8c47893aa3..f9eb18da6d 100644 --- a/assignment-client/src/audio/AudioMixer.h +++ b/assignment-client/src/audio/AudioMixer.h @@ -58,6 +58,9 @@ public: to.getPublicSocket() != from.getPublicSocket() && to.getLocalSocket() != from.getLocalSocket(); } + + virtual void aboutToFinish() override; + public slots: void run() override; void sendStatsPacket() override; diff --git a/assignment-client/src/scripts/EntityScriptServer.cpp b/assignment-client/src/scripts/EntityScriptServer.cpp index eea8e8b470..607ab28b20 100644 --- a/assignment-client/src/scripts/EntityScriptServer.cpp +++ b/assignment-client/src/scripts/EntityScriptServer.cpp @@ -58,6 +58,7 @@ EntityScriptServer::EntityScriptServer(ReceivedMessage& message) : ThreadedAssig DependencyManager::get()->setPacketSender(&_entityEditSender); DependencyManager::set(); + DependencyManager::set(); DependencyManager::registerInheritance(); @@ -572,6 +573,8 @@ void EntityScriptServer::aboutToFinish() { DependencyManager::get()->cleanup(); + DependencyManager::destroy(); + // cleanup the AudioInjectorManager (and any still running injectors) DependencyManager::destroy(); DependencyManager::destroy(); diff --git a/libraries/plugins/src/plugins/PluginManager.cpp b/libraries/plugins/src/plugins/PluginManager.cpp index 40b6ed820a..94ce16cf00 100644 --- a/libraries/plugins/src/plugins/PluginManager.cpp +++ b/libraries/plugins/src/plugins/PluginManager.cpp @@ -135,9 +135,6 @@ const LoaderList& getLoadedPlugins() { return loadedPlugins; } -PluginManager::PluginManager() { -} - const CodecPluginList& PluginManager::getCodecPlugins() { static CodecPluginList codecPlugins; static std::once_flag once; diff --git a/libraries/plugins/src/plugins/PluginManager.h b/libraries/plugins/src/plugins/PluginManager.h index 226ccc8060..65a4012aed 100644 --- a/libraries/plugins/src/plugins/PluginManager.h +++ b/libraries/plugins/src/plugins/PluginManager.h @@ -18,9 +18,10 @@ class PluginManager; using PluginManagerPointer = QSharedPointer; class PluginManager : public QObject, public Dependency { + SINGLETON_DEPENDENCY + public: static PluginManagerPointer getInstance(); - PluginManager(); const DisplayPluginList& getDisplayPlugins(); const InputPluginList& getInputPlugins(); @@ -45,6 +46,8 @@ public: void setInputPluginSettingsPersister(const InputPluginSettingsPersister& persister); private: + PluginManager() = default; + DisplayPluginProvider _displayPluginProvider { []()->DisplayPluginList { return {}; } }; InputPluginProvider _inputPluginProvider { []()->InputPluginList { return {}; } }; CodecPluginProvider _codecPluginProvider { []()->CodecPluginList { return {}; } }; From c1856a5e3637652c7aa87fd8e402e2200bedc243 Mon Sep 17 00:00:00 2001 From: Sam Date: Mon, 2 Jul 2018 10:46:53 +0200 Subject: [PATCH 54/61] Make shadows work with one cascade --- .../gpu-gl/src/gpu/gl41/GL41BackendTexture.cpp | 4 ++-- .../gpu-gl/src/gpu/gl45/GL45BackendTexture.cpp | 4 ++-- libraries/gpu/src/gpu/Framebuffer.cpp | 2 +- libraries/render-utils/src/RenderShadowTask.cpp | 16 ++++++++++------ libraries/render-utils/src/Shadow.slh | 14 ++++++++++++++ libraries/render-utils/src/Shadows_shared.slh | 2 +- libraries/render/src/render/CullTask.cpp | 5 ++++- 7 files changed, 34 insertions(+), 13 deletions(-) diff --git a/libraries/gpu-gl/src/gpu/gl41/GL41BackendTexture.cpp b/libraries/gpu-gl/src/gpu/gl41/GL41BackendTexture.cpp index a255cc5878..4be82f0158 100644 --- a/libraries/gpu-gl/src/gpu/gl41/GL41BackendTexture.cpp +++ b/libraries/gpu-gl/src/gpu/gl41/GL41BackendTexture.cpp @@ -182,7 +182,7 @@ void GL41Texture::syncSampler() const { glTexParameteri(_target, GL_TEXTURE_MAG_FILTER, fm.magFilter); if (sampler.doComparison()) { - glTexParameteri(_target, GL_TEXTURE_COMPARE_MODE, GL_COMPARE_R_TO_TEXTURE_ARB); + glTexParameteri(_target, GL_TEXTURE_COMPARE_MODE, GL_COMPARE_REF_TO_TEXTURE); glTexParameteri(_target, GL_TEXTURE_COMPARE_FUNC, COMPARISON_TO_GL[sampler.getComparisonFunction()]); } else { glTexParameteri(_target, GL_TEXTURE_COMPARE_MODE, GL_NONE); @@ -197,7 +197,7 @@ void GL41Texture::syncSampler() const { glTexParameterf(_target, GL_TEXTURE_MIN_LOD, (float)sampler.getMinMip()); glTexParameterf(_target, GL_TEXTURE_MAX_LOD, (sampler.getMaxMip() == Sampler::MAX_MIP_LEVEL ? 1000.f : sampler.getMaxMip())); - glTexParameterf(_target, GL_TEXTURE_MAX_ANISOTROPY_EXT, sampler.getMaxAnisotropy()); + glTexParameterf(_target, GL_TEXTURE_MAX_ANISOTROPY, sampler.getMaxAnisotropy()); } using GL41FixedAllocationTexture = GL41Backend::GL41FixedAllocationTexture; diff --git a/libraries/gpu-gl/src/gpu/gl45/GL45BackendTexture.cpp b/libraries/gpu-gl/src/gpu/gl45/GL45BackendTexture.cpp index fda7ac22dd..7cc639da5e 100644 --- a/libraries/gpu-gl/src/gpu/gl45/GL45BackendTexture.cpp +++ b/libraries/gpu-gl/src/gpu/gl45/GL45BackendTexture.cpp @@ -152,7 +152,7 @@ public: glSamplerParameteri(result, GL_TEXTURE_MIN_FILTER, fm.minFilter); glSamplerParameteri(result, GL_TEXTURE_MAG_FILTER, fm.magFilter); if (sampler.doComparison()) { - glSamplerParameteri(result, GL_TEXTURE_COMPARE_MODE, GL_COMPARE_R_TO_TEXTURE_ARB); + glSamplerParameteri(result, GL_TEXTURE_COMPARE_MODE, GL_COMPARE_REF_TO_TEXTURE); glSamplerParameteri(result, GL_TEXTURE_COMPARE_FUNC, COMPARISON_TO_GL[sampler.getComparisonFunction()]); } else { glSamplerParameteri(result, GL_TEXTURE_COMPARE_MODE, GL_NONE); @@ -341,7 +341,7 @@ void GL45Texture::syncSampler() const { glTextureParameteri(_id, GL_TEXTURE_MAG_FILTER, fm.magFilter); if (sampler.doComparison()) { - glTextureParameteri(_id, GL_TEXTURE_COMPARE_MODE, GL_COMPARE_R_TO_TEXTURE_ARB); + glTextureParameteri(_id, GL_TEXTURE_COMPARE_MODE, GL_COMPARE_REF_TO_TEXTURE); glTextureParameteri(_id, GL_TEXTURE_COMPARE_FUNC, COMPARISON_TO_GL[sampler.getComparisonFunction()]); } else { glTextureParameteri(_id, GL_TEXTURE_COMPARE_MODE, GL_NONE); diff --git a/libraries/gpu/src/gpu/Framebuffer.cpp b/libraries/gpu/src/gpu/Framebuffer.cpp index 8bb9be4a76..7e7db1345c 100755 --- a/libraries/gpu/src/gpu/Framebuffer.cpp +++ b/libraries/gpu/src/gpu/Framebuffer.cpp @@ -61,7 +61,7 @@ Framebuffer* Framebuffer::createShadowmap(uint16 width) { samplerDesc._borderColor = glm::vec4(1.0f); samplerDesc._wrapModeU = Sampler::WRAP_BORDER; samplerDesc._wrapModeV = Sampler::WRAP_BORDER; - samplerDesc._filter = Sampler::FILTER_MIN_MAG_LINEAR; + samplerDesc._filter = Sampler::FILTER_MIN_MAG_POINT; samplerDesc._comparisonFunc = LESS; depthTexture->setSampler(Sampler(samplerDesc)); diff --git a/libraries/render-utils/src/RenderShadowTask.cpp b/libraries/render-utils/src/RenderShadowTask.cpp index fbb4bba263..91eb777199 100644 --- a/libraries/render-utils/src/RenderShadowTask.cpp +++ b/libraries/render-utils/src/RenderShadowTask.cpp @@ -227,7 +227,7 @@ void RenderShadowTask::build(JobModel& task, const render::Varying& input, rende } const auto setupOutput = task.addJob("ShadowSetup"); - const auto queryResolution = setupOutput.getN(2); + const auto queryResolution = setupOutput.getN(1); // Fetch and cull the items from the scene static const auto shadowCasterReceiverFilter = ItemFilter::Builder::visibleWorldItems().withTypeShape().withOpaque().withoutLayered().withTagBits(tagBits, tagMask); @@ -248,10 +248,12 @@ void RenderShadowTask::build(JobModel& task, const render::Varying& input, rende const auto sortedShapes = task.addJob("DepthSortShadow", sortedPipelines, true); render::Varying cascadeFrustums[SHADOW_CASCADE_MAX_COUNT] = { - ViewFrustumPointer(), - ViewFrustumPointer(), + ViewFrustumPointer() +#if SHADOW_CASCADE_MAX_COUNT>1 + ,ViewFrustumPointer(), ViewFrustumPointer(), ViewFrustumPointer() +#endif }; for (auto i = 0; i < SHADOW_CASCADE_MAX_COUNT; i++) { @@ -293,13 +295,15 @@ RenderShadowSetup::RenderShadowSetup() : void RenderShadowSetup::configure(const Config& configuration) { setConstantBias(0, configuration.constantBias0); - setConstantBias(1, configuration.constantBias1); - setConstantBias(2, configuration.constantBias2); - setConstantBias(3, configuration.constantBias3); setSlopeBias(0, configuration.slopeBias0); +#if SHADOW_CASCADE_MAX_COUNT>1 + setConstantBias(1, configuration.constantBias1); setSlopeBias(1, configuration.slopeBias1); + setConstantBias(2, configuration.constantBias2); setSlopeBias(2, configuration.slopeBias2); + setConstantBias(3, configuration.constantBias3); setSlopeBias(3, configuration.slopeBias3); +#endif } void RenderShadowSetup::setConstantBias(int cascadeIndex, float value) { diff --git a/libraries/render-utils/src/Shadow.slh b/libraries/render-utils/src/Shadow.slh index 36eb35c757..4a63e24082 100644 --- a/libraries/render-utils/src/Shadow.slh +++ b/libraries/render-utils/src/Shadow.slh @@ -17,11 +17,19 @@ #define SHADOW_SCREEN_SPACE_DITHER 1 // the shadow texture +#if SHADOW_CASCADE_MAX_COUNT>1 uniform sampler2DShadow shadowMaps[SHADOW_CASCADE_MAX_COUNT]; +#else +uniform sampler2DShadow shadowMaps; +#endif // Sample the shadowMap with PCF (built-in) float fetchShadow(int cascadeIndex, vec3 shadowTexcoord) { +#if SHADOW_CASCADE_MAX_COUNT>1 return texture(shadowMaps[cascadeIndex], shadowTexcoord); +#else + return texture(shadowMaps, shadowTexcoord); +#endif } vec2 PCFkernel[4] = vec2[4]( @@ -89,6 +97,7 @@ float evalShadowCascadeAttenuation(int cascadeIndex, ShadowSampleOffsets offsets float evalShadowAttenuation(vec3 worldLightDir, vec4 worldPosition, float viewDepth, vec3 worldNormal) { ShadowSampleOffsets offsets = evalShadowFilterOffsets(worldPosition); +#if 0 vec4 cascadeShadowCoords[2]; cascadeShadowCoords[0] = vec4(0); cascadeShadowCoords[1] = vec4(0); @@ -105,6 +114,11 @@ float evalShadowAttenuation(vec3 worldLightDir, vec4 worldPosition, float viewDe float attenuation = mix(cascadeAttenuations.x, cascadeAttenuations.y, cascadeMix); // Falloff to max distance return mix(1.0, attenuation, evalShadowFalloff(viewDepth)); +#else +vec4 shadowTexcoord = evalShadowTexcoord(0, worldPosition); +float attenuation = fetchShadow(0, shadowTexcoord.xyz); +return attenuation; +#endif } <@endif@> diff --git a/libraries/render-utils/src/Shadows_shared.slh b/libraries/render-utils/src/Shadows_shared.slh index bc8063e018..7dea11cd8b 100644 --- a/libraries/render-utils/src/Shadows_shared.slh +++ b/libraries/render-utils/src/Shadows_shared.slh @@ -5,7 +5,7 @@ # define MAT4 mat4 #endif -#define SHADOW_CASCADE_MAX_COUNT 4 +#define SHADOW_CASCADE_MAX_COUNT 1 struct ShadowTransform { MAT4 reprojection; diff --git a/libraries/render/src/render/CullTask.cpp b/libraries/render/src/render/CullTask.cpp index 3f55e6dedc..8cfe7683ce 100644 --- a/libraries/render/src/render/CullTask.cpp +++ b/libraries/render/src/render/CullTask.cpp @@ -370,10 +370,13 @@ void CullShapeBounds::run(const RenderContextPointer& renderContext, const Input const auto& inShapes = inputs.get0(); const auto& cullFilter = inputs.get1(); const auto& boundsFilter = inputs.get2(); - const auto& antiFrustum = inputs.get3(); + ViewFrustumPointer antiFrustum; auto& outShapes = outputs.edit0(); auto& outBounds = outputs.edit1(); + if (!inputs[3].isNull()) { + antiFrustum = inputs.get3(); + } outShapes.clear(); outBounds = AABox(); From 1f90e86b87dd2fa9ce9ce117e1622ea5657b3c41 Mon Sep 17 00:00:00 2001 From: Sam Date: Mon, 2 Jul 2018 11:08:14 +0200 Subject: [PATCH 55/61] fix shader shadow bug on mac --- libraries/render-utils/src/Shadows_shared.slh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libraries/render-utils/src/Shadows_shared.slh b/libraries/render-utils/src/Shadows_shared.slh index 7dea11cd8b..bc8063e018 100644 --- a/libraries/render-utils/src/Shadows_shared.slh +++ b/libraries/render-utils/src/Shadows_shared.slh @@ -5,7 +5,7 @@ # define MAT4 mat4 #endif -#define SHADOW_CASCADE_MAX_COUNT 1 +#define SHADOW_CASCADE_MAX_COUNT 4 struct ShadowTransform { MAT4 reprojection; From 419e8e6eb9118b133ab546228d26465cbaa020b1 Mon Sep 17 00:00:00 2001 From: Olivier Prat Date: Mon, 2 Jul 2018 11:32:33 +0200 Subject: [PATCH 56/61] Forgot to put back linear filtering on single shadow map --- libraries/gpu/src/gpu/Framebuffer.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libraries/gpu/src/gpu/Framebuffer.cpp b/libraries/gpu/src/gpu/Framebuffer.cpp index 7e7db1345c..8bb9be4a76 100755 --- a/libraries/gpu/src/gpu/Framebuffer.cpp +++ b/libraries/gpu/src/gpu/Framebuffer.cpp @@ -61,7 +61,7 @@ Framebuffer* Framebuffer::createShadowmap(uint16 width) { samplerDesc._borderColor = glm::vec4(1.0f); samplerDesc._wrapModeU = Sampler::WRAP_BORDER; samplerDesc._wrapModeV = Sampler::WRAP_BORDER; - samplerDesc._filter = Sampler::FILTER_MIN_MAG_POINT; + samplerDesc._filter = Sampler::FILTER_MIN_MAG_LINEAR; samplerDesc._comparisonFunc = LESS; depthTexture->setSampler(Sampler(samplerDesc)); From 1a5c382d88bdce3721c05211f0e799707eefaf1c Mon Sep 17 00:00:00 2001 From: Olivier Prat Date: Mon, 2 Jul 2018 12:41:24 +0200 Subject: [PATCH 57/61] Fixed on Android --- .../gpu-gles/src/gpu/gles/GLESBackendOutput.cpp | 14 ++++++++++++-- .../gpu-gles/src/gpu/gles/GLESBackendTexture.cpp | 16 +++++++++++++--- 2 files changed, 25 insertions(+), 5 deletions(-) diff --git a/libraries/gpu-gles/src/gpu/gles/GLESBackendOutput.cpp b/libraries/gpu-gles/src/gpu/gles/GLESBackendOutput.cpp index 0bf1548a4b..9c3a83ce13 100644 --- a/libraries/gpu-gles/src/gpu/gles/GLESBackendOutput.cpp +++ b/libraries/gpu-gles/src/gpu/gles/GLESBackendOutput.cpp @@ -64,7 +64,12 @@ public: } if (gltexture) { - glFramebufferTexture2D(GL_FRAMEBUFFER, colorAttachments[unit], GL_TEXTURE_2D, gltexture->_texture, 0); + if (gltexture->_target == GL_TEXTURE_2D) { + glFramebufferTexture2D(GL_FRAMEBUFFER, colorAttachments[unit], GL_TEXTURE_2D, gltexture->_texture, 0); + } else { + glFramebufferTextureLayer(GL_FRAMEBUFFER, colorAttachments[unit], gltexture->_texture, 0, + b._subresource); + } _colorBuffers.push_back(colorAttachments[unit]); } else { glFramebufferTexture2D(GL_FRAMEBUFFER, colorAttachments[unit], GL_TEXTURE_2D, 0, 0); @@ -91,7 +96,12 @@ public: } if (gltexture) { - glFramebufferTexture2D(GL_FRAMEBUFFER, attachement, GL_TEXTURE_2D, gltexture->_texture, 0); + if (gltexture->_target == GL_TEXTURE_2D) { + glFramebufferTexture2D(GL_FRAMEBUFFER, attachement, GL_TEXTURE_2D, gltexture->_texture, 0); + } else { + glFramebufferTextureLayer(GL_FRAMEBUFFER, attachement, gltexture->_texture, 0, + _gpuObject.getDepthStencilBufferSubresource()); + } } else { glFramebufferTexture2D(GL_FRAMEBUFFER, attachement, GL_TEXTURE_2D, 0, 0); } diff --git a/libraries/gpu-gles/src/gpu/gles/GLESBackendTexture.cpp b/libraries/gpu-gles/src/gpu/gles/GLESBackendTexture.cpp index bbc02c2af6..2e7faa1454 100644 --- a/libraries/gpu-gles/src/gpu/gles/GLESBackendTexture.cpp +++ b/libraries/gpu-gles/src/gpu/gles/GLESBackendTexture.cpp @@ -274,10 +274,20 @@ void GLESFixedAllocationTexture::allocateStorage() const { Vec3u dimensions = _gpuObject.evalMipDimensions(level); for (GLenum target : getFaceTargets(_target)) { if (texelFormat.isCompressed()) { - glCompressedTexImage2D(target, level, texelFormat.internalFormat, dimensions.x, dimensions.y, 0, - getCompressedImageSize(dimensions.x, dimensions.y, texelFormat.internalFormat), nullptr); + auto size = getCompressedImageSize(dimensions.x, dimensions.y, texelFormat.internalFormat); + if (!_gpuObject.isArray()) { + glCompressedTexImage2D(target, level, texelFormat.internalFormat, dimensions.x, dimensions.y, 0, size, nullptr); + } else { + glCompressedTexImage3D(target, level, texelFormat.internalFormat, dimensions.x, dimensions.y, numSlices, 0, size * numSlices, nullptr); + } } else { - glTexImage2D(target, level, texelFormat.internalFormat, dimensions.x, dimensions.y, 0, texelFormat.format, texelFormat.type, nullptr); + if (!_gpuObject.isArray()) { + glTexImage2D(target, level, texelFormat.internalFormat, dimensions.x, dimensions.y, 0, texelFormat.format, + texelFormat.type, nullptr); + } else { + glTexImage3D(target, level, texelFormat.internalFormat, dimensions.x, dimensions.y, numSlices, 0, + texelFormat.format, texelFormat.type, nullptr); + } } } } From 51fe60ec45dbb37303d7db86f4252d789e4f5bd0 Mon Sep 17 00:00:00 2001 From: Olivier Prat Date: Mon, 2 Jul 2018 14:59:09 +0200 Subject: [PATCH 58/61] Fixed android compilation error and removed _glUniformi call --- .../src/gpu/gles/GLESBackendTexture.cpp | 1 + .../render-utils/src/DebugDeferredBuffer.cpp | 22 ++++++------- .../render-utils/src/DebugDeferredBuffer.h | 31 +++++++++++++------ .../src/debug_deferred_buffer.slf | 7 +++++ .../src/debug_deferred_buffer_shared.slh | 17 ++++++++++ 5 files changed, 57 insertions(+), 21 deletions(-) create mode 100644 libraries/render-utils/src/debug_deferred_buffer_shared.slh diff --git a/libraries/gpu-gles/src/gpu/gles/GLESBackendTexture.cpp b/libraries/gpu-gles/src/gpu/gles/GLESBackendTexture.cpp index 2e7faa1454..911dfb8bb8 100644 --- a/libraries/gpu-gles/src/gpu/gles/GLESBackendTexture.cpp +++ b/libraries/gpu-gles/src/gpu/gles/GLESBackendTexture.cpp @@ -268,6 +268,7 @@ GLsizei getCompressedImageSize(int width, int height, GLenum internalFormat) { void GLESFixedAllocationTexture::allocateStorage() const { const GLTexelFormat texelFormat = GLTexelFormat::evalGLTexelFormat(_gpuObject.getTexelFormat()); const auto numMips = _gpuObject.getNumMips(); + const auto numSlices = _gpuObject.getNumSlices(); // glTextureStorage2D(_id, mips, texelFormat.internalFormat, dimensions.x, dimensions.y); for (GLint level = 0; level < numMips; level++) { diff --git a/libraries/render-utils/src/DebugDeferredBuffer.cpp b/libraries/render-utils/src/DebugDeferredBuffer.cpp index 7728c1406c..8575df399e 100644 --- a/libraries/render-utils/src/DebugDeferredBuffer.cpp +++ b/libraries/render-utils/src/DebugDeferredBuffer.cpp @@ -60,7 +60,8 @@ enum TextureSlot { enum ParamSlot { CameraCorrection = 0, DeferredFrameTransform, - ShadowTransform + ShadowTransform, + DebugParametersBuffer }; static const std::string DEFAULT_ALBEDO_SHADER { @@ -139,13 +140,11 @@ static const std::string DEFAULT_LIGHTING_SHADER { " }" }; -static const std::string DEFAULT_SHADOW_SHADER{ - "uniform sampler2DArrayShadow shadowMaps;" - "uniform int shadowCascadeIndex;" +static const std::string DEFAULT_SHADOW_DEPTH_SHADER{ "vec4 getFragmentColor() {" " for (int i = 255; i >= 0; --i) {" " float depth = i / 255.0;" - " if (texture(shadowMaps, vec4(uv, shadowCascadeIndex, depth)) > 0.5) {" + " if (texture(shadowMaps, vec4(uv, parameters._shadowCascadeIndex, depth)) > 0.5) {" " return vec4(vec3(depth), 1.0);" " }" " }" @@ -324,7 +323,7 @@ std::string DebugDeferredBuffer::getShaderSourceCode(Mode mode, std::string cust case ShadowCascade1Mode: case ShadowCascade2Mode: case ShadowCascade3Mode: - return DEFAULT_SHADOW_SHADER; + return DEFAULT_SHADOW_DEPTH_SHADER; case ShadowCascadeIndicesMode: return DEFAULT_SHADOW_CASCADE_SHADER; case LinearDepthMode: @@ -397,6 +396,7 @@ const gpu::PipelinePointer& DebugDeferredBuffer::getPipeline(Mode mode, std::str slotBindings.insert(gpu::Shader::Binding("cameraCorrectionBuffer", CameraCorrection)); slotBindings.insert(gpu::Shader::Binding("deferredFrameTransformBuffer", DeferredFrameTransform)); slotBindings.insert(gpu::Shader::Binding("shadowTransformBuffer", ShadowTransform)); + slotBindings.insert(gpu::Shader::Binding("parametersBuffer", DebugParametersBuffer)); slotBindings.insert(gpu::Shader::Binding("albedoMap", Albedo)); slotBindings.insert(gpu::Shader::Binding("normalMap", Normal)); @@ -433,8 +433,11 @@ const gpu::PipelinePointer& DebugDeferredBuffer::getPipeline(Mode mode, std::str } void DebugDeferredBuffer::configure(const Config& config) { + auto& parameters = _parameters.edit(); + _mode = (Mode)config.mode; _size = config.size; + parameters._shadowCascadeIndex = glm::clamp(_mode - Mode::ShadowCascade0Mode, 0, (int)SHADOW_CASCADE_MAX_COUNT - 1); } void DebugDeferredBuffer::run(const RenderContextPointer& renderContext, const Inputs& inputs) { @@ -484,18 +487,15 @@ void DebugDeferredBuffer::run(const RenderContextPointer& renderContext, const I batch.setResourceTexture(Velocity, velocityFramebuffer->getVelocityTexture()); } + batch.setUniformBuffer(DebugParametersBuffer, _parameters); + auto lightStage = renderContext->_scene->getStage(); assert(lightStage); assert(lightStage->getNumLights() > 0); auto lightAndShadow = lightStage->getCurrentKeyLightAndShadow(); const auto& globalShadow = lightAndShadow.second; if (globalShadow) { - const auto cascadeIndex = glm::clamp(_mode - Mode::ShadowCascade0Mode, 0, (int)globalShadow->getCascadeCount() - 1); - const auto cascadeIndexLocation = pipeline->getProgram()->getUniforms().findLocation("shadowCascadeIndex"); batch.setResourceTexture(Shadow, globalShadow->map); - if (cascadeIndexLocation >= 0) { - batch._glUniform1i(cascadeIndexLocation, cascadeIndex); - } batch.setUniformBuffer(ShadowTransform, globalShadow->getBuffer()); batch.setUniformBuffer(DeferredFrameTransform, frameTransform->getFrameTransformBuffer()); } diff --git a/libraries/render-utils/src/DebugDeferredBuffer.h b/libraries/render-utils/src/DebugDeferredBuffer.h index 5384a77b76..9daa8fd530 100644 --- a/libraries/render-utils/src/DebugDeferredBuffer.h +++ b/libraries/render-utils/src/DebugDeferredBuffer.h @@ -30,7 +30,7 @@ public: DebugDeferredBufferConfig() : render::Job::Config(false) {} void setMode(int newMode); - + int mode{ 0 }; glm::vec4 size{ 0.0f, -1.0f, 1.0f, 1.0f }; signals: @@ -39,20 +39,26 @@ signals: class DebugDeferredBuffer { public: - using Inputs = render::VaryingSet6; + using Inputs = render::VaryingSet6; using Config = DebugDeferredBufferConfig; using JobModel = render::Job::ModelI; - + DebugDeferredBuffer(); ~DebugDeferredBuffer(); void configure(const Config& config); void run(const render::RenderContextPointer& renderContext, const Inputs& inputs); - + protected: friend class DebugDeferredBufferConfig; - enum Mode : uint8_t { + enum Mode : uint8_t + { // Use Mode suffix to avoid collisions Off = 0, DepthMode, @@ -83,7 +89,7 @@ protected: AmbientOcclusionMode, AmbientOcclusionBlurredMode, VelocityMode, - CustomMode, // Needs to stay last + CustomMode, // Needs to stay last NumModes, }; @@ -92,20 +98,25 @@ private: Mode _mode{ Off }; glm::vec4 _size; +#include "debug_deferred_buffer_shared.slh" + + using ParametersBuffer = gpu::StructBuffer; + struct CustomPipeline { gpu::PipelinePointer pipeline; mutable QFileInfo info; }; using StandardPipelines = std::array; using CustomPipelines = std::unordered_map; - + bool pipelineNeedsUpdate(Mode mode, std::string customFile = std::string()) const; const gpu::PipelinePointer& getPipeline(Mode mode, std::string customFile = std::string()); std::string getShaderSourceCode(Mode mode, std::string customFile = std::string()); - + + ParametersBuffer _parameters; StandardPipelines _pipelines; CustomPipelines _customPipelines; - int _geometryId { 0 }; + int _geometryId{ 0 }; }; -#endif // hifi_DebugDeferredBuffer_h \ No newline at end of file +#endif // hifi_DebugDeferredBuffer_h \ No newline at end of file diff --git a/libraries/render-utils/src/debug_deferred_buffer.slf b/libraries/render-utils/src/debug_deferred_buffer.slf index fded04ca87..5f974acfeb 100644 --- a/libraries/render-utils/src/debug_deferred_buffer.slf +++ b/libraries/render-utils/src/debug_deferred_buffer.slf @@ -23,11 +23,18 @@ uniform sampler2D occlusionMap; uniform sampler2D occlusionBlurredMap; uniform sampler2D scatteringMap; uniform sampler2D velocityMap; +uniform sampler2DArrayShadow shadowMaps; <@include ShadowCore.slh@> <$declareDeferredCurvature()$> +<@include debug_deferred_buffer_shared.slh@> + +layout(std140) uniform parametersBuffer { + DebugParameters parameters; +}; + float curvatureAO(float k) { return 1.0f - (0.0022f * k * k) + (0.0776f * k) + 0.7369f; } diff --git a/libraries/render-utils/src/debug_deferred_buffer_shared.slh b/libraries/render-utils/src/debug_deferred_buffer_shared.slh new file mode 100644 index 0000000000..2d11a66d61 --- /dev/null +++ b/libraries/render-utils/src/debug_deferred_buffer_shared.slh @@ -0,0 +1,17 @@ +// glsl / C++ compatible source as interface for FadeEffect +#ifdef __cplusplus +# define INT32 glm::int32 +#else +# define INT32 int +#endif + +struct DebugParameters +{ + INT32 _shadowCascadeIndex; +}; + + // <@if 1@> + // Trigger Scribe include + // <@endif@> +// + From c95b359aa74811971f3184c522632bb578b21c0c Mon Sep 17 00:00:00 2001 From: Zach Fox Date: Mon, 2 Jul 2018 10:23:53 -0700 Subject: [PATCH 59/61] Fix MS16390: Correctly update UI when Buy endpoint fails --- interface/resources/qml/hifi/commerce/checkout/Checkout.qml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/interface/resources/qml/hifi/commerce/checkout/Checkout.qml b/interface/resources/qml/hifi/commerce/checkout/Checkout.qml index 16c1b55930..653d814020 100644 --- a/interface/resources/qml/hifi/commerce/checkout/Checkout.qml +++ b/interface/resources/qml/hifi/commerce/checkout/Checkout.qml @@ -92,9 +92,9 @@ Rectangle { onBuyResult: { if (result.status !== 'success') { - failureErrorText.text = result.message; + failureErrorText.text = result.data.message; root.activeView = "checkoutFailure"; - UserActivityLogger.commercePurchaseFailure(root.itemId, root.itemAuthor, root.itemPrice, !root.alreadyOwned, result.message); + UserActivityLogger.commercePurchaseFailure(root.itemId, root.itemAuthor, root.itemPrice, !root.alreadyOwned, result.data.message); } else { root.certificateId = result.data.certificate_id; root.itemHref = result.data.download_url; From 773efe8cf0435c80d6be06fbc33525b33d4a20d9 Mon Sep 17 00:00:00 2001 From: SamGondelman Date: Mon, 2 Jul 2018 13:32:25 -0700 Subject: [PATCH 60/61] fix blurry tablet if overlay is drawing --- libraries/render-utils/src/RenderCommonTask.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libraries/render-utils/src/RenderCommonTask.cpp b/libraries/render-utils/src/RenderCommonTask.cpp index 63d07af1c2..24715f0afb 100644 --- a/libraries/render-utils/src/RenderCommonTask.cpp +++ b/libraries/render-utils/src/RenderCommonTask.cpp @@ -60,7 +60,7 @@ void DrawOverlay3D::run(const RenderContextPointer& renderContext, const Inputs& if (_opaquePass) { gpu::doInBatch("DrawOverlay3D::run::clear", args->_context, [&](gpu::Batch& batch){ batch.enableStereo(false); - batch.clearFramebuffer(gpu::Framebuffer::BUFFER_DEPTHSTENCIL, glm::vec4(), 1.f, 0, false); + batch.clearFramebuffer(gpu::Framebuffer::BUFFER_DEPTH, glm::vec4(), 1.f, 0, false); }); } From 3f6793b46227dbab37fa9dadf092239a0fa5103a Mon Sep 17 00:00:00 2001 From: Thijs Wenker Date: Tue, 3 Jul 2018 18:42:39 +0200 Subject: [PATCH 61/61] - center default native window - close button destroys window by default unless Desktop.CLOSE_BUTTON_HIDES flag is set --- interface/resources/qml/InteractiveWindow.qml | 25 ++++++++---- libraries/ui/src/InteractiveWindow.cpp | 4 +- libraries/ui/src/InteractiveWindow.h | 39 +++---------------- 3 files changed, 26 insertions(+), 42 deletions(-) diff --git a/interface/resources/qml/InteractiveWindow.qml b/interface/resources/qml/InteractiveWindow.qml index d1e9284101..e7a5585912 100644 --- a/interface/resources/qml/InteractiveWindow.qml +++ b/interface/resources/qml/InteractiveWindow.qml @@ -28,6 +28,8 @@ Windows.Window { // Don't destroy on close... otherwise the JS/C++ will have a dangling pointer destroyOnCloseButton: false; + signal selfDestruct(); + property var flags: 0; property var source; @@ -67,8 +69,14 @@ Windows.Window { x = interactiveWindowPosition.x; y = interactiveWindowPosition.y; } else if (presentationMode === Desktop.PresentationMode.NATIVE && nativeWindow) { - nativeWindow.x = interactiveWindowPosition.x; - nativeWindow.y = interactiveWindowPosition.y; + if (interactiveWindowPosition.x === 0 && interactiveWindowPosition.y === 0) { + // default position for native window in center of main application window + nativeWindow.x = Math.floor(Window.x + (Window.innerWidth / 2) - (interactiveWindowSize.width / 2)); + nativeWindow.y = Math.floor(Window.y + (Window.innerHeight / 2) - (interactiveWindowSize.height / 2)); + } else { + nativeWindow.x = interactiveWindowPosition.x; + nativeWindow.y = interactiveWindowPosition.y; + } } } @@ -83,7 +91,6 @@ Windows.Window { } function setupPresentationMode() { - console.warn(presentationMode); if (presentationMode === Desktop.PresentationMode.VIRTUAL) { if (nativeWindow) { nativeWindow.setVisible(false); @@ -104,7 +111,6 @@ Windows.Window { } Component.onCompleted: { - x = interactiveWindowPosition.x; y = interactiveWindowPosition.y; width = interactiveWindowSize.width; @@ -161,6 +167,11 @@ Windows.Window { } }); + nativeWindow.closing.connect(function(closeEvent) { + closeEvent.accepted = false; + windowClosed(); + }); + // finally set the initial window mode: setupPresentationMode(); @@ -243,10 +254,10 @@ Windows.Window { onWindowClosed: { // set invisible on close, to make it not re-appear unintended after switching PresentationMode interactiveWindowVisible = false; - } - onWindowDestroyed: { - console.warn("destroyed"); + if ((flags & Desktop.CLOSE_BUTTON_HIDES) !== Desktop.CLOSE_BUTTON_HIDES) { + selfDestruct(); + } } Item { diff --git a/libraries/ui/src/InteractiveWindow.cpp b/libraries/ui/src/InteractiveWindow.cpp index ad74ff3720..5078fcb602 100644 --- a/libraries/ui/src/InteractiveWindow.cpp +++ b/libraries/ui/src/InteractiveWindow.cpp @@ -84,7 +84,8 @@ InteractiveWindow::InteractiveWindow(const QString& sourceUrl, const QVariantMap connect(object, SIGNAL(interactiveWindowVisibleChanged()), this, SIGNAL(visibleChanged()), Qt::QueuedConnection); connect(object, SIGNAL(presentationModeChanged()), this, SIGNAL(presentationModeChanged()), Qt::QueuedConnection); connect(object, SIGNAL(titleChanged()), this, SIGNAL(titleChanged()), Qt::QueuedConnection); - + connect(object, SIGNAL(windowClosed()), this, SIGNAL(closed()), Qt::QueuedConnection); + connect(object, SIGNAL(selfDestruct()), this, SLOT(close()), Qt::QueuedConnection); QUrl sourceURL{ sourceUrl }; // If the passed URL doesn't correspond to a known scheme, assume it's a local file path @@ -182,7 +183,6 @@ bool InteractiveWindow::isVisible() const { return result; } - // The tool window itself has special logic based on whether any tabs are enabled if (_qmlWindow.isNull()) { return false; } diff --git a/libraries/ui/src/InteractiveWindow.h b/libraries/ui/src/InteractiveWindow.h index 541ff2e140..800b810796 100644 --- a/libraries/ui/src/InteractiveWindow.h +++ b/libraries/ui/src/InteractiveWindow.h @@ -47,46 +47,19 @@ using namespace InteractiveWindowEnums; * @hifi-interface * @hifi-client-en * - * @property {string} mode + * @property {string} title + * @property {Vec2} position + * @property {Vec2} size + * @property {boolean} visible + * @property {Desktop.PresentationMode} presentationMode + * */ class InteractiveWindow : public QObject { Q_OBJECT - /**jsdoc - * title of the window - * - * @name InteractiveWindow#title - * @type string - * @default "InteractiveWindow" - */ Q_PROPERTY(QString title READ getTitle WRITE setTitle) - - /**jsdoc - * window position on current desktop - * - * @name InteractiveWindow#position - * @type Vec2 - */ Q_PROPERTY(glm::vec2 position READ getPosition WRITE setPosition) - - /**jsdoc - * window size - * - * @name InteractiveWindow#size - * @type Vec2 - */ Q_PROPERTY(glm::vec2 size READ getSize WRITE setSize) - - /**jsdoc - * visibility of the window - * - * @name InteractiveWindow#visible - * @type boolean - * @default true - * @example - * // Toggle window visiblity; - * interactiveWindow.visible = !interactiveWindow.visible; - */ Q_PROPERTY(bool visible READ isVisible WRITE setVisible) Q_PROPERTY(int presentationMode READ getPresentationMode WRITE setPresentationMode)