From f1b85aefa9633b797ce6673414b44dd9f5edb82f Mon Sep 17 00:00:00 2001 From: ZappoMan Date: Tue, 14 Jul 2015 17:59:20 -0700 Subject: [PATCH] more dead code removal: NodeBounds --- interface/src/Application.cpp | 3 - interface/src/Application.h | 5 - interface/src/Menu.cpp | 8 -- interface/src/ui/ApplicationOverlay.cpp | 13 -- interface/src/ui/NodeBounds.cpp | 183 ------------------------ interface/src/ui/NodeBounds.h | 47 ------ 6 files changed, 259 deletions(-) delete mode 100644 interface/src/ui/NodeBounds.cpp delete mode 100644 interface/src/ui/NodeBounds.h diff --git a/interface/src/Application.cpp b/interface/src/Application.cpp index a0a4af29f6..65615a65b0 100644 --- a/interface/src/Application.cpp +++ b/interface/src/Application.cpp @@ -337,7 +337,6 @@ Application::Application(int& argc, char** argv, QElapsedTimer &startup_time) : _mousePressed(false), _enableProcessOctreeThread(true), _octreeProcessor(), - _nodeBoundsDisplay(this), _runningScriptsWidget(NULL), _runningScriptsWidgetWasVisible(false), _trayIcon(new QSystemTrayIcon(_window)), @@ -3587,8 +3586,6 @@ void Application::displaySide(RenderArgs* renderArgs, Camera& theCamera, bool se } if (!selfAvatarOnly) { - _nodeBoundsDisplay.draw(); - // give external parties a change to hook in { PerformanceTimer perfTimer("inWorldInterface"); diff --git a/interface/src/Application.h b/interface/src/Application.h index 55dbaf7f27..44ead54563 100644 --- a/interface/src/Application.h +++ b/interface/src/Application.h @@ -60,7 +60,6 @@ #include "ui/BandwidthDialog.h" #include "ui/HMDToolsDialog.h" #include "ui/ModelsBrowser.h" -#include "ui/NodeBounds.h" #include "ui/OctreeStatsDialog.h" #include "ui/SnapshotShareDialog.h" #include "ui/LodToolsDialog.h" @@ -303,8 +302,6 @@ public: virtual void endOverrideEnvironmentData() { _environment.endOverride(); } virtual qreal getDevicePixelRatio(); - NodeBounds& getNodeBoundsDisplay() { return _nodeBoundsDisplay; } - FileLogger* getLogger() { return _logger; } glm::vec2 getViewportDimensions() const; @@ -621,8 +618,6 @@ private: NodeToOctreeSceneStats _octreeServerSceneStats; QReadWriteLock _octreeSceneStatsLock; - NodeBounds _nodeBoundsDisplay; - ControllerScriptingInterface _controllerScriptingInterface; QPointer _logDialog; QPointer _snapshotShareDialog; diff --git a/interface/src/Menu.cpp b/interface/src/Menu.cpp index ff6a144fce..60311904de 100644 --- a/interface/src/Menu.cpp +++ b/interface/src/Menu.cpp @@ -37,7 +37,6 @@ #include "SpeechRecognizer.h" #endif #include "ui/DialogsManager.h" -#include "ui/NodeBounds.h" #include "ui/StandAloneJSConsole.h" #include "InterfaceLogging.h" @@ -316,13 +315,6 @@ Menu::Menu() { qApp, SLOT(setEnable3DTVMode(bool))); - - MenuWrapper* nodeBordersMenu = viewMenu->addMenu("Server Borders"); - NodeBounds& nodeBounds = qApp->getNodeBoundsDisplay(); - addCheckableActionToQMenuAndActionHash(nodeBordersMenu, MenuOption::ShowBordersEntityNodes, - Qt::CTRL | Qt::SHIFT | Qt::Key_1, false, - &nodeBounds, SLOT(setShowEntityNodes(bool))); - addCheckableActionToQMenuAndActionHash(viewMenu, MenuOption::TurnWithHead, 0, false); addCheckableActionToQMenuAndActionHash(viewMenu, MenuOption::Stats); diff --git a/interface/src/ui/ApplicationOverlay.cpp b/interface/src/ui/ApplicationOverlay.cpp index 44904a8655..b28c5c83a2 100644 --- a/interface/src/ui/ApplicationOverlay.cpp +++ b/interface/src/ui/ApplicationOverlay.cpp @@ -165,19 +165,6 @@ void ApplicationOverlay::renderStatsAndLogs(RenderArgs* renderArgs) { drawText(canvasSize.x - 100, canvasSize.y - timerBottom, 0.30f, 0.0f, 0, frameTimer.toUtf8().constData(), WHITE_TEXT); } - - glPointSize(1.0f); - glDisable(GL_DEPTH_TEST); - glDisable(GL_LIGHTING); - glEnable(GL_BLEND); - glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); - NodeBounds& nodeBoundsDisplay = qApp->getNodeBoundsDisplay(); - nodeBoundsDisplay.drawOverlay(); - glEnable(GL_DEPTH_TEST); - glEnable(GL_LIGHTING); - glEnable(GL_BLEND); - glBlendFuncSeparate(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, GL_CONSTANT_ALPHA, GL_ONE); - fboViewport(_overlayFramebuffer); */ } diff --git a/interface/src/ui/NodeBounds.cpp b/interface/src/ui/NodeBounds.cpp deleted file mode 100644 index 2b1b2f56e1..0000000000 --- a/interface/src/ui/NodeBounds.cpp +++ /dev/null @@ -1,183 +0,0 @@ -// -// NodeBounds.cpp -// interface/src/ui -// -// Created by Ryan Huffman on 05/14/14. -// Copyright 2014 High Fidelity, Inc. -// -// This class draws a border around the different Entity nodes on the current domain, -// and a semi-transparent cube around the currently mouse-overed node. -// -// 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 - -#include "Application.h" -#include "Util.h" - -#include "NodeBounds.h" - -NodeBounds::NodeBounds(QObject* parent) : - QObject(parent), - _showEntityNodes(false), - _overlayText() { - -} - -void NodeBounds::draw() { - if (!_showEntityNodes) { - _overlayText[0] = '\0'; - return; - } - - NodeToJurisdictionMap& entityServerJurisdictions = Application::getInstance()->getEntityServerJurisdictions(); - NodeToJurisdictionMap* serverJurisdictions; - - // Compute ray to find selected nodes later on. We can't use the pre-computed ray in Application because it centers - // itself after the cursor disappears. - PickRay pickRay = qApp->computePickRay(); - - // Variables to keep track of the selected node and properties to draw the cube later if needed - Node* selectedNode = NULL; - float selectedDistance = FLT_MAX; - bool selectedIsInside = true; - glm::vec3 selectedCenter; - float selectedScale = 0; - - auto nodeList = DependencyManager::get(); - nodeList->eachNode([&](const SharedNodePointer& node){ - NodeType_t nodeType = node->getType(); - - if (nodeType == NodeType::EntityServer && _showEntityNodes) { - serverJurisdictions = &entityServerJurisdictions; - } else { - return; - } - - QUuid nodeUUID = node->getUUID(); - serverJurisdictions->lockForRead(); - if (serverJurisdictions->find(nodeUUID) != serverJurisdictions->end()) { - const JurisdictionMap& map = (*serverJurisdictions)[nodeUUID]; - - unsigned char* rootCode = map.getRootOctalCode(); - - if (rootCode) { - VoxelPositionSize rootDetails; - voxelDetailsForCode(rootCode, rootDetails); - serverJurisdictions->unlock(); - glm::vec3 location(rootDetails.x, rootDetails.y, rootDetails.z); - - AACube serverBounds(location, rootDetails.s); - - glm::vec3 center = serverBounds.getVertex(BOTTOM_RIGHT_NEAR) - + ((serverBounds.getVertex(TOP_LEFT_FAR) - serverBounds.getVertex(BOTTOM_RIGHT_NEAR)) / 2.0f); - - const float ENTITY_NODE_SCALE = 0.99f; - - float scaleFactor = rootDetails.s; - - // Scale by 0.92 - 1.00 depending on the scale of the node. This allows smaller nodes to scale in - // a bit and not overlap larger nodes. - scaleFactor *= 0.92f + (rootDetails.s * 0.08f); - - // Scale different node types slightly differently because it's common for them to overlap. - if (nodeType == NodeType::EntityServer) { - scaleFactor *= ENTITY_NODE_SCALE; - } - - float red, green, blue; - getColorForNodeType(nodeType, red, green, blue); - drawNodeBorder(center, scaleFactor, red, green, blue); - - float distance; - BoxFace face; - - bool inside = serverBounds.contains(pickRay.origin); - bool colliding = serverBounds.findRayIntersection(pickRay.origin, pickRay.direction, distance, face); - - // If the camera is inside a node it will be "selected" if you don't have your cursor over another node - // that you aren't inside. - if (colliding && (!selectedNode || (!inside && (distance < selectedDistance || selectedIsInside)))) { - selectedNode = node.data(); - selectedDistance = distance; - selectedIsInside = inside; - selectedCenter = center; - selectedScale = scaleFactor; - } - } else { - serverJurisdictions->unlock(); - } - } else { - serverJurisdictions->unlock(); - } - }); - - if (selectedNode) { - glPushMatrix(); - - glTranslatef(selectedCenter.x, selectedCenter.y, selectedCenter.z); - glScalef(selectedScale, selectedScale, selectedScale); - - float red, green, blue; - getColorForNodeType(selectedNode->getType(), red, green, blue); - - DependencyManager::get()->renderSolidCube(1.0f, glm::vec4(red, green, blue, 0.2f)); - - glPopMatrix(); - - HifiSockAddr addr = selectedNode->getPublicSocket(); - QString overlay = QString("%1:%2 %3ms") - .arg(addr.getAddress().toString()) - .arg(addr.getPort()) - .arg(selectedNode->getPingMs()) - .left(MAX_OVERLAY_TEXT_LENGTH); - - // Ideally we'd just use a QString, but I ran into weird blinking issues using - // constData() directly, as if the data was being overwritten. - strcpy(_overlayText, overlay.toLocal8Bit().constData()); - } else { - _overlayText[0] = '\0'; - } -} - -void NodeBounds::drawNodeBorder(const glm::vec3& center, float scale, float red, float green, float blue) { - glPushMatrix(); - glTranslatef(center.x, center.y, center.z); - glScalef(scale, scale, scale); - glLineWidth(2.5); - DependencyManager::get()->renderWireCube(1.0f, glm::vec4(red, green, blue, 1.0f)); - glPopMatrix(); -} - -void NodeBounds::getColorForNodeType(NodeType_t nodeType, float& red, float& green, float& blue) { - red = nodeType == 0.0; - green = 0.0; - blue = nodeType == NodeType::EntityServer ? 1.0 : 0.0; -} - -void NodeBounds::drawOverlay() { - if (strlen(_overlayText) > 0) { - Application* application = Application::getInstance(); - - const float TEXT_COLOR[] = { 0.90f, 0.90f, 0.90f }; - const float TEXT_SCALE = 0.1f; - const int TEXT_HEIGHT = 10; - const float ROTATION = 0.0f; - const int FONT = 2; - const int PADDING = 10; - const int MOUSE_OFFSET = 10; - const int BACKGROUND_BEVEL = 3; - - int mouseX = application->getTrueMouseX(), - mouseY = application->getTrueMouseY(), - textWidth = widthText(TEXT_SCALE, 0, _overlayText); - DependencyManager::get()->renderBevelCornersRect( - mouseX + MOUSE_OFFSET, mouseY - TEXT_HEIGHT - PADDING, - textWidth + (2 * PADDING), TEXT_HEIGHT + (2 * PADDING), BACKGROUND_BEVEL, - glm::vec4(0.4f, 0.4f, 0.4f, 0.6f)); - drawText(mouseX + MOUSE_OFFSET + PADDING, mouseY, TEXT_SCALE, ROTATION, FONT, _overlayText, TEXT_COLOR); - } -} diff --git a/interface/src/ui/NodeBounds.h b/interface/src/ui/NodeBounds.h deleted file mode 100644 index 66255a6432..0000000000 --- a/interface/src/ui/NodeBounds.h +++ /dev/null @@ -1,47 +0,0 @@ -// -// NodeBounds.h -// interface/src/ui -// -// Created by Ryan Huffman on 05/14/14. -// Copyright 2014 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_NodeBounds_h -#define hifi_NodeBounds_h - -#include - -#include - -const int MAX_OVERLAY_TEXT_LENGTH = 64; - -class NodeBounds : public QObject { - Q_OBJECT -public: - NodeBounds(QObject* parent = NULL); - - bool getShowEntityNodes() { return _showEntityNodes; } - bool getShowParticleNodes() { return _showParticleNodes; } - - void draw(); - void drawOverlay(); - -public slots: - void setShowEntityNodes(bool value) { _showEntityNodes = value; } - void setShowParticleNodes(bool value) { _showParticleNodes = value; } - -protected: - void drawNodeBorder(const glm::vec3& center, float scale, float red, float green, float blue); - void getColorForNodeType(NodeType_t nodeType, float& red, float& green, float& blue); - -private: - bool _showEntityNodes; - bool _showParticleNodes; - char _overlayText[MAX_OVERLAY_TEXT_LENGTH + 1]; - -}; - -#endif // hifi_NodeBounds_h