From 93afdf79a3e32108a565d2b889c4c1999eabe3a0 Mon Sep 17 00:00:00 2001 From: Sam Gateau Date: Tue, 21 Jul 2015 11:17:41 -0700 Subject: [PATCH 01/18] Removing the gl driver version report intiialization code out of applciation --- interface/src/Application.h | 1 + libraries/gpu/src/gpu/GLBackend.cpp | 5 +++++ 2 files changed, 6 insertions(+) diff --git a/interface/src/Application.h b/interface/src/Application.h index 736f515390..9e234354b1 100644 --- a/interface/src/Application.h +++ b/interface/src/Application.h @@ -482,6 +482,7 @@ private: glm::vec3 getSunDirection(); void renderRearViewMirror(RenderArgs* renderArgs, const QRect& region, bool billboard = false); + void setMenuShortcutsEnabled(bool enabled); static void attachNewHeadToNode(Node *newNode); diff --git a/libraries/gpu/src/gpu/GLBackend.cpp b/libraries/gpu/src/gpu/GLBackend.cpp index adebee2f20..558c94f062 100644 --- a/libraries/gpu/src/gpu/GLBackend.cpp +++ b/libraries/gpu/src/gpu/GLBackend.cpp @@ -91,6 +91,11 @@ GLBackend::GLBackend() : { initInput(); initTransform(); + + qCDebug(gpulogging) << "GL Version: " << QString((const char*) glGetString(GL_VERSION)); + qCDebug(gpulogging) << "GL Shader Language Version: " << QString((const char*) glGetString(GL_SHADING_LANGUAGE_VERSION)); + qCDebug(gpulogging) << "GL Vendor: " << QString((const char*) glGetString(GL_VENDOR)); + qCDebug(gpulogging) << "GL Renderer: " << QString((const char*) glGetString(GL_RENDERER)); } GLBackend::~GLBackend() { From 7ac20308621f19afd921c49693e7f8b2cce9d254 Mon Sep 17 00:00:00 2001 From: Sam Gateau Date: Wed, 22 Jul 2015 10:43:50 -0700 Subject: [PATCH 02/18] Preparing for first pr --- interface/src/Application.cpp | 43 ++++----------------- interface/src/Application.h | 4 ++ interface/src/avatar/MyAvatar.cpp | 4 +- interface/src/ui/ApplicationOverlay.h | 1 - libraries/gpu/src/gpu/Context.h | 2 +- libraries/gpu/src/gpu/GLBackend.cpp | 40 ++++++++++++++++--- libraries/gpu/src/gpu/GLBackend.h | 1 + libraries/render-utils/src/TextureCache.cpp | 21 ---------- libraries/render-utils/src/TextureCache.h | 9 +++-- libraries/shared/src/RenderArgs.h | 4 +- 10 files changed, 57 insertions(+), 72 deletions(-) diff --git a/interface/src/Application.cpp b/interface/src/Application.cpp index f0dcdd1a8a..62c1374179 100644 --- a/interface/src/Application.cpp +++ b/interface/src/Application.cpp @@ -765,32 +765,9 @@ void Application::initializeGL() { } #endif - qCDebug(interfaceapp) << "GL Version: " << QString((const char*) glGetString(GL_VERSION)); - qCDebug(interfaceapp) << "GL Shader Language Version: " << QString((const char*) glGetString(GL_SHADING_LANGUAGE_VERSION)); - qCDebug(interfaceapp) << "GL Vendor: " << QString((const char*) glGetString(GL_VENDOR)); - qCDebug(interfaceapp) << "GL Renderer: " << QString((const char*) glGetString(GL_RENDERER)); - #ifdef WIN32 - GLenum err = glewInit(); - if (GLEW_OK != err) { - /* Problem: glewInit failed, something is seriously wrong. */ - qCDebug(interfaceapp, "Error: %s\n", glewGetErrorString(err)); - } - qCDebug(interfaceapp, "Status: Using GLEW %s\n", glewGetString(GLEW_VERSION)); - - if (wglewGetExtension("WGL_EXT_swap_control")) { - int swapInterval = wglGetSwapIntervalEXT(); - qCDebug(interfaceapp, "V-Sync is %s\n", (swapInterval > 0 ? "ON" : "OFF")); - } - #endif - -#if defined(Q_OS_LINUX) - // TODO: Write the correct code for Linux... - /* if (wglewGetExtension("WGL_EXT_swap_control")) { - int swapInterval = wglGetSwapIntervalEXT(); - qCDebug(interfaceapp, "V-Sync is %s\n", (swapInterval > 0 ? "ON" : "OFF")); - }*/ -#endif + // Where the gpuContext is created and where the TRUE Backend is created and assigned + _gpuContext = std::make_shared(new gpu::GLBackend()); initDisplay(); qCDebug(interfaceapp, "Initialized Display."); @@ -879,8 +856,9 @@ void Application::paintGL() { _glWidget->makeCurrent(); auto lodManager = DependencyManager::get(); - gpu::Context context(new gpu::GLBackend()); - RenderArgs renderArgs(&context, nullptr, getViewFrustum(), lodManager->getOctreeSizeScale(), + + + RenderArgs renderArgs(_gpuContext, nullptr, getViewFrustum(), lodManager->getOctreeSizeScale(), lodManager->getBoundaryLevelAdjust(), RenderArgs::DEFAULT_RENDER_MODE, RenderArgs::MONO, RenderArgs::RENDER_DEBUG_NONE); @@ -896,6 +874,7 @@ void Application::paintGL() { PerformanceWarning warn(showWarnings, "Application::paintGL()"); resizeGL(); + { PerformanceTimer perfTimer("renderOverlay"); @@ -906,8 +885,6 @@ void Application::paintGL() { _applicationOverlay.renderOverlay(&renderArgs); } - glEnable(GL_LINE_SMOOTH); - if (_myCamera.getMode() == CAMERA_MODE_FIRST_PERSON || _myCamera.getMode() == CAMERA_MODE_THIRD_PERSON) { Menu::getInstance()->setIsOptionChecked(MenuOption::FirstPerson, _myAvatar->getBoomLength() <= MyAvatar::ZOOM_MIN); Menu::getInstance()->setIsOptionChecked(MenuOption::ThirdPerson, !(_myAvatar->getBoomLength() <= MyAvatar::ZOOM_MIN)); @@ -958,7 +935,6 @@ void Application::paintGL() { } // Sync up the View Furstum with the camera - // FIXME: it's happening again in the updateSHadow and it shouldn't, this should be the place loadViewFrustum(_myCamera, _viewFrustum); @@ -997,7 +973,7 @@ void Application::paintGL() { displaySide(&renderArgs, _myCamera); - if (_myCamera.getMode() != CAMERA_MODE_MIRROR && Menu::getInstance()->isOptionChecked(MenuOption::Mirror)) { + if (Menu::getInstance()->isOptionChecked(MenuOption::Mirror)) { renderArgs._renderMode = RenderArgs::MIRROR_RENDER_MODE; renderRearViewMirror(&renderArgs, _mirrorViewRect); renderArgs._renderMode = RenderArgs::NORMAL_RENDER_MODE; @@ -3172,10 +3148,6 @@ namespace render { model::Skybox::render(batch, *(Application::getInstance()->getDisplayViewFrustum()), *skybox); } } - // FIX ME - If I don't call this renderBatch() here, then the atmosphere and skybox don't render, but it - // seems like these payloadRender() methods shouldn't be doing this. We need to investigate why the engine - // isn't rendering our batch - gpu::GLBackend::renderBatch(batch, true); } } @@ -3444,7 +3416,6 @@ void Application::renderRearViewMirror(RenderArgs* renderArgs, const QRect& regi bool updateViewFrustum = false; loadViewFrustum(_mirrorCamera, _viewFrustum); - // render rear mirror view displaySide(renderArgs, _mirrorCamera, true, billboard); diff --git a/interface/src/Application.h b/interface/src/Application.h index 766ab14eff..ea800d60cb 100644 --- a/interface/src/Application.h +++ b/interface/src/Application.h @@ -69,6 +69,7 @@ #include "octree/OctreePacketProcessor.h" #include "UndoStackScriptingInterface.h" +#include "gpu/Context.h" #include "render/Engine.h" class QGLWidget; @@ -326,6 +327,8 @@ public: render::ScenePointer getMain3DScene() const { return _main3DScene; } + gpu::ContextPointer getGPUContext() const { return _gpuContext; } + signals: /// Fired when we're simulating; allows external parties to hook in. @@ -633,6 +636,7 @@ private: render::ScenePointer _main3DScene{ new render::Scene() }; render::EnginePointer _renderEngine{ new render::Engine() }; + gpu::ContextPointer _gpuContext; // initialized during window creation Overlays _overlays; ApplicationOverlay _applicationOverlay; diff --git a/interface/src/avatar/MyAvatar.cpp b/interface/src/avatar/MyAvatar.cpp index 27a54fc42d..a5ddb43637 100644 --- a/interface/src/avatar/MyAvatar.cpp +++ b/interface/src/avatar/MyAvatar.cpp @@ -1524,8 +1524,8 @@ void MyAvatar::maybeUpdateBillboard() { return; } } - gpu::Context context(new gpu::GLBackend()); - RenderArgs renderArgs(&context); + + RenderArgs renderArgs(qApp->getGPUContext()); QImage image = qApp->renderAvatarBillboard(&renderArgs); _billboard.clear(); QBuffer buffer(&_billboard); diff --git a/interface/src/ui/ApplicationOverlay.h b/interface/src/ui/ApplicationOverlay.h index ae09aa0b10..532fea23dc 100644 --- a/interface/src/ui/ApplicationOverlay.h +++ b/interface/src/ui/ApplicationOverlay.h @@ -49,7 +49,6 @@ private: gpu::TexturePointer _overlayDepthTexture; gpu::TexturePointer _overlayColorTexture; gpu::FramebufferPointer _overlayFramebuffer; - }; #endif // hifi_ApplicationOverlay_h diff --git a/libraries/gpu/src/gpu/Context.h b/libraries/gpu/src/gpu/Context.h index 4eb0976e3c..484c772c71 100644 --- a/libraries/gpu/src/gpu/Context.h +++ b/libraries/gpu/src/gpu/Context.h @@ -134,7 +134,7 @@ protected: friend class Shader; }; - +typedef std::shared_ptr ContextPointer; }; diff --git a/libraries/gpu/src/gpu/GLBackend.cpp b/libraries/gpu/src/gpu/GLBackend.cpp index 558c94f062..0a6f3a423d 100644 --- a/libraries/gpu/src/gpu/GLBackend.cpp +++ b/libraries/gpu/src/gpu/GLBackend.cpp @@ -14,6 +14,8 @@ using namespace gpu; +bool GLBackend::_initialized = false; + GLBackend::CommandCall GLBackend::_commandCalls[Batch::NUM_COMMANDS] = { (&::gpu::GLBackend::do_draw), @@ -89,13 +91,38 @@ GLBackend::GLBackend() : _pipeline(), _output() { + if (!_initialized) { + qCDebug(gpulogging) << "GL Version: " << QString((const char*) glGetString(GL_VERSION)); + qCDebug(gpulogging) << "GL Shader Language Version: " << QString((const char*) glGetString(GL_SHADING_LANGUAGE_VERSION)); + qCDebug(gpulogging) << "GL Vendor: " << QString((const char*) glGetString(GL_VENDOR)); + qCDebug(gpulogging) << "GL Renderer: " << QString((const char*) glGetString(GL_RENDERER)); + +#ifdef WIN32 + GLenum err = glewInit(); + if (GLEW_OK != err) { + /* Problem: glewInit failed, something is seriously wrong. */ + qCDebug(gpulogging, "Error: %s\n", glewGetErrorString(err)); + } + qCDebug(gpulogging, "Status: Using GLEW %s\n", glewGetString(GLEW_VERSION)); + + if (wglewGetExtension("WGL_EXT_swap_control")) { + int swapInterval = wglGetSwapIntervalEXT(); + qCDebug(gpulogging, "V-Sync is %s\n", (swapInterval > 0 ? "ON" : "OFF")); + } +#endif + +#if defined(Q_OS_LINUX) + // TODO: Write the correct code for Linux... + /* if (wglewGetExtension("WGL_EXT_swap_control")) { + int swapInterval = wglGetSwapIntervalEXT(); + qCDebug(gpulogging, "V-Sync is %s\n", (swapInterval > 0 ? "ON" : "OFF")); + }*/ +#endif + _initialized = true; + } + initInput(); initTransform(); - - qCDebug(gpulogging) << "GL Version: " << QString((const char*) glGetString(GL_VERSION)); - qCDebug(gpulogging) << "GL Shader Language Version: " << QString((const char*) glGetString(GL_SHADING_LANGUAGE_VERSION)); - qCDebug(gpulogging) << "GL Vendor: " << QString((const char*) glGetString(GL_VENDOR)); - qCDebug(gpulogging) << "GL Renderer: " << QString((const char*) glGetString(GL_RENDERER)); } GLBackend::~GLBackend() { @@ -118,6 +145,7 @@ void GLBackend::render(Batch& batch) { } void GLBackend::renderBatch(Batch& batch, bool syncCache) { + qCDebug(gpulogging) << "GLBackend::renderBatch : Deprecated call, don;t do it!!!"; GLBackend backend; if (syncCache) { backend.syncCache(); @@ -171,6 +199,8 @@ void GLBackend::syncCache() { syncTransformStateCache(); syncPipelineStateCache(); syncInputStateCache(); + + glEnable(GL_LINE_SMOOTH); } void GLBackend::do_draw(Batch& batch, uint32 paramOffset) { diff --git a/libraries/gpu/src/gpu/GLBackend.h b/libraries/gpu/src/gpu/GLBackend.h index 60c01a815c..b4906b4ac7 100644 --- a/libraries/gpu/src/gpu/GLBackend.h +++ b/libraries/gpu/src/gpu/GLBackend.h @@ -448,6 +448,7 @@ protected: typedef void (GLBackend::*CommandCall)(Batch&, uint32); static CommandCall _commandCalls[Batch::NUM_COMMANDS]; + static bool _initialized; }; diff --git a/libraries/render-utils/src/TextureCache.cpp b/libraries/render-utils/src/TextureCache.cpp index ddfcc1589c..2baa58d256 100644 --- a/libraries/render-utils/src/TextureCache.cpp +++ b/libraries/render-utils/src/TextureCache.cpp @@ -237,27 +237,6 @@ GLuint TextureCache::getPrimaryDepthTextureID() { return gpu::GLBackend::getTextureID(getPrimaryDepthTexture()); } -void TextureCache::setPrimaryDrawBuffers(bool color, bool normal, bool specular) { - gpu::Batch batch; - setPrimaryDrawBuffers(batch, color, normal, specular); - gpu::GLBackend::renderBatch(batch); -} - -void TextureCache::setPrimaryDrawBuffers(gpu::Batch& batch, bool color, bool normal, bool specular) { - GLenum buffers[3]; - int bufferCount = 0; - if (color) { - buffers[bufferCount++] = GL_COLOR_ATTACHMENT0; - } - if (normal) { - buffers[bufferCount++] = GL_COLOR_ATTACHMENT1; - } - if (specular) { - buffers[bufferCount++] = GL_COLOR_ATTACHMENT2; - } - batch._glDrawBuffers(bufferCount, buffers); -} - gpu::FramebufferPointer TextureCache::getSecondaryFramebuffer() { if (!_secondaryFramebuffer) { _secondaryFramebuffer = gpu::FramebufferPointer(gpu::Framebuffer::create(gpu::Element::COLOR_RGBA_32, _frameBufferSize.width(), _frameBufferSize.height())); diff --git a/libraries/render-utils/src/TextureCache.h b/libraries/render-utils/src/TextureCache.h index 6b4fff4f6b..020b502eb9 100644 --- a/libraries/render-utils/src/TextureCache.h +++ b/libraries/render-utils/src/TextureCache.h @@ -79,10 +79,6 @@ public: /// Returns the ID of the primary framebuffer object's depth texture. This contains the Z buffer used in rendering. uint32_t getPrimaryDepthTextureID(); - /// Enables or disables draw buffers on the primary framebuffer. Note: the primary framebuffer must be bound. - void setPrimaryDrawBuffers(bool color, bool normal = false, bool specular = false); - void setPrimaryDrawBuffers(gpu::Batch& batch, bool color, bool normal = false, bool specular = false); - /// Returns a pointer to the secondary framebuffer object, used as an additional render target when performing full /// screen effects. gpu::FramebufferPointer getSecondaryFramebuffer(); @@ -94,6 +90,11 @@ public: /// Returns the framebuffer object used to render shadow maps; gpu::FramebufferPointer getShadowFramebuffer(); + + // The framebuffer used for the selfie view of the avatar. used for creating the billboard view and the rearViewMirror image + gpu::FramebufferPointer getSelfieFramebuffer(); + + protected: virtual QSharedPointer createResource(const QUrl& url, diff --git a/libraries/shared/src/RenderArgs.h b/libraries/shared/src/RenderArgs.h index 604cb46731..7a5daf7a17 100644 --- a/libraries/shared/src/RenderArgs.h +++ b/libraries/shared/src/RenderArgs.h @@ -80,7 +80,7 @@ public: RENDER_DEBUG_SIMULATION_OWNERSHIP = 2, }; - RenderArgs(gpu::Context* context = nullptr, + RenderArgs(std::shared_ptr context = nullptr, OctreeRenderer* renderer = nullptr, ViewFrustum* viewFrustum = nullptr, float sizeScale = 1.0f, @@ -102,7 +102,7 @@ public: _shouldRender(shouldRender) { } - gpu::Context* _context = nullptr; + std::shared_ptr _context = nullptr; OctreeRenderer* _renderer = nullptr; ViewFrustum* _viewFrustum = nullptr; glm::ivec4 _viewport{ 0, 0, 1, 1 }; From 8dbd991652d5d881c9bc6e5c4b70ac68cc6f9735 Mon Sep 17 00:00:00 2001 From: Sam Gateau Date: Wed, 22 Jul 2015 10:54:40 -0700 Subject: [PATCH 03/18] USing a modern singleton guard --- libraries/gpu/src/gpu/GLBackend.cpp | 9 ++++----- libraries/gpu/src/gpu/GLBackend.h | 2 -- 2 files changed, 4 insertions(+), 7 deletions(-) diff --git a/libraries/gpu/src/gpu/GLBackend.cpp b/libraries/gpu/src/gpu/GLBackend.cpp index 0a6f3a423d..721be0f402 100644 --- a/libraries/gpu/src/gpu/GLBackend.cpp +++ b/libraries/gpu/src/gpu/GLBackend.cpp @@ -8,14 +8,13 @@ // Distributed under the Apache License, Version 2.0. // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // +#include #include "GPULogging.h" #include "GLBackendShared.h" #include using namespace gpu; -bool GLBackend::_initialized = false; - GLBackend::CommandCall GLBackend::_commandCalls[Batch::NUM_COMMANDS] = { (&::gpu::GLBackend::do_draw), @@ -91,7 +90,8 @@ GLBackend::GLBackend() : _pipeline(), _output() { - if (!_initialized) { + static std::once_flag once; + std::call_once(once, [] { qCDebug(gpulogging) << "GL Version: " << QString((const char*) glGetString(GL_VERSION)); qCDebug(gpulogging) << "GL Shader Language Version: " << QString((const char*) glGetString(GL_SHADING_LANGUAGE_VERSION)); qCDebug(gpulogging) << "GL Vendor: " << QString((const char*) glGetString(GL_VENDOR)); @@ -118,8 +118,7 @@ GLBackend::GLBackend() : qCDebug(gpulogging, "V-Sync is %s\n", (swapInterval > 0 ? "ON" : "OFF")); }*/ #endif - _initialized = true; - } + }); initInput(); initTransform(); diff --git a/libraries/gpu/src/gpu/GLBackend.h b/libraries/gpu/src/gpu/GLBackend.h index b4906b4ac7..b3e905bf21 100644 --- a/libraries/gpu/src/gpu/GLBackend.h +++ b/libraries/gpu/src/gpu/GLBackend.h @@ -447,8 +447,6 @@ protected: typedef void (GLBackend::*CommandCall)(Batch&, uint32); static CommandCall _commandCalls[Batch::NUM_COMMANDS]; - - static bool _initialized; }; From 837ff4576396c32bc102618860b57168cbf8c205 Mon Sep 17 00:00:00 2001 From: Sam Gateau Date: Wed, 22 Jul 2015 10:57:08 -0700 Subject: [PATCH 04/18] Removing code aroung the selfie fremebuffer --- libraries/render-utils/src/TextureCache.h | 5 ----- 1 file changed, 5 deletions(-) diff --git a/libraries/render-utils/src/TextureCache.h b/libraries/render-utils/src/TextureCache.h index 020b502eb9..be7aef5cfe 100644 --- a/libraries/render-utils/src/TextureCache.h +++ b/libraries/render-utils/src/TextureCache.h @@ -90,11 +90,6 @@ public: /// Returns the framebuffer object used to render shadow maps; gpu::FramebufferPointer getShadowFramebuffer(); - - // The framebuffer used for the selfie view of the avatar. used for creating the billboard view and the rearViewMirror image - gpu::FramebufferPointer getSelfieFramebuffer(); - - protected: virtual QSharedPointer createResource(const QUrl& url, From 55b4784a02969adbe4d7f4ae0ae44af41c720d9f Mon Sep 17 00:00:00 2001 From: Stephen Birarda Date: Wed, 22 Jul 2015 13:52:49 -0700 Subject: [PATCH 05/18] avoid entity-server node/octree deadlock on shutdown --- assignment-client/src/octree/OctreeSendThread.h | 2 +- assignment-client/src/octree/OctreeServer.cpp | 17 +++++++++++++---- 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/assignment-client/src/octree/OctreeSendThread.h b/assignment-client/src/octree/OctreeSendThread.h index 78f480b5eb..f22d63611c 100644 --- a/assignment-client/src/octree/OctreeSendThread.h +++ b/assignment-client/src/octree/OctreeSendThread.h @@ -42,7 +42,7 @@ protected: virtual bool process(); private: - OctreeServer* _myServer; + QPointer _myServer; SharedNodePointer _node; QUuid _nodeUUID; diff --git a/assignment-client/src/octree/OctreeServer.cpp b/assignment-client/src/octree/OctreeServer.cpp index f5d599b5d3..c018d65f98 100644 --- a/assignment-client/src/octree/OctreeServer.cpp +++ b/assignment-client/src/octree/OctreeServer.cpp @@ -1175,13 +1175,22 @@ void OctreeServer::aboutToFinish() { if (_jurisdictionSender) { _jurisdictionSender->terminating(); } + + QSet nodesToKill; - // force a shutdown of all of our OctreeSendThreads - at this point it has to be impossible for a - // linkedDataCreateCallback to be called for a new node - nodeList->eachNode([this](const SharedNodePointer& node) { + // Force a shutdown of all of our OctreeSendThreads. + // At this point it has to be impossible for a linkedDataCreateCallback to be called for a new node + nodeList->eachNode([&nodesToKill](const SharedNodePointer& node) { + nodesToKill << node; + }); + + // What follows is a hack to force OctreeSendThreads to cleanup before the OctreeServer is gone. + // I would prefer to allow the SharedNodePointer ref count drop to zero to do this automatically + // but that isn't possible as long as the OctreeSendThread has an OctreeServer* that it uses. + for (auto& node : nodesToKill) { qDebug() << qPrintable(_safeServerName) << "server about to finish while node still connected node:" << *node; forceNodeShutdown(node); - }); + } if (_persistThread) { _persistThread->aboutToFinish(); From d22219a1f2c00a98437de5ba2e87628a9b37d9ff Mon Sep 17 00:00:00 2001 From: Stephen Birarda Date: Wed, 22 Jul 2015 13:54:39 -0700 Subject: [PATCH 06/18] make myServer pointer an OctreeServer* again, it's not checked --- assignment-client/src/octree/OctreeSendThread.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/assignment-client/src/octree/OctreeSendThread.h b/assignment-client/src/octree/OctreeSendThread.h index f22d63611c..78f480b5eb 100644 --- a/assignment-client/src/octree/OctreeSendThread.h +++ b/assignment-client/src/octree/OctreeSendThread.h @@ -42,7 +42,7 @@ protected: virtual bool process(); private: - QPointer _myServer; + OctreeServer* _myServer; SharedNodePointer _node; QUuid _nodeUUID; From 67294d3a23ac3a7c1a8fb88c235cf16d4e829a20 Mon Sep 17 00:00:00 2001 From: Stephen Birarda Date: Wed, 22 Jul 2015 13:55:22 -0700 Subject: [PATCH 07/18] rename nodesToKill to nodesToShutdown --- assignment-client/src/octree/OctreeServer.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/assignment-client/src/octree/OctreeServer.cpp b/assignment-client/src/octree/OctreeServer.cpp index c018d65f98..76d701f0e3 100644 --- a/assignment-client/src/octree/OctreeServer.cpp +++ b/assignment-client/src/octree/OctreeServer.cpp @@ -1176,18 +1176,18 @@ void OctreeServer::aboutToFinish() { _jurisdictionSender->terminating(); } - QSet nodesToKill; + QSet nodesToShutdown; // Force a shutdown of all of our OctreeSendThreads. // At this point it has to be impossible for a linkedDataCreateCallback to be called for a new node - nodeList->eachNode([&nodesToKill](const SharedNodePointer& node) { - nodesToKill << node; + nodeList->eachNode([&nodesToShutdown](const SharedNodePointer& node) { + nodesToShutdown << node; }); // What follows is a hack to force OctreeSendThreads to cleanup before the OctreeServer is gone. // I would prefer to allow the SharedNodePointer ref count drop to zero to do this automatically // but that isn't possible as long as the OctreeSendThread has an OctreeServer* that it uses. - for (auto& node : nodesToKill) { + for (auto& node : nodesToShutdown) { qDebug() << qPrintable(_safeServerName) << "server about to finish while node still connected node:" << *node; forceNodeShutdown(node); } From 9e2eb7fdbdc861241ff4a93279b410884cb48841 Mon Sep 17 00:00:00 2001 From: Ryan Huffman Date: Wed, 22 Jul 2015 14:49:20 -0700 Subject: [PATCH 08/18] Fix face-camera functionality for BillboardOverlay --- interface/src/ui/overlays/BillboardOverlay.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/interface/src/ui/overlays/BillboardOverlay.cpp b/interface/src/ui/overlays/BillboardOverlay.cpp index b2843230f3..d26ecc5c67 100644 --- a/interface/src/ui/overlays/BillboardOverlay.cpp +++ b/interface/src/ui/overlays/BillboardOverlay.cpp @@ -91,6 +91,7 @@ void BillboardOverlay::render(RenderArgs* args) { if (batch) { Transform transform = _transform; transform.postScale(glm::vec3(getDimensions(), 1.0f)); + transform.setRotation(rotation); batch->setModelTransform(transform); batch->setResourceTexture(0, _texture->getGPUTexture()); From bf3ff8daea9e53359ea15e11c72d2ff0f1fe2b58 Mon Sep 17 00:00:00 2001 From: Andrew Meadows Date: Wed, 22 Jul 2015 15:06:10 -0700 Subject: [PATCH 09/18] fix crash for convex hull of co-planar points --- libraries/physics/src/ShapeFactory.cpp | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/libraries/physics/src/ShapeFactory.cpp b/libraries/physics/src/ShapeFactory.cpp index 74b0304ace..cfe7abd4db 100644 --- a/libraries/physics/src/ShapeFactory.cpp +++ b/libraries/physics/src/ShapeFactory.cpp @@ -43,9 +43,18 @@ btConvexHullShape* ShapeFactory::createConvexHull(const QVector& poin const float MIN_MARGIN = 0.01f; glm::vec3 diagonal = maxCorner - minCorner; - float minDimension = glm::min(diagonal[0], diagonal[1]); - minDimension = glm::min(minDimension, diagonal[2]); - margin = glm::min(glm::max(0.5f * minDimension, MIN_MARGIN), margin); + float smallestDimension = glm::min(diagonal[0], diagonal[1]); + smallestDimension = glm::min(smallestDimension, diagonal[2]); + const float MIN_DIMENSION = 2.0f * MIN_MARGIN + 0.001f; + if (smallestDimension < MIN_DIMENSION) { + for (int i = 0; i < 3; ++i) { + if (diagonal[i] < MIN_DIMENSION) { + diagonal[i] = MIN_DIMENSION; + } + } + smallestDimension = MIN_DIMENSION; + } + margin = glm::min(glm::max(0.5f * smallestDimension, MIN_MARGIN), margin); hull->setMargin(margin); // add the points, correcting for margin From 71eeecc7f6a4e3a25b1d5dc1e952d7a00c2bdae8 Mon Sep 17 00:00:00 2001 From: ZappoMan Date: Wed, 22 Jul 2015 16:53:56 -0700 Subject: [PATCH 10/18] Revert "Instrument the inter-idle time and tweaking the timeout setting" This reverts commit 0c88972f090abde0b2b91460aa4da37311445c9f. --- interface/src/Application.cpp | 25 +++---------------------- 1 file changed, 3 insertions(+), 22 deletions(-) diff --git a/interface/src/Application.cpp b/interface/src/Application.cpp index 7de69ef602..9cbe7ed37c 100644 --- a/interface/src/Application.cpp +++ b/interface/src/Application.cpp @@ -1761,25 +1761,8 @@ void Application::checkFPS() { } void Application::idle() { - PROFILE_RANGE(__FUNCTION__); - static SimpleAverage interIdleDurations; - static uint64_t lastIdleEnd{ 0 }; - - if (lastIdleEnd != 0) { - uint64_t now = usecTimestampNow(); - interIdleDurations.update(now - lastIdleEnd); - static uint64_t lastReportTime = now; - if ((now - lastReportTime) >= (USECS_PER_SECOND)) { - static QString LOGLINE("Average inter-idle time: %1 us for %2 samples"); - if (Menu::getInstance()->isOptionChecked(MenuOption::LogExtraTimings)) { - qCDebug(interfaceapp_timing) << LOGLINE.arg((int)interIdleDurations.getAverage()).arg(interIdleDurations.getCount()); - } - interIdleDurations.reset(); - lastReportTime = now; - } - } - PerformanceTimer perfTimer("idle"); + if (_aboutToQuit) { return; // bail early, nothing to do here. } @@ -1823,15 +1806,13 @@ void Application::idle() { _idleLoopStdev.reset(); } + // After finishing all of the above work, restart the idle timer, allowing 2ms to process events. + idleTimer->start(2); } - // After finishing all of the above work, ensure the idle timer is set to the proper interval, - // depending on whether we're throttling or not - idleTimer->start(_glWidget->isThrottleRendering() ? THROTTLED_IDLE_TIMER_DELAY : 1); } // check for any requested background downloads. emit checkBackgroundDownloads(); - lastIdleEnd = usecTimestampNow(); } void Application::setFullscreen(bool fullscreen) { From 785ae190cac19425ee3768d14fa791bda5aabd7c Mon Sep 17 00:00:00 2001 From: Stephen Birarda Date: Wed, 22 Jul 2015 17:49:27 -0700 Subject: [PATCH 11/18] add back send posted touch events --- interface/src/Application.cpp | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/interface/src/Application.cpp b/interface/src/Application.cpp index 9cbe7ed37c..3d44f45e38 100644 --- a/interface/src/Application.cpp +++ b/interface/src/Application.cpp @@ -882,7 +882,7 @@ void Application::paintGL() { // NOTE: There is no batch associated with this renderArgs // the ApplicationOverlay class assumes it's viewport is setup to be the device size QSize size = qApp->getDeviceSize(); - renderArgs._viewport = glm::ivec4(0, 0, size.width(), size.height()); + renderArgs._viewport = glm::ivec4(0, 0, size.width(), size.height()); _applicationOverlay.renderOverlay(&renderArgs); } @@ -959,7 +959,7 @@ void Application::paintGL() { batch.setFramebuffer(primaryFbo); // clear the normal and specular buffers batch.clearFramebuffer( - gpu::Framebuffer::BUFFER_COLOR0 | + gpu::Framebuffer::BUFFER_COLOR0 | gpu::Framebuffer::BUFFER_COLOR1 | gpu::Framebuffer::BUFFER_COLOR2 | gpu::Framebuffer::BUFFER_DEPTH, @@ -1781,6 +1781,14 @@ void Application::idle() { } double timeSinceLastUpdate = (double)_lastTimeUpdated.nsecsElapsed() / 1000000.0; if (timeSinceLastUpdate > targetFramePeriod) { + + { + PerformanceTimer perfTimer("sendPostedEvents(touch)"); + sendPostedEvents(NULL, QEvent::TouchBegin); + sendPostedEvents(NULL, QEvent::TouchUpdate); + sendPostedEvents(NULL, QEvent::TouchEnd); + } + _lastTimeUpdated.start(); { PerformanceTimer perfTimer("update"); @@ -1805,9 +1813,6 @@ void Application::idle() { _idleLoopMeasuredJitter = _idleLoopStdev.getStDev(); _idleLoopStdev.reset(); } - - // After finishing all of the above work, restart the idle timer, allowing 2ms to process events. - idleTimer->start(2); } } From b515b163fbd07a446e5bb73646d520739e66a8bf Mon Sep 17 00:00:00 2001 From: David Rowe Date: Wed, 22 Jul 2015 11:51:26 -0700 Subject: [PATCH 12/18] Remove dead code from Head --- interface/src/avatar/Avatar.cpp | 2 +- interface/src/avatar/Head.cpp | 2 +- interface/src/avatar/Head.h | 2 +- interface/src/avatar/MyAvatar.cpp | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/interface/src/avatar/Avatar.cpp b/interface/src/avatar/Avatar.cpp index 3a55e73fa6..a0414838ed 100644 --- a/interface/src/avatar/Avatar.cpp +++ b/interface/src/avatar/Avatar.cpp @@ -586,7 +586,7 @@ void Avatar::renderBody(RenderArgs* renderArgs, ViewFrustum* renderFrustum, bool getHand()->render(renderArgs, false); } } - getHead()->render(renderArgs, 1.0f, renderFrustum, postLighting); + getHead()->render(renderArgs, 1.0f, renderFrustum); } bool Avatar::shouldRenderHead(const RenderArgs* renderArgs) const { diff --git a/interface/src/avatar/Head.cpp b/interface/src/avatar/Head.cpp index 43e68557ce..040d145284 100644 --- a/interface/src/avatar/Head.cpp +++ b/interface/src/avatar/Head.cpp @@ -293,7 +293,7 @@ void Head::relaxLean(float deltaTime) { _deltaLeanForward *= relaxationFactor; } -void Head::render(RenderArgs* renderArgs, float alpha, ViewFrustum* renderFrustum, bool postLighting) { +void Head::render(RenderArgs* renderArgs, float alpha, ViewFrustum* renderFrustum) { if (_renderLookatVectors) { renderLookatVectors(renderArgs, _leftEyePosition, _rightEyePosition, getCorrectedLookAtPosition()); } diff --git a/interface/src/avatar/Head.h b/interface/src/avatar/Head.h index d7a8462693..f6283c93ea 100644 --- a/interface/src/avatar/Head.h +++ b/interface/src/avatar/Head.h @@ -33,7 +33,7 @@ public: void init(); void reset(); void simulate(float deltaTime, bool isMine, bool billboard = false); - void render(RenderArgs* renderArgs, float alpha, ViewFrustum* renderFrustum, bool postLighting); + void render(RenderArgs* renderArgs, float alpha, ViewFrustum* renderFrustum); void setScale(float scale); void setPosition(glm::vec3 position) { _position = position; } void setAverageLoudness(float averageLoudness) { _averageLoudness = averageLoudness; } diff --git a/interface/src/avatar/MyAvatar.cpp b/interface/src/avatar/MyAvatar.cpp index 4147d24b15..55202a9709 100644 --- a/interface/src/avatar/MyAvatar.cpp +++ b/interface/src/avatar/MyAvatar.cpp @@ -1236,7 +1236,7 @@ void MyAvatar::renderBody(RenderArgs* renderArgs, ViewFrustum* renderFrustum, bo // Render head so long as the camera isn't inside it if (shouldRenderHead(renderArgs)) { - getHead()->render(renderArgs, 1.0f, renderFrustum, postLighting); + getHead()->render(renderArgs, 1.0f, renderFrustum); } getHand()->render(renderArgs, true); } From 3362358dcd8323e7113e855423022f5126dbb5b8 Mon Sep 17 00:00:00 2001 From: David Rowe Date: Wed, 22 Jul 2015 16:14:27 -0700 Subject: [PATCH 13/18] Remove unused postLighting variable from Avatar and MyAvatar Fixes Leap and Hydra laser pointers not displaying. Enables: - Avatar billboard display - Avatar collision bounding shape display - Hand information display --- interface/src/avatar/Avatar.cpp | 47 +++++++++++++------------------ interface/src/avatar/Avatar.h | 5 ++-- interface/src/avatar/MyAvatar.cpp | 6 ++-- interface/src/avatar/MyAvatar.h | 4 +-- 4 files changed, 26 insertions(+), 36 deletions(-) diff --git a/interface/src/avatar/Avatar.cpp b/interface/src/avatar/Avatar.cpp index a0414838ed..9120632f80 100644 --- a/interface/src/avatar/Avatar.cpp +++ b/interface/src/avatar/Avatar.cpp @@ -316,15 +316,14 @@ void Avatar::removeFromScene(AvatarSharedPointer self, std::shared_ptrupdate(); } auto& batch = *renderArgs->_batch; - if (postLighting && - glm::distance(DependencyManager::get()->getMyAvatar()->getPosition(), _position) < 10.0f) { + if (glm::distance(DependencyManager::get()->getMyAvatar()->getPosition(), _position) < 10.0f) { auto geometryCache = DependencyManager::get(); auto deferredLighting = DependencyManager::get(); @@ -414,9 +413,9 @@ void Avatar::render(RenderArgs* renderArgs, const glm::vec3& cameraPosition, boo : GLOW_FROM_AVERAGE_LOUDNESS; // render body - renderBody(renderArgs, frustum, postLighting, glowLevel); + renderBody(renderArgs, frustum, glowLevel); - if (!postLighting && renderArgs->_renderMode != RenderArgs::SHADOW_RENDER_MODE) { + if (renderArgs->_renderMode != RenderArgs::SHADOW_RENDER_MODE) { // add local lights const float BASE_LIGHT_DISTANCE = 2.0f; const float LIGHT_EXPONENT = 1.0f; @@ -431,21 +430,17 @@ void Avatar::render(RenderArgs* renderArgs, const glm::vec3& cameraPosition, boo } } - if (postLighting) { - bool renderSkeleton = Menu::getInstance()->isOptionChecked(MenuOption::RenderSkeletonCollisionShapes); - bool renderHead = Menu::getInstance()->isOptionChecked(MenuOption::RenderHeadCollisionShapes); - bool renderBounding = Menu::getInstance()->isOptionChecked(MenuOption::RenderBoundingCollisionShapes); - - if (renderSkeleton) { - _skeletonModel.renderJointCollisionShapes(0.7f); - } - - if (renderHead && shouldRenderHead(renderArgs)) { - getHead()->getFaceModel().renderJointCollisionShapes(0.7f); - } - if (renderBounding && shouldRenderHead(renderArgs)) { - _skeletonModel.renderBoundingCollisionShapes(*renderArgs->_batch, 0.7f); - } + bool renderSkeleton = Menu::getInstance()->isOptionChecked(MenuOption::RenderSkeletonCollisionShapes); + bool renderHead = Menu::getInstance()->isOptionChecked(MenuOption::RenderHeadCollisionShapes); + bool renderBounding = Menu::getInstance()->isOptionChecked(MenuOption::RenderBoundingCollisionShapes); + if (renderSkeleton) { + _skeletonModel.renderJointCollisionShapes(0.7f); + } + if (renderHead && shouldRenderHead(renderArgs)) { + getHead()->getFaceModel().renderJointCollisionShapes(0.7f); + } + if (renderBounding && shouldRenderHead(renderArgs)) { + _skeletonModel.renderBoundingCollisionShapes(*renderArgs->_batch, 0.7f); } // Stack indicator spheres @@ -569,22 +564,18 @@ void Avatar::fixupModelsInScene() { scene->enqueuePendingChanges(pendingChanges); } -void Avatar::renderBody(RenderArgs* renderArgs, ViewFrustum* renderFrustum, bool postLighting, float glowLevel) { +void Avatar::renderBody(RenderArgs* renderArgs, ViewFrustum* renderFrustum, float glowLevel) { fixupModelsInScene(); { if (_shouldRenderBillboard || !(_skeletonModel.isRenderable() && getHead()->getFaceModel().isRenderable())) { - if (postLighting || renderArgs->_renderMode == RenderArgs::SHADOW_RENDER_MODE) { - // render the billboard until both models are loaded - renderBillboard(renderArgs); - } + // render the billboard until both models are loaded + renderBillboard(renderArgs); return; } - if (postLighting) { - getHand()->render(renderArgs, false); - } + getHand()->render(renderArgs, false); } getHead()->render(renderArgs, 1.0f, renderFrustum); } diff --git a/interface/src/avatar/Avatar.h b/interface/src/avatar/Avatar.h index ae99317541..253c94b0b3 100644 --- a/interface/src/avatar/Avatar.h +++ b/interface/src/avatar/Avatar.h @@ -81,8 +81,7 @@ public: void init(); void simulate(float deltaTime); - virtual void render(RenderArgs* renderArgs, const glm::vec3& cameraPosition, - bool postLighting = false); + virtual void render(RenderArgs* renderArgs, const glm::vec3& cameraPosition); bool addToScene(AvatarSharedPointer self, std::shared_ptr scene, render::PendingChanges& pendingChanges); @@ -235,7 +234,7 @@ protected: Transform calculateDisplayNameTransform(const ViewFrustum& frustum, float fontSize, const glm::ivec4& viewport) const; void renderDisplayName(gpu::Batch& batch, const ViewFrustum& frustum, const glm::ivec4& viewport) const; - virtual void renderBody(RenderArgs* renderArgs, ViewFrustum* renderFrustum, bool postLighting, float glowLevel = 0.0f); + virtual void renderBody(RenderArgs* renderArgs, ViewFrustum* renderFrustum, float glowLevel = 0.0f); virtual bool shouldRenderHead(const RenderArgs* renderArgs) const; virtual void fixupModelsInScene(); diff --git a/interface/src/avatar/MyAvatar.cpp b/interface/src/avatar/MyAvatar.cpp index 55202a9709..ac0cb3feda 100644 --- a/interface/src/avatar/MyAvatar.cpp +++ b/interface/src/avatar/MyAvatar.cpp @@ -332,13 +332,13 @@ void MyAvatar::updateFromTrackers(float deltaTime) { // virtual -void MyAvatar::render(RenderArgs* renderArgs, const glm::vec3& cameraPosition, bool postLighting) { +void MyAvatar::render(RenderArgs* renderArgs, const glm::vec3& cameraPosition) { // don't render if we've been asked to disable local rendering if (!_shouldRender) { return; // exit early } - Avatar::render(renderArgs, cameraPosition, postLighting); + Avatar::render(renderArgs, cameraPosition); // don't display IK constraints in shadow mode if (Menu::getInstance()->isOptionChecked(MenuOption::ShowIKConstraints) && @@ -1226,7 +1226,7 @@ void MyAvatar::attach(const QString& modelURL, const QString& jointName, const g Avatar::attach(modelURL, jointName, translation, rotation, scale, allowDuplicates, useSaved); } -void MyAvatar::renderBody(RenderArgs* renderArgs, ViewFrustum* renderFrustum, bool postLighting, float glowLevel) { +void MyAvatar::renderBody(RenderArgs* renderArgs, ViewFrustum* renderFrustum, float glowLevel) { if (!(_skeletonModel.isRenderable() && getHead()->getFaceModel().isRenderable())) { return; // wait until all models are loaded diff --git a/interface/src/avatar/MyAvatar.h b/interface/src/avatar/MyAvatar.h index 3253319204..b18b8df121 100644 --- a/interface/src/avatar/MyAvatar.h +++ b/interface/src/avatar/MyAvatar.h @@ -45,8 +45,8 @@ public: void preRender(RenderArgs* renderArgs); void updateFromTrackers(float deltaTime); - virtual void render(RenderArgs* renderArgs, const glm::vec3& cameraPosition, bool postLighting = false) override; - virtual void renderBody(RenderArgs* renderArgs, ViewFrustum* renderFrustum, bool postLighting, float glowLevel = 0.0f) override; + virtual void render(RenderArgs* renderArgs, const glm::vec3& cameraPositio) override; + virtual void renderBody(RenderArgs* renderArgs, ViewFrustum* renderFrustum, float glowLevel = 0.0f) override; virtual bool shouldRenderHead(const RenderArgs* renderArgs) const override; // setters From 11078d0d02d50cd081a7374aaf485432de225f50 Mon Sep 17 00:00:00 2001 From: David Rowe Date: Wed, 22 Jul 2015 16:15:17 -0700 Subject: [PATCH 14/18] Get Developer > Avatar > Show Collision Bounding Shapes working again Note: Currently doesn't display well because alpha isn't working. --- interface/src/avatar/SkeletonModel.cpp | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/interface/src/avatar/SkeletonModel.cpp b/interface/src/avatar/SkeletonModel.cpp index d92481494a..4963571f56 100644 --- a/interface/src/avatar/SkeletonModel.cpp +++ b/interface/src/avatar/SkeletonModel.cpp @@ -13,6 +13,7 @@ #include #include +#include #include #include "Application.h" @@ -785,31 +786,34 @@ void SkeletonModel::resetShapePositionsToDefaultPose() { void SkeletonModel::renderBoundingCollisionShapes(gpu::Batch& batch, float alpha) { const int BALL_SUBDIVISIONS = 10; if (_shapes.isEmpty()) { - // the bounding shape has not been propery computed + // the bounding shape has not been properly computed // so no need to render it return; } - // draw a blue sphere at the capsule endpoint + auto geometryCache = DependencyManager::get(); + auto deferredLighting = DependencyManager::get(); + Transform transform; // = Transform(); + + // draw a blue sphere at the capsule end point glm::vec3 endPoint; _boundingShape.getEndPoint(endPoint); endPoint = endPoint + _translation; - Transform transform = Transform(); transform.setTranslation(endPoint); batch.setModelTransform(transform); - auto geometryCache = DependencyManager::get(); - geometryCache->renderSphere(batch, _boundingShape.getRadius(), BALL_SUBDIVISIONS, BALL_SUBDIVISIONS, + deferredLighting->bindSimpleProgram(batch); + geometryCache->renderSphere(batch, _boundingShape.getRadius(), BALL_SUBDIVISIONS, BALL_SUBDIVISIONS, glm::vec4(0.6f, 0.6f, 0.8f, alpha)); - // draw a yellow sphere at the capsule startpoint + // draw a yellow sphere at the capsule start point glm::vec3 startPoint; _boundingShape.getStartPoint(startPoint); startPoint = startPoint + _translation; glm::vec3 axis = endPoint - startPoint; - Transform axisTransform = Transform(); - axisTransform.setTranslation(-axis); - batch.setModelTransform(axisTransform); - geometryCache->renderSphere(batch, _boundingShape.getRadius(), BALL_SUBDIVISIONS, BALL_SUBDIVISIONS, + transform.setTranslation(startPoint); + batch.setModelTransform(transform); + deferredLighting->bindSimpleProgram(batch); + geometryCache->renderSphere(batch, _boundingShape.getRadius(), BALL_SUBDIVISIONS, BALL_SUBDIVISIONS, glm::vec4(0.8f, 0.8f, 0.6f, alpha)); // draw a green cylinder between the two points From db5e8c72ee58388edde2aea7ce47adc903abce70 Mon Sep 17 00:00:00 2001 From: Stephen Birarda Date: Wed, 22 Jul 2015 17:59:07 -0700 Subject: [PATCH 15/18] force event processing up to a certain max time --- interface/src/Application.cpp | 36 ++++++++++++++++++++++++++++++----- 1 file changed, 31 insertions(+), 5 deletions(-) diff --git a/interface/src/Application.cpp b/interface/src/Application.cpp index 3d44f45e38..7acc05236e 100644 --- a/interface/src/Application.cpp +++ b/interface/src/Application.cpp @@ -1761,8 +1761,25 @@ void Application::checkFPS() { } void Application::idle() { - PerformanceTimer perfTimer("idle"); + PROFILE_RANGE(__FUNCTION__); + static SimpleAverage interIdleDurations; + static uint64_t lastIdleEnd{ 0 }; + if (lastIdleEnd != 0) { + uint64_t now = usecTimestampNow(); + interIdleDurations.update(now - lastIdleEnd); + static uint64_t lastReportTime = now; + if ((now - lastReportTime) >= (USECS_PER_SECOND)) { + static QString LOGLINE("Average inter-idle time: %1 us for %2 samples"); + if (Menu::getInstance()->isOptionChecked(MenuOption::LogExtraTimings)) { + qCDebug(interfaceapp_timing) << LOGLINE.arg((int)interIdleDurations.getAverage()).arg(interIdleDurations.getCount()); + } + interIdleDurations.reset(); + lastReportTime = now; + } + } + + PerformanceTimer perfTimer("idle"); if (_aboutToQuit) { return; // bail early, nothing to do here. } @@ -1783,10 +1800,9 @@ void Application::idle() { if (timeSinceLastUpdate > targetFramePeriod) { { - PerformanceTimer perfTimer("sendPostedEvents(touch)"); - sendPostedEvents(NULL, QEvent::TouchBegin); - sendPostedEvents(NULL, QEvent::TouchUpdate); - sendPostedEvents(NULL, QEvent::TouchEnd); + static const int IDLE_EVENT_PROCESS_MAX_TIME_MS = 2; + PerformanceTimer perfTimer("processEvents"); + processEvents(QEventLoop::AllEvents, IDLE_EVENT_PROCESS_MAX_TIME_MS); } _lastTimeUpdated.start(); @@ -1814,10 +1830,20 @@ void Application::idle() { _idleLoopStdev.reset(); } } + + // After finishing all of the above work, ensure the idle timer is set to the proper interval, + // depending on whether we're throttling or not. + // Once rendering is off on another thread we should be able to have Application::idle run at start(0) in + // perpetuity and not expect events to get backed up. + + static const int IDLE_TIMER_DELAY_MS = 0; + + idleTimer->start(_glWidget->isThrottleRendering() ? THROTTLED_IDLE_TIMER_DELAY : IDLE_TIMER_DELAY_MS); } // check for any requested background downloads. emit checkBackgroundDownloads(); + lastIdleEnd = usecTimestampNow(); } void Application::setFullscreen(bool fullscreen) { From 7cee5f3ce5c49bfb311b1d538a38409e935bbcee Mon Sep 17 00:00:00 2001 From: Stephen Birarda Date: Wed, 22 Jul 2015 18:05:04 -0700 Subject: [PATCH 16/18] don't reset the idleTimer if the interval hasn't changed --- interface/src/Application.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/interface/src/Application.cpp b/interface/src/Application.cpp index 7acc05236e..0a5d9bd68e 100644 --- a/interface/src/Application.cpp +++ b/interface/src/Application.cpp @@ -1837,8 +1837,11 @@ void Application::idle() { // perpetuity and not expect events to get backed up. static const int IDLE_TIMER_DELAY_MS = 0; + int desiredInterval = _glWidget->isThrottleRendering() ? THROTTLED_IDLE_TIMER_DELAY : IDLE_TIMER_DELAY_MS; - idleTimer->start(_glWidget->isThrottleRendering() ? THROTTLED_IDLE_TIMER_DELAY : IDLE_TIMER_DELAY_MS); + if (idleTimer->interval() != desiredInterval) { + idleTimer->start(desiredInterval); + } } // check for any requested background downloads. From 198b6cfa887b8c5127ab049d6ac91f320c54c7f5 Mon Sep 17 00:00:00 2001 From: Ryan Huffman Date: Thu, 23 Jul 2015 06:17:08 -0700 Subject: [PATCH 17/18] Fix ray picking working intermittently Ray picking relies on the Application's viewFrustum which was being set to both the main camera and mirror camera for their respective pass while rendering. This makes sure the viewFrustum only ever holds the main camera. Application::_displayViewFrustum still gets updated to the current camera while rendering. --- interface/src/Application.cpp | 3 --- 1 file changed, 3 deletions(-) diff --git a/interface/src/Application.cpp b/interface/src/Application.cpp index 9cbe7ed37c..a3e8e61fc4 100644 --- a/interface/src/Application.cpp +++ b/interface/src/Application.cpp @@ -3395,9 +3395,6 @@ void Application::renderRearViewMirror(RenderArgs* renderArgs, const QRect& regi renderArgs->_context->render(batch); } - bool updateViewFrustum = false; - loadViewFrustum(_mirrorCamera, _viewFrustum); - // render rear mirror view displaySide(renderArgs, _mirrorCamera, true, billboard); From c17a603714bbe222e84e195d61f4987bebdb921f Mon Sep 17 00:00:00 2001 From: Ryan Huffman Date: Thu, 23 Jul 2015 08:42:29 -0700 Subject: [PATCH 18/18] Fix model entity not showing up in list on creation --- examples/edit.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/examples/edit.js b/examples/edit.js index b33f47c2b7..1af016958f 100644 --- a/examples/edit.js +++ b/examples/edit.js @@ -318,11 +318,15 @@ var toolBar = (function () { print("Resize failed: timed out waiting for model (" + url + ") to load"); } } else { - entityProperties.dimensions = naturalDimensions; - Entities.editEntity(entityId, entityProperties); + Entities.editEntity(entityId, { dimensions: naturalDimensions }); + + // Reset selection so that the selection overlays will be updated + selectionManager.setSelections([entityId]); } } + selectionManager.setSelections([entityId]); + Script.setTimeout(resize, RESIZE_INTERVAL); } else { print("Can't add model: Model would be out of bounds.");