diff --git a/interface/resources/images/reset.png b/interface/resources/images/reset.png new file mode 100644 index 0000000000..30735e9ed9 Binary files /dev/null and b/interface/resources/images/reset.png differ diff --git a/interface/src/Application.cpp b/interface/src/Application.cpp index 4e18a99259..c05ebaa56e 100644 --- a/interface/src/Application.cpp +++ b/interface/src/Application.cpp @@ -89,8 +89,6 @@ const int MIRROR_VIEW_TOP_PADDING = 5; const int MIRROR_VIEW_LEFT_PADDING = 10; const int MIRROR_VIEW_WIDTH = 265; const int MIRROR_VIEW_HEIGHT = 215; -const int MIRROR_ICON_SIZE = 16; -const int MIRROR_CLOSE_ICON_PADDING = 5; void messageHandler(QtMsgType type, const QMessageLogContext& context, const QString &message) { fprintf(stdout, "%s", message.toLocal8Bit().constData()); @@ -109,6 +107,7 @@ Application::Application(int& argc, char** argv, timeval &startup_time) : _wantToKillLocalVoxels(false), _audioScope(256, 200, true), _profile(QString()), + _mirrorViewRect(QRect(MIRROR_VIEW_LEFT_PADDING, MIRROR_VIEW_TOP_PADDING, MIRROR_VIEW_WIDTH, MIRROR_VIEW_HEIGHT)), _mouseX(0), _mouseY(0), _lastMouseMove(usecTimestampNow()), @@ -454,16 +453,14 @@ void Application::paintGL() { displaySide(_mirrorCamera, selfAvatarOnly); glPopMatrix(); - // render rear view tools if mouse is in the bounds - QPoint mousePosition = _glWidget->mapFromGlobal(QCursor::pos()); - if (_mirrorViewRect.contains(mousePosition.x(), mousePosition.y())) { - displayRearMirrorTools(); - } + _rearMirrorTools->render(false); // reset Viewport and projection matrix glViewport(0, 0, _glWidget->width(), _glWidget->height()); glDisable(GL_SCISSOR_TEST); updateProjectionMatrix(_myCamera, updateViewFrustum); + } else if (Menu::getInstance()->isOptionChecked(MenuOption::FullscreenMirror)) { + _rearMirrorTools->render(true); } displayOverlay(); @@ -489,8 +486,6 @@ void Application::resizeGL(int width, int height) { resetCamerasOnResizeGL(_viewFrustumOffsetCamera, width, height); resetCamerasOnResizeGL(_myCamera, width, height); - _mirrorViewRect = QRect(MIRROR_VIEW_LEFT_PADDING, MIRROR_VIEW_TOP_PADDING, MIRROR_VIEW_WIDTH, MIRROR_VIEW_HEIGHT); - glViewport(0, 0, width, height); // shouldn't this account for the menu??? updateProjectionMatrix(); @@ -690,7 +685,6 @@ void Application::keyPressEvent(QKeyEvent* event) { case Qt::Key_Space: resetSensors(); - _audio.reset(); break; case Qt::Key_G: @@ -1085,12 +1079,9 @@ void Application::mousePressEvent(QMouseEvent* event) { return; } - if (Menu::getInstance()->isOptionChecked(MenuOption::Mirror)) { - QRect closeIconRect = QRect(MIRROR_CLOSE_ICON_PADDING + _mirrorViewRect.left(), MIRROR_CLOSE_ICON_PADDING + _mirrorViewRect.top(), MIRROR_ICON_SIZE, MIRROR_ICON_SIZE); - - if (closeIconRect.contains(_mouseX, _mouseY)) { - Menu::getInstance()->triggerOption(MenuOption::Mirror); - } + if (_rearMirrorTools->mousePressEvent(_mouseX, _mouseY)) { + // stop propagation + return; } if (!_palette.isActive() && (!_isHoverVoxel || _lookatTargetAvatar)) { @@ -1675,10 +1666,6 @@ void Application::init() { _mirrorCamera.setMode(CAMERA_MODE_MIRROR); _mirrorCamera.setAspectRatio((float)MIRROR_VIEW_WIDTH / (float)MIRROR_VIEW_HEIGHT); _mirrorCamera.setFieldOfView(30); - _mirrorViewRect = QRect(MIRROR_VIEW_LEFT_PADDING, MIRROR_VIEW_TOP_PADDING, MIRROR_VIEW_WIDTH, MIRROR_VIEW_HEIGHT); - - switchToResourcesParentIfRequired(); - _closeTextureId = _glWidget->bindTexture(QImage("./resources/images/close.png")); OculusManager::connect(); if (OculusManager::isConnected()) { @@ -1731,8 +1718,39 @@ void Application::init() { _pieMenu.addAction(_followMode); _audio.init(_glWidget); + + _rearMirrorTools = new RearMirrorTools(_glWidget, _mirrorViewRect); + connect(_rearMirrorTools, SIGNAL(closeView()), SLOT(closeMirrorView())); + connect(_rearMirrorTools, SIGNAL(restoreView()), SLOT(restoreMirrorView())); + connect(_rearMirrorTools, SIGNAL(shrinkView()), SLOT(shrinkMirrorView())); + connect(_rearMirrorTools, SIGNAL(resetView()), SLOT(resetSensors())); } +void Application::closeMirrorView() { + if (Menu::getInstance()->isOptionChecked(MenuOption::Mirror)) { + Menu::getInstance()->triggerOption(MenuOption::Mirror);; + } +} + +void Application::restoreMirrorView() { + if (Menu::getInstance()->isOptionChecked(MenuOption::Mirror)) { + Menu::getInstance()->triggerOption(MenuOption::Mirror);; + } + + if (!Menu::getInstance()->isOptionChecked(MenuOption::FullscreenMirror)) { + Menu::getInstance()->triggerOption(MenuOption::FullscreenMirror); + } +} + +void Application::shrinkMirrorView() { + if (!Menu::getInstance()->isOptionChecked(MenuOption::Mirror)) { + Menu::getInstance()->triggerOption(MenuOption::Mirror);; + } + + if (Menu::getInstance()->isOptionChecked(MenuOption::FullscreenMirror)) { + Menu::getInstance()->triggerOption(MenuOption::FullscreenMirror); + } +} const float MAX_AVATAR_EDIT_VELOCITY = 1.0f; const float MAX_VOXEL_EDIT_DISTANCE = 20.0f; @@ -3758,6 +3776,8 @@ void Application::resetSensors() { _myTransmitter.resetLevels(); _myAvatar.setVelocity(glm::vec3(0,0,0)); _myAvatar.setThrust(glm::vec3(0,0,0)); + + _audio.reset(); } static void setShortcutsEnabled(QWidget* widget, bool enabled) { @@ -3957,41 +3977,3 @@ void Application::packetSentNotification(ssize_t length) { _bandwidthMeter.outputStream(BandwidthMeter::VOXELS).updateValue(length); } -void Application::displayRearMirrorTools() { - - glMatrixMode(GL_PROJECTION); - glPushMatrix(); - glLoadIdentity(); - gluOrtho2D(_mirrorViewRect.left(), _mirrorViewRect.right(), _mirrorViewRect.bottom(), _mirrorViewRect.top()); - glDisable(GL_DEPTH_TEST); - glDisable(GL_LIGHTING); - - glEnable(GL_TEXTURE_2D); - glBindTexture(GL_TEXTURE_2D, _closeTextureId); - - glColor3f(1, 1, 1); - glBegin(GL_QUADS); - - int lp = MIRROR_CLOSE_ICON_PADDING + _mirrorViewRect.left(); - int tp = MIRROR_CLOSE_ICON_PADDING + _mirrorViewRect.top(); - int lwp = MIRROR_ICON_SIZE + lp; - int twp = MIRROR_ICON_SIZE + tp; - - glTexCoord2f(1, 1); - glVertex2f(lp, tp); - - glTexCoord2f(0, 1); - glVertex2f(lwp, tp); - - glTexCoord2f(0, 0); - glVertex2f(lwp, twp); - - glTexCoord2f(1, 0); - glVertex2f(lp, twp); - - glEnd(); - - glPopMatrix(); - - glDisable(GL_TEXTURE_2D); -} diff --git a/interface/src/Application.h b/interface/src/Application.h index fb258f0353..531ff1813b 100644 --- a/interface/src/Application.h +++ b/interface/src/Application.h @@ -59,6 +59,7 @@ #include "ui/BandwidthDialog.h" #include "ui/ChatEntry.h" #include "ui/VoxelStatsDialog.h" +#include "ui/RearMirrorTools.h" class QAction; class QActionGroup; @@ -175,6 +176,7 @@ public slots: void decreaseVoxelSize(); void increaseVoxelSize(); + private slots: void timer(); @@ -195,6 +197,11 @@ private slots: glm::vec2 getScaledScreenPoint(glm::vec2 projectedPoint); void toggleFollowMode(); + + void closeMirrorView(); + void restoreMirrorView(); + void shrinkMirrorView(); + void resetSensors(); private: void resetCamerasOnResizeGL(Camera& camera, int width, int height); @@ -235,7 +242,6 @@ private: bool maybeEditVoxelUnderCursor(); void deleteVoxelUnderCursor(); void eyedropperVoxelUnderCursor(); - void resetSensors(); void injectVoxelAddedSoundEffect(); void setMenuShortcutsEnabled(bool enabled); @@ -303,7 +309,7 @@ private: Camera _viewFrustumOffsetCamera; // The camera we use to sometimes show the view frustum from an offset mode Camera _mirrorCamera; // Cammera for mirror view QRect _mirrorViewRect; - GLuint _closeTextureId; + RearMirrorTools* _rearMirrorTools; Environment _environment; diff --git a/interface/src/ui/RearMirrorTools.cpp b/interface/src/ui/RearMirrorTools.cpp new file mode 100644 index 0000000000..302c58d8a3 --- /dev/null +++ b/interface/src/ui/RearMirrorTools.cpp @@ -0,0 +1,103 @@ +// +// RearMirrorTools.cpp +// interface +// +// Created by stojce on 23.10.2013. +// Copyright (c) 2013 High Fidelity, Inc. All rights reserved. + +#include "RearMirrorTools.h" +#include +#include + +const int ICON_SIZE = 16; +const int ICON_PADDING = 5; + +RearMirrorTools::RearMirrorTools(QGLWidget* parent, QRect& bounds) : _parent(parent), _bounds(bounds), _windowed(false), _fullScreen(false) { + switchToResourcesParentIfRequired(); + _closeTextureId = _parent->bindTexture(QImage("./resources/images/close.png")); + _resetTextureId = _parent->bindTexture(QImage("./resources/images/reset.png")); +}; + +void RearMirrorTools::render(bool fullScreen) { + if (fullScreen) { + _fullScreen = true; + displayIcon(_parent->geometry(), ICON_PADDING, ICON_PADDING, _closeTextureId); + } else { + // render rear view tools if mouse is in the bounds + QPoint mousePosition = _parent->mapFromGlobal(QCursor::pos()); + _windowed = _bounds.contains(mousePosition.x(), mousePosition.y()); + if (_windowed) { + displayIcon(_bounds, _bounds.left() + ICON_PADDING, _bounds.top() + ICON_PADDING, _closeTextureId); + displayIcon(_bounds, _bounds.width() - ICON_SIZE - ICON_PADDING, _bounds.top() + ICON_PADDING, _resetTextureId); + } + } +} + +bool RearMirrorTools::mousePressEvent(int x, int y) { + if (_windowed) { + QRect closeIconRect = QRect(_bounds.left() + ICON_PADDING, _bounds.top() + ICON_PADDING, ICON_SIZE, ICON_SIZE); + if (closeIconRect.contains(x, y)) { + _windowed = false; + emit closeView(); + return true; + } + + QRect resetIconRect = QRect(_bounds.width() - ICON_SIZE - ICON_PADDING, _bounds.top() + ICON_PADDING, ICON_SIZE, ICON_SIZE); + if (resetIconRect.contains(x, y)) { + emit resetView(); + return true; + } + + if (_bounds.contains(x, y)) { + _windowed = false; + emit restoreView(); + return true; + } + } + + if (_fullScreen) { + QRect shrinkIconRect = QRect(ICON_PADDING, ICON_PADDING, ICON_SIZE, ICON_SIZE); + if (shrinkIconRect.contains(x, y)) { + _fullScreen = false; + emit shrinkView(); + return true; + } + } + return false; +} + +void RearMirrorTools::displayIcon(QRect bounds, int left, int top, GLuint textureId) { + + int twp = ICON_SIZE + top; + + glMatrixMode(GL_PROJECTION); + glPushMatrix(); + glLoadIdentity(); + + gluOrtho2D(bounds.left(), bounds.right(), bounds.bottom(), bounds.top()); + glDisable(GL_DEPTH_TEST); + glDisable(GL_LIGHTING); + glEnable(GL_TEXTURE_2D); + + glColor3f(1, 1, 1); + + glBindTexture(GL_TEXTURE_2D, textureId); + glBegin(GL_QUADS); + { + glTexCoord2f(0, 0); + glVertex2f(left, top); + + glTexCoord2f(1, 0); + glVertex2f(ICON_SIZE + left, top); + + glTexCoord2f(1, 1); + glVertex2f(ICON_SIZE + left, twp); + + glTexCoord2f(0, 1); + glVertex2f(left, twp); + } + glEnd(); + glPopMatrix(); + glBindTexture(GL_TEXTURE_2D, 0); + glDisable(GL_TEXTURE_2D); +} diff --git a/interface/src/ui/RearMirrorTools.h b/interface/src/ui/RearMirrorTools.h new file mode 100644 index 0000000000..b62731c8b2 --- /dev/null +++ b/interface/src/ui/RearMirrorTools.h @@ -0,0 +1,40 @@ +// +// RearMirrorTools.h +// interface +// +// Created by stojce on 23.10.2013. +// Copyright (c) 2013 High Fidelity, Inc. All rights reserved. + + +#ifndef __hifi__RearMirrorTools__ +#define __hifi__RearMirrorTools__ + +#include "InterfaceConfig.h" + +#include + +class RearMirrorTools : public QObject { + Q_OBJECT +public: + RearMirrorTools(QGLWidget* parent, QRect& bounds); + void render(bool fullScreen); + bool mousePressEvent(int x, int y); + +signals: + void closeView(); + void shrinkView(); + void resetView(); + void restoreView(); + +private: + QGLWidget* _parent; + QRect _bounds; + GLuint _closeTextureId; + GLuint _resetTextureId; + bool _windowed; + bool _fullScreen; + + void displayIcon(QRect bounds, int left, int top, GLuint textureId); +}; + +#endif /* defined(__hifi__RearMirrorTools__) */ diff --git a/libraries/voxels/src/VoxelTree.cpp b/libraries/voxels/src/VoxelTree.cpp index 031d407ea0..ac14f0dc58 100644 --- a/libraries/voxels/src/VoxelTree.cpp +++ b/libraries/voxels/src/VoxelTree.cpp @@ -1234,7 +1234,7 @@ int VoxelTree::encodeTreeBitstreamRecursion(VoxelNode* node, unsigned char* outp // even if they don't in our local tree bool notMyJurisdiction = false; if (params.jurisdictionMap) { - notMyJurisdiction = (JurisdictionMap::BELOW == params.jurisdictionMap->isMyJurisdiction(node->getOctalCode(), i)); + notMyJurisdiction = (JurisdictionMap::WITHIN != params.jurisdictionMap->isMyJurisdiction(node->getOctalCode(), i)); } if (params.includeExistsBits) { // If the child is known to exist, OR, it's not my jurisdiction, then we mark the bit as existing