From 10c412d8c7c2ff06573ec4f3d631f45bdf79a045 Mon Sep 17 00:00:00 2001 From: Atlante45 Date: Mon, 16 May 2016 18:43:59 -0700 Subject: [PATCH 01/14] Fix settings getting reset fixes bugzid:531 When a setting handle was created but never initialized/used, it would override the current value with the default value on destruction. --- libraries/shared/src/SettingInterface.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libraries/shared/src/SettingInterface.cpp b/libraries/shared/src/SettingInterface.cpp index 6c5431a13e..a931875771 100644 --- a/libraries/shared/src/SettingInterface.cpp +++ b/libraries/shared/src/SettingInterface.cpp @@ -97,7 +97,7 @@ namespace Setting { } void Interface::deinit() { - if (privateInstance) { + if (_isInitialized && privateInstance) { // Save value to disk save(); From de36cd150e8d00dd82df9e6b002c4730fd6eaa4c Mon Sep 17 00:00:00 2001 From: Atlante45 Date: Mon, 16 May 2016 19:48:20 -0700 Subject: [PATCH 02/14] Move runnings scripts setting storage So that it doesn't conflict with the "Settings" menu setting storage. Running script would clear those settings while storing its data This adds some backward compatible code to move the scripts settings to the new location. --- libraries/script-engine/src/ScriptEngines.cpp | 39 ++++++++++++++++++- 1 file changed, 38 insertions(+), 1 deletion(-) diff --git a/libraries/script-engine/src/ScriptEngines.cpp b/libraries/script-engine/src/ScriptEngines.cpp index 70eb055d22..4fd680025a 100644 --- a/libraries/script-engine/src/ScriptEngines.cpp +++ b/libraries/script-engine/src/ScriptEngines.cpp @@ -256,7 +256,7 @@ QVariantList ScriptEngines::getRunning() { } -static const QString SETTINGS_KEY = "Settings"; +static const QString SETTINGS_KEY = "RunningScripts"; void ScriptEngines::loadDefaultScripts() { QUrl defaultScriptsLoc = defaultScriptsLocation(); @@ -281,6 +281,43 @@ void ScriptEngines::loadScripts() { // loads all saved scripts Settings settings; + + + // START of backward compatibility code + // This following if statement is only meant to update the settings file still using the old setting key. + // If you read that comment and it has been more than a couple months since it was merged, + // then by all means, feel free to remove it. + if (!settings.childGroups().contains(SETTINGS_KEY)) { + qWarning() << "Detected old script settings config, loading from previous location"; + const QString oldKey = "Settings"; + + // Load old scripts array from settings + int size = settings.beginReadArray(oldKey); + for (int i = 0; i < size; ++i) { + settings.setArrayIndex(i); + QString string = settings.value("script").toString(); + if (!string.isEmpty()) { + loadScript(string); + } + } + settings.endArray(); + + // Cleanup old scripts array from settings + settings.beginWriteArray(oldKey); + for (int i = 0; i < size; ++i) { + settings.setArrayIndex(i); + settings.remove(""); + } + settings.endArray(); + settings.beginGroup(oldKey); + settings.remove("size"); + settings.endGroup(); + + return; + } + // END of backward compatibility code + + int size = settings.beginReadArray(SETTINGS_KEY); for (int i = 0; i < size; ++i) { settings.setArrayIndex(i); From 89f18aee3b54661075204d238e2da5136a4e4c30 Mon Sep 17 00:00:00 2001 From: samcake Date: Wed, 18 May 2016 13:14:42 -0700 Subject: [PATCH 03/14] Simplifying the deferredbuffer clear and enableing z test for lighting pass --- .../src/DeferredLightingEffect.cpp | 42 ++++++++++--------- 1 file changed, 23 insertions(+), 19 deletions(-) diff --git a/libraries/render-utils/src/DeferredLightingEffect.cpp b/libraries/render-utils/src/DeferredLightingEffect.cpp index 1d9ce65581..fd7826070d 100644 --- a/libraries/render-utils/src/DeferredLightingEffect.cpp +++ b/libraries/render-utils/src/DeferredLightingEffect.cpp @@ -149,17 +149,12 @@ void DeferredLightingEffect::prepare(RenderArgs* args) { batch.setFramebuffer(deferredFbo); - // Clear Color, Depth and Stencil + // Clear Color, Depth and Stencil for deferred buffer batch.clearFramebuffer( - gpu::Framebuffer::BUFFER_COLOR0 | + gpu::Framebuffer::BUFFER_COLOR0 | gpu::Framebuffer::BUFFER_COLOR1 | gpu::Framebuffer::BUFFER_COLOR2 | gpu::Framebuffer::BUFFER_DEPTH | gpu::Framebuffer::BUFFER_STENCIL, - vec4(vec3(0), 1), 1.0, 0.0, true); - - // clear the normal and specular buffers - batch.clearColorFramebuffer(gpu::Framebuffer::BUFFER_COLOR1, glm::vec4(0.0f, 0.0f, 0.0f, 0.0f), true); - const float MAX_SPECULAR_EXPONENT = 128.0f; - batch.clearColorFramebuffer(gpu::Framebuffer::BUFFER_COLOR2, glm::vec4(0.0f, 0.0f, 0.0f, 1.0f / MAX_SPECULAR_EXPONENT), true); + vec4(vec3(0), 0), 1.0, 0.0, true); }); } @@ -469,9 +464,15 @@ void DeferredLightingEffect::render(const render::RenderContextPointer& renderCo batch.setInputBuffer(0, mesh->getVertexBuffer()); batch.setInputFormat(mesh->getVertexFormat()); - auto& part = mesh->getPartBuffer().get(); - - batch.drawIndexed(model::Mesh::topologyToPrimitive(part._topology), part._numIndices, part._startIndex); + { + auto& part = mesh->getPartBuffer().get(0); + batch.drawIndexed(model::Mesh::topologyToPrimitive(part._topology), part._numIndices, part._startIndex); + } + // keep for debug + /* { + auto& part = mesh->getPartBuffer().get(1); + batch.drawIndexed(model::Mesh::topologyToPrimitive(part._topology), part._numIndices, part._startIndex); + }*/ } } } @@ -548,14 +549,13 @@ static void loadLightProgram(const char* vertSource, const char* fragSource, boo // Stencil test all the light passes for objects pixels only, not the background state->setStencilTest(true, 0xFF, gpu::State::StencilTest(0, 0xFF, gpu::NOT_EQUAL, gpu::State::STENCIL_OP_KEEP, gpu::State::STENCIL_OP_KEEP, gpu::State::STENCIL_OP_KEEP)); - + if (lightVolume) { state->setCullMode(gpu::State::CULL_BACK); - - // No need for z test since the depth buffer is not bound state->setDepthTest(true, false, gpu::LESS_EQUAL); - // TODO: We should bind the true depth buffer both as RT and texture for the depth test + state->setDepthTest(true, false, gpu::LESS_EQUAL); + // TODO: We should use DepthClamp and avoid changing geometry for inside /outside cases - state->setDepthClampEnable(true); + //state->setDepthClampEnable(true); // additive blending state->setBlendFunction(true, gpu::State::ONE, gpu::State::BLEND_OP_ADD, gpu::State::ONE); @@ -662,10 +662,14 @@ model::MeshPointer DeferredLightingEffect::getSpotLightMesh() { _spotLightMesh->setIndexBuffer(gpu::BufferView(new gpu::Buffer(sizeof(unsigned short) * indices, (gpu::Byte*) indexData), gpu::Element::INDEX_UINT16)); delete[] indexData; - model::Mesh::Part part(0, indices, 0, model::Mesh::TRIANGLES); - //DEBUG: model::Mesh::Part part(0, indices, 0, model::Mesh::LINE_STRIP); - _spotLightMesh->setPartBuffer(gpu::BufferView(new gpu::Buffer(sizeof(part), (gpu::Byte*) &part), gpu::Element::PART_DRAWCALL)); + std::vector parts; + parts.push_back(model::Mesh::Part(0, indices, 0, model::Mesh::TRIANGLES)); + //DEBUG: + parts.push_back(model::Mesh::Part(0, indices, 0, model::Mesh::LINE_STRIP)); + + + _spotLightMesh->setPartBuffer(gpu::BufferView(new gpu::Buffer(parts.size() * sizeof(model::Mesh::Part), (gpu::Byte*) parts.data()), gpu::Element::PART_DRAWCALL)); } return _spotLightMesh; } From b4df7cada73dc8f8b5ec6b7ea52af38fc3424100 Mon Sep 17 00:00:00 2001 From: Seth Alves Date: Wed, 18 May 2016 16:16:31 -0700 Subject: [PATCH 04/14] don't mouse-grab things through an overlay --- scripts/system/controllers/grab.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/scripts/system/controllers/grab.js b/scripts/system/controllers/grab.js index a7e08451bc..ef39e95880 100644 --- a/scripts/system/controllers/grab.js +++ b/scripts/system/controllers/grab.js @@ -316,7 +316,12 @@ Grabber.prototype.pressEvent = function(event) { return; } - if (event.isLeftButton!==true ||event.isRightButton===true || event.isMiddleButton===true) { + if (event.isLeftButton !== true || event.isRightButton === true || event.isMiddleButton === true) { + return; + } + + if (Overlays.getOverlayAtPoint(Reticle.position) > 0) { + // the mouse is pointing at an overlay; don't look for entities underneath the overlay. return; } From 107b1b830eb156077546016e2042ad0867a24679 Mon Sep 17 00:00:00 2001 From: Zach Pomerantz Date: Wed, 18 May 2016 17:46:12 -0700 Subject: [PATCH 05/14] Stop ScriptCache callbacks when scripts are stopped --- libraries/script-engine/src/ScriptCache.cpp | 43 ++++++++++++--------- libraries/script-engine/src/ScriptEngines.h | 2 +- 2 files changed, 26 insertions(+), 19 deletions(-) diff --git a/libraries/script-engine/src/ScriptCache.cpp b/libraries/script-engine/src/ScriptCache.cpp index 3ebd3d53ce..2114289095 100644 --- a/libraries/script-engine/src/ScriptCache.cpp +++ b/libraries/script-engine/src/ScriptCache.cpp @@ -9,6 +9,8 @@ // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // +#include "ScriptCache.h" + #include #include #include @@ -20,7 +22,7 @@ #include #include -#include "ScriptCache.h" +#include "ScriptEngines.h" #include "ScriptEngineLogging.h" ScriptCache::ScriptCache(QObject* parent) { @@ -78,22 +80,25 @@ void ScriptCache::scriptDownloaded() { QList scriptUsers = _scriptUsers.values(url); _scriptUsers.remove(url); - if (req->getResult() == ResourceRequest::Success) { - auto scriptContents = req->getData(); - _scriptCache[url] = scriptContents; - lock.unlock(); - qCDebug(scriptengine) << "Done downloading script at:" << url.toString(); + if (!DependencyManager::get()->isStopped()) { + if (req->getResult() == ResourceRequest::Success) { + auto scriptContents = req->getData(); + _scriptCache[url] = scriptContents; + lock.unlock(); + qCDebug(scriptengine) << "Done downloading script at:" << url.toString(); - foreach(ScriptUser* user, scriptUsers) { - user->scriptContentsAvailable(url, scriptContents); - } - } else { - lock.unlock(); - qCWarning(scriptengine) << "Error loading script from URL " << url; - foreach(ScriptUser* user, scriptUsers) { - user->errorInLoadingScript(url); + foreach(ScriptUser* user, scriptUsers) { + user->scriptContentsAvailable(url, scriptContents); + } + } else { + lock.unlock(); + qCWarning(scriptengine) << "Error loading script from URL " << url; + foreach(ScriptUser* user, scriptUsers) { + user->errorInLoadingScript(url); + } } } + req->deleteLater(); } @@ -162,9 +167,11 @@ void ScriptCache::scriptContentAvailable() { } } - foreach(contentAvailableCallback thisCallback, allCallbacks) { - thisCallback(url.toString(), scriptContent, true, success); - } req->deleteLater(); -} + if (!DependencyManager::get()->isStopped()) { + foreach(contentAvailableCallback thisCallback, allCallbacks) { + thisCallback(url.toString(), scriptContent, true, success); + } + } +} diff --git a/libraries/script-engine/src/ScriptEngines.h b/libraries/script-engine/src/ScriptEngines.h index 72bf7d529e..a9c273b2a7 100644 --- a/libraries/script-engine/src/ScriptEngines.h +++ b/libraries/script-engine/src/ScriptEngines.h @@ -68,6 +68,7 @@ public: // Called at shutdown time void shutdownScripting(); + bool isStopped() const { return _isStopped; } signals: void scriptCountChanged(); @@ -86,7 +87,6 @@ protected: void onScriptEngineLoaded(const QString& scriptFilename); void onScriptEngineError(const QString& scriptFilename); void launchScriptEngine(ScriptEngine* engine); - bool isStopped() const { return _isStopped; } QReadWriteLock _scriptEnginesHashLock; QHash _scriptEnginesHash; From e1971f5ed34f7bb692e49d1c53066277149cc2a9 Mon Sep 17 00:00:00 2001 From: Zach Pomerantz Date: Wed, 18 May 2016 18:58:28 -0700 Subject: [PATCH 06/14] Fix shadow bounds checking --- libraries/render-utils/src/RenderShadowTask.cpp | 9 ++++++--- libraries/render-utils/src/Shadow.slh | 3 ++- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/libraries/render-utils/src/RenderShadowTask.cpp b/libraries/render-utils/src/RenderShadowTask.cpp index f695e2d04c..5680660122 100644 --- a/libraries/render-utils/src/RenderShadowTask.cpp +++ b/libraries/render-utils/src/RenderShadowTask.cpp @@ -52,17 +52,19 @@ void RenderShadowMap::run(const render::SceneContextPointer& sceneContext, const batch.setFramebuffer(fbo); batch.clearFramebuffer( gpu::Framebuffer::BUFFER_COLOR0 | gpu::Framebuffer::BUFFER_DEPTH, - vec4(vec3(1.0, 1.0, 1.0), 1.0), 1.0, 0, true); + vec4(vec3(1.0, 1.0, 1.0), 0.0), 1.0, 0, true); batch.setProjectionTransform(shadow.getProjection()); batch.setViewTransform(shadow.getView()); auto shadowPipeline = _shapePlumber->pickPipeline(args, ShapeKey()); auto shadowSkinnedPipeline = _shapePlumber->pickPipeline(args, ShapeKey::Builder().withSkinned()); - args->_pipeline = shadowPipeline; - batch.setPipeline(shadowPipeline->pipeline); std::vector skinnedShapeKeys{}; + + // Iterate through all inShapes and render the unskinned + args->_pipeline = shadowPipeline; + batch.setPipeline(shadowPipeline->pipeline); for (auto items : inShapes) { if (items.first.isSkinned()) { skinnedShapeKeys.push_back(items.first); @@ -71,6 +73,7 @@ void RenderShadowMap::run(const render::SceneContextPointer& sceneContext, const } } + // Reiterate to render the skinned args->_pipeline = shadowSkinnedPipeline; batch.setPipeline(shadowSkinnedPipeline->pipeline); for (const auto& key : skinnedShapeKeys) { diff --git a/libraries/render-utils/src/Shadow.slh b/libraries/render-utils/src/Shadow.slh index 43a20057cd..7b86b9b660 100755 --- a/libraries/render-utils/src/Shadow.slh +++ b/libraries/render-utils/src/Shadow.slh @@ -87,7 +87,8 @@ float evalShadowAttenuationPCF(vec4 position, vec4 shadowTexcoord) { float evalShadowAttenuation(vec4 position) { vec4 shadowTexcoord = evalShadowTexcoord(position); if (shadowTexcoord.x < 0.0 || shadowTexcoord.x > 1.0 || - shadowTexcoord.y < 0.0 || shadowTexcoord.y > 1.0) { + shadowTexcoord.y < 0.0 || shadowTexcoord.y > 1.0 || + shadowTexcoord.z < 0.0 || shadowTexcoord.z > 1.0) { // If a point is not in the map, do not attenuate return 1.0; } From 53956c8210b1f93363e5c3f12deee002bb4234e7 Mon Sep 17 00:00:00 2001 From: Brad Hefta-Gaub Date: Thu, 19 May 2016 07:50:06 -0700 Subject: [PATCH 07/14] reduce log spam --- scripts/system/controllers/handControllerPointer.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/scripts/system/controllers/handControllerPointer.js b/scripts/system/controllers/handControllerPointer.js index 921c55b7b2..78b7c4eb84 100644 --- a/scripts/system/controllers/handControllerPointer.js +++ b/scripts/system/controllers/handControllerPointer.js @@ -186,7 +186,9 @@ function updateSeeking() { averageMouseVelocity = lastIntegration = 0; var lookAt2D = HMD.getHUDLookAtPosition2D(); if (!lookAt2D) { - print('Cannot seek without lookAt position'); + // FIXME - determine if this message is useful but make it so it doesn't spam the + // log in the case that it is happening + //print('Cannot seek without lookAt position'); return; } // E.g., if parallel to location in HUD var copy = Reticle.position; @@ -420,7 +422,9 @@ function update() { var hudPoint3d = calculateRayUICollisionPoint(controllerPosition, controllerDirection); if (!hudPoint3d) { - print('Controller is parallel to HUD'); + // FIXME - determine if this message is useful but make it so it doesn't spam the + // log in the case that it is happening + //print('Controller is parallel to HUD'); return turnOffVisualization(); } var hudPoint2d = overlayFromWorldPoint(hudPoint3d); From 2d7118dacc87260faca4f232727823ca7b8985d2 Mon Sep 17 00:00:00 2001 From: samcake Date: Thu, 19 May 2016 10:21:00 -0700 Subject: [PATCH 08/14] clening up the code --- libraries/render-utils/src/DeferredLightingEffect.cpp | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/libraries/render-utils/src/DeferredLightingEffect.cpp b/libraries/render-utils/src/DeferredLightingEffect.cpp index fd7826070d..0a562de3ba 100644 --- a/libraries/render-utils/src/DeferredLightingEffect.cpp +++ b/libraries/render-utils/src/DeferredLightingEffect.cpp @@ -468,11 +468,6 @@ void DeferredLightingEffect::render(const render::RenderContextPointer& renderCo auto& part = mesh->getPartBuffer().get(0); batch.drawIndexed(model::Mesh::topologyToPrimitive(part._topology), part._numIndices, part._startIndex); } - // keep for debug - /* { - auto& part = mesh->getPartBuffer().get(1); - batch.drawIndexed(model::Mesh::topologyToPrimitive(part._topology), part._numIndices, part._startIndex); - }*/ } } } @@ -555,7 +550,6 @@ static void loadLightProgram(const char* vertSource, const char* fragSource, boo state->setDepthTest(true, false, gpu::LESS_EQUAL); // TODO: We should use DepthClamp and avoid changing geometry for inside /outside cases - //state->setDepthClampEnable(true); // additive blending state->setBlendFunction(true, gpu::State::ONE, gpu::State::BLEND_OP_ADD, gpu::State::ONE); @@ -665,8 +659,7 @@ model::MeshPointer DeferredLightingEffect::getSpotLightMesh() { std::vector parts; parts.push_back(model::Mesh::Part(0, indices, 0, model::Mesh::TRIANGLES)); - //DEBUG: - parts.push_back(model::Mesh::Part(0, indices, 0, model::Mesh::LINE_STRIP)); + parts.push_back(model::Mesh::Part(0, indices, 0, model::Mesh::LINE_STRIP)); // outline version _spotLightMesh->setPartBuffer(gpu::BufferView(new gpu::Buffer(parts.size() * sizeof(model::Mesh::Part), (gpu::Byte*) parts.data()), gpu::Element::PART_DRAWCALL)); From 7ea7bd3e1dacd21702452421cc0737a89fd1aea7 Mon Sep 17 00:00:00 2001 From: Seth Alves Date: Thu, 19 May 2016 10:21:04 -0700 Subject: [PATCH 09/14] set created-time for imported entities to 'now' --- libraries/entities/src/EntityTree.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/libraries/entities/src/EntityTree.cpp b/libraries/entities/src/EntityTree.cpp index 30c37d46b1..97d4e91acd 100644 --- a/libraries/entities/src/EntityTree.cpp +++ b/libraries/entities/src/EntityTree.cpp @@ -1376,6 +1376,10 @@ bool EntityTree::sendEntitiesOperation(OctreeElementPointer element, void* extra item->globalizeProperties(properties, "Cannot find %3 parent of %2 %1", args->root); } } + + // set creation time to "now" for imported entities + properties.setCreated(usecTimestampNow()); + properties.markAllChanged(); // so the entire property set is considered new, since we're making a new entity // queue the packet to send to the server From 9a4b30a50bb0c3178de83b6e53fbbf2d090cb4b5 Mon Sep 17 00:00:00 2001 From: Zach Pomerantz Date: Thu, 19 May 2016 12:52:32 -0700 Subject: [PATCH 10/14] Fix AvatarInputs phantom movement --- interface/src/Application.cpp | 16 ++++++++-------- interface/src/Application.h | 2 +- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/interface/src/Application.cpp b/interface/src/Application.cpp index 9e3bd0c69c..cf14d01771 100644 --- a/interface/src/Application.cpp +++ b/interface/src/Application.cpp @@ -1510,17 +1510,17 @@ void Application::paintGL() { renderArgs._context->syncCache(); } - if (Menu::getInstance()->isOptionChecked(MenuOption::MiniMirror)) { + auto inputs = AvatarInputs::getInstance(); + if (inputs->mirrorVisible()) { PerformanceTimer perfTimer("Mirror"); auto primaryFbo = DependencyManager::get()->getPrimaryFramebuffer(); renderArgs._renderMode = RenderArgs::MIRROR_RENDER_MODE; renderArgs._blitFramebuffer = DependencyManager::get()->getSelfieFramebuffer(); - auto inputs = AvatarInputs::getInstance(); _mirrorViewRect.moveTo(inputs->x(), inputs->y()); - renderRearViewMirror(&renderArgs, _mirrorViewRect); + renderRearViewMirror(&renderArgs, _mirrorViewRect, inputs->mirrorZoomed()); renderArgs._blitFramebuffer.reset(); renderArgs._renderMode = RenderArgs::DEFAULT_RENDER_MODE; @@ -1839,6 +1839,9 @@ bool Application::event(QEvent* event) { idle(); return true; } else if ((int)event->type() == (int)Paint) { + // NOTE: This must be updated as close to painting as possible, + // or AvatarInputs will mysteriously move to the bottom-right + AvatarInputs::getInstance()->update(); justPresented = true; paintGL(); return true; @@ -2670,9 +2673,6 @@ void Application::idle() { firstIdle = false; connect(offscreenUi.data(), &OffscreenUi::showDesktop, this, &Application::showDesktop); _overlayConductor.setEnabled(Menu::getInstance()->isOptionChecked(MenuOption::Overlays)); - } else { - // FIXME: AvatarInputs are positioned incorrectly if instantiated before the first paint - AvatarInputs::getInstance()->update(); } PROFILE_RANGE(__FUNCTION__); @@ -4101,7 +4101,7 @@ void Application::displaySide(RenderArgs* renderArgs, Camera& theCamera, bool se activeRenderingThread = nullptr; } -void Application::renderRearViewMirror(RenderArgs* renderArgs, const QRect& region) { +void Application::renderRearViewMirror(RenderArgs* renderArgs, const QRect& region, bool isZoomed) { auto originalViewport = renderArgs->_viewport; // Grab current viewport to reset it at the end @@ -4111,7 +4111,7 @@ void Application::renderRearViewMirror(RenderArgs* renderArgs, const QRect& regi auto myAvatar = getMyAvatar(); // bool eyeRelativeCamera = false; - if (!AvatarInputs::getInstance()->mirrorZoomed()) { + if (!isZoomed) { _mirrorCamera.setPosition(myAvatar->getChestPosition() + myAvatar->getOrientation() * glm::vec3(0.0f, 0.0f, -1.0f) * MIRROR_REARVIEW_BODY_DISTANCE * myAvatar->getScale()); diff --git a/interface/src/Application.h b/interface/src/Application.h index 5616722c92..28dbcead47 100644 --- a/interface/src/Application.h +++ b/interface/src/Application.h @@ -342,7 +342,7 @@ private: glm::vec3 getSunDirection() const; - void renderRearViewMirror(RenderArgs* renderArgs, const QRect& region); + void renderRearViewMirror(RenderArgs* renderArgs, const QRect& region, bool isZoomed); int sendNackPackets(); From 8be6bc6460e18ab1647c12dd07218f91bf32c101 Mon Sep 17 00:00:00 2001 From: Atlante45 Date: Thu, 19 May 2016 22:00:22 -0700 Subject: [PATCH 11/14] Add missing overrides --- assignment-client/src/entities/EntityServer.h | 4 ++-- tests/controllers/src/main.cpp | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/assignment-client/src/entities/EntityServer.h b/assignment-client/src/entities/EntityServer.h index 1685f08e01..0486a97ede 100644 --- a/assignment-client/src/entities/EntityServer.h +++ b/assignment-client/src/entities/EntityServer.h @@ -60,8 +60,8 @@ public: virtual void trackViewerGone(const QUuid& sessionID) override; public slots: - virtual void nodeAdded(SharedNodePointer node); - virtual void nodeKilled(SharedNodePointer node); + virtual void nodeAdded(SharedNodePointer node) override; + virtual void nodeKilled(SharedNodePointer node) override; void pruneDeletedEntities(); protected: diff --git a/tests/controllers/src/main.cpp b/tests/controllers/src/main.cpp index e978dd9a38..3a5b4a4a4d 100644 --- a/tests/controllers/src/main.cpp +++ b/tests/controllers/src/main.cpp @@ -89,7 +89,7 @@ public: virtual GLWidget* getPrimaryWidget() override { return nullptr; } virtual MainWindow* getPrimaryWindow() override { return nullptr; } virtual QOpenGLContext* getPrimaryContext() override { return nullptr; } - virtual ui::Menu* getPrimaryMenu() { return nullptr; } + virtual ui::Menu* getPrimaryMenu() override { return nullptr; } virtual bool isForeground() override { return true; } virtual const DisplayPluginPointer getActiveDisplayPlugin() const override { return DisplayPluginPointer(); } }; From 2026226fe2b09a7664fd5b4a7f97246c7029584c Mon Sep 17 00:00:00 2001 From: Zach Pomerantz Date: Thu, 19 May 2016 13:18:02 -0700 Subject: [PATCH 12/14] Handle vsync without halving fps --- interface/src/Application.cpp | 28 ++++++++++++++++------------ 1 file changed, 16 insertions(+), 12 deletions(-) diff --git a/interface/src/Application.cpp b/interface/src/Application.cpp index cf14d01771..6190de5875 100644 --- a/interface/src/Application.cpp +++ b/interface/src/Application.cpp @@ -1822,28 +1822,37 @@ bool Application::event(QEvent* event) { return false; } - static bool justPresented = false; + // Presentation/painting logic + // TODO: Decouple presentation and painting loops + static bool isPainting = false; if ((int)event->type() == (int)Present) { - if (justPresented) { - justPresented = false; - - // If presentation is hogging the main thread, repost as low priority to avoid hanging the GUI. + if (isPainting) { + // If painting (triggered by presentation) is hogging the main thread, + // repost as low priority to avoid hanging the GUI. // This has the effect of allowing presentation to exceed the paint budget by X times and - // only dropping every (1/X) frames, instead of every ceil(X) frames. + // only dropping every (1/X) frames, instead of every ceil(X) frames // (e.g. at a 60FPS target, painting for 17us would fall to 58.82FPS instead of 30FPS). removePostedEvents(this, Present); postEvent(this, new QEvent(static_cast(Present)), Qt::LowEventPriority); + isPainting = false; return true; } idle(); + + postEvent(this, new QEvent(static_cast(Paint)), Qt::HighEventPriority); + isPainting = true; + return true; } else if ((int)event->type() == (int)Paint) { // NOTE: This must be updated as close to painting as possible, // or AvatarInputs will mysteriously move to the bottom-right AvatarInputs::getInstance()->update(); - justPresented = true; + paintGL(); + + isPainting = false; + return true; } @@ -2658,9 +2667,6 @@ void Application::idle() { // Sync up the _renderedFrameIndex _renderedFrameIndex = displayPlugin->presentCount(); - // Request a paint ASAP - postEvent(this, new QEvent(static_cast(Paint)), Qt::HighEventPriority + 1); - // Update the deadlock watchdog updateHeartbeat(); @@ -2687,8 +2693,6 @@ void Application::idle() { _keyboardDeviceHasFocus = true; } - - // We're going to execute idle processing, so restart the last idle timer _lastTimeUpdated.start(); From 76f4a25694f1d3adf82e92f0683a5ca759747878 Mon Sep 17 00:00:00 2001 From: Seth Alves Date: Fri, 20 May 2016 11:40:46 -0700 Subject: [PATCH 13/14] move code that clears old scale and registration to after model is loaded --- .../src/RenderableModelEntityItem.cpp | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/libraries/entities-renderer/src/RenderableModelEntityItem.cpp b/libraries/entities-renderer/src/RenderableModelEntityItem.cpp index a537ecd0f3..7b51283bac 100644 --- a/libraries/entities-renderer/src/RenderableModelEntityItem.cpp +++ b/libraries/entities-renderer/src/RenderableModelEntityItem.cpp @@ -48,13 +48,6 @@ RenderableModelEntityItem::~RenderableModelEntityItem() { void RenderableModelEntityItem::setModelURL(const QString& url) { auto& currentURL = getParsedModelURL(); - if (_model && (currentURL != url)) { - // The machinery for updateModelBounds will give existing models the opportunity to fix their translation/rotation/scale/registration. - // The first two are straightforward, but the latter two have guards to make sure they don't happen after they've already been set. - // Here we reset those guards. This doesn't cause the entity values to change -- it just allows the model to match once it comes in. - _model->setScaleToFit(false, getDimensions()); - _model->setSnapModelToRegistrationPoint(false, getRegistrationPoint()); - } ModelEntityItem::setModelURL(url); if (currentURL != getParsedModelURL() || !_model) { @@ -163,6 +156,14 @@ void RenderableModelEntityItem::remapTextures() { } void RenderableModelEntityItem::doInitialModelSimulation() { + // The machinery for updateModelBounds will give existing models the opportunity to fix their + // translation/rotation/scale/registration. The first two are straightforward, but the latter two have guards to + // make sure they don't happen after they've already been set. Here we reset those guards. This doesn't cause the + // entity values to change -- it just allows the model to match once it comes in. + _model->setScaleToFit(false, getDimensions()); + _model->setSnapModelToRegistrationPoint(false, getRegistrationPoint()); + + // now recalculate the bounds and registration _model->setScaleToFit(true, getDimensions()); _model->setSnapModelToRegistrationPoint(true, getRegistrationPoint()); _model->setRotation(getRotation()); From c299aef8f214b39b5dd51acb831292be129d7f82 Mon Sep 17 00:00:00 2001 From: howard-stearns Date: Fri, 20 May 2016 12:15:30 -0700 Subject: [PATCH 14/14] fix 588, 558 --- scripts/system/controllers/handControllerPointer.js | 8 ++++++-- scripts/system/edit.js | 4 +++- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/scripts/system/controllers/handControllerPointer.js b/scripts/system/controllers/handControllerPointer.js index 78b7c4eb84..f4e4492a88 100644 --- a/scripts/system/controllers/handControllerPointer.js +++ b/scripts/system/controllers/handControllerPointer.js @@ -178,7 +178,10 @@ var NON_LINEAR_DIVISOR = 2; var MINIMUM_SEEK_DISTANCE = 0.01; function updateSeeking() { if (!Reticle.visible || isShakingMouse()) { - isSeeking = true; + if (!isSeeking) { + print('Start seeking mouse.'); + isSeeking = true; + } } // e.g., if we're about to turn it on with first movement. if (!isSeeking) { return; @@ -203,6 +206,7 @@ function updateSeeking() { } var okX = !updateDimension('x'), okY = !updateDimension('y'); // Evaluate both. Don't short-circuit. if (okX && okY) { + print('Finished seeking mouse'); isSeeking = false; } else { Reticle.setPosition(copy); // Not setReticlePosition @@ -444,7 +448,7 @@ function update() { updateVisualization(controllerPosition, controllerDirection, hudPoint3d, hudPoint2d); } -var UPDATE_INTERVAL = 20; // milliseconds. Script.update is too frequent. +var UPDATE_INTERVAL = 50; // milliseconds. Script.update is too frequent. var updater = Script.setInterval(update, UPDATE_INTERVAL); Script.scriptEnding.connect(function () { Script.clearInterval(updater); diff --git a/scripts/system/edit.js b/scripts/system/edit.js index e84cdf7971..afbc679ec4 100644 --- a/scripts/system/edit.js +++ b/scripts/system/edit.js @@ -352,7 +352,9 @@ var toolBar = (function() { gridTool.setVisible(true); grid.setEnabled(true); propertiesTool.setVisible(true); - Window.setFocus(); + // Not sure what the following was meant to accomplish, but it currently causes + // everybody else to think that Interface has lost focus overall. fogbugzid:558 + // Window.setFocus(); } that.showTools(isActive); }