From b2788570916b7eccb302409b4688ba9c74786a5b Mon Sep 17 00:00:00 2001 From: Andrzej Kapolka Date: Fri, 5 Sep 2014 13:51:22 -0700 Subject: [PATCH 1/5] Wireframe option, fix for shadow menu group. --- interface/src/Application.cpp | 8 ++++++++ interface/src/Menu.cpp | 3 ++- interface/src/Menu.h | 1 + 3 files changed, 11 insertions(+), 1 deletion(-) diff --git a/interface/src/Application.cpp b/interface/src/Application.cpp index 966f222c52..3f7ee7a776 100644 --- a/interface/src/Application.cpp +++ b/interface/src/Application.cpp @@ -2809,6 +2809,10 @@ void Application::displaySide(Camera& whichCamera, bool selfAvatarOnly) { _stars.render(whichCamera.getFieldOfView(), whichCamera.getAspectRatio(), whichCamera.getNearClip(), alpha); } + if (Menu::getInstance()->isOptionChecked(MenuOption::Wireframe)) { + glPolygonMode(GL_FRONT_AND_BACK, GL_LINE); + } + // draw the sky dome if (!selfAvatarOnly && Menu::getInstance()->isOptionChecked(MenuOption::Atmosphere)) { PerformanceTimer perfTimer("atmosphere"); @@ -2947,6 +2951,10 @@ void Application::displaySide(Camera& whichCamera, bool selfAvatarOnly) { _overlays.render3D(); } } + + if (Menu::getInstance()->isOptionChecked(MenuOption::Wireframe)) { + glPolygonMode(GL_FRONT_AND_BACK, GL_FILL); + } } void Application::updateUntranslatedViewMatrix(const glm::vec3& viewMatrixTranslation) { diff --git a/interface/src/Menu.cpp b/interface/src/Menu.cpp index e78b954fd5..f95301027e 100644 --- a/interface/src/Menu.cpp +++ b/interface/src/Menu.cpp @@ -370,7 +370,7 @@ Menu::Menu() : shadowGroup->addAction(addCheckableActionToQMenuAndActionHash(shadowMenu, "None", 0, true)); shadowGroup->addAction(addCheckableActionToQMenuAndActionHash(shadowMenu, MenuOption::SimpleShadows, 0, false)); shadowGroup->addAction(addCheckableActionToQMenuAndActionHash(shadowMenu, MenuOption::CascadedShadows, 0, false)); - shadowGroup->addAction(addCheckableActionToQMenuAndActionHash(shadowMenu, MenuOption::AvatarsReceiveShadows, 0, true)); + addCheckableActionToQMenuAndActionHash(shadowMenu, MenuOption::AvatarsReceiveShadows, 0, true); addCheckableActionToQMenuAndActionHash(renderOptionsMenu, MenuOption::Stars, Qt::Key_Asterisk, true); @@ -386,6 +386,7 @@ Menu::Menu() : 0, appInstance->getGlowEffect(), SLOT(cycleRenderMode())); + addCheckableActionToQMenuAndActionHash(renderOptionsMenu, MenuOption::Wireframe, 0, false); addActionToQMenuAndActionHash(renderOptionsMenu, MenuOption::LodTools, Qt::SHIFT | Qt::Key_L, this, SLOT(lodTools())); QMenu* avatarDebugMenu = developerMenu->addMenu("Avatar"); diff --git a/interface/src/Menu.h b/interface/src/Menu.h index 42b6af5b80..dd77c50968 100644 --- a/interface/src/Menu.h +++ b/interface/src/Menu.h @@ -471,6 +471,7 @@ namespace MenuOption { const QString Voxels = "Voxels"; const QString VoxelTextures = "Voxel Textures"; const QString WalletPrivateKey = "Wallet Private Key..."; + const QString Wireframe = "Wireframe"; } void sendFakeEnterEvent(); From 98c51f87d2e37a3dd5729b6edc14ebd689bbc47c Mon Sep 17 00:00:00 2001 From: Andrzej Kapolka Date: Fri, 5 Sep 2014 14:00:27 -0700 Subject: [PATCH 2/5] Make sure edit colors are either 100% opaque or 100% transparent. --- interface/src/ui/MetavoxelEditor.cpp | 24 ++++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) diff --git a/interface/src/ui/MetavoxelEditor.cpp b/interface/src/ui/MetavoxelEditor.cpp index dc669365e8..0871da3be8 100644 --- a/interface/src/ui/MetavoxelEditor.cpp +++ b/interface/src/ui/MetavoxelEditor.cpp @@ -1251,8 +1251,11 @@ QColor VoxelColorBoxTool::getColor() { } void VoxelColorBoxTool::applyValue(const glm::vec3& minimum, const glm::vec3& maximum) { + // ensure that color is either 100% transparent or 100% opaque + QColor color = _color->getColor(); + color.setAlphaF(color.alphaF() > 0.5f ? 1.0f : 0.0f); MetavoxelEditMessage message = { QVariant::fromValue(VoxelColorBoxEdit(Box(minimum, maximum), - _editor->getGridSpacing(), _color->getColor())) }; + _editor->getGridSpacing(), color)) }; Application::getInstance()->getMetavoxels()->applyEdit(message, true); } @@ -1279,8 +1282,13 @@ QColor VoxelMaterialBoxTool::getColor() { void VoxelMaterialBoxTool::applyValue(const glm::vec3& minimum, const glm::vec3& maximum) { SharedObjectPointer material = _materialEditor->getObject(); _materialEditor->detachObject(); + QColor color; + if (_texture) { + color = _texture->getAverageColor(); + color.setAlphaF(1.0f); + } MetavoxelEditMessage message = { QVariant::fromValue(VoxelMaterialBoxEdit(Box(minimum, maximum), - _editor->getGridSpacing(), material, _texture ? _texture->getAverageColor() : QColor())) }; + _editor->getGridSpacing(), material, color)) }; Application::getInstance()->getMetavoxels()->applyEdit(message, true); } @@ -1363,8 +1371,11 @@ QColor VoxelColorSphereTool::getColor() { } void VoxelColorSphereTool::applyValue(const glm::vec3& position, float radius) { + // ensure that color is either 100% transparent or 100% opaque + QColor color = _color->getColor(); + color.setAlphaF(color.alphaF() > 0.5f ? 1.0f : 0.0f); MetavoxelEditMessage message = { QVariant::fromValue(VoxelColorSphereEdit(position, radius, - _editor->getGridSpacing(), _color->getColor())) }; + _editor->getGridSpacing(), color)) }; Application::getInstance()->getMetavoxels()->applyEdit(message, true); } @@ -1386,8 +1397,13 @@ QColor VoxelMaterialSphereTool::getColor() { void VoxelMaterialSphereTool::applyValue(const glm::vec3& position, float radius) { SharedObjectPointer material = _materialEditor->getObject(); _materialEditor->detachObject(); + QColor color; + if (_texture) { + color = _texture->getAverageColor(); + color.setAlphaF(1.0f); + } MetavoxelEditMessage message = { QVariant::fromValue(VoxelMaterialSphereEdit(position, radius, - _editor->getGridSpacing(), material, _texture ? _texture->getAverageColor() : QColor())) }; + _editor->getGridSpacing(), material, color)) }; Application::getInstance()->getMetavoxels()->applyEdit(message, true); } From 37b4fe51665decb0b4ec9841f7fdc4377947c3fc Mon Sep 17 00:00:00 2001 From: Andrzej Kapolka Date: Fri, 5 Sep 2014 14:16:12 -0700 Subject: [PATCH 3/5] Fix for deferred lighting/ambient occlusion when glow effect is disabled. --- interface/src/Application.cpp | 19 ++++--------------- interface/src/renderer/GlowEffect.cpp | 2 +- 2 files changed, 5 insertions(+), 16 deletions(-) diff --git a/interface/src/Application.cpp b/interface/src/Application.cpp index 3f7ee7a776..b33f2d3d9d 100644 --- a/interface/src/Application.cpp +++ b/interface/src/Application.cpp @@ -589,8 +589,6 @@ void Application::paintGL() { bool showWarnings = Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings); PerformanceWarning warn(showWarnings, "Application::paintGL()"); - const bool glowEnabled = Menu::getInstance()->isOptionChecked(MenuOption::EnableGlowEffect); - // Set the desired FBO texture size. If it hasn't changed, this does nothing. // Otherwise, it must rebuild the FBOs if (OculusManager::isConnected()) { @@ -665,16 +663,11 @@ void Application::paintGL() { updateShadowMap(); } - //If we aren't using the glow shader, we have to clear the color and depth buffer - if (!glowEnabled) { - glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); - } else if (OculusManager::isConnected()) { + if (OculusManager::isConnected()) { //Clear the color buffer to ensure that there isnt any residual color //Left over from when OR was not connected. glClear(GL_COLOR_BUFFER_BIT); - } - - if (OculusManager::isConnected()) { + //When in mirror mode, use camera rotation. Otherwise, use body rotation if (whichCamera.getMode() == CAMERA_MODE_MIRROR) { OculusManager::display(whichCamera.getRotation(), whichCamera.getPosition(), whichCamera); @@ -687,9 +680,7 @@ void Application::paintGL() { TV3DManager::display(whichCamera); } else { - if (glowEnabled) { - _glowEffect.prepare(); - } + _glowEffect.prepare(); glMatrixMode(GL_MODELVIEW); glPushMatrix(); @@ -697,9 +688,7 @@ void Application::paintGL() { displaySide(whichCamera); glPopMatrix(); - if (glowEnabled) { - _glowEffect.render(); - } + _glowEffect.render(); if (Menu::getInstance()->isOptionChecked(MenuOption::Mirror)) { renderRearViewMirror(_mirrorViewRect); diff --git a/interface/src/renderer/GlowEffect.cpp b/interface/src/renderer/GlowEffect.cpp index 1fdebb66d7..8341bb960c 100644 --- a/interface/src/renderer/GlowEffect.cpp +++ b/interface/src/renderer/GlowEffect.cpp @@ -140,7 +140,7 @@ QOpenGLFramebufferObject* GlowEffect::render(bool toTexture) { QOpenGLFramebufferObject* destFBO = toTexture ? Application::getInstance()->getTextureCache()->getSecondaryFramebufferObject() : NULL; - if (_isEmpty && _renderMode != DIFFUSE_ADD_MODE) { + if (!Menu::getInstance()->isOptionChecked(MenuOption::EnableGlowEffect) || (_isEmpty && _renderMode != DIFFUSE_ADD_MODE)) { // copy the primary to the screen if (QOpenGLFramebufferObject::hasOpenGLFramebufferBlit()) { QOpenGLFramebufferObject::blitFramebuffer(destFBO, primaryFBO); From 742989a0e4f16c2ccb0cf61dc08d43b549b91bf6 Mon Sep 17 00:00:00 2001 From: Andrzej Kapolka Date: Fri, 5 Sep 2014 14:35:32 -0700 Subject: [PATCH 4/5] Save metavoxel data regularly, as with voxel data. --- .../src/metavoxels/MetavoxelServer.cpp | 25 ++++++++++++++++--- .../src/metavoxels/MetavoxelServer.h | 3 +++ 2 files changed, 25 insertions(+), 3 deletions(-) diff --git a/assignment-client/src/metavoxels/MetavoxelServer.cpp b/assignment-client/src/metavoxels/MetavoxelServer.cpp index 3535a00573..fdb8065359 100644 --- a/assignment-client/src/metavoxels/MetavoxelServer.cpp +++ b/assignment-client/src/metavoxels/MetavoxelServer.cpp @@ -23,7 +23,8 @@ MetavoxelServer::MetavoxelServer(const QByteArray& packet) : ThreadedAssignment(packet), - _nextSender(0) { + _nextSender(0), + _savedDataInitialized(false) { } void MetavoxelServer::applyEdit(const MetavoxelEditMessage& edit) { @@ -33,8 +34,20 @@ void MetavoxelServer::applyEdit(const MetavoxelEditMessage& edit) { } void MetavoxelServer::setData(const MetavoxelData& data) { - if (_data != data) { - emit dataChanged(_data = data); + if (_data == data) { + return; + } + emit dataChanged(_data = data); + + if (!_savedDataInitialized) { + _savedData = data; + _savedDataInitialized = true; + + // start the save timer + QTimer* saveTimer = new QTimer(); + connect(saveTimer, &QTimer::timeout, this, &MetavoxelServer::maybeSaveData); + const int SAVE_INTERVAL = 1000 * 30; + saveTimer->start(SAVE_INTERVAL); } } @@ -135,6 +148,12 @@ void MetavoxelServer::maybeDeleteSession(const SharedNodePointer& node) { } } +void MetavoxelServer::maybeSaveData() { + if (_savedData != _data) { + QMetaObject::invokeMethod(_persister, "save", Q_ARG(const MetavoxelData&, _savedData = _data)); + } +} + MetavoxelSender::MetavoxelSender(MetavoxelServer* server) : _server(server), _sendTimer(this) { diff --git a/assignment-client/src/metavoxels/MetavoxelServer.h b/assignment-client/src/metavoxels/MetavoxelServer.h index 6d62884633..70c49fad64 100644 --- a/assignment-client/src/metavoxels/MetavoxelServer.h +++ b/assignment-client/src/metavoxels/MetavoxelServer.h @@ -52,6 +52,7 @@ private slots: void maybeAttachSession(const SharedNodePointer& node); void maybeDeleteSession(const SharedNodePointer& node); + void maybeSaveData(); private: @@ -61,6 +62,8 @@ private: MetavoxelPersister* _persister; MetavoxelData _data; + MetavoxelData _savedData; + bool _savedDataInitialized; }; /// Handles update sending for one thread. From e476119bd19dc5933125c738b3e7ba471839d131 Mon Sep 17 00:00:00 2001 From: Andrzej Kapolka Date: Fri, 5 Sep 2014 14:51:14 -0700 Subject: [PATCH 5/5] Timer should be a child of the server object. --- assignment-client/src/metavoxels/MetavoxelServer.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/assignment-client/src/metavoxels/MetavoxelServer.cpp b/assignment-client/src/metavoxels/MetavoxelServer.cpp index fdb8065359..a74b5bee90 100644 --- a/assignment-client/src/metavoxels/MetavoxelServer.cpp +++ b/assignment-client/src/metavoxels/MetavoxelServer.cpp @@ -44,7 +44,7 @@ void MetavoxelServer::setData(const MetavoxelData& data) { _savedDataInitialized = true; // start the save timer - QTimer* saveTimer = new QTimer(); + QTimer* saveTimer = new QTimer(this); connect(saveTimer, &QTimer::timeout, this, &MetavoxelServer::maybeSaveData); const int SAVE_INTERVAL = 1000 * 30; saveTimer->start(SAVE_INTERVAL);